Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2007 Henri Sivonen |
michael@0 | 3 | * Copyright (c) 2007-2011 Mozilla Foundation |
michael@0 | 4 | * |
michael@0 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
michael@0 | 6 | * copy of this software and associated documentation files (the "Software"), |
michael@0 | 7 | * to deal in the Software without restriction, including without limitation |
michael@0 | 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
michael@0 | 9 | * and/or sell copies of the Software, and to permit persons to whom the |
michael@0 | 10 | * Software is furnished to do so, subject to the following conditions: |
michael@0 | 11 | * |
michael@0 | 12 | * The above copyright notice and this permission notice shall be included in |
michael@0 | 13 | * all copies or substantial portions of the Software. |
michael@0 | 14 | * |
michael@0 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
michael@0 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
michael@0 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
michael@0 | 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
michael@0 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
michael@0 | 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
michael@0 | 21 | * DEALINGS IN THE SOFTWARE. |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | /* |
michael@0 | 25 | * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. |
michael@0 | 26 | * Please edit StackNode.java instead and regenerate. |
michael@0 | 27 | */ |
michael@0 | 28 | |
michael@0 | 29 | #define nsHtml5StackNode_cpp__ |
michael@0 | 30 | |
michael@0 | 31 | #include "nsIAtom.h" |
michael@0 | 32 | #include "nsHtml5AtomTable.h" |
michael@0 | 33 | #include "nsString.h" |
michael@0 | 34 | #include "nsNameSpaceManager.h" |
michael@0 | 35 | #include "nsIContent.h" |
michael@0 | 36 | #include "nsTraceRefcnt.h" |
michael@0 | 37 | #include "jArray.h" |
michael@0 | 38 | #include "nsHtml5ArrayCopy.h" |
michael@0 | 39 | #include "nsAHtml5TreeBuilderState.h" |
michael@0 | 40 | #include "nsHtml5Atoms.h" |
michael@0 | 41 | #include "nsHtml5ByteReadable.h" |
michael@0 | 42 | #include "nsIUnicodeDecoder.h" |
michael@0 | 43 | #include "nsHtml5Macros.h" |
michael@0 | 44 | #include "nsIContentHandle.h" |
michael@0 | 45 | |
michael@0 | 46 | #include "nsHtml5Tokenizer.h" |
michael@0 | 47 | #include "nsHtml5TreeBuilder.h" |
michael@0 | 48 | #include "nsHtml5MetaScanner.h" |
michael@0 | 49 | #include "nsHtml5AttributeName.h" |
michael@0 | 50 | #include "nsHtml5ElementName.h" |
michael@0 | 51 | #include "nsHtml5HtmlAttributes.h" |
michael@0 | 52 | #include "nsHtml5UTF16Buffer.h" |
michael@0 | 53 | #include "nsHtml5StateSnapshot.h" |
michael@0 | 54 | #include "nsHtml5Portability.h" |
michael@0 | 55 | |
michael@0 | 56 | #include "nsHtml5StackNode.h" |
michael@0 | 57 | |
michael@0 | 58 | int32_t |
michael@0 | 59 | nsHtml5StackNode::getGroup() |
michael@0 | 60 | { |
michael@0 | 61 | return flags & NS_HTML5ELEMENT_NAME_GROUP_MASK; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | bool |
michael@0 | 65 | nsHtml5StackNode::isScoping() |
michael@0 | 66 | { |
michael@0 | 67 | return (flags & NS_HTML5ELEMENT_NAME_SCOPING); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | bool |
michael@0 | 71 | nsHtml5StackNode::isSpecial() |
michael@0 | 72 | { |
michael@0 | 73 | return (flags & NS_HTML5ELEMENT_NAME_SPECIAL); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | bool |
michael@0 | 77 | nsHtml5StackNode::isFosterParenting() |
michael@0 | 78 | { |
michael@0 | 79 | return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | bool |
michael@0 | 83 | nsHtml5StackNode::isHtmlIntegrationPoint() |
michael@0 | 84 | { |
michael@0 | 85 | return (flags & NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | |
michael@0 | 89 | nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes) |
michael@0 | 90 | : flags(flags), |
michael@0 | 91 | name(name), |
michael@0 | 92 | popName(popName), |
michael@0 | 93 | ns(ns), |
michael@0 | 94 | node(node), |
michael@0 | 95 | attributes(attributes), |
michael@0 | 96 | refcount(1) |
michael@0 | 97 | { |
michael@0 | 98 | MOZ_COUNT_CTOR(nsHtml5StackNode); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | |
michael@0 | 102 | nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node) |
michael@0 | 103 | : flags(elementName->getFlags()), |
michael@0 | 104 | name(elementName->name), |
michael@0 | 105 | popName(elementName->name), |
michael@0 | 106 | ns(kNameSpaceID_XHTML), |
michael@0 | 107 | node(node), |
michael@0 | 108 | attributes(nullptr), |
michael@0 | 109 | refcount(1) |
michael@0 | 110 | { |
michael@0 | 111 | MOZ_COUNT_CTOR(nsHtml5StackNode); |
michael@0 | 112 | MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements."); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | |
michael@0 | 116 | nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes) |
michael@0 | 117 | : flags(elementName->getFlags()), |
michael@0 | 118 | name(elementName->name), |
michael@0 | 119 | popName(elementName->name), |
michael@0 | 120 | ns(kNameSpaceID_XHTML), |
michael@0 | 121 | node(node), |
michael@0 | 122 | attributes(attributes), |
michael@0 | 123 | refcount(1) |
michael@0 | 124 | { |
michael@0 | 125 | MOZ_COUNT_CTOR(nsHtml5StackNode); |
michael@0 | 126 | MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements."); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | |
michael@0 | 130 | nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName) |
michael@0 | 131 | : flags(elementName->getFlags()), |
michael@0 | 132 | name(elementName->name), |
michael@0 | 133 | popName(popName), |
michael@0 | 134 | ns(kNameSpaceID_XHTML), |
michael@0 | 135 | node(node), |
michael@0 | 136 | attributes(nullptr), |
michael@0 | 137 | refcount(1) |
michael@0 | 138 | { |
michael@0 | 139 | MOZ_COUNT_CTOR(nsHtml5StackNode); |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | |
michael@0 | 143 | nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node) |
michael@0 | 144 | : flags(prepareSvgFlags(elementName->getFlags())), |
michael@0 | 145 | name(elementName->name), |
michael@0 | 146 | popName(popName), |
michael@0 | 147 | ns(kNameSpaceID_SVG), |
michael@0 | 148 | node(node), |
michael@0 | 149 | attributes(nullptr), |
michael@0 | 150 | refcount(1) |
michael@0 | 151 | { |
michael@0 | 152 | MOZ_COUNT_CTOR(nsHtml5StackNode); |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | |
michael@0 | 156 | nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint) |
michael@0 | 157 | : flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)), |
michael@0 | 158 | name(elementName->name), |
michael@0 | 159 | popName(popName), |
michael@0 | 160 | ns(kNameSpaceID_MathML), |
michael@0 | 161 | node(node), |
michael@0 | 162 | attributes(nullptr), |
michael@0 | 163 | refcount(1) |
michael@0 | 164 | { |
michael@0 | 165 | MOZ_COUNT_CTOR(nsHtml5StackNode); |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | int32_t |
michael@0 | 169 | nsHtml5StackNode::prepareSvgFlags(int32_t flags) |
michael@0 | 170 | { |
michael@0 | 171 | flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG); |
michael@0 | 172 | if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG)) { |
michael@0 | 173 | flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT); |
michael@0 | 174 | } |
michael@0 | 175 | return flags; |
michael@0 | 176 | } |
michael@0 | 177 | |
michael@0 | 178 | int32_t |
michael@0 | 179 | nsHtml5StackNode::prepareMathFlags(int32_t flags, bool markAsIntegrationPoint) |
michael@0 | 180 | { |
michael@0 | 181 | flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG); |
michael@0 | 182 | if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) { |
michael@0 | 183 | flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL); |
michael@0 | 184 | } |
michael@0 | 185 | if (markAsIntegrationPoint) { |
michael@0 | 186 | flags |= NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT; |
michael@0 | 187 | } |
michael@0 | 188 | return flags; |
michael@0 | 189 | } |
michael@0 | 190 | |
michael@0 | 191 | |
michael@0 | 192 | nsHtml5StackNode::~nsHtml5StackNode() |
michael@0 | 193 | { |
michael@0 | 194 | MOZ_COUNT_DTOR(nsHtml5StackNode); |
michael@0 | 195 | delete attributes; |
michael@0 | 196 | } |
michael@0 | 197 | |
michael@0 | 198 | void |
michael@0 | 199 | nsHtml5StackNode::dropAttributes() |
michael@0 | 200 | { |
michael@0 | 201 | attributes = nullptr; |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | void |
michael@0 | 205 | nsHtml5StackNode::retain() |
michael@0 | 206 | { |
michael@0 | 207 | refcount++; |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | void |
michael@0 | 211 | nsHtml5StackNode::release() |
michael@0 | 212 | { |
michael@0 | 213 | refcount--; |
michael@0 | 214 | if (!refcount) { |
michael@0 | 215 | delete this; |
michael@0 | 216 | } |
michael@0 | 217 | } |
michael@0 | 218 | |
michael@0 | 219 | void |
michael@0 | 220 | nsHtml5StackNode::initializeStatics() |
michael@0 | 221 | { |
michael@0 | 222 | } |
michael@0 | 223 | |
michael@0 | 224 | void |
michael@0 | 225 | nsHtml5StackNode::releaseStatics() |
michael@0 | 226 | { |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 |