Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / parser / html / nsHtml5StackNode.cpp
blob48fce8dd3796a3590cce5b88b699c267ebde08e6
1 /*
2 * Copyright (c) 2007 Henri Sivonen
3 * Copyright (c) 2007-2009 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 "prtypes.h"
32 #include "nsIAtom.h"
33 #include "nsHtml5AtomTable.h"
34 #include "nsString.h"
35 #include "nsINameSpaceManager.h"
36 #include "nsIContent.h"
37 #include "nsIDocument.h"
38 #include "nsTraceRefcnt.h"
39 #include "jArray.h"
40 #include "nsHtml5DocumentMode.h"
41 #include "nsHtml5ArrayCopy.h"
42 #include "nsHtml5NamedCharacters.h"
43 #include "nsHtml5NamedCharactersAccel.h"
44 #include "nsHtml5Atoms.h"
45 #include "nsHtml5ByteReadable.h"
46 #include "nsIUnicodeDecoder.h"
47 #include "nsAHtml5TreeBuilderState.h"
48 #include "nsHtml5Macros.h"
50 #include "nsHtml5Tokenizer.h"
51 #include "nsHtml5TreeBuilder.h"
52 #include "nsHtml5MetaScanner.h"
53 #include "nsHtml5AttributeName.h"
54 #include "nsHtml5ElementName.h"
55 #include "nsHtml5HtmlAttributes.h"
56 #include "nsHtml5UTF16Buffer.h"
57 #include "nsHtml5StateSnapshot.h"
58 #include "nsHtml5Portability.h"
60 #include "nsHtml5StackNode.h"
62 PRInt32
63 nsHtml5StackNode::getGroup()
65 return flags & NS_HTML5ELEMENT_NAME_GROUP_MASK;
68 PRBool
69 nsHtml5StackNode::isScoping()
71 return (flags & NS_HTML5ELEMENT_NAME_SCOPING);
74 PRBool
75 nsHtml5StackNode::isSpecial()
77 return (flags & NS_HTML5ELEMENT_NAME_SPECIAL);
80 PRBool
81 nsHtml5StackNode::isFosterParenting()
83 return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
86 PRBool
87 nsHtml5StackNode::isHtmlIntegrationPoint()
89 return (flags & NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
93 nsHtml5StackNode::nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
94 : flags(flags),
95 name(name),
96 popName(popName),
97 ns(ns),
98 node(node),
99 attributes(attributes),
100 refcount(1)
102 MOZ_COUNT_CTOR(nsHtml5StackNode);
106 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node)
107 : flags(elementName->getFlags()),
108 name(elementName->name),
109 popName(elementName->name),
110 ns(kNameSpaceID_XHTML),
111 node(node),
112 attributes(nsnull),
113 refcount(1)
115 MOZ_COUNT_CTOR(nsHtml5StackNode);
120 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes)
121 : flags(elementName->getFlags()),
122 name(elementName->name),
123 popName(elementName->name),
124 ns(kNameSpaceID_XHTML),
125 node(node),
126 attributes(attributes),
127 refcount(1)
129 MOZ_COUNT_CTOR(nsHtml5StackNode);
134 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName)
135 : flags(elementName->getFlags()),
136 name(elementName->name),
137 popName(popName),
138 ns(kNameSpaceID_XHTML),
139 node(node),
140 attributes(nsnull),
141 refcount(1)
143 MOZ_COUNT_CTOR(nsHtml5StackNode);
147 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContent** node)
148 : flags(prepareSvgFlags(elementName->getFlags())),
149 name(elementName->name),
150 popName(popName),
151 ns(kNameSpaceID_SVG),
152 node(node),
153 attributes(nsnull),
154 refcount(1)
156 MOZ_COUNT_CTOR(nsHtml5StackNode);
160 nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint)
161 : flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)),
162 name(elementName->name),
163 popName(popName),
164 ns(kNameSpaceID_MathML),
165 node(node),
166 attributes(nsnull),
167 refcount(1)
169 MOZ_COUNT_CTOR(nsHtml5StackNode);
172 PRInt32
173 nsHtml5StackNode::prepareSvgFlags(PRInt32 flags)
175 flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
176 if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG)) {
177 flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
179 return flags;
182 PRInt32
183 nsHtml5StackNode::prepareMathFlags(PRInt32 flags, PRBool markAsIntegrationPoint)
185 flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
186 if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
187 flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
189 if (markAsIntegrationPoint) {
190 flags |= NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT;
192 return flags;
196 nsHtml5StackNode::~nsHtml5StackNode()
198 MOZ_COUNT_DTOR(nsHtml5StackNode);
199 delete attributes;
202 void
203 nsHtml5StackNode::dropAttributes()
205 attributes = nsnull;
208 void
209 nsHtml5StackNode::retain()
211 refcount++;
214 void
215 nsHtml5StackNode::release()
217 refcount--;
218 if (!refcount) {
219 delete this;
223 void
224 nsHtml5StackNode::initializeStatics()
228 void
229 nsHtml5StackNode::releaseStatics()