Bug 818976 - Part 3: Generated code for HTML5 parser. r=hsivonen

This commit is contained in:
William Chen 2013-03-26 00:15:23 -07:00
parent 591ce8a1df
commit a74ccbd5e9
12 changed files with 851 additions and 406 deletions

View File

@ -32,7 +32,7 @@ import nu.validator.htmlparser.common.Interner;
public final class ElementName
// uncomment when regenerating self
// implements Comparable<ElementName>
// implements Comparable<ElementName>
{
/**
@ -190,7 +190,7 @@ public final class ElementName
// }
// if ((flags & SCOPING) != 0) {
// buf.append(" | SCOPING");
// }
// }
// if ((flags & SCOPING_AS_MATHML) != 0) {
// buf.append(" | SCOPING_AS_MATHML");
// }
@ -202,7 +202,7 @@ public final class ElementName
// }
// return buf.toString();
// }
//
//
// private String constName() {
// char[] buf = new char[name.length()];
// for (int i = 0; i < name.length(); i++) {
@ -312,6 +312,8 @@ public final class ElementName
// return "TEXTAREA";
// case TreeBuilder.TITLE:
// return "TITLE";
// case TreeBuilder.TEMPLATE:
// return "TEMPLATE";
// case TreeBuilder.TR:
// return "TR";
// case TreeBuilder.XMP:
@ -349,7 +351,7 @@ public final class ElementName
// case TreeBuilder.FIELDSET:
// return "FIELDSET";
// case TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY:
// return "ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_NAV_OR_SECTION_OR_SUMMARY";
// return "ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY";
// case TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR:
// return "RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR";
// case TreeBuilder.RT_OR_RP:
@ -374,7 +376,7 @@ public final class ElementName
//
// /**
// * Regenerate self
// *
// *
// * @param args
// */
// public static void main(String[] args) {
@ -724,6 +726,7 @@ public final class ElementName
public static final ElementName QUOTIENT = new ElementName("quotient", "quotient", TreeBuilder.OTHER);
public static final ElementName SELECTOR = new ElementName("selector", "selector", TreeBuilder.OTHER);
public static final ElementName TEXTAREA = new ElementName("textarea", "textarea", TreeBuilder.TEXTAREA | SPECIAL);
public static final ElementName TEMPLATE = new ElementName("template", "template", TreeBuilder.TEMPLATE | SPECIAL);
public static final ElementName TEXTPATH = new ElementName("textpath", "textPath", TreeBuilder.OTHER);
public static final ElementName VARIANCE = new ElementName("variance", "variance", TreeBuilder.OTHER);
public static final ElementName ANIMATION = new ElementName("animation", "animation", TreeBuilder.OTHER);
@ -1118,6 +1121,7 @@ public final class ElementName
QUOTIENT,
SELECTOR,
TEXTAREA,
TEMPLATE,
TEXTPATH,
VARIANCE,
ANIMATION,
@ -1513,6 +1517,7 @@ public final class ElementName
286931113,
288964227,
289445441,
289591340,
289689648,
291671489,
303512884,

View File

@ -36,22 +36,24 @@ public abstract class MetaScanner {
/**
* Constant for "charset".
*/
private static final char[] CHARSET = "harset".toCharArray();
private static final char[] CHARSET = { 'h', 'a', 'r', 's', 'e', 't' };
/**
* Constant for "content".
*/
private static final char[] CONTENT = "ontent".toCharArray();
private static final char[] CONTENT = { 'o', 'n', 't', 'e', 'n', 't' };
/**
* Constant for "http-equiv".
*/
private static final char[] HTTP_EQUIV = "ttp-equiv".toCharArray();
private static final char[] HTTP_EQUIV = { 't', 't', 'p', '-', 'e', 'q',
'u', 'i', 'v' };
/**
* Constant for "content-type".
*/
private static final char[] CONTENT_TYPE = "content-type".toCharArray();
private static final char[] CONTENT_TYPE = { 'c', 'o', 'n', 't', 'e', 'n',
't', '-', 't', 'y', 'p', 'e' };
private static final int NO = 0;

View File

@ -270,22 +270,24 @@ public class Tokenizer implements Locator {
/**
* "CDATA[" as <code>char[]</code>
*/
private static final @NoLength char[] CDATA_LSQB = "CDATA[".toCharArray();
private static final @NoLength char[] CDATA_LSQB = { 'C', 'D', 'A', 'T',
'A', '[' };
/**
* "octype" as <code>char[]</code>
*/
private static final @NoLength char[] OCTYPE = "octype".toCharArray();
private static final @NoLength char[] OCTYPE = { 'o', 'c', 't', 'y', 'p',
'e' };
/**
* "ublic" as <code>char[]</code>
*/
private static final @NoLength char[] UBLIC = "ublic".toCharArray();
private static final @NoLength char[] UBLIC = { 'u', 'b', 'l', 'i', 'c' };
/**
* "ystem" as <code>char[]</code>
*/
private static final @NoLength char[] YSTEM = "ystem".toCharArray();
private static final @NoLength char[] YSTEM = { 'y', 's', 't', 'e', 'm' };
private static final char[] TITLE_ARR = { 't', 'i', 't', 'l', 'e' };

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@
*/
HTML5_ATOM(emptystring, "")
HTML5_ATOM(template_, "template")
HTML5_ATOM(title, "title")
HTML5_ATOM(textarea, "textarea")
HTML5_ATOM(style, "style")
@ -44,6 +45,9 @@ HTML5_ATOM(option, "option")
HTML5_ATOM(ruby, "ruby")
HTML5_ATOM(select, "select")
HTML5_ATOM(optgroup, "optgroup")
HTML5_ATOM(tbody, "tbody")
HTML5_ATOM(tfoot, "tfoot")
HTML5_ATOM(thead, "thead")
HTML5_ATOM(frameset, "frameset")
HTML5_ATOM(button, "button")
HTML5_ATOM(ul, "ul")
@ -52,9 +56,6 @@ HTML5_ATOM(html, "html")
HTML5_ATOM(td, "td")
HTML5_ATOM(th, "th")
HTML5_ATOM(tr, "tr")
HTML5_ATOM(tbody, "tbody")
HTML5_ATOM(thead, "thead")
HTML5_ATOM(tfoot, "tfoot")
HTML5_ATOM(colgroup, "colgroup")
HTML5_ATOM(head, "head")
HTML5_ATOM(body, "body")
@ -331,7 +332,6 @@ HTML5_ATOM(mathsize, "mathsize")
HTML5_ATOM(multiple, "multiple")
HTML5_ATOM(longdesc, "longdesc")
HTML5_ATOM(language, "language")
HTML5_ATOM(template_, "template")
HTML5_ATOM(tabindex, "tabindex")
HTML5_ATOM(readonly, "readonly")
HTML5_ATOM(selected, "selected")

File diff suppressed because one or more lines are too long

View File

@ -451,6 +451,7 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_PRSUBSET = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_QUOTIENT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_SELECTOR = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_TEXTAREA = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_TEMPLATE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_TEXTPATH = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_VARIANCE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ANIMATION = nullptr;
@ -528,8 +529,8 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_FESPECULARLIGHTING = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_DOMAINOFAPPLICATION = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FECOMPONENTTRANSFER = nullptr;
nsHtml5ElementName** nsHtml5ElementName::ELEMENT_NAMES = 0;
static int32_t const ELEMENT_HASHES_DATA[] = { 1057, 1090, 1255, 1321, 1552, 1585, 1651, 1717, 68162, 68899, 69059, 69764, 70020, 70276, 71077, 71205, 72134, 72232, 72264, 72296, 72328, 72360, 72392, 73351, 74312, 75209, 78124, 78284, 78476, 79149, 79309, 79341, 79469, 81295, 81487, 82224, 84498, 84626, 86164, 86292, 86612, 86676, 87445, 3183041, 3186241, 3198017, 3218722, 3226754, 3247715, 3256803, 3263971, 3264995, 3289252, 3291332, 3295524, 3299620, 3326725, 3379303, 3392679, 3448233, 3460553, 3461577, 3510347, 3546604, 3552364, 3556524, 3576461, 3586349, 3588141, 3590797, 3596333, 3622062, 3625454, 3627054, 3675728, 3749042, 3771059, 3771571, 3776211, 3782323, 3782963, 3784883, 3785395, 3788979, 3815476, 3839605, 3885110, 3917911, 3948984, 3951096, 135304769, 135858241, 136498210, 136906434, 137138658, 137512995, 137531875, 137548067, 137629283, 137645539, 137646563, 137775779, 138529956, 138615076, 139040932, 140954086, 141179366, 141690439, 142738600, 143013512, 146979116, 147175724, 147475756, 147902637, 147936877, 148017645, 148131885, 148228141, 148229165, 148309165, 148317229, 148395629, 148551853, 148618829, 149076462, 149490158, 149572782, 151277616, 151639440, 153268914, 153486514, 153563314, 153750706, 153763314, 153914034, 154406067, 154417459, 154600979, 154678323, 154680979, 154866835, 155366708, 155375188, 155391572, 155465780, 155869364, 158045494, 168988979, 169321621, 169652752, 173151309, 174240818, 174247297, 174669292, 175391532, 176638123, 177380397, 177879204, 177886734, 180753473, 181020073, 181503558, 181686320, 181999237, 181999311, 182048201, 182074866, 182078003, 182083764, 182920847, 184716457, 184976961, 185145071, 187281445, 187872052, 188100653, 188875944, 188919873, 188920457, 189107250, 189203987, 189371817, 189414886, 189567458, 190266670, 191318187, 191337609, 202479203, 202493027, 202835587, 202843747, 203013219, 203036048, 203045987, 203177552, 203898516, 204648562, 205067918, 205078130, 205096654, 205689142, 205690439, 205988909, 207213161, 207794484, 207800999, 208023602, 208213644, 208213647, 210261490, 210310273, 210940978, 213325049, 213946445, 214055079, 215125040, 215134273, 215135028, 215237420, 215418148, 215553166, 215553394, 215563858, 215627949, 215754324, 217529652, 217713834, 217732628, 218731945, 221417045, 221424946, 221493746, 221515401, 221658189, 221908140, 221910626, 221921586, 222659762, 225001091, 236105833, 236113965, 236194995, 236195427, 236206132, 236206387, 236211683, 236212707, 236381647, 236571826, 237124271, 238172205, 238210544, 238270764, 238435405, 238501172, 239224867, 239257644, 239710497, 240307721, 241208789, 241241557, 241318060, 241319404, 241343533, 241344069, 241405397, 241765845, 243864964, 244502085, 244946220, 245109902, 247647266, 247707956, 248648814, 248648836, 248682161, 248986932, 249058914, 249697357, 252132601, 252135604, 252317348, 255007012, 255278388, 255641645, 256365156, 257566121, 269763372, 271202790, 271863856, 272049197, 272127474, 274339449, 274939471, 275388004, 275388005, 275388006, 275977800, 278267602, 278513831, 278712622, 281613765, 281683369, 282120228, 282250732, 282498697, 282508942, 283743649, 283787570, 284710386, 285391148, 285478533, 285854898, 285873762, 286931113, 288964227, 289445441, 289689648, 291671489, 303512884, 305319975, 305610036, 305764101, 308448294, 308675890, 312085683, 312264750, 315032867, 316391000, 317331042, 317902135, 318950711, 319447220, 321499182, 322538804, 323145200, 337067316, 337826293, 339905989, 340833697, 341457068, 342310196, 345302593, 349554733, 349771471, 349786245, 350819405, 356072847, 370349192, 373962798, 375558638, 375574835, 376053993, 383276530, 383373833, 383407586, 384439906, 386079012, 404133513, 404307343, 407031852, 408072233, 409112005, 409608425, 409771500, 419040932, 437730612, 439529766, 442616365, 442813037, 443157674, 443295316, 450118444, 450482697, 456789668, 459935396, 471217869, 474073645, 476230702, 476665218, 476717289, 483014825, 485083298, 489306281, 538364390, 540675748, 543819186, 543958612, 576960820, 577242548, 610515252, 642202932, 644420819 };
staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HASHES_DATA, NS_ARRAY_LENGTH(ELEMENT_HASHES_DATA) };
static int32_t const ELEMENT_HASHES_DATA[] = { 1057, 1090, 1255, 1321, 1552, 1585, 1651, 1717, 68162, 68899, 69059, 69764, 70020, 70276, 71077, 71205, 72134, 72232, 72264, 72296, 72328, 72360, 72392, 73351, 74312, 75209, 78124, 78284, 78476, 79149, 79309, 79341, 79469, 81295, 81487, 82224, 84498, 84626, 86164, 86292, 86612, 86676, 87445, 3183041, 3186241, 3198017, 3218722, 3226754, 3247715, 3256803, 3263971, 3264995, 3289252, 3291332, 3295524, 3299620, 3326725, 3379303, 3392679, 3448233, 3460553, 3461577, 3510347, 3546604, 3552364, 3556524, 3576461, 3586349, 3588141, 3590797, 3596333, 3622062, 3625454, 3627054, 3675728, 3749042, 3771059, 3771571, 3776211, 3782323, 3782963, 3784883, 3785395, 3788979, 3815476, 3839605, 3885110, 3917911, 3948984, 3951096, 135304769, 135858241, 136498210, 136906434, 137138658, 137512995, 137531875, 137548067, 137629283, 137645539, 137646563, 137775779, 138529956, 138615076, 139040932, 140954086, 141179366, 141690439, 142738600, 143013512, 146979116, 147175724, 147475756, 147902637, 147936877, 148017645, 148131885, 148228141, 148229165, 148309165, 148317229, 148395629, 148551853, 148618829, 149076462, 149490158, 149572782, 151277616, 151639440, 153268914, 153486514, 153563314, 153750706, 153763314, 153914034, 154406067, 154417459, 154600979, 154678323, 154680979, 154866835, 155366708, 155375188, 155391572, 155465780, 155869364, 158045494, 168988979, 169321621, 169652752, 173151309, 174240818, 174247297, 174669292, 175391532, 176638123, 177380397, 177879204, 177886734, 180753473, 181020073, 181503558, 181686320, 181999237, 181999311, 182048201, 182074866, 182078003, 182083764, 182920847, 184716457, 184976961, 185145071, 187281445, 187872052, 188100653, 188875944, 188919873, 188920457, 189107250, 189203987, 189371817, 189414886, 189567458, 190266670, 191318187, 191337609, 202479203, 202493027, 202835587, 202843747, 203013219, 203036048, 203045987, 203177552, 203898516, 204648562, 205067918, 205078130, 205096654, 205689142, 205690439, 205988909, 207213161, 207794484, 207800999, 208023602, 208213644, 208213647, 210261490, 210310273, 210940978, 213325049, 213946445, 214055079, 215125040, 215134273, 215135028, 215237420, 215418148, 215553166, 215553394, 215563858, 215627949, 215754324, 217529652, 217713834, 217732628, 218731945, 221417045, 221424946, 221493746, 221515401, 221658189, 221908140, 221910626, 221921586, 222659762, 225001091, 236105833, 236113965, 236194995, 236195427, 236206132, 236206387, 236211683, 236212707, 236381647, 236571826, 237124271, 238172205, 238210544, 238270764, 238435405, 238501172, 239224867, 239257644, 239710497, 240307721, 241208789, 241241557, 241318060, 241319404, 241343533, 241344069, 241405397, 241765845, 243864964, 244502085, 244946220, 245109902, 247647266, 247707956, 248648814, 248648836, 248682161, 248986932, 249058914, 249697357, 252132601, 252135604, 252317348, 255007012, 255278388, 255641645, 256365156, 257566121, 269763372, 271202790, 271863856, 272049197, 272127474, 274339449, 274939471, 275388004, 275388005, 275388006, 275977800, 278267602, 278513831, 278712622, 281613765, 281683369, 282120228, 282250732, 282498697, 282508942, 283743649, 283787570, 284710386, 285391148, 285478533, 285854898, 285873762, 286931113, 288964227, 289445441, 289591340, 289689648, 291671489, 303512884, 305319975, 305610036, 305764101, 308448294, 308675890, 312085683, 312264750, 315032867, 316391000, 317331042, 317902135, 318950711, 319447220, 321499182, 322538804, 323145200, 337067316, 337826293, 339905989, 340833697, 341457068, 342310196, 345302593, 349554733, 349771471, 349786245, 350819405, 356072847, 370349192, 373962798, 375558638, 375574835, 376053993, 383276530, 383373833, 383407586, 384439906, 386079012, 404133513, 404307343, 407031852, 408072233, 409112005, 409608425, 409771500, 419040932, 437730612, 439529766, 442616365, 442813037, 443157674, 443295316, 450118444, 450482697, 456789668, 459935396, 471217869, 474073645, 476230702, 476665218, 476717289, 483014825, 485083298, 489306281, 538364390, 540675748, 543819186, 543958612, 576960820, 577242548, 610515252, 642202932, 644420819 };
staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HASHES_DATA, MOZ_ARRAY_LENGTH(ELEMENT_HASHES_DATA) };
void
nsHtml5ElementName::initializeStatics()
{
@ -851,6 +852,7 @@ nsHtml5ElementName::initializeStatics()
ELT_QUOTIENT = new nsHtml5ElementName(nsHtml5Atoms::quotient, nsHtml5Atoms::quotient, NS_HTML5TREE_BUILDER_OTHER);
ELT_SELECTOR = new nsHtml5ElementName(nsHtml5Atoms::selector, nsHtml5Atoms::selector, NS_HTML5TREE_BUILDER_OTHER);
ELT_TEXTAREA = new nsHtml5ElementName(nsHtml5Atoms::textarea, nsHtml5Atoms::textarea, NS_HTML5TREE_BUILDER_TEXTAREA | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_TEMPLATE = new nsHtml5ElementName(nsHtml5Atoms::template_, nsHtml5Atoms::template_, NS_HTML5TREE_BUILDER_TEMPLATE | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_TEXTPATH = new nsHtml5ElementName(nsHtml5Atoms::textpath, nsHtml5Atoms::textPath, NS_HTML5TREE_BUILDER_OTHER);
ELT_VARIANCE = new nsHtml5ElementName(nsHtml5Atoms::variance, nsHtml5Atoms::variance, NS_HTML5TREE_BUILDER_OTHER);
ELT_ANIMATION = new nsHtml5ElementName(nsHtml5Atoms::animation, nsHtml5Atoms::animation, NS_HTML5TREE_BUILDER_OTHER);
@ -927,7 +929,7 @@ nsHtml5ElementName::initializeStatics()
ELT_FESPECULARLIGHTING = new nsHtml5ElementName(nsHtml5Atoms::fespecularlighting, nsHtml5Atoms::feSpecularLighting, NS_HTML5TREE_BUILDER_OTHER);
ELT_DOMAINOFAPPLICATION = new nsHtml5ElementName(nsHtml5Atoms::domainofapplication, nsHtml5Atoms::domainofapplication, NS_HTML5TREE_BUILDER_OTHER);
ELT_FECOMPONENTTRANSFER = new nsHtml5ElementName(nsHtml5Atoms::fecomponenttransfer, nsHtml5Atoms::feComponentTransfer, NS_HTML5TREE_BUILDER_OTHER);
ELEMENT_NAMES = new nsHtml5ElementName*[393];
ELEMENT_NAMES = new nsHtml5ElementName*[394];
ELEMENT_NAMES[0] = ELT_A;
ELEMENT_NAMES[1] = ELT_B;
ELEMENT_NAMES[2] = ELT_G;
@ -1245,82 +1247,83 @@ nsHtml5ElementName::initializeStatics()
ELEMENT_NAMES[314] = ELT_QUOTIENT;
ELEMENT_NAMES[315] = ELT_SELECTOR;
ELEMENT_NAMES[316] = ELT_TEXTAREA;
ELEMENT_NAMES[317] = ELT_TEXTPATH;
ELEMENT_NAMES[318] = ELT_VARIANCE;
ELEMENT_NAMES[319] = ELT_ANIMATION;
ELEMENT_NAMES[320] = ELT_CONJUGATE;
ELEMENT_NAMES[321] = ELT_CONDITION;
ELEMENT_NAMES[322] = ELT_COMPLEXES;
ELEMENT_NAMES[323] = ELT_FONT_FACE;
ELEMENT_NAMES[324] = ELT_FACTORIAL;
ELEMENT_NAMES[325] = ELT_INTERSECT;
ELEMENT_NAMES[326] = ELT_IMAGINARY;
ELEMENT_NAMES[327] = ELT_LAPLACIAN;
ELEMENT_NAMES[328] = ELT_MATRIXROW;
ELEMENT_NAMES[329] = ELT_NOTSUBSET;
ELEMENT_NAMES[330] = ELT_OTHERWISE;
ELEMENT_NAMES[331] = ELT_PIECEWISE;
ELEMENT_NAMES[332] = ELT_PLAINTEXT;
ELEMENT_NAMES[333] = ELT_RATIONALS;
ELEMENT_NAMES[334] = ELT_SEMANTICS;
ELEMENT_NAMES[335] = ELT_TRANSPOSE;
ELEMENT_NAMES[336] = ELT_ANNOTATION;
ELEMENT_NAMES[337] = ELT_BLOCKQUOTE;
ELEMENT_NAMES[338] = ELT_DIVERGENCE;
ELEMENT_NAMES[339] = ELT_EULERGAMMA;
ELEMENT_NAMES[340] = ELT_EQUIVALENT;
ELEMENT_NAMES[341] = ELT_FIGCAPTION;
ELEMENT_NAMES[342] = ELT_IMAGINARYI;
ELEMENT_NAMES[343] = ELT_MALIGNMARK;
ELEMENT_NAMES[344] = ELT_MUNDEROVER;
ELEMENT_NAMES[345] = ELT_MLABELEDTR;
ELEMENT_NAMES[346] = ELT_NOTANUMBER;
ELEMENT_NAMES[347] = ELT_SOLIDCOLOR;
ELEMENT_NAMES[348] = ELT_ALTGLYPHDEF;
ELEMENT_NAMES[349] = ELT_DETERMINANT;
ELEMENT_NAMES[350] = ELT_FEMERGENODE;
ELEMENT_NAMES[351] = ELT_FECOMPOSITE;
ELEMENT_NAMES[352] = ELT_FESPOTLIGHT;
ELEMENT_NAMES[353] = ELT_MALIGNGROUP;
ELEMENT_NAMES[354] = ELT_MPRESCRIPTS;
ELEMENT_NAMES[355] = ELT_MOMENTABOUT;
ELEMENT_NAMES[356] = ELT_NOTPRSUBSET;
ELEMENT_NAMES[357] = ELT_PARTIALDIFF;
ELEMENT_NAMES[358] = ELT_ALTGLYPHITEM;
ELEMENT_NAMES[359] = ELT_ANIMATECOLOR;
ELEMENT_NAMES[360] = ELT_DATATEMPLATE;
ELEMENT_NAMES[361] = ELT_EXPONENTIALE;
ELEMENT_NAMES[362] = ELT_FETURBULENCE;
ELEMENT_NAMES[363] = ELT_FEPOINTLIGHT;
ELEMENT_NAMES[364] = ELT_FEMORPHOLOGY;
ELEMENT_NAMES[365] = ELT_OUTERPRODUCT;
ELEMENT_NAMES[366] = ELT_ANIMATEMOTION;
ELEMENT_NAMES[367] = ELT_COLOR_PROFILE;
ELEMENT_NAMES[368] = ELT_FONT_FACE_SRC;
ELEMENT_NAMES[369] = ELT_FONT_FACE_URI;
ELEMENT_NAMES[370] = ELT_FOREIGNOBJECT;
ELEMENT_NAMES[371] = ELT_FECOLORMATRIX;
ELEMENT_NAMES[372] = ELT_MISSING_GLYPH;
ELEMENT_NAMES[373] = ELT_MMULTISCRIPTS;
ELEMENT_NAMES[374] = ELT_SCALARPRODUCT;
ELEMENT_NAMES[375] = ELT_VECTORPRODUCT;
ELEMENT_NAMES[376] = ELT_ANNOTATION_XML;
ELEMENT_NAMES[377] = ELT_DEFINITION_SRC;
ELEMENT_NAMES[378] = ELT_FONT_FACE_NAME;
ELEMENT_NAMES[379] = ELT_FEGAUSSIANBLUR;
ELEMENT_NAMES[380] = ELT_FEDISTANTLIGHT;
ELEMENT_NAMES[381] = ELT_LINEARGRADIENT;
ELEMENT_NAMES[382] = ELT_NATURALNUMBERS;
ELEMENT_NAMES[383] = ELT_RADIALGRADIENT;
ELEMENT_NAMES[384] = ELT_ANIMATETRANSFORM;
ELEMENT_NAMES[385] = ELT_CARTESIANPRODUCT;
ELEMENT_NAMES[386] = ELT_FONT_FACE_FORMAT;
ELEMENT_NAMES[387] = ELT_FECONVOLVEMATRIX;
ELEMENT_NAMES[388] = ELT_FEDIFFUSELIGHTING;
ELEMENT_NAMES[389] = ELT_FEDISPLACEMENTMAP;
ELEMENT_NAMES[390] = ELT_FESPECULARLIGHTING;
ELEMENT_NAMES[391] = ELT_DOMAINOFAPPLICATION;
ELEMENT_NAMES[392] = ELT_FECOMPONENTTRANSFER;
ELEMENT_NAMES[317] = ELT_TEMPLATE;
ELEMENT_NAMES[318] = ELT_TEXTPATH;
ELEMENT_NAMES[319] = ELT_VARIANCE;
ELEMENT_NAMES[320] = ELT_ANIMATION;
ELEMENT_NAMES[321] = ELT_CONJUGATE;
ELEMENT_NAMES[322] = ELT_CONDITION;
ELEMENT_NAMES[323] = ELT_COMPLEXES;
ELEMENT_NAMES[324] = ELT_FONT_FACE;
ELEMENT_NAMES[325] = ELT_FACTORIAL;
ELEMENT_NAMES[326] = ELT_INTERSECT;
ELEMENT_NAMES[327] = ELT_IMAGINARY;
ELEMENT_NAMES[328] = ELT_LAPLACIAN;
ELEMENT_NAMES[329] = ELT_MATRIXROW;
ELEMENT_NAMES[330] = ELT_NOTSUBSET;
ELEMENT_NAMES[331] = ELT_OTHERWISE;
ELEMENT_NAMES[332] = ELT_PIECEWISE;
ELEMENT_NAMES[333] = ELT_PLAINTEXT;
ELEMENT_NAMES[334] = ELT_RATIONALS;
ELEMENT_NAMES[335] = ELT_SEMANTICS;
ELEMENT_NAMES[336] = ELT_TRANSPOSE;
ELEMENT_NAMES[337] = ELT_ANNOTATION;
ELEMENT_NAMES[338] = ELT_BLOCKQUOTE;
ELEMENT_NAMES[339] = ELT_DIVERGENCE;
ELEMENT_NAMES[340] = ELT_EULERGAMMA;
ELEMENT_NAMES[341] = ELT_EQUIVALENT;
ELEMENT_NAMES[342] = ELT_FIGCAPTION;
ELEMENT_NAMES[343] = ELT_IMAGINARYI;
ELEMENT_NAMES[344] = ELT_MALIGNMARK;
ELEMENT_NAMES[345] = ELT_MUNDEROVER;
ELEMENT_NAMES[346] = ELT_MLABELEDTR;
ELEMENT_NAMES[347] = ELT_NOTANUMBER;
ELEMENT_NAMES[348] = ELT_SOLIDCOLOR;
ELEMENT_NAMES[349] = ELT_ALTGLYPHDEF;
ELEMENT_NAMES[350] = ELT_DETERMINANT;
ELEMENT_NAMES[351] = ELT_FEMERGENODE;
ELEMENT_NAMES[352] = ELT_FECOMPOSITE;
ELEMENT_NAMES[353] = ELT_FESPOTLIGHT;
ELEMENT_NAMES[354] = ELT_MALIGNGROUP;
ELEMENT_NAMES[355] = ELT_MPRESCRIPTS;
ELEMENT_NAMES[356] = ELT_MOMENTABOUT;
ELEMENT_NAMES[357] = ELT_NOTPRSUBSET;
ELEMENT_NAMES[358] = ELT_PARTIALDIFF;
ELEMENT_NAMES[359] = ELT_ALTGLYPHITEM;
ELEMENT_NAMES[360] = ELT_ANIMATECOLOR;
ELEMENT_NAMES[361] = ELT_DATATEMPLATE;
ELEMENT_NAMES[362] = ELT_EXPONENTIALE;
ELEMENT_NAMES[363] = ELT_FETURBULENCE;
ELEMENT_NAMES[364] = ELT_FEPOINTLIGHT;
ELEMENT_NAMES[365] = ELT_FEMORPHOLOGY;
ELEMENT_NAMES[366] = ELT_OUTERPRODUCT;
ELEMENT_NAMES[367] = ELT_ANIMATEMOTION;
ELEMENT_NAMES[368] = ELT_COLOR_PROFILE;
ELEMENT_NAMES[369] = ELT_FONT_FACE_SRC;
ELEMENT_NAMES[370] = ELT_FONT_FACE_URI;
ELEMENT_NAMES[371] = ELT_FOREIGNOBJECT;
ELEMENT_NAMES[372] = ELT_FECOLORMATRIX;
ELEMENT_NAMES[373] = ELT_MISSING_GLYPH;
ELEMENT_NAMES[374] = ELT_MMULTISCRIPTS;
ELEMENT_NAMES[375] = ELT_SCALARPRODUCT;
ELEMENT_NAMES[376] = ELT_VECTORPRODUCT;
ELEMENT_NAMES[377] = ELT_ANNOTATION_XML;
ELEMENT_NAMES[378] = ELT_DEFINITION_SRC;
ELEMENT_NAMES[379] = ELT_FONT_FACE_NAME;
ELEMENT_NAMES[380] = ELT_FEGAUSSIANBLUR;
ELEMENT_NAMES[381] = ELT_FEDISTANTLIGHT;
ELEMENT_NAMES[382] = ELT_LINEARGRADIENT;
ELEMENT_NAMES[383] = ELT_NATURALNUMBERS;
ELEMENT_NAMES[384] = ELT_RADIALGRADIENT;
ELEMENT_NAMES[385] = ELT_ANIMATETRANSFORM;
ELEMENT_NAMES[386] = ELT_CARTESIANPRODUCT;
ELEMENT_NAMES[387] = ELT_FONT_FACE_FORMAT;
ELEMENT_NAMES[388] = ELT_FECONVOLVEMATRIX;
ELEMENT_NAMES[389] = ELT_FEDIFFUSELIGHTING;
ELEMENT_NAMES[390] = ELT_FEDISPLACEMENTMAP;
ELEMENT_NAMES[391] = ELT_FESPECULARLIGHTING;
ELEMENT_NAMES[392] = ELT_DOMAINOFAPPLICATION;
ELEMENT_NAMES[393] = ELT_FECOMPONENTTRANSFER;
}
void
@ -1644,6 +1647,7 @@ nsHtml5ElementName::releaseStatics()
delete ELT_QUOTIENT;
delete ELT_SELECTOR;
delete ELT_TEXTAREA;
delete ELT_TEMPLATE;
delete ELT_TEXTPATH;
delete ELT_VARIANCE;
delete ELT_ANIMATION;

View File

@ -395,6 +395,7 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_QUOTIENT;
static nsHtml5ElementName* ELT_SELECTOR;
static nsHtml5ElementName* ELT_TEXTAREA;
static nsHtml5ElementName* ELT_TEMPLATE;
static nsHtml5ElementName* ELT_TEXTPATH;
static nsHtml5ElementName* ELT_VARIANCE;
static nsHtml5ElementName* ELT_ANIMATION;

View File

@ -55,13 +55,13 @@
#include "nsHtml5MetaScanner.h"
static PRUnichar const CHARSET_DATA[] = { 'h', 'a', 'r', 's', 'e', 't' };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CHARSET = { CHARSET_DATA, NS_ARRAY_LENGTH(CHARSET_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CHARSET = { CHARSET_DATA, MOZ_ARRAY_LENGTH(CHARSET_DATA) };
static PRUnichar const CONTENT_DATA[] = { 'o', 'n', 't', 'e', 'n', 't' };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CONTENT = { CONTENT_DATA, NS_ARRAY_LENGTH(CONTENT_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CONTENT = { CONTENT_DATA, MOZ_ARRAY_LENGTH(CONTENT_DATA) };
static PRUnichar const HTTP_EQUIV_DATA[] = { 't', 't', 'p', '-', 'e', 'q', 'u', 'i', 'v' };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::HTTP_EQUIV = { HTTP_EQUIV_DATA, NS_ARRAY_LENGTH(HTTP_EQUIV_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::HTTP_EQUIV = { HTTP_EQUIV_DATA, MOZ_ARRAY_LENGTH(HTTP_EQUIV_DATA) };
static PRUnichar const CONTENT_TYPE_DATA[] = { 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p', 'e' };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE_DATA, NS_ARRAY_LENGTH(CONTENT_TYPE_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE_DATA, MOZ_ARRAY_LENGTH(CONTENT_TYPE_DATA) };
nsHtml5MetaScanner::nsHtml5MetaScanner()
: readable(nullptr),

View File

@ -68,25 +68,25 @@ PRUnichar nsHtml5Tokenizer::OCTYPE[] = { 'o', 'c', 't', 'y', 'p', 'e' };
PRUnichar nsHtml5Tokenizer::UBLIC[] = { 'u', 'b', 'l', 'i', 'c' };
PRUnichar nsHtml5Tokenizer::YSTEM[] = { 'y', 's', 't', 'e', 'm' };
static PRUnichar const TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, NS_ARRAY_LENGTH(TITLE_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, MOZ_ARRAY_LENGTH(TITLE_ARR_DATA) };
static PRUnichar const SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, NS_ARRAY_LENGTH(SCRIPT_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(SCRIPT_ARR_DATA) };
static PRUnichar const STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, NS_ARRAY_LENGTH(STYLE_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, MOZ_ARRAY_LENGTH(STYLE_ARR_DATA) };
static PRUnichar const PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, NS_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, MOZ_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) };
static PRUnichar const XMP_ARR_DATA[] = { 'x', 'm', 'p' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, NS_ARRAY_LENGTH(XMP_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, MOZ_ARRAY_LENGTH(XMP_ARR_DATA) };
static PRUnichar const TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, NS_ARRAY_LENGTH(TEXTAREA_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, MOZ_ARRAY_LENGTH(TEXTAREA_ARR_DATA) };
static PRUnichar const IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, NS_ARRAY_LENGTH(IFRAME_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, MOZ_ARRAY_LENGTH(IFRAME_ARR_DATA) };
static PRUnichar const NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, NS_ARRAY_LENGTH(NOEMBED_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, MOZ_ARRAY_LENGTH(NOEMBED_ARR_DATA) };
static PRUnichar const NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, NS_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) };
static PRUnichar const NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, NS_ARRAY_LENGTH(NOFRAMES_ARR_DATA) };
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, MOZ_ARRAY_LENGTH(NOFRAMES_ARR_DATA) };
nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource)
: tokenHandler(tokenHandler),

View File

@ -1,25 +1,25 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2011 Mozilla Foundation
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
@ -50,6 +50,7 @@
#include "nsHtml5StreamParser.h"
#include "nsAHtml5TreeBuilderState.h"
#include "nsHtml5Highlighter.h"
#include "nsHtml5PlainTextUtils.h"
#include "nsHtml5ViewSourceUtils.h"
#include "mozilla/Likely.h"
@ -67,15 +68,17 @@
PRUnichar nsHtml5TreeBuilder::REPLACEMENT_CHARACTER[] = { 0xfffd };
static const char* const QUIRKY_PUBLIC_IDS_DATA[] = { "+//silmaril//dtd html pro v0r11 19970101//", "-//advasoft ltd//dtd html 3.0 aswedit + extensions//", "-//as//dtd html 3.0 aswedit + extensions//", "-//ietf//dtd html 2.0 level 1//", "-//ietf//dtd html 2.0 level 2//", "-//ietf//dtd html 2.0 strict level 1//", "-//ietf//dtd html 2.0 strict level 2//", "-//ietf//dtd html 2.0 strict//", "-//ietf//dtd html 2.0//", "-//ietf//dtd html 2.1e//", "-//ietf//dtd html 3.0//", "-//ietf//dtd html 3.2 final//", "-//ietf//dtd html 3.2//", "-//ietf//dtd html 3//", "-//ietf//dtd html level 0//", "-//ietf//dtd html level 1//", "-//ietf//dtd html level 2//", "-//ietf//dtd html level 3//", "-//ietf//dtd html strict level 0//", "-//ietf//dtd html strict level 1//", "-//ietf//dtd html strict level 2//", "-//ietf//dtd html strict level 3//", "-//ietf//dtd html strict//", "-//ietf//dtd html//", "-//metrius//dtd metrius presentational//", "-//microsoft//dtd internet explorer 2.0 html strict//", "-//microsoft//dtd internet explorer 2.0 html//", "-//microsoft//dtd internet explorer 2.0 tables//", "-//microsoft//dtd internet explorer 3.0 html strict//", "-//microsoft//dtd internet explorer 3.0 html//", "-//microsoft//dtd internet explorer 3.0 tables//", "-//netscape comm. corp.//dtd html//", "-//netscape comm. corp.//dtd strict html//", "-//o'reilly and associates//dtd html 2.0//", "-//o'reilly and associates//dtd html extended 1.0//", "-//o'reilly and associates//dtd html extended relaxed 1.0//", "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//", "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//", "-//spyglass//dtd html 2.0 extended//", "-//sq//dtd html 2.0 hotmetal + extensions//", "-//sun microsystems corp.//dtd hotjava html//", "-//sun microsystems corp.//dtd hotjava strict html//", "-//w3c//dtd html 3 1995-03-24//", "-//w3c//dtd html 3.2 draft//", "-//w3c//dtd html 3.2 final//", "-//w3c//dtd html 3.2//", "-//w3c//dtd html 3.2s draft//", "-//w3c//dtd html 4.0 frameset//", "-//w3c//dtd html 4.0 transitional//", "-//w3c//dtd html experimental 19960712//", "-//w3c//dtd html experimental 970421//", "-//w3c//dtd w3 html//", "-//w3o//dtd w3 html 3.0//", "-//webtechs//dtd mozilla html 2.0//", "-//webtechs//dtd mozilla html//" };
staticJArray<const char*,int32_t> nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = { QUIRKY_PUBLIC_IDS_DATA, NS_ARRAY_LENGTH(QUIRKY_PUBLIC_IDS_DATA) };
staticJArray<const char*,int32_t> nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = { QUIRKY_PUBLIC_IDS_DATA, MOZ_ARRAY_LENGTH(QUIRKY_PUBLIC_IDS_DATA) };
void
nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
{
tokenizer = self;
stack = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
templateModeStack = jArray<int32_t,int32_t>::newJArray(64);
listOfActiveFormattingElements = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
needToDropLF = false;
originalMode = NS_HTML5TREE_BUILDER_INITIAL;
templateModePtr = -1;
currentPtr = -1;
listPtr = -1;
formPointer = nullptr;
@ -95,6 +98,9 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
currentPtr++;
stack[currentPtr] = node;
if (nsHtml5Atoms::template_ == contextName) {
pushTemplateMode(NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS);
}
resetTheInsertionMode();
if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) {
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, contextName);
@ -231,6 +237,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
continue;
}
case NS_HTML5TREE_BUILDER_FRAMESET_OK:
case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS:
case NS_HTML5TREE_BUILDER_IN_BODY:
case NS_HTML5TREE_BUILDER_IN_CELL:
case NS_HTML5TREE_BUILDER_IN_CAPTION: {
@ -333,6 +340,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
i--;
continue;
}
case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS:
case NS_HTML5TREE_BUILDER_IN_BODY:
case NS_HTML5TREE_BUILDER_IN_CELL:
case NS_HTML5TREE_BUILDER_IN_CAPTION: {
@ -358,7 +366,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
accumulateCharacters(buf, start, i - start);
start = i;
}
if (!currentPtr) {
if (!currentPtr || stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
errNonSpaceInColgroupInFragment();
start = i + 1;
continue;
@ -512,6 +520,15 @@ nsHtml5TreeBuilder::eof()
case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
NS_HTML5_BREAK(eofloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS: {
if (!currentPtr) {
MOZ_ASSERT(fragment);
NS_HTML5_BREAK(eofloop);
}
popOnEof();
resetTheInsertionMode();
continue;
}
case NS_HTML5TREE_BUILDER_AFTER_BODY:
case NS_HTML5TREE_BUILDER_AFTER_FRAMESET:
case NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY:
@ -536,6 +553,7 @@ nsHtml5TreeBuilder::endTokenization()
formPointer = nullptr;
headPointer = nullptr;
deepTreeSurrogateParent = nullptr;
templateModeStack = nullptr;
if (stack) {
while (currentPtr > -1) {
stack[currentPtr]->release();
@ -629,6 +647,76 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
}
}
switch(mode) {
case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS: {
switch(group) {
case NS_HTML5TREE_BUILDER_FRAME: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_FRAMESET);
mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
continue;
}
case NS_HTML5TREE_BUILDER_COL: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP);
mode = NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP;
continue;
}
case NS_HTML5TREE_BUILDER_CAPTION:
case NS_HTML5TREE_BUILDER_COLGROUP:
case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TABLE);
mode = NS_HTML5TREE_BUILDER_IN_TABLE;
continue;
}
case NS_HTML5TREE_BUILDER_TR: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TABLE_BODY);
mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
continue;
}
case NS_HTML5TREE_BUILDER_TD_OR_TH: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_ROW);
mode = NS_HTML5TREE_BUILDER_IN_ROW;
continue;
}
case NS_HTML5TREE_BUILDER_META: {
checkMetaCharset(attributes);
appendVoidElementToCurrentMayFoster(elementName, attributes);
selfClosing = false;
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
appendVoidElementToCurrentMayFoster(elementName, attributes);
selfClosing = false;
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_SCRIPT: {
startTagScriptInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_STYLE: {
startTagGenericRawText(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
startTagTemplateInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
default: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_BODY);
mode = NS_HTML5TREE_BUILDER_IN_BODY;
continue;
}
}
}
case NS_HTML5TREE_BUILDER_IN_ROW: {
switch(group) {
case NS_HTML5TREE_BUILDER_TD_OR_TH: {
@ -646,7 +734,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_TR: {
eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR);
if (!eltPos) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errNoTableRowToClose();
NS_HTML5_BREAK(starttagloop);
}
@ -662,7 +750,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_IN_TABLE_BODY: {
switch(group) {
case NS_HTML5TREE_BUILDER_TR: {
clearStackBackTo(findLastInTableScopeOrRootTbodyTheadTfoot());
clearStackBackTo(findLastInTableScopeOrRootTemplateTbodyTheadTfoot());
appendToCurrentNodeAndPushElement(elementName, attributes);
mode = NS_HTML5TREE_BUILDER_IN_ROW;
attributes = nullptr;
@ -670,7 +758,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
}
case NS_HTML5TREE_BUILDER_TD_OR_TH: {
errStartTagInTableBody(name);
clearStackBackTo(findLastInTableScopeOrRootTbodyTheadTfoot());
clearStackBackTo(findLastInTableScopeOrRootTemplateTbodyTheadTfoot());
appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_TR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
mode = NS_HTML5TREE_BUILDER_IN_ROW;
continue;
@ -679,8 +767,9 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_COL:
case NS_HTML5TREE_BUILDER_COLGROUP:
case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
eltPos = findLastInTableScopeOrRootTbodyTheadTfoot();
if (!eltPos) {
eltPos = findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
if (!eltPos || stack[eltPos]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
MOZ_ASSERT(fragment || isTemplateContents());
errStrayStartTag(name);
NS_HTML5_BREAK(starttagloop);
} else {
@ -732,11 +821,14 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
NS_HTML5_CONTINUE(starttagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
NS_HTML5_BREAK(intableloop);
}
case NS_HTML5TREE_BUILDER_TABLE: {
errTableSeenWhileTableOpen();
eltPos = findLastInTableScope(name);
if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
NS_HTML5_BREAK(starttagloop);
}
generateImpliedEndTags();
@ -847,7 +939,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_FRAMESET: {
if (mode == NS_HTML5TREE_BUILDER_FRAMESET_OK) {
if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errStrayStartTag(name);
NS_HTML5_BREAK(starttagloop);
} else {
@ -897,7 +989,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -909,12 +1001,13 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_STYLE:
case NS_HTML5TREE_BUILDER_SCRIPT:
case NS_HTML5TREE_BUILDER_TITLE:
case NS_HTML5TREE_BUILDER_COMMAND: {
case NS_HTML5TREE_BUILDER_COMMAND:
case NS_HTML5TREE_BUILDER_TEMPLATE: {
NS_HTML5_BREAK(inbodyloop);
}
case NS_HTML5TREE_BUILDER_BODY: {
if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY) {
MOZ_ASSERT(fragment);
if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY || isTemplateContents()) {
MOZ_ASSERT(fragment || isTemplateContents());
errStrayStartTag(name);
NS_HTML5_BREAK(starttagloop);
}
@ -1186,10 +1279,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_NOFRAMES:
case NS_HTML5TREE_BUILDER_IFRAME:
case NS_HTML5TREE_BUILDER_NOEMBED: {
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
startTagGenericRawText(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
@ -1297,7 +1387,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1336,19 +1426,13 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_SCRIPT: {
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
startTagScriptInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_STYLE:
case NS_HTML5TREE_BUILDER_NOFRAMES: {
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
startTagGenericRawText(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
@ -1356,6 +1440,11 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
errFooSeenWhenFooOpen(name);
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
startTagTemplateInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
default: {
pop();
mode = NS_HTML5TREE_BUILDER_AFTER_HEAD;
@ -1369,7 +1458,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1417,7 +1506,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1429,9 +1518,14 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
startTagTemplateInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
default: {
if (!currentPtr) {
MOZ_ASSERT(fragment);
if (!currentPtr || stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
MOZ_ASSERT(fragment || isTemplateContents());
errGarbageInColgroup();
NS_HTML5_BREAK(starttagloop);
}
@ -1524,10 +1618,12 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
continue;
}
case NS_HTML5TREE_BUILDER_SCRIPT: {
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
startTagScriptInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
startTagTemplateInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
@ -1541,7 +1637,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1567,6 +1663,11 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
startTagTemplateInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
default:
; // fall through
}
@ -1575,7 +1676,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1624,7 +1725,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1647,7 +1748,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1744,7 +1845,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
@ -1762,17 +1863,14 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
switch(group) {
case NS_HTML5TREE_BUILDER_HTML: {
errStrayStartTag(name);
if (!fragment) {
if (!fragment && !isTemplateContents()) {
addAttributesToHtml(attributes);
attributes = nullptr;
}
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_NOFRAMES: {
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
startTagScriptInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
@ -1797,6 +1895,40 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
}
}
void
nsHtml5TreeBuilder::startTagGenericRawText(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
}
void
nsHtml5TreeBuilder::startTagScriptInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEXT;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
}
void
nsHtml5TreeBuilder::startTagTemplateInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
insertMarker();
appendToCurrentNodeAndPushElement(elementName, attributes);
originalMode = mode;
mode = NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS;
pushTemplateMode(NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS);
}
bool
nsHtml5TreeBuilder::isTemplateContents()
{
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK != findLast(nsHtml5Atoms::template_);
}
bool
nsHtml5TreeBuilder::isSpecialParentInForeign(nsHtml5StackNode* stackNode)
{
@ -2052,12 +2184,23 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
}
switch(mode) {
case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS: {
switch(group) {
case NS_HTML5TREE_BUILDER_TEMPLATE: {
break;
}
default: {
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
}
}
case NS_HTML5TREE_BUILDER_IN_ROW: {
switch(group) {
case NS_HTML5TREE_BUILDER_TR: {
eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR);
if (!eltPos) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errNoTableRowToClose();
NS_HTML5_BREAK(endtagloop);
}
@ -2069,7 +2212,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_TABLE: {
eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR);
if (!eltPos) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errNoTableRowToClose();
NS_HTML5_BREAK(endtagloop);
}
@ -2085,7 +2228,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR);
if (!eltPos) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errNoTableRowToClose();
NS_HTML5_BREAK(endtagloop);
}
@ -2121,9 +2264,9 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TABLE: {
eltPos = findLastInTableScopeOrRootTbodyTheadTfoot();
if (!eltPos) {
MOZ_ASSERT(fragment);
eltPos = findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
if (!eltPos || stack[eltPos]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
MOZ_ASSERT(fragment || isTemplateContents());
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@ -2151,7 +2294,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_TABLE: {
eltPos = findLast(nsHtml5Atoms::table);
if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@ -2172,6 +2315,9 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
break;
}
default: {
errStrayEndTag(name);
}
@ -2249,6 +2395,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
case NS_HTML5TREE_BUILDER_TR: {
if (findLastInTableScope(name) == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
MOZ_ASSERT(name == nsHtml5Atoms::tbody || name == nsHtml5Atoms::tfoot || name == nsHtml5Atoms::thead || fragment || isTemplateContents());
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@ -2272,7 +2419,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
switch(group) {
case NS_HTML5TREE_BUILDER_BODY: {
if (!isSecondOnStackBody()) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@ -2303,7 +2450,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
case NS_HTML5TREE_BUILDER_HTML: {
if (!isSecondOnStackBody()) {
MOZ_ASSERT(fragment);
MOZ_ASSERT(fragment || isTemplateContents());
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@ -2465,6 +2612,9 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
appendVoidElementToCurrentMayFoster(elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
break;
}
case NS_HTML5TREE_BUILDER_AREA_OR_WBR:
#ifdef ENABLE_VOID_MENUITEM
case NS_HTML5TREE_BUILDER_MENUITEM:
@ -2540,6 +2690,10 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
mode = NS_HTML5TREE_BUILDER_AFTER_HEAD;
continue;
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
endTagTemplateInHead(name);
NS_HTML5_BREAK(endtagloop);
}
default: {
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
@ -2568,8 +2722,8 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP: {
switch(group) {
case NS_HTML5TREE_BUILDER_COLGROUP: {
if (!currentPtr) {
MOZ_ASSERT(fragment);
if (!currentPtr || stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
MOZ_ASSERT(fragment || isTemplateContents());
errGarbageInColgroup();
NS_HTML5_BREAK(endtagloop);
}
@ -2581,9 +2735,13 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
endTagTemplateInHead(name);
NS_HTML5_BREAK(endtagloop);
}
default: {
if (!currentPtr) {
MOZ_ASSERT(fragment);
if (!currentPtr || stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
MOZ_ASSERT(fragment || isTemplateContents());
errGarbageInColgroup();
NS_HTML5_BREAK(endtagloop);
}
@ -2655,6 +2813,10 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
resetTheInsertionMode();
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
endTagTemplateInHead(name);
NS_HTML5_BREAK(endtagloop);
}
default: {
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
@ -2682,8 +2844,8 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
switch(group) {
case NS_HTML5TREE_BUILDER_FRAMESET: {
if (!currentPtr) {
MOZ_ASSERT(fragment);
if (!currentPtr || isTemplateContents()) {
MOZ_ASSERT(fragment || isTemplateContents());
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@ -2693,6 +2855,10 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
endTagTemplateInHead(name);
NS_HTML5_BREAK(endtagloop);
}
default: {
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
@ -2787,11 +2953,31 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
endtagloop_end: ;
}
void
nsHtml5TreeBuilder::endTagTemplateInHead(nsIAtom* name)
{
int32_t eltPos = findLast(name);
if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
errStrayEndTag(name);
return;
}
generateImpliedEndTags();
if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
errUnclosedElements(eltPos, name);
}
while (currentPtr >= eltPos) {
pop();
}
clearTheListOfActiveFormattingElementsUpToTheLastMarker();
popTemplateMode();
resetTheInsertionMode();
}
int32_t
nsHtml5TreeBuilder::findLastInTableScopeOrRootTbodyTheadTfoot()
nsHtml5TreeBuilder::findLastInTableScopeOrRootTemplateTbodyTheadTfoot()
{
for (int32_t i = currentPtr; i > 0; i--) {
if (stack[i]->getGroup() == NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT) {
if (stack[i]->getGroup() == NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT || stack[i]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
return i;
}
}
@ -2815,7 +3001,7 @@ nsHtml5TreeBuilder::findLastInTableScope(nsIAtom* name)
for (int32_t i = currentPtr; i > 0; i--) {
if (stack[i]->name == name) {
return i;
} else if (stack[i]->name == nsHtml5Atoms::table) {
} else if (stack[i]->name == nsHtml5Atoms::table || stack[i]->name == nsHtml5Atoms::template_) {
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
}
}
@ -3008,7 +3194,7 @@ nsHtml5TreeBuilder::findLastInTableScopeTdTh()
nsIAtom* name = stack[i]->name;
if (nsHtml5Atoms::td == name || nsHtml5Atoms::th == name) {
return i;
} else if (name == nsHtml5Atoms::table) {
} else if (name == nsHtml5Atoms::table || name == nsHtml5Atoms::template_) {
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
}
}
@ -3018,7 +3204,11 @@ nsHtml5TreeBuilder::findLastInTableScopeTdTh()
void
nsHtml5TreeBuilder::clearStackBackTo(int32_t eltPos)
{
int32_t eltGroup = stack[eltPos]->getGroup();
while (currentPtr > eltPos) {
if (stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE && (eltGroup == NS_HTML5TREE_BUILDER_TABLE || eltGroup == NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT || eltGroup == NS_HTML5TREE_BUILDER_TR || eltGroup == NS_HTML5TREE_BUILDER_HTML)) {
return;
}
pop();
}
}
@ -3042,7 +3232,10 @@ nsHtml5TreeBuilder::resetTheInsertionMode()
return;
}
}
if (nsHtml5Atoms::select == name) {
if (nsHtml5Atoms::template_ == name) {
mode = templateModeStack[templateModePtr];
return;
} else if (nsHtml5Atoms::select == name) {
mode = NS_HTML5TREE_BUILDER_IN_SELECT;
return;
} else if (nsHtml5Atoms::td == name || nsHtml5Atoms::th == name) {
@ -3067,7 +3260,11 @@ nsHtml5TreeBuilder::resetTheInsertionMode()
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
return;
} else if (nsHtml5Atoms::head == name) {
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
if (name == contextName) {
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
} else {
mode = NS_HTML5TREE_BUILDER_IN_HEAD;
}
return;
} else if (nsHtml5Atoms::body == name) {
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
@ -3119,6 +3316,18 @@ nsHtml5TreeBuilder::debugOnlyClearLastListSlot()
return true;
}
void
nsHtml5TreeBuilder::pushTemplateMode(int32_t mode)
{
templateModePtr++;
if (templateModePtr == templateModeStack.length) {
jArray<int32_t,int32_t> newStack = jArray<int32_t,int32_t>::newJArray(templateModeStack.length + 64);
nsHtml5ArrayCopy::arraycopy(templateModeStack, newStack, templateModeStack.length);
templateModeStack = newStack;
}
templateModeStack[templateModePtr] = mode;
}
void
nsHtml5TreeBuilder::push(nsHtml5StackNode* node)
{
@ -3503,14 +3712,14 @@ nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
void
nsHtml5TreeBuilder::insertIntoFosterParent(nsIContent** child)
{
int32_t eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE);
nsHtml5StackNode* node = stack[eltPos];
nsIContent** elt = node->node;
if (!eltPos) {
appendElement(child, elt);
int32_t tablePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE);
int32_t templatePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TEMPLATE);
if (templatePos >= tablePos) {
appendElement(child, stack[templatePos]->node);
return;
}
insertFosterParentedChild(child, elt, stack[eltPos - 1]->node);
nsHtml5StackNode* node = stack[tablePos];
insertFosterParentedChild(child, node->node, stack[tablePos - 1]->node);
}
bool
@ -3524,6 +3733,12 @@ nsHtml5TreeBuilder::isInStack(nsHtml5StackNode* node)
return false;
}
void
nsHtml5TreeBuilder::popTemplateMode()
{
templateModePtr--;
}
void
nsHtml5TreeBuilder::pop()
{
@ -3628,6 +3843,9 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(nsHtml5ElementName* elemen
{
nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes);
appendElement(elt, stack[currentPtr]->node);
if (nsHtml5ElementName::ELT_TEMPLATE == elementName) {
elt = getDocumentFragmentForTemplate(elt);
}
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt);
push(node);
}

View File

@ -1,25 +1,25 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2011 Mozilla Foundation
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
@ -84,6 +84,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
nsIAtom* contextName;
int32_t contextNamespace;
nsIContent** contextNode;
autoJArray<int32_t,int32_t> templateModeStack;
int32_t templateModePtr;
autoJArray<nsHtml5StackNode*,int32_t> stack;
int32_t currentPtr;
autoJArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements;
@ -106,6 +108,10 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void endTokenization();
void startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, bool selfClosing);
private:
void startTagGenericRawText(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void startTagScriptInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void startTagTemplateInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
bool isTemplateContents();
bool isSpecialParentInForeign(nsHtml5StackNode* stackNode);
public:
static nsString* extractCharsetFromContent(nsString* attributeValue);
@ -114,7 +120,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
public:
void endTag(nsHtml5ElementName* elementName);
private:
int32_t findLastInTableScopeOrRootTbodyTheadTfoot();
void endTagTemplateInHead(nsIAtom* name);
int32_t findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
int32_t findLast(nsIAtom* name);
int32_t findLastInTableScope(nsIAtom* name);
int32_t findLastInButtonScope(nsIAtom* name);
@ -134,6 +141,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void implicitlyCloseP();
bool debugOnlyClearLastStackSlot();
bool debugOnlyClearLastListSlot();
void pushTemplateMode(int32_t mode);
void push(nsHtml5StackNode* node);
void silentPush(nsHtml5StackNode* node);
void append(nsHtml5StackNode* node);
@ -165,6 +173,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void reconstructTheActiveFormattingElements();
void insertIntoFosterParent(nsIContent** child);
bool isInStack(nsHtml5StackNode* node);
void popTemplateMode();
void pop();
void silentPop();
void popOnEof();
@ -320,6 +329,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#define NS_HTML5TREE_BUILDER_FONT 64
#define NS_HTML5TREE_BUILDER_KEYGEN 65
#define NS_HTML5TREE_BUILDER_MENUITEM 66
#define NS_HTML5TREE_BUILDER_TEMPLATE 67
#define NS_HTML5TREE_BUILDER_IN_ROW 0
#define NS_HTML5TREE_BUILDER_IN_TABLE_BODY 1
#define NS_HTML5TREE_BUILDER_IN_TABLE 2
@ -342,6 +352,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY 19
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET 20
#define NS_HTML5TREE_BUILDER_TEXT 21
#define NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS 22
#define NS_HTML5TREE_BUILDER_CHARSET_INITIAL 0
#define NS_HTML5TREE_BUILDER_CHARSET_C 1
#define NS_HTML5TREE_BUILDER_CHARSET_H 2