backout 29799f914cab, Bug 917642 - [Helix] Please update the helix blobs
[gecko.git] / parser / html / nsHtml5StackNode.cpp
blob1f16f7bcade3149c948c8f0793e1ab8d205f10f6
1 /*
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 "nsIAtom.h"
32 #include "nsHtml5AtomTable.h"
33 #include "nsString.h"
34 #include "nsINameSpaceManager.h"
35 #include "nsIContent.h"
36 #include "nsTraceRefcnt.h"
37 #include "jArray.h"
38 #include "nsHtml5ArrayCopy.h"
39 #include "nsAHtml5TreeBuilderState.h"
40 #include "nsHtml5Atoms.h"
41 #include "nsHtml5ByteReadable.h"
42 #include "nsIUnicodeDecoder.h"
43 #include "nsHtml5Macros.h"
45 #include "nsHtml5Tokenizer.h"
46 #include "nsHtml5TreeBuilder.h"
47 #include "nsHtml5MetaScanner.h"
48 #include "nsHtml5AttributeName.h"
49 #include "nsHtml5ElementName.h"
50 #include "nsHtml5HtmlAttributes.h"
51 #include "nsHtml5UTF16Buffer.h"
52 #include "nsHtml5StateSnapshot.h"
53 #include "nsHtml5Portability.h"
55 #include "nsHtml5StackNode.h"
57 int32_t
58 nsHtml5StackNode::getGroup()
60 return flags & NS_HTML5ELEMENT_NAME_GROUP_MASK;
63 bool
64 nsHtml5StackNode::isScoping()
66 return (flags & NS_HTML5ELEMENT_NAME_SCOPING);
69 bool
70 nsHtml5StackNode::isSpecial()
72 return (flags & NS_HTML5ELEMENT_NAME_SPECIAL);
75 bool
76 nsHtml5StackNode::isFosterParenting()
78 return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
81 bool
82 nsHtml5StackNode::isHtmlIntegrationPoint()
84 return (flags & NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
88 nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
89 : flags(flags),
90 name(name),
91 popName(popName),
92 ns(ns),
93 node(node),
94 attributes(attributes),
95 refcount(1)
97 MOZ_COUNT_CTOR(nsHtml5StackNode);
101 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node)
102 : flags(elementName->getFlags()),
103 name(elementName->name),
104 popName(elementName->name),
105 ns(kNameSpaceID_XHTML),
106 node(node),
107 attributes(nullptr),
108 refcount(1)
110 MOZ_COUNT_CTOR(nsHtml5StackNode);
111 MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements.");
115 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes)
116 : flags(elementName->getFlags()),
117 name(elementName->name),
118 popName(elementName->name),
119 ns(kNameSpaceID_XHTML),
120 node(node),
121 attributes(attributes),
122 refcount(1)
124 MOZ_COUNT_CTOR(nsHtml5StackNode);
125 MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements.");
129 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName)
130 : flags(elementName->getFlags()),
131 name(elementName->name),
132 popName(popName),
133 ns(kNameSpaceID_XHTML),
134 node(node),
135 attributes(nullptr),
136 refcount(1)
138 MOZ_COUNT_CTOR(nsHtml5StackNode);
142 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContent** node)
143 : flags(prepareSvgFlags(elementName->getFlags())),
144 name(elementName->name),
145 popName(popName),
146 ns(kNameSpaceID_SVG),
147 node(node),
148 attributes(nullptr),
149 refcount(1)
151 MOZ_COUNT_CTOR(nsHtml5StackNode);
155 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, bool markAsIntegrationPoint)
156 : flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)),
157 name(elementName->name),
158 popName(popName),
159 ns(kNameSpaceID_MathML),
160 node(node),
161 attributes(nullptr),
162 refcount(1)
164 MOZ_COUNT_CTOR(nsHtml5StackNode);
167 int32_t
168 nsHtml5StackNode::prepareSvgFlags(int32_t flags)
170 flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
171 if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG)) {
172 flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
174 return flags;
177 int32_t
178 nsHtml5StackNode::prepareMathFlags(int32_t flags, bool markAsIntegrationPoint)
180 flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
181 if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
182 flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
184 if (markAsIntegrationPoint) {
185 flags |= NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT;
187 return flags;
191 nsHtml5StackNode::~nsHtml5StackNode()
193 MOZ_COUNT_DTOR(nsHtml5StackNode);
194 delete attributes;
197 void
198 nsHtml5StackNode::dropAttributes()
200 attributes = nullptr;
203 void
204 nsHtml5StackNode::retain()
206 refcount++;
209 void
210 nsHtml5StackNode::release()
212 refcount--;
213 if (!refcount) {
214 delete this;
218 void
219 nsHtml5StackNode::initializeStatics()
223 void
224 nsHtml5StackNode::releaseStatics()