Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/parser/html/nsHtml5AttributeEntry.h
Line
Count
Source (jump to first uncovered line)
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
  nsHtml5AttributeEntry(nsHtml5AttributeName* aName,
14
                        nsHtml5String aValue,
15
                        int32_t aLine)
16
    : mLine(aLine)
17
    , mValue(aValue)
18
0
  {
19
0
    // Let's hope the compiler coalesces the following as appropriate.
20
0
    mLocals[0] = aName->getLocal(0);
21
0
    mLocals[1] = aName->getLocal(1);
22
0
    mLocals[2] = aName->getLocal(2);
23
0
    mPrefixes[0] = aName->getPrefix(0);
24
0
    mPrefixes[1] = aName->getPrefix(1);
25
0
    mPrefixes[2] = aName->getPrefix(2);
26
0
    mUris[0] = aName->getUri(0);
27
0
    mUris[1] = aName->getUri(1);
28
0
    mUris[2] = aName->getUri(2);
29
0
  }
30
31
  // Isindex-only so doesn't need to deal with SVG and MathML
32
  nsHtml5AttributeEntry(nsAtom* aName, nsHtml5String aValue, int32_t aLine)
33
    : mLine(aLine)
34
    , mValue(aValue)
35
0
  {
36
0
    // 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
0
  inline nsAtom* GetLocal(int32_t aMode) { return mLocals[aMode]; }
49
50
0
  inline nsAtom* GetPrefix(int32_t aMode) { return mPrefixes[aMode]; }
51
52
0
  inline int32_t GetUri(int32_t aMode) { return mUris[aMode]; }
53
54
0
  inline nsHtml5String GetValue() { return mValue; }
55
56
0
  inline int32_t GetLine() { return mLine; }
57
58
0
  inline void ReleaseValue() { mValue.Release(); }
59
60
  inline nsHtml5AttributeEntry Clone(nsHtml5AtomTable* aInterner)
61
0
  {
62
0
    // Copy the memory
63
0
    nsHtml5AttributeEntry clone(*this);
64
0
    // Increment refcount for value
65
0
    clone.mValue = this->mValue.Clone();
66
0
    if (aInterner) {
67
0
      // Now if we have an interner, we'll need to rewrite non-static atoms.
68
0
      // Only the local names may be non-static, in which case all three
69
0
      // are the same.
70
0
      nsAtom* local = GetLocal(0);
71
0
      if (!local->IsStatic()) {
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
0
      }
79
0
    }
80
0
    return clone;
81
0
  }
82
83
private:
84
  nsAtom* mLocals[3];
85
  nsAtom* mPrefixes[3];
86
  int32_t mUris[3];
87
  int32_t mLine;
88
  nsHtml5String mValue;
89
};
90
91
#endif // nsHtml5AttributeEntry_h