nsHtml5ElementName.h (14360B)
1 /* 2 * Copyright (c) 2008-2017 Mozilla Foundation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE. 21 */ 22 23 /* 24 * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. 25 * Please edit ElementName.java instead and regenerate. 26 */ 27 28 #ifndef nsHtml5ElementName_h 29 #define nsHtml5ElementName_h 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 class nsHtml5StreamParser; 48 49 class nsHtml5AttributeName; 50 class nsHtml5Tokenizer; 51 class nsHtml5TreeBuilder; 52 class nsHtml5UTF16Buffer; 53 class nsHtml5StateSnapshot; 54 class nsHtml5Portability; 55 56 class nsHtml5ElementName { 57 public: 58 static const int32_t GROUP_MASK = 127; 59 60 static const int32_t NOT_INTERNED = (1 << 30); 61 62 static const int32_t SPECIAL = (1 << 29); 63 64 static const int32_t FOSTER_PARENTING = (1 << 28); 65 66 static const int32_t SCOPING = (1 << 27); 67 68 static const int32_t SCOPING_AS_SVG = (1 << 26); 69 70 static const int32_t SCOPING_AS_MATHML = (1 << 25); 71 72 static const int32_t HTML_INTEGRATION_POINT = (1 << 24); 73 74 static const int32_t OPTIONAL_END_TAG = (1 << 23); 75 76 private: 77 RefPtr<nsAtom> name; 78 RefPtr<nsAtom> camelCaseName; 79 mozilla::dom::HTMLContentCreatorFunction htmlCreator; 80 mozilla::dom::SVGContentCreatorFunction svgCreator; 81 82 public: 83 int32_t flags; 84 inline nsAtom* getName() { return name; } 85 86 inline nsAtom* getCamelCaseName() { return camelCaseName; } 87 88 inline mozilla::dom::HTMLContentCreatorFunction getHtmlCreator() { 89 return htmlCreator; 90 } 91 92 inline mozilla::dom::SVGContentCreatorFunction getSvgCreator() { 93 return svgCreator; 94 } 95 96 inline int32_t getFlags() { return flags; } 97 98 inline int32_t getGroup() { return flags & nsHtml5ElementName::GROUP_MASK; } 99 100 inline bool isInterned() { 101 return !(flags & nsHtml5ElementName::NOT_INTERNED); 102 } 103 104 inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data, 105 int32_t key) { 106 int32_t n = data.length; 107 int32_t i = 0; 108 while (i < n) { 109 int32_t val = data[i]; 110 if (val < key) { 111 i = 2 * i + 2; 112 } else if (val > key) { 113 i = 2 * i + 1; 114 } else { 115 return i; 116 } 117 } 118 return -1; 119 } 120 121 inline static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, 122 int32_t length) { 123 uint32_t hash = nsHtml5ElementName::bufToHash(buf, length); 124 jArray<int32_t, int32_t> hashes; 125 hashes = nsHtml5ElementName::ELEMENT_HASHES; 126 int32_t index = levelOrderBinarySearch(hashes, hash); 127 if (index < 0) { 128 return nullptr; 129 } else { 130 nsHtml5ElementName* elementName = 131 nsHtml5ElementName::ELEMENT_NAMES[index]; 132 nsAtom* name = elementName->name; 133 if (!nsHtml5Portability::localEqualsBuffer(name, buf, length)) { 134 return nullptr; 135 } 136 return elementName; 137 } 138 } 139 140 private: 141 inline static uint32_t bufToHash(char16_t* buf, int32_t length) { 142 uint32_t len = length; 143 uint32_t first = buf[0]; 144 first <<= 19; 145 uint32_t second = 1 << 23; 146 uint32_t third = 0; 147 uint32_t fourth = 0; 148 uint32_t fifth = 0; 149 if (length >= 4) { 150 second = buf[length - 4]; 151 second <<= 4; 152 third = buf[length - 3]; 153 third <<= 9; 154 fourth = buf[length - 2]; 155 fourth <<= 14; 156 fifth = buf[length - 1]; 157 fifth <<= 24; 158 } else if (length == 3) { 159 second = buf[1]; 160 second <<= 4; 161 third = buf[2]; 162 third <<= 9; 163 } else if (length == 2) { 164 second = buf[1]; 165 second <<= 24; 166 } 167 return len + first + second + third + fourth + fifth; 168 } 169 170 nsHtml5ElementName(nsAtom* name, nsAtom* camelCaseName, 171 mozilla::dom::HTMLContentCreatorFunction htmlCreator, 172 mozilla::dom::SVGContentCreatorFunction svgCreator, 173 int32_t flags); 174 175 public: 176 nsHtml5ElementName(); 177 ~nsHtml5ElementName(); 178 inline void setNameForNonInterned(nsAtom* name, bool custom) { 179 this->name = name; 180 this->camelCaseName = name; 181 if (custom) { 182 this->htmlCreator = NS_NewCustomElement; 183 } else { 184 this->htmlCreator = NS_NewHTMLUnknownElement; 185 } 186 MOZ_ASSERT(this->flags == nsHtml5ElementName::NOT_INTERNED); 187 } 188 189 inline bool isCustom() { return this->htmlCreator == NS_NewCustomElement; } 190 191 static nsHtml5ElementName* ELT_ANNOTATION_XML; 192 static nsHtml5ElementName* ELT_BIG; 193 static nsHtml5ElementName* ELT_BDI; 194 static nsHtml5ElementName* ELT_BDO; 195 static nsHtml5ElementName* ELT_COL; 196 static nsHtml5ElementName* ELT_DEL; 197 static nsHtml5ElementName* ELT_DFN; 198 static nsHtml5ElementName* ELT_DIR; 199 static nsHtml5ElementName* ELT_DIV; 200 static nsHtml5ElementName* ELT_IMG; 201 static nsHtml5ElementName* ELT_INS; 202 static nsHtml5ElementName* ELT_KBD; 203 static nsHtml5ElementName* ELT_MAP; 204 static nsHtml5ElementName* ELT_NAV; 205 static nsHtml5ElementName* ELT_PRE; 206 static nsHtml5ElementName* ELT_A; 207 static nsHtml5ElementName* ELT_B; 208 static nsHtml5ElementName* ELT_RTC; 209 static nsHtml5ElementName* ELT_SUB; 210 static nsHtml5ElementName* ELT_SVG; 211 static nsHtml5ElementName* ELT_SUP; 212 static nsHtml5ElementName* ELT_SET; 213 static nsHtml5ElementName* ELT_USE; 214 static nsHtml5ElementName* ELT_VAR; 215 static nsHtml5ElementName* ELT_G; 216 static nsHtml5ElementName* ELT_WBR; 217 static nsHtml5ElementName* ELT_XMP; 218 static nsHtml5ElementName* ELT_I; 219 static nsHtml5ElementName* ELT_P; 220 static nsHtml5ElementName* ELT_Q; 221 static nsHtml5ElementName* ELT_S; 222 static nsHtml5ElementName* ELT_U; 223 static nsHtml5ElementName* ELT_H1; 224 static nsHtml5ElementName* ELT_H2; 225 static nsHtml5ElementName* ELT_H3; 226 static nsHtml5ElementName* ELT_H4; 227 static nsHtml5ElementName* ELT_H5; 228 static nsHtml5ElementName* ELT_H6; 229 static nsHtml5ElementName* ELT_AREA; 230 static nsHtml5ElementName* ELT_DATA; 231 static nsHtml5ElementName* ELT_FEFUNCA; 232 static nsHtml5ElementName* ELT_METADATA; 233 static nsHtml5ElementName* ELT_META; 234 static nsHtml5ElementName* ELT_TEXTAREA; 235 static nsHtml5ElementName* ELT_FEFUNCB; 236 static nsHtml5ElementName* ELT_RB; 237 static nsHtml5ElementName* ELT_DESC; 238 static nsHtml5ElementName* ELT_DD; 239 static nsHtml5ElementName* ELT_BGSOUND; 240 static nsHtml5ElementName* ELT_EMBED; 241 static nsHtml5ElementName* ELT_FEBLEND; 242 static nsHtml5ElementName* ELT_FEFLOOD; 243 static nsHtml5ElementName* ELT_HEAD; 244 static nsHtml5ElementName* ELT_LEGEND; 245 static nsHtml5ElementName* ELT_NOEMBED; 246 static nsHtml5ElementName* ELT_TD; 247 static nsHtml5ElementName* ELT_THEAD; 248 static nsHtml5ElementName* ELT_ASIDE; 249 static nsHtml5ElementName* ELT_ARTICLE; 250 static nsHtml5ElementName* ELT_ANIMATE; 251 static nsHtml5ElementName* ELT_BASE; 252 static nsHtml5ElementName* ELT_BLOCKQUOTE; 253 static nsHtml5ElementName* ELT_CODE; 254 static nsHtml5ElementName* ELT_CIRCLE; 255 static nsHtml5ElementName* ELT_CITE; 256 static nsHtml5ElementName* ELT_ELLIPSE; 257 static nsHtml5ElementName* ELT_FETURBULENCE; 258 static nsHtml5ElementName* ELT_FEMERGENODE; 259 static nsHtml5ElementName* ELT_FEIMAGE; 260 static nsHtml5ElementName* ELT_FEMERGE; 261 static nsHtml5ElementName* ELT_FETILE; 262 static nsHtml5ElementName* ELT_FRAME; 263 static nsHtml5ElementName* ELT_FIGURE; 264 static nsHtml5ElementName* ELT_FECOMPOSITE; 265 static nsHtml5ElementName* ELT_IMAGE; 266 static nsHtml5ElementName* ELT_IFRAME; 267 static nsHtml5ElementName* ELT_LINE; 268 static nsHtml5ElementName* ELT_MARQUEE; 269 static nsHtml5ElementName* ELT_POLYLINE; 270 static nsHtml5ElementName* ELT_PICTURE; 271 static nsHtml5ElementName* ELT_SOURCE; 272 static nsHtml5ElementName* ELT_STRIKE; 273 static nsHtml5ElementName* ELT_STYLE; 274 static nsHtml5ElementName* ELT_TABLE; 275 static nsHtml5ElementName* ELT_TITLE; 276 static nsHtml5ElementName* ELT_TIME; 277 static nsHtml5ElementName* ELT_TEMPLATE; 278 static nsHtml5ElementName* ELT_ALTGLYPHDEF; 279 static nsHtml5ElementName* ELT_GLYPHREF; 280 static nsHtml5ElementName* ELT_DIALOG; 281 static nsHtml5ElementName* ELT_FEFUNCG; 282 static nsHtml5ElementName* ELT_FEDIFFUSELIGHTING; 283 static nsHtml5ElementName* ELT_FESPECULARLIGHTING; 284 static nsHtml5ElementName* ELT_LISTING; 285 static nsHtml5ElementName* ELT_STRONG; 286 static nsHtml5ElementName* ELT_ALTGLYPH; 287 static nsHtml5ElementName* ELT_CLIPPATH; 288 static nsHtml5ElementName* ELT_MGLYPH; 289 static nsHtml5ElementName* ELT_MATH; 290 static nsHtml5ElementName* ELT_MPATH; 291 static nsHtml5ElementName* ELT_PATH; 292 static nsHtml5ElementName* ELT_TH; 293 static nsHtml5ElementName* ELT_SEARCH; 294 static nsHtml5ElementName* ELT_SWITCH; 295 static nsHtml5ElementName* ELT_TEXTPATH; 296 static nsHtml5ElementName* ELT_LI; 297 static nsHtml5ElementName* ELT_MI; 298 static nsHtml5ElementName* ELT_LINK; 299 static nsHtml5ElementName* ELT_MARK; 300 static nsHtml5ElementName* ELT_MALIGNMARK; 301 static nsHtml5ElementName* ELT_MASK; 302 static nsHtml5ElementName* ELT_TRACK; 303 static nsHtml5ElementName* ELT_DL; 304 static nsHtml5ElementName* ELT_HTML; 305 static nsHtml5ElementName* ELT_OL; 306 static nsHtml5ElementName* ELT_LABEL; 307 static nsHtml5ElementName* ELT_UL; 308 static nsHtml5ElementName* ELT_SMALL; 309 static nsHtml5ElementName* ELT_SYMBOL; 310 static nsHtml5ElementName* ELT_ALTGLYPHITEM; 311 static nsHtml5ElementName* ELT_ANIMATETRANSFORM; 312 static nsHtml5ElementName* ELT_ACRONYM; 313 static nsHtml5ElementName* ELT_EM; 314 static nsHtml5ElementName* ELT_FORM; 315 static nsHtml5ElementName* ELT_PARAM; 316 static nsHtml5ElementName* ELT_ANIMATEMOTION; 317 static nsHtml5ElementName* ELT_BUTTON; 318 static nsHtml5ElementName* ELT_CAPTION; 319 static nsHtml5ElementName* ELT_FIGCAPTION; 320 static nsHtml5ElementName* ELT_MN; 321 static nsHtml5ElementName* ELT_KEYGEN; 322 static nsHtml5ElementName* ELT_MAIN; 323 static nsHtml5ElementName* ELT_OPTION; 324 static nsHtml5ElementName* ELT_POLYGON; 325 static nsHtml5ElementName* ELT_PATTERN; 326 static nsHtml5ElementName* ELT_SPAN; 327 static nsHtml5ElementName* ELT_SECTION; 328 static nsHtml5ElementName* ELT_TSPAN; 329 static nsHtml5ElementName* ELT_AUDIO; 330 static nsHtml5ElementName* ELT_MO; 331 static nsHtml5ElementName* ELT_VIDEO; 332 static nsHtml5ElementName* ELT_COLGROUP; 333 static nsHtml5ElementName* ELT_FEDISPLACEMENTMAP; 334 static nsHtml5ElementName* ELT_HGROUP; 335 static nsHtml5ElementName* ELT_RP; 336 static nsHtml5ElementName* ELT_OPTGROUP; 337 static nsHtml5ElementName* ELT_SAMP; 338 static nsHtml5ElementName* ELT_STOP; 339 static nsHtml5ElementName* ELT_BR; 340 static nsHtml5ElementName* ELT_ABBR; 341 static nsHtml5ElementName* ELT_ANIMATECOLOR; 342 static nsHtml5ElementName* ELT_CENTER; 343 static nsHtml5ElementName* ELT_HR; 344 static nsHtml5ElementName* ELT_FEFUNCR; 345 static nsHtml5ElementName* ELT_FECOMPONENTTRANSFER; 346 static nsHtml5ElementName* ELT_FILTER; 347 static nsHtml5ElementName* ELT_FOOTER; 348 static nsHtml5ElementName* ELT_FEGAUSSIANBLUR; 349 static nsHtml5ElementName* ELT_HEADER; 350 static nsHtml5ElementName* ELT_MARKER; 351 static nsHtml5ElementName* ELT_METER; 352 static nsHtml5ElementName* ELT_NOBR; 353 static nsHtml5ElementName* ELT_TR; 354 static nsHtml5ElementName* ELT_ADDRESS; 355 static nsHtml5ElementName* ELT_CANVAS; 356 static nsHtml5ElementName* ELT_DEFS; 357 static nsHtml5ElementName* ELT_DETAILS; 358 static nsHtml5ElementName* ELT_MS; 359 static nsHtml5ElementName* ELT_NOFRAMES; 360 static nsHtml5ElementName* ELT_PROGRESS; 361 static nsHtml5ElementName* ELT_DT; 362 static nsHtml5ElementName* ELT_APPLET; 363 static nsHtml5ElementName* ELT_BASEFONT; 364 static nsHtml5ElementName* ELT_DATALIST; 365 static nsHtml5ElementName* ELT_FOREIGNOBJECT; 366 static nsHtml5ElementName* ELT_FIELDSET; 367 static nsHtml5ElementName* ELT_FRAMESET; 368 static nsHtml5ElementName* ELT_FEOFFSET; 369 static nsHtml5ElementName* ELT_FESPOTLIGHT; 370 static nsHtml5ElementName* ELT_FEPOINTLIGHT; 371 static nsHtml5ElementName* ELT_FEDISTANTLIGHT; 372 static nsHtml5ElementName* ELT_FONT; 373 static nsHtml5ElementName* ELT_INPUT; 374 static nsHtml5ElementName* ELT_LINEARGRADIENT; 375 static nsHtml5ElementName* ELT_MTEXT; 376 static nsHtml5ElementName* ELT_NOSCRIPT; 377 static nsHtml5ElementName* ELT_RT; 378 static nsHtml5ElementName* ELT_OBJECT; 379 static nsHtml5ElementName* ELT_OUTPUT; 380 static nsHtml5ElementName* ELT_PLAINTEXT; 381 static nsHtml5ElementName* ELT_TT; 382 static nsHtml5ElementName* ELT_RECT; 383 static nsHtml5ElementName* ELT_RADIALGRADIENT; 384 static nsHtml5ElementName* ELT_SELECT; 385 static nsHtml5ElementName* ELT_SLOT; 386 static nsHtml5ElementName* ELT_SCRIPT; 387 static nsHtml5ElementName* ELT_TFOOT; 388 static nsHtml5ElementName* ELT_TEXT; 389 static nsHtml5ElementName* ELT_MENU; 390 static nsHtml5ElementName* ELT_FEDROPSHADOW; 391 static nsHtml5ElementName* ELT_VIEW; 392 static nsHtml5ElementName* ELT_FECOLORMATRIX; 393 static nsHtml5ElementName* ELT_FECONVOLVEMATRIX; 394 static nsHtml5ElementName* ELT_BODY; 395 static nsHtml5ElementName* ELT_FEMORPHOLOGY; 396 static nsHtml5ElementName* ELT_RUBY; 397 static nsHtml5ElementName* ELT_SUMMARY; 398 static nsHtml5ElementName* ELT_TBODY; 399 400 private: 401 static nsHtml5ElementName** ELEMENT_NAMES; 402 static staticJArray<int32_t, int32_t> ELEMENT_HASHES; 403 404 public: 405 static void initializeStatics(); 406 static void releaseStatics(); 407 }; 408 409 #endif