summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5TreeBuilder.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser/html/nsHtml5TreeBuilder.h')
-rw-r--r--parser/html/nsHtml5TreeBuilder.h349
1 files changed, 233 insertions, 116 deletions
diff --git a/parser/html/nsHtml5TreeBuilder.h b/parser/html/nsHtml5TreeBuilder.h
index ff6cdd4ae..4f484a104 100644
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -61,11 +61,10 @@
class nsHtml5StreamParser;
-class nsHtml5Tokenizer;
-class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
-class nsHtml5HtmlAttributes;
+class nsHtml5Tokenizer;
+class nsHtml5MetaScanner;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@@ -75,7 +74,217 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
{
private:
static char16_t REPLACEMENT_CHARACTER[];
+ public:
+ static const int32_t OTHER = 0;
+
+ static const int32_t A = 1;
+
+ static const int32_t BASE = 2;
+
+ static const int32_t BODY = 3;
+
+ static const int32_t BR = 4;
+
+ static const int32_t BUTTON = 5;
+
+ static const int32_t CAPTION = 6;
+
+ static const int32_t COL = 7;
+
+ static const int32_t COLGROUP = 8;
+
+ static const int32_t FORM = 9;
+
+ static const int32_t FRAME = 10;
+
+ static const int32_t FRAMESET = 11;
+
+ static const int32_t IMAGE = 12;
+
+ static const int32_t INPUT = 13;
+
+ static const int32_t ISINDEX = 14;
+
+ static const int32_t LI = 15;
+
+ static const int32_t LINK_OR_BASEFONT_OR_BGSOUND = 16;
+
+ static const int32_t MATH = 17;
+
+ static const int32_t META = 18;
+
+ static const int32_t SVG = 19;
+
+ static const int32_t HEAD = 20;
+
+ static const int32_t HR = 22;
+
+ static const int32_t HTML = 23;
+
+ static const int32_t NOBR = 24;
+
+ static const int32_t NOFRAMES = 25;
+
+ static const int32_t NOSCRIPT = 26;
+
+ static const int32_t OPTGROUP = 27;
+
+ static const int32_t OPTION = 28;
+
+ static const int32_t P = 29;
+
+ static const int32_t PLAINTEXT = 30;
+
+ static const int32_t SCRIPT = 31;
+
+ static const int32_t SELECT = 32;
+
+ static const int32_t STYLE = 33;
+
+ static const int32_t TABLE = 34;
+
+ static const int32_t TEXTAREA = 35;
+
+ static const int32_t TITLE = 36;
+
+ static const int32_t TR = 37;
+
+ static const int32_t XMP = 38;
+
+ static const int32_t TBODY_OR_THEAD_OR_TFOOT = 39;
+
+ static const int32_t TD_OR_TH = 40;
+
+ static const int32_t DD_OR_DT = 41;
+
+ static const int32_t H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 = 42;
+
+ static const int32_t MARQUEE_OR_APPLET = 43;
+
+ static const int32_t PRE_OR_LISTING = 44;
+
+ static const int32_t B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U = 45;
+
+ static const int32_t UL_OR_OL_OR_DL = 46;
+
+ static const int32_t IFRAME = 47;
+
+ static const int32_t EMBED = 48;
+
+ static const int32_t AREA_OR_WBR = 49;
+
+ static const int32_t DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU = 50;
+
+ static const int32_t ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY = 51;
+
+ static const int32_t RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR = 52;
+
+ static const int32_t RB_OR_RTC = 53;
+
+ static const int32_t PARAM_OR_SOURCE_OR_TRACK = 55;
+
+ static const int32_t MGLYPH_OR_MALIGNMARK = 56;
+
+ static const int32_t MI_MO_MN_MS_MTEXT = 57;
+
+ static const int32_t ANNOTATION_XML = 58;
+
+ static const int32_t FOREIGNOBJECT_OR_DESC = 59;
+
+ static const int32_t NOEMBED = 60;
+
+ static const int32_t FIELDSET = 61;
+
+ static const int32_t OUTPUT = 62;
+
+ static const int32_t OBJECT = 63;
+
+ static const int32_t FONT = 64;
+
+ static const int32_t KEYGEN = 65;
+
+ static const int32_t MENUITEM = 66;
+
+ static const int32_t TEMPLATE = 67;
+
+ static const int32_t IMG = 68;
+
+ static const int32_t RT_OR_RP = 69;
+
+ private:
+ static const int32_t IN_ROW = 0;
+
+ static const int32_t IN_TABLE_BODY = 1;
+
+ static const int32_t IN_TABLE = 2;
+
+ static const int32_t IN_CAPTION = 3;
+
+ static const int32_t IN_CELL = 4;
+
+ static const int32_t FRAMESET_OK = 5;
+
+ static const int32_t IN_BODY = 6;
+
+ static const int32_t IN_HEAD = 7;
+
+ static const int32_t IN_HEAD_NOSCRIPT = 8;
+
+ static const int32_t IN_COLUMN_GROUP = 9;
+
+ static const int32_t IN_SELECT_IN_TABLE = 10;
+
+ static const int32_t IN_SELECT = 11;
+
+ static const int32_t AFTER_BODY = 12;
+
+ static const int32_t IN_FRAMESET = 13;
+
+ static const int32_t AFTER_FRAMESET = 14;
+
+ static const int32_t INITIAL = 15;
+
+ static const int32_t BEFORE_HTML = 16;
+
+ static const int32_t BEFORE_HEAD = 17;
+
+ static const int32_t AFTER_HEAD = 18;
+
+ static const int32_t AFTER_AFTER_BODY = 19;
+
+ static const int32_t AFTER_AFTER_FRAMESET = 20;
+
+ static const int32_t TEXT = 21;
+
+ static const int32_t IN_TEMPLATE = 22;
+
+ static const int32_t CHARSET_INITIAL = 0;
+
+ static const int32_t CHARSET_C = 1;
+
+ static const int32_t CHARSET_H = 2;
+
+ static const int32_t CHARSET_A = 3;
+
+ static const int32_t CHARSET_R = 4;
+
+ static const int32_t CHARSET_S = 5;
+
+ static const int32_t CHARSET_E = 6;
+
+ static const int32_t CHARSET_T = 7;
+
+ static const int32_t CHARSET_EQUALS = 8;
+
+ static const int32_t CHARSET_SINGLE_QUOTED = 9;
+
+ static const int32_t CHARSET_DOUBLE_QUOTED = 10;
+
+ static const int32_t CHARSET_UNQUOTED = 11;
+
static staticJArray<const char*,int32_t> QUIRKY_PUBLIC_IDS;
+ static const int32_t NOT_FOUND_ON_STACK = INT32_MAX;
+
int32_t mode;
int32_t originalMode;
bool framesetOk;
@@ -103,6 +312,20 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
private:
bool quirks;
bool isSrcdocDocument;
+ inline nsHtml5ContentCreatorFunction htmlCreator(mozilla::dom::HTMLContentCreatorFunction htmlCreator)
+ {
+ nsHtml5ContentCreatorFunction creator;
+ creator.html = htmlCreator;
+ return creator;
+ }
+
+ inline nsHtml5ContentCreatorFunction svgCreator(mozilla::dom::SVGContentCreatorFunction svgCreator)
+ {
+ nsHtml5ContentCreatorFunction creator;
+ creator.svg = svgCreator;
+ return creator;
+ }
+
public:
void startTokenization(nsHtml5Tokenizer* self);
void doctype(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool forceQuirks);
@@ -179,8 +402,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void pushHeadPointerOntoStack();
void reconstructTheActiveFormattingElements();
void insertIntoFosterParent(nsIContentHandle* child);
- nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
- nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+ nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsHtml5ContentCreatorFunction creator);
+ nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsHtml5ContentCreatorFunction creator);
bool isInStack(nsHtml5StackNode* node);
void popTemplateMode();
void pop();
@@ -199,24 +422,24 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
bool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
- void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+ void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
- void appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+ void appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
protected:
void accumulateCharacters(const char16_t* buf, int32_t start, int32_t length);
void requestSuspension();
- nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* intendedParent);
- nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* intendedParent);
+ nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* intendedParent, nsHtml5ContentCreatorFunction creator);
+ nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* intendedParent, nsHtml5ContentCreatorFunction creator);
nsIContentHandle* createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
void detachFromParent(nsIContentHandle* element);
bool hasChildren(nsIContentHandle* element);
void appendElement(nsIContentHandle* child, nsIContentHandle* newParent);
void appendChildrenToNewParent(nsIContentHandle* oldParent, nsIContentHandle* newParent);
void insertFosterParentedChild(nsIContentHandle* child, nsIContentHandle* table, nsIContentHandle* stackParent);
- nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* table, nsIContentHandle* stackParent);
+ nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* table, nsIContentHandle* stackParent, nsHtml5ContentCreatorFunction creator);
;void insertFosterParentedCharacters(char16_t* buf, int32_t start, int32_t length, nsIContentHandle* table, nsIContentHandle* stackParent);
void appendCharacters(nsIContentHandle* parent, char16_t* buf, int32_t start, int32_t length);
void appendIsindexPrompt(nsIContentHandle* parent);
@@ -276,111 +499,5 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#include "nsHtml5TreeBuilderHSupplement.h"
};
-#define NS_HTML5TREE_BUILDER_OTHER 0
-#define NS_HTML5TREE_BUILDER_A 1
-#define NS_HTML5TREE_BUILDER_BASE 2
-#define NS_HTML5TREE_BUILDER_BODY 3
-#define NS_HTML5TREE_BUILDER_BR 4
-#define NS_HTML5TREE_BUILDER_BUTTON 5
-#define NS_HTML5TREE_BUILDER_CAPTION 6
-#define NS_HTML5TREE_BUILDER_COL 7
-#define NS_HTML5TREE_BUILDER_COLGROUP 8
-#define NS_HTML5TREE_BUILDER_FORM 9
-#define NS_HTML5TREE_BUILDER_FRAME 10
-#define NS_HTML5TREE_BUILDER_FRAMESET 11
-#define NS_HTML5TREE_BUILDER_IMAGE 12
-#define NS_HTML5TREE_BUILDER_INPUT 13
-#define NS_HTML5TREE_BUILDER_ISINDEX 14
-#define NS_HTML5TREE_BUILDER_LI 15
-#define NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND 16
-#define NS_HTML5TREE_BUILDER_MATH 17
-#define NS_HTML5TREE_BUILDER_META 18
-#define NS_HTML5TREE_BUILDER_SVG 19
-#define NS_HTML5TREE_BUILDER_HEAD 20
-#define NS_HTML5TREE_BUILDER_HR 22
-#define NS_HTML5TREE_BUILDER_HTML 23
-#define NS_HTML5TREE_BUILDER_NOBR 24
-#define NS_HTML5TREE_BUILDER_NOFRAMES 25
-#define NS_HTML5TREE_BUILDER_NOSCRIPT 26
-#define NS_HTML5TREE_BUILDER_OPTGROUP 27
-#define NS_HTML5TREE_BUILDER_OPTION 28
-#define NS_HTML5TREE_BUILDER_P 29
-#define NS_HTML5TREE_BUILDER_PLAINTEXT 30
-#define NS_HTML5TREE_BUILDER_SCRIPT 31
-#define NS_HTML5TREE_BUILDER_SELECT 32
-#define NS_HTML5TREE_BUILDER_STYLE 33
-#define NS_HTML5TREE_BUILDER_TABLE 34
-#define NS_HTML5TREE_BUILDER_TEXTAREA 35
-#define NS_HTML5TREE_BUILDER_TITLE 36
-#define NS_HTML5TREE_BUILDER_TR 37
-#define NS_HTML5TREE_BUILDER_XMP 38
-#define NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT 39
-#define NS_HTML5TREE_BUILDER_TD_OR_TH 40
-#define NS_HTML5TREE_BUILDER_DD_OR_DT 41
-#define NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 42
-#define NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET 43
-#define NS_HTML5TREE_BUILDER_PRE_OR_LISTING 44
-#define NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U 45
-#define NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL 46
-#define NS_HTML5TREE_BUILDER_IFRAME 47
-#define NS_HTML5TREE_BUILDER_EMBED 48
-#define NS_HTML5TREE_BUILDER_AREA_OR_WBR 49
-#define NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU 50
-#define NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY 51
-#define NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR 52
-#define NS_HTML5TREE_BUILDER_RB_OR_RTC 53
-#define NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK 55
-#define NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK 56
-#define NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT 57
-#define NS_HTML5TREE_BUILDER_ANNOTATION_XML 58
-#define NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC 59
-#define NS_HTML5TREE_BUILDER_NOEMBED 60
-#define NS_HTML5TREE_BUILDER_FIELDSET 61
-#define NS_HTML5TREE_BUILDER_OUTPUT 62
-#define NS_HTML5TREE_BUILDER_OBJECT 63
-#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_IMG 68
-#define NS_HTML5TREE_BUILDER_RT_OR_RP 69
-#define NS_HTML5TREE_BUILDER_IN_ROW 0
-#define NS_HTML5TREE_BUILDER_IN_TABLE_BODY 1
-#define NS_HTML5TREE_BUILDER_IN_TABLE 2
-#define NS_HTML5TREE_BUILDER_IN_CAPTION 3
-#define NS_HTML5TREE_BUILDER_IN_CELL 4
-#define NS_HTML5TREE_BUILDER_FRAMESET_OK 5
-#define NS_HTML5TREE_BUILDER_IN_BODY 6
-#define NS_HTML5TREE_BUILDER_IN_HEAD 7
-#define NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT 8
-#define NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP 9
-#define NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE 10
-#define NS_HTML5TREE_BUILDER_IN_SELECT 11
-#define NS_HTML5TREE_BUILDER_AFTER_BODY 12
-#define NS_HTML5TREE_BUILDER_IN_FRAMESET 13
-#define NS_HTML5TREE_BUILDER_AFTER_FRAMESET 14
-#define NS_HTML5TREE_BUILDER_INITIAL 15
-#define NS_HTML5TREE_BUILDER_BEFORE_HTML 16
-#define NS_HTML5TREE_BUILDER_BEFORE_HEAD 17
-#define NS_HTML5TREE_BUILDER_AFTER_HEAD 18
-#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_IN_TEMPLATE 22
-#define NS_HTML5TREE_BUILDER_CHARSET_INITIAL 0
-#define NS_HTML5TREE_BUILDER_CHARSET_C 1
-#define NS_HTML5TREE_BUILDER_CHARSET_H 2
-#define NS_HTML5TREE_BUILDER_CHARSET_A 3
-#define NS_HTML5TREE_BUILDER_CHARSET_R 4
-#define NS_HTML5TREE_BUILDER_CHARSET_S 5
-#define NS_HTML5TREE_BUILDER_CHARSET_E 6
-#define NS_HTML5TREE_BUILDER_CHARSET_T 7
-#define NS_HTML5TREE_BUILDER_CHARSET_EQUALS 8
-#define NS_HTML5TREE_BUILDER_CHARSET_SINGLE_QUOTED 9
-#define NS_HTML5TREE_BUILDER_CHARSET_DOUBLE_QUOTED 10
-#define NS_HTML5TREE_BUILDER_CHARSET_UNQUOTED 11
-#define NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK INT32_MAX
-
-
#endif