diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:14:58 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:14:58 -0400 |
commit | 071957f9fab1f5065730c79ccc46a660ace35569 (patch) | |
tree | 52326da135ed3ed0d1a39f5bc128e36675f5c5f6 /parser | |
parent | e482e335bb8de6630a171cd0a784b420d91106b2 (diff) | |
download | uxp-071957f9fab1f5065730c79ccc46a660ace35569.tar.gz |
Bug 1394300 - Streamline nsElementTable.cpp
Tag #1375
Diffstat (limited to 'parser')
-rw-r--r-- | parser/htmlparser/nsElementTable.cpp | 743 | ||||
-rw-r--r-- | parser/htmlparser/nsElementTable.h | 4 |
2 files changed, 158 insertions, 589 deletions
diff --git a/parser/htmlparser/nsElementTable.cpp b/parser/htmlparser/nsElementTable.cpp index 5c69726d1f..86fbdad861 100644 --- a/parser/htmlparser/nsElementTable.cpp +++ b/parser/htmlparser/nsElementTable.cpp @@ -14,597 +14,164 @@ // The Element Table (sung to the tune of Modern Major General) +#ifdef DEBUG +#define ELEM(tag, parent, leaf) { eHTMLTag_##tag, parent, leaf }, +#else +#define ELEM(tag, parent, leaf) { parent, leaf }, +#endif + const nsHTMLElement gHTMLElements[] = { - { - /*tag*/ eHTMLTag_unknown, - /*parent,leaf*/ kNone, true - }, - { - /*tag*/ eHTMLTag_a, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_abbr, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_acronym, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_address, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_applet, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_area, - /*parent,leaf*/ kNone, true - }, - { - /*tag*/ eHTMLTag_article, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_aside, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_audio, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_b, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_base, - /*parent,leaf*/ kHeadContent, true - }, - { - /*tag*/ eHTMLTag_basefont, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_bdo, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_bgsound, - /*parent,leaf*/ (kFlowEntity|kHeadMisc), true - }, - { - /*tag*/ eHTMLTag_big, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_blockquote, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_body, - /*parent,leaf*/ kHTMLContent, false - }, - { - /*tag*/ eHTMLTag_br, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_button, - /*parent,leaf*/ kFormControl, false - }, - { - /*tag*/ eHTMLTag_canvas, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_caption, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_center, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_cite, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_code, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_col, - /*parent,leaf*/ kNone, true - }, - { - /*tag*/ eHTMLTag_colgroup, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_content, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_data, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_datalist, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_dd, - /*parent,leaf*/ kInlineEntity, false - }, - { - /*tag*/ eHTMLTag_del, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_details, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_dfn, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_dialog, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_dir, - /*parent,leaf*/ kList, false - }, - { - /*tag*/ eHTMLTag_div, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_dl, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_dt, - /*parent,leaf*/ kInlineEntity, false - }, - { - /*tag*/ eHTMLTag_em, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_embed, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_fieldset, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_figcaption, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_figure, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_font, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_footer, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_form, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_frame, - /*parent,leaf*/ kNone, true - }, - { - /*tag*/ eHTMLTag_frameset, - /*parent,leaf*/ kHTMLContent, false - }, - { - /*tag*/ eHTMLTag_h1, - /*parent,leaf*/ kHeading, false - }, - { - /*tag*/ eHTMLTag_h2, - /*parent,leaf*/ kHeading, false - }, - { - /*tag*/ eHTMLTag_h3, - /*parent,leaf*/ kHeading, false - }, - { - /*tag*/ eHTMLTag_h4, - /*parent,leaf*/ kHeading, false - }, - { - /*tag*/ eHTMLTag_h5, - /*parent,leaf*/ kHeading, false - }, - { - /*tag*/ eHTMLTag_h6, - /*parent,leaf*/ kHeading, false - }, - { - /*tag*/ eHTMLTag_head, - /*parent,leaf*/ kHTMLContent, false - }, - { - /*tag*/ eHTMLTag_header, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_hgroup, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_hr, - /*parent,leaf*/ kBlock, true - }, - { - /*tag*/ eHTMLTag_html, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_i, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_iframe, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_image, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_img, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_input, - /*parent,leaf*/ kFormControl, true - }, - { - /*tag*/ eHTMLTag_ins, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_kbd, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_keygen, - /*parent,leaf*/ kFlowEntity, true - }, - { - /*tag*/ eHTMLTag_label, - /*parent,leaf*/ kFormControl, false - }, - { - /*tag*/ eHTMLTag_legend, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_li, - /*parent,leaf*/ kBlockEntity, false - }, - { - /*tag*/ eHTMLTag_link, - /*parent,leaf*/ kAllTags - kHeadContent, true - }, - { - /*tag*/ eHTMLTag_listing, - /*parent,leaf*/ kPreformatted, false - }, - { - /*tag*/ eHTMLTag_main, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_map, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_mark, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_marquee, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_menu, - /*parent,leaf*/ kList, false - }, - { - /*tag*/ eHTMLTag_menuitem, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_meta, - /*parent,leaf*/ kHeadContent, true - }, - { - /*tag*/ eHTMLTag_meter, - /*parent,leaf*/ kFormControl, false - }, - { - /*tag*/ eHTMLTag_multicol, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_nav, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_nobr, - /*parent,leaf*/ kExtensions, false - }, - { - /*tag*/ eHTMLTag_noembed, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_noframes, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_noscript, - /*parent,leaf*/ kFlowEntity|kHeadMisc, false - }, - { - /*tag*/ eHTMLTag_object, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_ol, - /*parent,leaf*/ kList, false - }, - { - /*tag*/ eHTMLTag_optgroup, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_option, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_output, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_p, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_param, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_picture, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_plaintext, - /*parent,leaf*/ kExtensions, false - }, - { - /*tag*/ eHTMLTag_pre, - /*parent,leaf*/ kBlock|kPreformatted, false - }, - { - /*tag*/ eHTMLTag_progress, - /*parent,leaf*/ kFormControl, false - }, - { - /*tag*/ eHTMLTag_q, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_rb, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_rp, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_rt, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_rtc, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_ruby, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_s, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_samp, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_script, - /*parent,leaf*/ (kSpecial|kHeadContent), false - }, - { - /*tag*/ eHTMLTag_section, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_select, - /*parent,leaf*/ kFormControl, false - }, - { - /*tag*/ eHTMLTag_shadow, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_small, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_source, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_span, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_strike, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_strong, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_style, - /*parent,leaf*/ kAllTags - kHeadContent, false - }, - { - /*tag*/ eHTMLTag_sub, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_summary, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_sup, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_table, - /*parent,leaf*/ kBlock, false - }, - { - /*tag*/ eHTMLTag_tbody, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_td, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_textarea, - /*parent,leaf*/ kFormControl, false - }, - { - /*tag*/ eHTMLTag_tfoot, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_th, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_thead, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_template, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_time, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_title, - /*parent,leaf*/ kHeadContent, false - }, - { - /*tag*/ eHTMLTag_tr, - /*parent,leaf*/ kNone, false - }, - { - /*tag*/ eHTMLTag_track, - /*parent,leaf*/ kSpecial, true - }, - { - /*tag*/ eHTMLTag_tt, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_u, - /*parent,leaf*/ kFontStyle, false - }, - { - /*tag*/ eHTMLTag_ul, - /*parent,leaf*/ kList, false - }, - { - /*tag*/ eHTMLTag_var, - /*parent,leaf*/ kPhrase, false - }, - { - /*tag*/ eHTMLTag_video, - /*parent,leaf*/ kSpecial, false - }, - { - /*tag*/ eHTMLTag_wbr, - /*parent,leaf*/ kExtensions, true - }, - { - /*tag*/ eHTMLTag_xmp, - /*parent,leaf*/ kInlineEntity|kPreformatted, false - }, - { - /*tag*/ eHTMLTag_text, - /*parent,leaf*/ kFlowEntity, true - }, - { - /*tag*/ eHTMLTag_whitespace, - /*parent,leaf*/ kFlowEntity|kHeadMisc, true - }, - { - /*tag*/ eHTMLTag_newline, - /*parent,leaf*/ kFlowEntity|kHeadMisc, true - }, - { - /*tag*/ eHTMLTag_comment, - /*parent,leaf*/ kFlowEntity|kHeadMisc, false - }, - { - /*tag*/ eHTMLTag_entity, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_doctypeDecl, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_markupDecl, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_instruction, - /*parent,leaf*/ kFlowEntity, false - }, - { - /*tag*/ eHTMLTag_userdefined, - /*parent,leaf*/ (kFlowEntity|kHeadMisc), false - }, + ELEM(unknown, kNone, true) + ELEM(a, kSpecial, false) + ELEM(abbr, kPhrase, false) + ELEM(acronym, kPhrase, false) + ELEM(address, kBlock, false) + ELEM(applet, kSpecial, false) + ELEM(area, kNone, true) + ELEM(article, kBlock, false) + ELEM(aside, kBlock, false) + ELEM(audio, kSpecial, false) + ELEM(b, kFontStyle, false) + ELEM(base, kHeadContent, true) + ELEM(basefont, kSpecial, true) + ELEM(bdo, kSpecial, false) + ELEM(bgsound, (kFlowEntity|kHeadMisc), true) + ELEM(big, kFontStyle, false) + ELEM(blockquote, kBlock, false) + ELEM(body, kHTMLContent, false) + ELEM(br, kSpecial, true) + ELEM(button, kFormControl, false) + ELEM(canvas, kSpecial, false) + ELEM(caption, kNone, false) + ELEM(center, kBlock, false) + ELEM(cite, kPhrase, false) + ELEM(code, kPhrase, false) + ELEM(col, kNone, true) + ELEM(colgroup, kNone, false) + ELEM(content, kNone, false) + ELEM(data, kPhrase, false) + ELEM(datalist, kSpecial, false) + ELEM(dd, kInlineEntity, false) + ELEM(del, kFlowEntity, false) + ELEM(details, kBlock, false) + ELEM(dfn, kPhrase, false) + ELEM(dialog, kBlock, false) + ELEM(dir, kList, false) + ELEM(div, kBlock, false) + ELEM(dl, kBlock, false) + ELEM(dt, kInlineEntity, false) + ELEM(em, kPhrase, false) + ELEM(embed, kSpecial, true) + ELEM(fieldset, kBlock, false) + ELEM(figcaption, kPhrase, false) + ELEM(figure, kBlock, false) + ELEM(font, kFontStyle, false) + ELEM(footer, kBlock, false) + ELEM(form, kBlock, false) + ELEM(frame, kNone, true) + ELEM(frameset, kHTMLContent, false) + ELEM(h1, kHeading, false) + ELEM(h2, kHeading, false) + ELEM(h3, kHeading, false) + ELEM(h4, kHeading, false) + ELEM(h5, kHeading, false) + ELEM(h6, kHeading, false) + ELEM(head, kHTMLContent, false) + ELEM(header, kBlock, false) + ELEM(hgroup, kBlock, false) + ELEM(hr, kBlock, true) + ELEM(html, kNone, false) + ELEM(i, kFontStyle, false) + ELEM(iframe, kSpecial, false) + ELEM(image, kSpecial, true) + ELEM(img, kSpecial, true) + ELEM(input, kFormControl, true) + ELEM(ins, kFlowEntity, false) + ELEM(kbd, kPhrase, false) + ELEM(keygen, kFlowEntity, true) + ELEM(label, kFormControl, false) + ELEM(legend, kNone, false) + ELEM(li, kBlockEntity, false) + ELEM(link, kAllTags - kHeadContent, true) + ELEM(listing, kPreformatted, false) + ELEM(main, kBlock, false) + ELEM(map, kSpecial, false) + ELEM(mark, kSpecial, false) + ELEM(marquee, kSpecial, false) + ELEM(menu, kList, false) + ELEM(menuitem, kFlowEntity, false) + ELEM(meta, kHeadContent, true) + ELEM(meter, kFormControl, false) + ELEM(multicol, kBlock, false) + ELEM(nav, kBlock, false) + ELEM(nobr, kExtensions, false) + ELEM(noembed, kFlowEntity, false) + ELEM(noframes, kFlowEntity, false) + ELEM(noscript, kFlowEntity|kHeadMisc, false) + ELEM(object, kSpecial, false) + ELEM(ol, kList, false) + ELEM(optgroup, kNone, false) + ELEM(option, kNone, false) + ELEM(output, kSpecial, false) + ELEM(p, kBlock, false) + ELEM(param, kSpecial, true) + ELEM(picture, kSpecial, false) + ELEM(plaintext, kExtensions, false) + ELEM(pre, kBlock|kPreformatted, false) + ELEM(progress, kFormControl, false) + ELEM(q, kSpecial, false) + ELEM(rb, kPhrase, false) + ELEM(rp, kPhrase, false) + ELEM(rt, kPhrase, false) + ELEM(rtc, kPhrase, false) + ELEM(ruby, kPhrase, false) + ELEM(s, kFontStyle, false) + ELEM(samp, kPhrase, false) + ELEM(script, (kSpecial|kHeadContent), false) + ELEM(section, kBlock, false) + ELEM(select, kFormControl, false) + ELEM(shadow, kFlowEntity, false) + ELEM(small, kFontStyle, false) + ELEM(source, kSpecial, true) + ELEM(span, kSpecial, false) + ELEM(strike, kFontStyle, false) + ELEM(strong, kPhrase, false) + ELEM(style, kAllTags - kHeadContent, false) + ELEM(sub, kSpecial, false) + ELEM(summary, kBlock, false) + ELEM(sup, kSpecial, false) + ELEM(table, kBlock, false) + ELEM(tbody, kNone, false) + ELEM(td, kNone, false) + ELEM(textarea, kFormControl, false) + ELEM(tfoot, kNone, false) + ELEM(th, kNone, false) + ELEM(thead, kNone, false) + ELEM(template, kNone, false) + ELEM(time, kPhrase, false) + ELEM(title, kHeadContent, false) + ELEM(tr, kNone, false) + ELEM(track, kSpecial, true) + ELEM(tt, kFontStyle, false) + ELEM(u, kFontStyle, false) + ELEM(ul, kList, false) + ELEM(var, kPhrase, false) + ELEM(video, kSpecial, false) + ELEM(wbr, kExtensions, true) + ELEM(xmp, kInlineEntity|kPreformatted, false) + ELEM(text, kFlowEntity, true) + ELEM(whitespace, kFlowEntity|kHeadMisc, true) + ELEM(newline, kFlowEntity|kHeadMisc, true) + ELEM(comment, kFlowEntity|kHeadMisc, false) + ELEM(entity, kFlowEntity, false) + ELEM(doctypeDecl, kFlowEntity, false) + ELEM(markupDecl, kFlowEntity, false) + ELEM(instruction, kFlowEntity, false) + ELEM(userdefined, (kFlowEntity|kHeadMisc), false) }; +#undef ELEM + /*********************************************************************************************/ bool nsHTMLElement::IsContainer(eHTMLTags aChild) diff --git a/parser/htmlparser/nsElementTable.h b/parser/htmlparser/nsElementTable.h index a4b78c09e4..28d2fa532b 100644 --- a/parser/htmlparser/nsElementTable.h +++ b/parser/htmlparser/nsElementTable.h @@ -80,12 +80,14 @@ inline bool TestBits(int aBitset,int aTest) { struct nsHTMLElement { bool IsMemberOf(int32_t aType) const; +#ifdef DEBUG eHTMLTags mTagID; +#endif int mParentBits; //defines groups that can contain this element bool mLeaf; static bool IsContainer(eHTMLTags aTag); -}; +}; extern const nsHTMLElement gHTMLElements[]; |