Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/parser/html/nsHtml5StackNode.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2007 Henri Sivonen
3
 * Copyright (c) 2007-2011 Mozilla Foundation
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * copy of this software and associated documentation files (the "Software"),
7
 * to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * DEALINGS IN THE SOFTWARE.
22
 */
23
24
/*
25
 * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
26
 * Please edit StackNode.java instead and regenerate.
27
 */
28
29
#define nsHtml5StackNode_cpp__
30
31
#include "nsAtom.h"
32
#include "nsHtml5AtomTable.h"
33
#include "nsHtml5String.h"
34
#include "nsNameSpaceManager.h"
35
#include "nsIContent.h"
36
#include "nsTraceRefcnt.h"
37
#include "jArray.h"
38
#include "nsHtml5ArrayCopy.h"
39
#include "nsAHtml5TreeBuilderState.h"
40
#include "nsGkAtoms.h"
41
#include "nsHtml5ByteReadable.h"
42
#include "nsHtml5Macros.h"
43
#include "nsIContentHandle.h"
44
#include "nsHtml5Portability.h"
45
#include "nsHtml5ContentCreatorFunction.h"
46
47
#include "nsHtml5AttributeName.h"
48
#include "nsHtml5ElementName.h"
49
#include "nsHtml5Tokenizer.h"
50
#include "nsHtml5TreeBuilder.h"
51
#include "nsHtml5MetaScanner.h"
52
#include "nsHtml5UTF16Buffer.h"
53
#include "nsHtml5StateSnapshot.h"
54
#include "nsHtml5Portability.h"
55
56
#include "nsHtml5StackNode.h"
57
58
int32_t
59
nsHtml5StackNode::getGroup()
60
0
{
61
0
  return flags & nsHtml5ElementName::GROUP_MASK;
62
0
}
63
64
bool
65
nsHtml5StackNode::isScoping()
66
0
{
67
0
  return (flags & nsHtml5ElementName::SCOPING);
68
0
}
69
70
bool
71
nsHtml5StackNode::isSpecial()
72
0
{
73
0
  return (flags & nsHtml5ElementName::SPECIAL);
74
0
}
75
76
bool
77
nsHtml5StackNode::isFosterParenting()
78
0
{
79
0
  return (flags & nsHtml5ElementName::FOSTER_PARENTING);
80
0
}
81
82
bool
83
nsHtml5StackNode::isHtmlIntegrationPoint()
84
0
{
85
0
  return (flags & nsHtml5ElementName::HTML_INTEGRATION_POINT);
86
0
}
87
88
nsHtml5StackNode::nsHtml5StackNode(int32_t idxInTreeBuilder)
89
  : idxInTreeBuilder(idxInTreeBuilder)
90
  , flags(0)
91
  , name(nullptr)
92
  , popName(nullptr)
93
  , ns(0)
94
  , node(nullptr)
95
  , attributes(nullptr)
96
  , refcount(0)
97
  , htmlCreator(nullptr)
98
0
{
99
0
  MOZ_COUNT_CTOR(nsHtml5StackNode);
100
0
}
101
102
mozilla::dom::HTMLContentCreatorFunction
103
nsHtml5StackNode::getHtmlCreator()
104
0
{
105
0
  return htmlCreator;
106
0
}
107
108
void
109
nsHtml5StackNode::setValues(
110
  int32_t flags,
111
  int32_t ns,
112
  nsAtom* name,
113
  nsIContentHandle* node,
114
  nsAtom* popName,
115
  nsHtml5HtmlAttributes* attributes,
116
  mozilla::dom::HTMLContentCreatorFunction htmlCreator)
117
0
{
118
0
  MOZ_ASSERT(isUnused());
119
0
  this->flags = flags;
120
0
  this->name = name;
121
0
  this->popName = popName;
122
0
  this->ns = ns;
123
0
  this->node = node;
124
0
  this->attributes = attributes;
125
0
  this->refcount = 1;
126
0
  this->htmlCreator = htmlCreator;
127
0
}
128
129
void
130
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
131
                            nsIContentHandle* node)
132
0
{
133
0
  MOZ_ASSERT(isUnused());
134
0
  this->flags = elementName->getFlags();
135
0
  this->name = elementName->getName();
136
0
  this->popName = elementName->getName();
137
0
  this->ns = kNameSpaceID_XHTML;
138
0
  this->node = node;
139
0
  this->attributes = nullptr;
140
0
  this->refcount = 1;
141
0
  MOZ_ASSERT(elementName->isInterned(),
142
0
             "Don't use this constructor for custom elements.");
143
0
  this->htmlCreator = nullptr;
144
0
}
145
146
void
147
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
148
                            nsIContentHandle* node,
149
                            nsHtml5HtmlAttributes* attributes)
