tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsHtml5TreeBuilder.h (21035B)


      1 /*
      2 * Copyright (c) 2007 Henri Sivonen
      3 * Copyright (c) 2007-2017 Mozilla Foundation
      4 * Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
      5 * Foundation, and Opera Software ASA.
      6 *
      7 * Permission is hereby granted, free of charge, to any person obtaining a
      8 * copy of this software and associated documentation files (the "Software"),
      9 * to deal in the Software without restriction, including without limitation
     10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11 * and/or sell copies of the Software, and to permit persons to whom the
     12 * Software is furnished to do so, subject to the following conditions:
     13 *
     14 * The above copyright notice and this permission notice shall be included in
     15 * all copies or substantial portions of the Software.
     16 *
     17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
     20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     23 * DEALINGS IN THE SOFTWARE.
     24 */
     25 
     26 /*
     27 * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
     28 * Please edit TreeBuilder.java instead and regenerate.
     29 */
     30 
     31 #ifndef nsHtml5TreeBuilder_h
     32 #define nsHtml5TreeBuilder_h
     33 
     34 #include "jArray.h"
     35 #include "mozilla/ImportScanner.h"
     36 #include "nsAHtml5TreeBuilderState.h"
     37 #include "nsAtom.h"
     38 #include "nsContentUtils.h"
     39 #include "nsGkAtoms.h"
     40 #include "nsHtml5ArrayCopy.h"
     41 #include "nsHtml5AtomTable.h"
     42 #include "nsHtml5DocumentMode.h"
     43 #include "nsHtml5Highlighter.h"
     44 #include "nsHtml5OplessBuilder.h"
     45 #include "nsHtml5Parser.h"
     46 #include "nsHtml5PlainTextUtils.h"
     47 #include "nsHtml5StackNode.h"
     48 #include "nsHtml5StateSnapshot.h"
     49 #include "nsHtml5StreamParser.h"
     50 #include "nsHtml5String.h"
     51 #include "nsHtml5TreeOperation.h"
     52 #include "nsHtml5TreeOpExecutor.h"
     53 #include "nsHtml5ViewSourceUtils.h"
     54 #include "nsIContent.h"
     55 #include "nsIContentHandle.h"
     56 #include "nsNameSpaceManager.h"
     57 #include "nsTraceRefcnt.h"
     58 
     59 class nsHtml5StreamParser;
     60 
     61 class nsHtml5AttributeName;
     62 class nsHtml5ElementName;
     63 class nsHtml5Tokenizer;
     64 class nsHtml5UTF16Buffer;
     65 class nsHtml5StateSnapshot;
     66 class nsHtml5Portability;
     67 
     68 class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState {
     69 private:
     70  static char16_t REPLACEMENT_CHARACTER[];
     71 
     72 public:
     73  static const int32_t OTHER = 0;
     74 
     75  static const int32_t A = 1;
     76 
     77  static const int32_t BASE = 2;
     78 
     79  static const int32_t BODY = 3;
     80 
     81  static const int32_t BR = 4;
     82 
     83  static const int32_t BUTTON = 5;
     84 
     85  static const int32_t CAPTION = 6;
     86 
     87  static const int32_t COL = 7;
     88 
     89  static const int32_t COLGROUP = 8;
     90 
     91  static const int32_t FORM = 9;
     92 
     93  static const int32_t FRAME = 10;
     94 
     95  static const int32_t FRAMESET = 11;
     96 
     97  static const int32_t IMAGE = 12;
     98 
     99  static const int32_t INPUT = 13;
    100 
    101  static const int32_t RT_OR_RP = 14;
    102 
    103  static const int32_t LI = 15;
    104 
    105  static const int32_t LINK_OR_BASEFONT_OR_BGSOUND = 16;
    106 
    107  static const int32_t MATH = 17;
    108 
    109  static const int32_t META = 18;
    110 
    111  static const int32_t SVG = 19;
    112 
    113  static const int32_t HEAD = 20;
    114 
    115  static const int32_t HR = 22;
    116 
    117  static const int32_t HTML = 23;
    118 
    119  static const int32_t NOBR = 24;
    120 
    121  static const int32_t NOFRAMES = 25;
    122 
    123  static const int32_t NOSCRIPT = 26;
    124 
    125  static const int32_t OPTGROUP = 27;
    126 
    127  static const int32_t OPTION = 28;
    128 
    129  static const int32_t P = 29;
    130 
    131  static const int32_t PLAINTEXT = 30;
    132 
    133  static const int32_t SCRIPT = 31;
    134 
    135  static const int32_t SELECT = 32;
    136 
    137  static const int32_t STYLE = 33;
    138 
    139  static const int32_t TABLE = 34;
    140 
    141  static const int32_t TEXTAREA = 35;
    142 
    143  static const int32_t TITLE = 36;
    144 
    145  static const int32_t TR = 37;
    146 
    147  static const int32_t XMP = 38;
    148 
    149  static const int32_t TBODY_OR_THEAD_OR_TFOOT = 39;
    150 
    151  static const int32_t TD_OR_TH = 40;
    152 
    153  static const int32_t DD_OR_DT = 41;
    154 
    155  static const int32_t H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 = 42;
    156 
    157  static const int32_t MARQUEE_OR_APPLET = 43;
    158 
    159  static const int32_t PRE_OR_LISTING = 44;
    160 
    161  static const int32_t
    162      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U =
    163          45;
    164 
    165  static const int32_t UL_OR_OL_OR_DL = 46;
    166 
    167  static const int32_t IFRAME = 47;
    168 
    169  static const int32_t EMBED = 48;
    170 
    171  static const int32_t AREA_OR_WBR = 49;
    172 
    173  static const int32_t DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU = 50;
    174 
    175  static const int32_t
    176      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_SEARCH_OR_SECTION_OR_SUMMARY =
    177          51;
    178 
    179  static const int32_t RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR = 52;
    180 
    181  static const int32_t RB_OR_RTC = 53;
    182 
    183  static const int32_t PARAM_OR_SOURCE_OR_TRACK = 55;
    184 
    185  static const int32_t MGLYPH_OR_MALIGNMARK = 56;
    186 
    187  static const int32_t MI_MO_MN_MS_MTEXT = 57;
    188 
    189  static const int32_t ANNOTATION_XML = 58;
    190 
    191  static const int32_t FOREIGNOBJECT_OR_DESC = 59;
    192 
    193  static const int32_t NOEMBED = 60;
    194 
    195  static const int32_t FIELDSET = 61;
    196 
    197  static const int32_t OUTPUT = 62;
    198 
    199  static const int32_t OBJECT = 63;
    200 
    201  static const int32_t FONT = 64;
    202 
    203  static const int32_t KEYGEN = 65;
    204 
    205  static const int32_t TEMPLATE = 66;
    206 
    207  static const int32_t IMG = 67;
    208 
    209 private:
    210  static const int32_t IN_ROW = 0;
    211 
    212  static const int32_t IN_TABLE_BODY = 1;
    213 
    214  static const int32_t IN_TABLE = 2;
    215 
    216  static const int32_t IN_CAPTION = 3;
    217 
    218  static const int32_t IN_CELL = 4;
    219 
    220  static const int32_t FRAMESET_OK = 5;
    221 
    222  static const int32_t IN_BODY = 6;
    223 
    224  static const int32_t IN_HEAD = 7;
    225 
    226  static const int32_t IN_HEAD_NOSCRIPT = 8;
    227 
    228  static const int32_t IN_COLUMN_GROUP = 9;
    229 
    230  static const int32_t IN_SELECT_IN_TABLE = 10;
    231 
    232  static const int32_t IN_SELECT = 11;
    233 
    234  static const int32_t AFTER_BODY = 12;
    235 
    236  static const int32_t IN_FRAMESET = 13;
    237 
    238  static const int32_t AFTER_FRAMESET = 14;
    239 
    240  static const int32_t INITIAL = 15;
    241 
    242  static const int32_t BEFORE_HTML = 16;
    243 
    244  static const int32_t BEFORE_HEAD = 17;
    245 
    246  static const int32_t AFTER_HEAD = 18;
    247 
    248  static const int32_t AFTER_AFTER_BODY = 19;
    249 
    250  static const int32_t AFTER_AFTER_FRAMESET = 20;
    251 
    252  static const int32_t TEXT = 21;
    253 
    254  static const int32_t IN_TEMPLATE = 22;
    255 
    256  static const int32_t CHARSET_INITIAL = 0;
    257 
    258  static const int32_t CHARSET_C = 1;
    259 
    260  static const int32_t CHARSET_H = 2;
    261 
    262  static const int32_t CHARSET_A = 3;
    263 
    264  static const int32_t CHARSET_R = 4;
    265 
    266  static const int32_t CHARSET_S = 5;
    267 
    268  static const int32_t CHARSET_E = 6;
    269 
    270  static const int32_t CHARSET_T = 7;
    271 
    272  static const int32_t CHARSET_EQUALS = 8;
    273 
    274  static const int32_t CHARSET_SINGLE_QUOTED = 9;
    275 
    276  static const int32_t CHARSET_DOUBLE_QUOTED = 10;
    277 
    278  static const int32_t CHARSET_UNQUOTED = 11;
    279 
    280  static staticJArray<const char*, int32_t> QUIRKY_PUBLIC_IDS;
    281  static const int32_t NOT_FOUND_ON_STACK = INT32_MAX;
    282 
    283  int32_t mode;
    284  int32_t originalMode;
    285  bool framesetOk;
    286 
    287 protected:
    288  nsHtml5Tokenizer* tokenizer;
    289 
    290 private:
    291  bool scriptingEnabled;
    292  bool needToDropLF;
    293  bool fragment;
    294  RefPtr<nsAtom> contextName;
    295  int32_t contextNamespace;
    296  nsIContentHandle* contextNode;
    297  autoJArray<int32_t, int32_t> templateModeStack;
    298  int32_t templateModePtr;
    299  autoJArray<nsHtml5StackNode*, int32_t> stackNodes;
    300  int32_t stackNodesIdx;
    301  int32_t numStackNodes;
    302  autoJArray<nsHtml5StackNode*, int32_t> stack;
    303  int32_t currentPtr;
    304  autoJArray<nsHtml5StackNode*, int32_t> listOfActiveFormattingElements;
    305  int32_t listPtr;
    306  nsIContentHandle* formPointer;
    307  nsIContentHandle* headPointer;
    308 
    309 protected:
    310  autoJArray<char16_t, int32_t> charBuffer;
    311  int32_t charBufferLen;
    312 
    313 private:
    314  bool quirks;
    315  bool forceNoQuirks;
    316  bool allowDeclarativeShadowRoots;
    317  bool keepBuffer;
    318  inline nsHtml5ContentCreatorFunction htmlCreator(
    319      mozilla::dom::HTMLContentCreatorFunction htmlCreator) {
    320    nsHtml5ContentCreatorFunction creator;
    321    creator.html = htmlCreator;
    322    return creator;
    323  }
    324 
    325  inline nsHtml5ContentCreatorFunction svgCreator(
    326      mozilla::dom::SVGContentCreatorFunction svgCreator) {
    327    nsHtml5ContentCreatorFunction creator;
    328    creator.svg = svgCreator;
    329    return creator;
    330  }
    331 
    332 public:
    333  void setKeepBuffer(bool keepBuffer);
    334  bool dropBufferIfLongerThan(int32_t length);
    335  void startTokenization(nsHtml5Tokenizer* self);
    336  void doctype(nsAtom* name, nsHtml5String publicIdentifier,
    337               nsHtml5String systemIdentifier, bool forceQuirks);
    338  void comment(char16_t* buf, int32_t start, int32_t length);
    339  void characters(const char16_t* buf, int32_t start, int32_t length);
    340  void zeroOriginatingReplacementCharacter();
    341  void zeroOrReplacementCharacter();
    342  void eof();
    343  void endTokenization();
    344  void startTag(nsHtml5ElementName* elementName,
    345                nsHtml5HtmlAttributes* attributes, bool selfClosing);
    346 
    347 private:
    348  void startTagTitleInHead(nsHtml5ElementName* elementName,
    349                           nsHtml5HtmlAttributes* attributes);
    350  void startTagGenericRawText(nsHtml5ElementName* elementName,
    351                              nsHtml5HtmlAttributes* attributes);
    352  void startTagScriptInHead(nsHtml5ElementName* elementName,
    353                            nsHtml5HtmlAttributes* attributes);
    354  void startTagTemplateInHead(nsHtml5ElementName* elementName,
    355                              nsHtml5HtmlAttributes* attributes);
    356  bool isTemplateContents();
    357  bool isTemplateModeStackEmpty();
    358  bool isSpecialParentInForeign(nsHtml5StackNode* stackNode);
    359  nsIContentHandle* getDeclarativeShadowRoot(nsIContentHandle* currentNode,
    360                                             nsIContentHandle* templateNode,
    361                                             nsHtml5HtmlAttributes* attributes);
    362 
    363 public:
    364  static nsHtml5String extractCharsetFromContent(nsHtml5String attributeValue,
    365                                                 nsHtml5TreeBuilder* tb);
    366 
    367 private:
    368  void checkMetaCharset(nsHtml5HtmlAttributes* attributes);
    369 
    370 public:
    371  void endTag(nsHtml5ElementName* elementName);
    372 
    373 private:
    374  void endTagTemplateInHead();
    375  int32_t findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
    376  int32_t findLast(nsAtom* name);
    377  int32_t findLastInTableScope(nsAtom* name);
    378  int32_t findLastInButtonScope(nsAtom* name);
    379  int32_t findLastInScope(nsAtom* name);
    380  int32_t findLastInListScope(nsAtom* name);
    381  int32_t findLastInScopeHn();
    382  void generateImpliedEndTagsExceptFor(nsAtom* name);
    383  void generateImpliedEndTags();
    384  void generateImpliedEndTagsThoroughly();
    385  bool isSecondOnStackBody();
    386  void documentModeInternal(nsHtml5DocumentMode m,
    387                            nsHtml5String publicIdentifier,
    388                            nsHtml5String systemIdentifier);
    389  bool isAlmostStandards(nsHtml5String publicIdentifier,
    390                         nsHtml5String systemIdentifier);
    391  bool isQuirky(nsAtom* name, nsHtml5String publicIdentifier,
    392                nsHtml5String systemIdentifier, bool forceQuirks);
    393  void closeTheCell(int32_t eltPos);
    394  int32_t findLastInTableScopeTdTh();
    395  void clearStackBackTo(int32_t eltPos);
    396  void resetTheInsertionMode();
    397  void implicitlyCloseP();
    398  bool debugOnlyClearLastStackSlot();
    399  bool debugOnlyClearLastListSlot();
    400  void pushTemplateMode(int32_t mode);
    401  void push(nsHtml5StackNode* node);
    402  void silentPush(nsHtml5StackNode* node);
    403  void append(nsHtml5StackNode* node);
    404  inline void insertMarker() { append(nullptr); }
    405 
    406  void clearTheListOfActiveFormattingElementsUpToTheLastMarker();
    407  inline bool isCurrent(nsAtom* name) {
    408    return stack[currentPtr]->ns == kNameSpaceID_XHTML &&
    409           name == stack[currentPtr]->name;
    410  }
    411 
    412  void removeFromStack(int32_t pos);
    413  void removeFromStack(nsHtml5StackNode* node);
    414  void removeFromListOfActiveFormattingElements(int32_t pos);
    415  bool adoptionAgencyEndTag(nsAtom* name);
    416  void insertIntoStack(nsHtml5StackNode* node, int32_t position);
    417  void insertIntoListOfActiveFormattingElements(
    418      nsHtml5StackNode* formattingClone, int32_t bookmark);
    419  int32_t findInListOfActiveFormattingElements(nsHtml5StackNode* node);
    420  int32_t findInListOfActiveFormattingElementsContainsBetweenEndAndLastMarker(
    421      nsAtom* name);
    422  void maybeForgetEarlierDuplicateFormattingElement(
    423      nsAtom* name, nsHtml5HtmlAttributes* attributes);
    424  int32_t findLastOrRoot(nsAtom* name);
    425  int32_t findLastOrRoot(int32_t group);
    426  bool addAttributesToBody(nsHtml5HtmlAttributes* attributes);
    427  void addAttributesToHtml(nsHtml5HtmlAttributes* attributes);
    428  void pushHeadPointerOntoStack();
    429  void reconstructTheActiveFormattingElements();
    430 
    431 public:
    432  void notifyUnusedStackNode(int32_t idxInStackNodes);
    433 
    434 private:
    435  nsHtml5StackNode* getUnusedStackNode();
    436  nsHtml5StackNode* createStackNode(
    437      int32_t flags, int32_t ns, nsAtom* name, nsIContentHandle* node,
    438      nsAtom* popName, nsHtml5HtmlAttributes* attributes,
    439      mozilla::dom::HTMLContentCreatorFunction htmlCreator);
    440  nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
    441                                    nsIContentHandle* node);
    442  nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
    443                                    nsIContentHandle* node,
    444                                    nsHtml5HtmlAttributes* attributes);
    445  nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
    446                                    nsIContentHandle* node, nsAtom* popName);
    447  nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
    448                                    nsAtom* popName, nsIContentHandle* node);
    449  nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
    450                                    nsIContentHandle* node, nsAtom* popName,
    451                                    bool markAsIntegrationPoint);
    452  void insertIntoFosterParent(nsIContentHandle* child);
    453  nsIContentHandle* createAndInsertFosterParentedElement(
    454      int32_t ns, nsAtom* name, nsHtml5HtmlAttributes* attributes,
    455      nsHtml5ContentCreatorFunction creator);
    456  nsIContentHandle* createAndInsertFosterParentedElement(
    457      int32_t ns, nsAtom* name, nsHtml5HtmlAttributes* attributes,
    458      nsIContentHandle* form, nsHtml5ContentCreatorFunction creator);
    459  bool isInStack(nsHtml5StackNode* node);
    460  void popTemplateMode();
    461  void pop();
    462  void popForeign(int32_t origPos, int32_t eltPos);
    463  void silentPop();
    464  void popOnEof();
    465  void appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes);
    466  void appendHtmlElementToDocumentAndPush();
    467  void appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes);
    468  void appendToCurrentNodeAndPushBodyElement(nsHtml5HtmlAttributes* attributes);
    469  void appendToCurrentNodeAndPushBodyElement();
    470  void appendToCurrentNodeAndPushFormElementMayFoster(
    471      nsHtml5HtmlAttributes* attributes);
    472  void appendToCurrentNodeAndPushFormattingElementMayFoster(
    473      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
    474  void appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName,
    475                                         nsHtml5HtmlAttributes* attributes);
    476  void appendToCurrentNodeAndPushElementMayFoster(
    477      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
    478  void appendToCurrentNodeAndPushElementMayFosterMathML(
    479      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
    480  bool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
    481  void appendToCurrentNodeAndPushElementMayFosterSVG(
    482      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
    483  void appendToCurrentNodeAndPushElementMayFoster(
    484      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes,
    485      nsIContentHandle* form);
    486  void appendVoidElementToCurrent(nsHtml5ElementName* elementName,
    487                                  nsHtml5HtmlAttributes* attributes);
    488  void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName,
    489                                           nsHtml5HtmlAttributes* attributes,
    490                                           nsIContentHandle* form);
    491  void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName,
    492                                           nsHtml5HtmlAttributes* attributes);
    493  void appendVoidElementToCurrentMayFosterSVG(
    494      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
    495  void appendVoidElementToCurrentMayFosterMathML(
    496      nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
    497  void appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes,
    498                                nsIContentHandle* form);
    499  void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
    500 
    501 protected:
    502  void accumulateCharacters(const char16_t* buf, int32_t start, int32_t length);
    503  void requestSuspension();
    504  nsIContentHandle* createElement(int32_t ns, nsAtom* name,
    505                                  nsHtml5HtmlAttributes* attributes,
    506                                  nsIContentHandle* intendedParent,
    507                                  nsHtml5ContentCreatorFunction creator);
    508  nsIContentHandle* createElement(int32_t ns, nsAtom* name,
    509                                  nsHtml5HtmlAttributes* attributes,
    510                                  nsIContentHandle* form,
    511                                  nsIContentHandle* intendedParent,
    512                                  nsHtml5ContentCreatorFunction creator);
    513  nsIContentHandle* createHtmlElementSetAsRoot(
    514      nsHtml5HtmlAttributes* attributes);
    515  void detachFromParent(nsIContentHandle* element);
    516  bool hasChildren(nsIContentHandle* element);
    517  void appendElement(nsIContentHandle* child, nsIContentHandle* newParent);
    518  void appendChildrenToNewParent(nsIContentHandle* oldParent,
    519                                 nsIContentHandle* newParent);
    520  void insertFosterParentedChild(nsIContentHandle* child,
    521                                 nsIContentHandle* table,
    522                                 nsIContentHandle* stackParent);
    523  nsIContentHandle* createAndInsertFosterParentedElement(
    524      int32_t ns, nsAtom* name, nsHtml5HtmlAttributes* attributes,
    525      nsIContentHandle* form, nsIContentHandle* table,
    526      nsIContentHandle* stackParent, nsHtml5ContentCreatorFunction creator);
    527  ;
    528  void insertFosterParentedCharacters(char16_t* buf, int32_t start,
    529                                      int32_t length, nsIContentHandle* table,
    530                                      nsIContentHandle* stackParent);
    531  void appendCharacters(nsIContentHandle* parent, char16_t* buf, int32_t start,
    532                        int32_t length);
    533  void appendComment(nsIContentHandle* parent, char16_t* buf, int32_t start,
    534                     int32_t length);
    535  void appendCommentToDocument(char16_t* buf, int32_t start, int32_t length);
    536  void addAttributesToElement(nsIContentHandle* element,
    537                              nsHtml5HtmlAttributes* attributes);
    538  void markMalformedIfScript(nsIContentHandle* elt);
    539  void start(bool fragmentMode);
    540  void end();
    541  void appendDoctypeToDocument(nsAtom* name, nsHtml5String publicIdentifier,
    542                               nsHtml5String systemIdentifier);
    543  void elementPushed(int32_t ns, nsAtom* name, nsIContentHandle* node);
    544  void elementPopped(int32_t ns, nsAtom* name, nsIContentHandle* node);
    545 
    546 public:
    547  inline bool cdataSectionAllowed() { return isInForeign(); }
    548 
    549 private:
    550  bool isInForeign();
    551  bool isInForeignButNotHtmlOrMathTextIntegrationPoint();
    552 
    553 public:
    554  void setFragmentContext(nsAtom* context, int32_t ns, nsIContentHandle* node,
    555                          bool quirks);
    556 
    557 protected:
    558  nsIContentHandle* currentNode();
    559 
    560 public:
    561  bool isScriptingEnabled();
    562  void setScriptingEnabled(bool scriptingEnabled);
    563  void setForceNoQuirks(bool forceNoQuirks);
    564  void setIsSrcdocDocument(bool isSrcdocDocument);
    565  bool isAllowDeclarativeShadowRoots();
    566  void setAllowDeclarativeShadowRoots(bool allow);
    567  void flushCharacters();
    568 
    569 private:
    570  bool charBufferContainsNonWhitespace();
    571 
    572 public:
    573  nsAHtml5TreeBuilderState* newSnapshot();
    574  bool snapshotMatches(nsAHtml5TreeBuilderState* snapshot);
    575  void loadState(nsAHtml5TreeBuilderState* snapshot);
    576 
    577 private:
    578  int32_t findInArray(nsHtml5StackNode* node,
    579                      jArray<nsHtml5StackNode*, int32_t> arr);
    580  nsIContentHandle* nodeFromStackWithBlinkCompat(int32_t stackPos);
    581 
    582 public:
    583  nsIContentHandle* getFormPointer() override;
    584  nsIContentHandle* getHeadPointer() override;
    585  jArray<nsHtml5StackNode*, int32_t> getListOfActiveFormattingElements()
    586      override;
    587  jArray<nsHtml5StackNode*, int32_t> getStack() override;
    588  jArray<int32_t, int32_t> getTemplateModeStack() override;
    589  int32_t getMode() override;
    590  int32_t getOriginalMode() override;
    591  bool isFramesetOk() override;
    592  bool isNeedToDropLF() override;
    593  bool isQuirks() override;
    594  int32_t getListOfActiveFormattingElementsLength() override;
    595  int32_t getStackLength() override;
    596  int32_t getTemplateModeStackLength() override;
    597  static void initializeStatics();
    598  static void releaseStatics();
    599 
    600 #include "nsHtml5TreeBuilderHSupplement.h"
    601 };
    602 
    603 #endif