2 * Copyright (c) 2007 Henri Sivonen
3 * Copyright (c) 2007-2011 Mozilla Foundation
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
25 * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
26 * Please edit StackNode.java instead and regenerate.
29 #define nsHtml5StackNode_cpp__
31 #include "nsHtml5AttributeName.h"
32 #include "nsHtml5ElementName.h"
33 #include "nsHtml5Tokenizer.h"
34 #include "nsHtml5TreeBuilder.h"
35 #include "nsHtml5UTF16Buffer.h"
36 #include "nsHtml5StateSnapshot.h"
37 #include "nsHtml5Portability.h"
39 #include "nsHtml5StackNode.h"
41 int32_t nsHtml5StackNode::getGroup() {
42 return flags
& nsHtml5ElementName::GROUP_MASK
;
45 bool nsHtml5StackNode::isScoping() {
46 return (flags
& nsHtml5ElementName::SCOPING
);
49 bool nsHtml5StackNode::isSpecial() {
50 return (flags
& nsHtml5ElementName::SPECIAL
);
53 bool nsHtml5StackNode::isFosterParenting() {
54 return (flags
& nsHtml5ElementName::FOSTER_PARENTING
);
57 bool nsHtml5StackNode::isHtmlIntegrationPoint() {
58 return (flags
& nsHtml5ElementName::HTML_INTEGRATION_POINT
);
61 nsHtml5StackNode::nsHtml5StackNode(int32_t idxInTreeBuilder
)
62 : idxInTreeBuilder(idxInTreeBuilder
),
70 htmlCreator(nullptr) {
71 MOZ_COUNT_CTOR(nsHtml5StackNode
);
74 mozilla::dom::HTMLContentCreatorFunction
nsHtml5StackNode::getHtmlCreator() {
78 void nsHtml5StackNode::setValues(
79 int32_t flags
, int32_t ns
, nsAtom
* name
, nsIContentHandle
* node
,
80 nsAtom
* popName
, nsHtml5HtmlAttributes
* attributes
,
81 mozilla::dom::HTMLContentCreatorFunction htmlCreator
) {
82 MOZ_ASSERT(isUnused());
85 this->popName
= popName
;
88 this->attributes
= attributes
;
90 this->htmlCreator
= htmlCreator
;
93 void nsHtml5StackNode::setValues(nsHtml5ElementName
* elementName
,
94 nsIContentHandle
* node
) {
95 MOZ_ASSERT(isUnused());
96 this->flags
= elementName
->getFlags();
97 this->name
= elementName
->getName();
98 this->popName
= elementName
->getName();
99 this->ns
= kNameSpaceID_XHTML
;
101 this->attributes
= nullptr;
103 MOZ_ASSERT(elementName
->isInterned(),
104 "Don't use this constructor for custom elements.");
105 this->htmlCreator
= nullptr;
108 void nsHtml5StackNode::setValues(nsHtml5ElementName
* elementName
,
109 nsIContentHandle
* node
,
110 nsHtml5HtmlAttributes
* attributes
) {
111 MOZ_ASSERT(isUnused());
112 this->flags
= elementName
->getFlags();
113 this->name
= elementName
->getName();
114 this->popName
= elementName
->getName();
115 this->ns
= kNameSpaceID_XHTML
;
117 this->attributes
= attributes
;
119 MOZ_ASSERT(elementName
->isInterned(),
120 "Don't use this constructor for custom elements.");
121 this->htmlCreator
= elementName
->getHtmlCreator();
124 void nsHtml5StackNode::setValues(nsHtml5ElementName
* elementName
,
125 nsIContentHandle
* node
, nsAtom
* popName
) {
126 MOZ_ASSERT(isUnused());
127 this->flags
= elementName
->getFlags();
128 this->name
= elementName
->getName();
129 this->popName
= popName
;
130 this->ns
= kNameSpaceID_XHTML
;
132 this->attributes
= nullptr;
134 this->htmlCreator
= nullptr;
137 void nsHtml5StackNode::setValues(nsHtml5ElementName
* elementName
,
138 nsAtom
* popName
, nsIContentHandle
* node
) {
139 MOZ_ASSERT(isUnused());
140 this->flags
= prepareSvgFlags(elementName
->getFlags());
141 this->name
= elementName
->getName();
142 this->popName
= popName
;
143 this->ns
= kNameSpaceID_SVG
;
145 this->attributes
= nullptr;
147 this->htmlCreator
= nullptr;
150 void nsHtml5StackNode::setValues(nsHtml5ElementName
* elementName
,
151 nsIContentHandle
* node
, nsAtom
* popName
,
152 bool markAsIntegrationPoint
) {
153 MOZ_ASSERT(isUnused());
155 prepareMathFlags(elementName
->getFlags(), markAsIntegrationPoint
);
156 this->name
= elementName
->getName();
157 this->popName
= popName
;
158 this->ns
= kNameSpaceID_MathML
;
160 this->attributes
= nullptr;
162 this->htmlCreator
= nullptr;
165 int32_t nsHtml5StackNode::prepareSvgFlags(int32_t flags
) {
167 ~(nsHtml5ElementName::FOSTER_PARENTING
| nsHtml5ElementName::SCOPING
|
168 nsHtml5ElementName::SPECIAL
| nsHtml5ElementName::OPTIONAL_END_TAG
);
169 if ((flags
& nsHtml5ElementName::SCOPING_AS_SVG
)) {
170 flags
|= (nsHtml5ElementName::SCOPING
| nsHtml5ElementName::SPECIAL
|
171 nsHtml5ElementName::HTML_INTEGRATION_POINT
);
176 int32_t nsHtml5StackNode::prepareMathFlags(int32_t flags
,
177 bool markAsIntegrationPoint
) {
179 ~(nsHtml5ElementName::FOSTER_PARENTING
| nsHtml5ElementName::SCOPING
|
180 nsHtml5ElementName::SPECIAL
| nsHtml5ElementName::OPTIONAL_END_TAG
);
181 if ((flags
& nsHtml5ElementName::SCOPING_AS_MATHML
)) {
182 flags
|= (nsHtml5ElementName::SCOPING
| nsHtml5ElementName::SPECIAL
);
184 if (markAsIntegrationPoint
) {
185 flags
|= nsHtml5ElementName::HTML_INTEGRATION_POINT
;
190 nsHtml5StackNode::~nsHtml5StackNode() { MOZ_COUNT_DTOR(nsHtml5StackNode
); }
192 void nsHtml5StackNode::dropAttributes() { attributes
= nullptr; }
194 void nsHtml5StackNode::retain() { refcount
++; }
196 void nsHtml5StackNode::release(nsHtml5TreeBuilder
* owningTreeBuilder
) {
198 MOZ_ASSERT(refcount
>= 0);
201 if (idxInTreeBuilder
>= 0) {
202 owningTreeBuilder
->notifyUnusedStackNode(idxInTreeBuilder
);
204 MOZ_ASSERT(!owningTreeBuilder
);
210 bool nsHtml5StackNode::isUnused() { return !refcount
; }
212 void nsHtml5StackNode::initializeStatics() {}
214 void nsHtml5StackNode::releaseStatics() {}