150
0
{
151
0
  MOZ_ASSERT(isUnused());
152
0
  this->flags = elementName->getFlags();
153
0
  this->name = elementName->getName();
154
0
  this->popName = elementName->getName();
155
0
  this->ns = kNameSpaceID_XHTML;
156
0
  this->node = node;
157
0
  this->attributes = attributes;
158
0
  this->refcount = 1;
159
0
  MOZ_ASSERT(elementName->isInterned(),
160
0
             "Don't use this constructor for custom elements.");
161
0
  this->htmlCreator = elementName->getHtmlCreator();
162
0
}
163
164
void
165
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
166
                            nsIContentHandle* node,
167
                            nsAtom* popName)
168
0
{
169
0
  MOZ_ASSERT(isUnused());
170
0
  this->flags = elementName->getFlags();
171
0
  this->name = elementName->getName();
172
0
  this->popName = popName;
173
0
  this->ns = kNameSpaceID_XHTML;
174
0
  this->node = node;
175
0
  this->attributes = nullptr;
176
0
  this->refcount = 1;
177
0
  this->htmlCreator = nullptr;
178
0
}
179
180
void
181
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
182
                            nsAtom* popName,
183
                            nsIContentHandle* node)
184
0
{
185
0
  MOZ_ASSERT(isUnused());
186
0
  this->flags = prepareSvgFlags(elementName->getFlags());
187
0
  this->name = elementName->getName();
188
0
  this->popName = popName;
189
0
  this->ns = kNameSpaceID_SVG;
190
0
  this->node = node;
191
0
  this->attributes = nullptr;
192
0
  this->refcount = 1;
193
0
  this->htmlCreator = nullptr;
194
0
}
195
196
void
197
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
198
                            nsIContentHandle* node,
199
                            nsAtom* popName,
200
                            bool markAsIntegrationPoint)
201
0
{
202
0
  MOZ_ASSERT(isUnused());
203
0
  this->flags =
204
0
    prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint);
205
0
  this->name = elementName->getName();
206
0
  this->popName = popName;
207
0
  this->ns = kNameSpaceID_MathML;
208
0
  this->node = node;
209
0
  this->attributes = nullptr;
210
0
  this->refcount = 1;
211
0
  this->htmlCreator = nullptr;
212
0
}
213
214
int32_t
215
nsHtml5StackNode::prepareSvgFlags(int32_t flags)
216
0
{
217
0
  flags &=
218
0
    ~(nsHtml5ElementName::FOSTER_PARENTING | nsHtml5ElementName::SCOPING |
219
0
      nsHtml5ElementName::SPECIAL | nsHtml5ElementName::OPTIONAL_END_TAG);
220
0
  if ((flags & nsHtml5ElementName::SCOPING_AS_SVG)) {
221
0
    flags |= (nsHtml5ElementName::SCOPING | nsHtml5ElementName::SPECIAL |
222
0
              nsHtml5ElementName::HTML_INTEGRATION_POINT);
223
0
  }
224
0
  return flags;
225
0
}
226
227
int32_t
228
nsHtml5StackNode::prepareMathFlags(int32_t flags, bool markAsIntegrationPoint)
229
0
{
230
0
  flags &=
231
0
    ~(nsHtml5ElementName::FOSTER_PARENTING | nsHtml5ElementName::SCOPING |
232
0
      nsHtml5ElementName::SPECIAL | nsHtml5ElementName::OPTIONAL_END_TAG);
233
0
  if ((flags & nsHtml5ElementName::SCOPING_AS_MATHML)) {
234
0
    flags |= (nsHtml5ElementName::SCOPING | nsHtml5ElementName::SPECIAL);
235
0
  }
236
0
  if (markAsIntegrationPoint) {
237
0
    flags |= nsHtml5ElementName::HTML_INTEGRATION_POINT;
238
0
  }
239
0
  return flags;
240
0
}
241
242
nsHtml5StackNode::~nsHtml5StackNode()
243
0
{
244
0
  MOZ_COUNT_DTOR(nsHtml5StackNode);
245
0
}
246
247
void
248
nsHtml5StackNode::dropAttributes()
249
0
{
250
0
  attributes = nullptr;
251
0
}
252
253
void
254
nsHtml5StackNode::retain()
255
0
{
256
0
  refcount++;
257
0
}
258
259
void
260
nsHtml5StackNode::release(nsHtml5TreeBuilder* owningTreeBuilder)
261
0
{
262
0
  refcount--;
263
0
  MOZ_ASSERT(refcount >= 0);
264
0
  if (!refcount) {
265
0
    delete attributes;
266
0
    if (idxInTreeBuilder >= 0) {
267
0
      owningTreeBuilder->notifyUnusedStackNode(idxInTreeBuilder);
268
0
    } else {
269
0
      MOZ_ASSERT(!owningTreeBuilder);
270
0
      delete this;
271
0
    }
272
0
  }
273
0
}
274
275
bool
276
nsHtml5StackNode::isUnused()
277
0
{
278
0
  return !refcount;
279
0
}
280
281
void
282
nsHtml5StackNode::initializeStatics()
283
3
{
284
3
}
285
286
void
287
nsHtml5StackNode::releaseStatics()
288
0
{
289
0
}