LCOV - code coverage report
Current view: top level - parser/html - nsHtml5AttributeEntry.h (source / functions) Hit Total Coverage
Test: output.info Lines: 18 45 40.0 %
Date: 2017-07-14 16:53:18 Functions: 6 9 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef nsHtml5AttributeEntry_h
       6             : #define nsHtml5AttributeEntry_h
       7             : 
       8             : #include "nsHtml5AttributeName.h"
       9             : 
      10             : class nsHtml5AttributeEntry final
      11             : {
      12             : public:
      13          16 :   nsHtml5AttributeEntry(nsHtml5AttributeName* aName,
      14             :                         nsHtml5String aValue,
      15             :                         int32_t aLine)
      16          16 :     : mLine(aLine)
      17          16 :     , mValue(aValue)
      18             :   {
      19             :     // Let's hope the compiler coalesces the following as appropriate.
      20          16 :     mLocals[0] = aName->getLocal(0);
      21          16 :     mLocals[1] = aName->getLocal(1);
      22          16 :     mLocals[2] = aName->getLocal(2);
      23          16 :     mPrefixes[0] = aName->getPrefix(0);
      24          16 :     mPrefixes[1] = aName->getPrefix(1);
      25          16 :     mPrefixes[2] = aName->getPrefix(2);
      26          16 :     mUris[0] = aName->getUri(0);
      27          16 :     mUris[1] = aName->getUri(1);
      28          16 :     mUris[2] = aName->getUri(2);
      29          16 :   }
      30             : 
      31             :   // Isindex-only so doesn't need to deal with SVG and MathML
      32           0 :   nsHtml5AttributeEntry(nsIAtom* aName, nsHtml5String aValue, int32_t aLine)
      33           0 :     : mLine(aLine)
      34           0 :     , mValue(aValue)
      35             :   {
      36             :     // Let's hope the compiler coalesces the following as appropriate.
      37           0 :     mLocals[0] = aName;
      38           0 :     mLocals[1] = aName;
      39           0 :     mLocals[2] = aName;
      40           0 :     mPrefixes[0] = nullptr;
      41           0 :     mPrefixes[1] = nullptr;
      42           0 :     mPrefixes[2] = nullptr;
      43           0 :     mUris[0] = kNameSpaceID_None;
      44           0 :     mUris[1] = kNameSpaceID_None;
      45           0 :     mUris[2] = kNameSpaceID_None;
      46           0 :   }
      47             : 
      48         117 :   inline nsIAtom* GetLocal(int32_t aMode) { return mLocals[aMode]; }
      49             : 
      50          16 :   inline nsIAtom* GetPrefix(int32_t aMode) { return mPrefixes[aMode]; }
      51             : 
      52          16 :   inline int32_t GetUri(int32_t aMode) { return mUris[aMode]; }
      53             : 
      54          26 :   inline nsHtml5String GetValue() { return mValue; }
      55             : 
      56           0 :   inline int32_t GetLine() { return mLine; }
      57             : 
      58          16 :   inline void ReleaseValue() { mValue.Release(); }
      59             : 
      60           0 :   inline nsHtml5AttributeEntry Clone(nsHtml5AtomTable* aInterner)
      61             :   {
      62             :     // Copy the memory
      63           0 :     nsHtml5AttributeEntry clone(*this);
      64             :     // Increment refcount for value
      65           0 :     clone.mValue = this->mValue.Clone();
      66           0 :     if (aInterner) {
      67             :       // Now if we have an interner, we'll need to rewrite non-static atoms.
      68             :       // Only the local names may be non-static, in which case all three
      69             :       // are the same.
      70           0 :       nsIAtom* local = GetLocal(0);
      71           0 :       if (!local->IsStaticAtom()) {
      72           0 :         nsAutoString str;
      73           0 :         local->ToString(str);
      74           0 :         local = aInterner->GetAtom(str);
      75           0 :         clone.mLocals[0] = local;
      76           0 :         clone.mLocals[1] = local;
      77           0 :         clone.mLocals[2] = local;
      78             :       }
      79             :     }
      80           0 :     return clone;
      81             :   }
      82             : 
      83             : private:
      84             :   nsIAtom* mLocals[3];
      85             :   nsIAtom* mPrefixes[3];
      86             :   int32_t mUris[3];
      87             :   int32_t mLine;
      88             :   nsHtml5String mValue;
      89             : };
      90             : 
      91             : #endif // nsHtml5AttributeEntry_h

Generated by: LCOV version 1.13