nsHtml5AttributeEntry.h (2153B)
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 public: 12 nsHtml5AttributeEntry(nsHtml5AttributeName* aName, nsHtml5String aValue, 13 int32_t aLine) 14 : mLine(aLine), mValue(aValue) { 15 // Let's hope the compiler coalesces the following as appropriate. 16 mLocals[0] = aName->getLocal(0); 17 mLocals[1] = aName->getLocal(1); 18 mLocals[2] = aName->getLocal(2); 19 mPrefixes[0] = aName->getPrefix(0); 20 mPrefixes[1] = aName->getPrefix(1); 21 mPrefixes[2] = aName->getPrefix(2); 22 mUris[0] = aName->getUri(0); 23 mUris[1] = aName->getUri(1); 24 mUris[2] = aName->getUri(2); 25 } 26 27 // Isindex-only so doesn't need to deal with SVG and MathML 28 nsHtml5AttributeEntry(nsAtom* aName, nsHtml5String aValue, int32_t aLine) 29 : mLine(aLine), mValue(aValue) { 30 // Let's hope the compiler coalesces the following as appropriate. 31 mLocals[0] = aName; 32 mLocals[1] = aName; 33 mLocals[2] = aName; 34 mPrefixes[0] = nullptr; 35 mPrefixes[1] = nullptr; 36 mPrefixes[2] = nullptr; 37 mUris[0] = kNameSpaceID_None; 38 mUris[1] = kNameSpaceID_None; 39 mUris[2] = kNameSpaceID_None; 40 } 41 42 inline nsAtom* GetLocal(int32_t aMode) { return mLocals[aMode]; } 43 44 inline nsAtom* GetPrefix(int32_t aMode) { return mPrefixes[aMode]; } 45 46 inline int32_t GetUri(int32_t aMode) { return mUris[aMode]; } 47 48 inline nsHtml5String GetValue() { return mValue; } 49 50 inline int32_t GetLine() { return mLine; } 51 52 inline void ReleaseValue() { mValue.Release(); } 53 54 inline nsHtml5AttributeEntry Clone() { 55 // Copy the memory 56 nsHtml5AttributeEntry clone(*this); 57 // Increment refcount for value 58 clone.mValue = this->mValue.Clone(); 59 return clone; 60 } 61 62 private: 63 RefPtr<nsAtom> mLocals[3]; 64 RefPtr<nsAtom> mPrefixes[3]; 65 int32_t mUris[3]; 66 int32_t mLine; 67 nsHtml5String mValue; 68 }; 69 70 #endif // nsHtml5AttributeEntry_h