parser/html/nsHtml5TreeBuilderHSupplement.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #define NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH 512
michael@0 6
michael@0 7 private:
michael@0 8 nsHtml5OplessBuilder* mBuilder;
michael@0 9 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
michael@0 10 // If mBuilder is not null, the tree op machinery is not in use and
michael@0 11 // the fields below aren't in use, either.
michael@0 12 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
michael@0 13 nsHtml5Highlighter* mViewSource;
michael@0 14 nsTArray<nsHtml5TreeOperation> mOpQueue;
michael@0 15 nsTArray<nsHtml5SpeculativeLoad> mSpeculativeLoadQueue;
michael@0 16 nsAHtml5TreeOpSink* mOpSink;
michael@0 17 nsAutoArrayPtr<nsIContent*> mHandles;
michael@0 18 int32_t mHandlesUsed;
michael@0 19 nsTArray<nsAutoArrayPtr<nsIContent*> > mOldHandles;
michael@0 20 nsHtml5TreeOpStage* mSpeculativeLoadStage;
michael@0 21 bool mCurrentHtmlScriptIsAsyncOrDefer;
michael@0 22 bool mPreventScriptExecution;
michael@0 23 #ifdef DEBUG
michael@0 24 bool mActive;
michael@0 25 #endif
michael@0 26
michael@0 27 // DocumentModeHandler
michael@0 28 /**
michael@0 29 * Tree builder uses this to report quirkiness of the document
michael@0 30 */
michael@0 31 void documentMode(nsHtml5DocumentMode m);
michael@0 32
michael@0 33 nsIContentHandle* getDocumentFragmentForTemplate(nsIContentHandle* aTemplate);
michael@0 34
michael@0 35 nsIContentHandle* getFormPointerForContext(nsIContentHandle* aContext);
michael@0 36
michael@0 37 /**
michael@0 38 * Using nsIContent** instead of nsIContent* is the parser deals with DOM
michael@0 39 * nodes in a way that works off the main thread. Non-main-thread code
michael@0 40 * can't refcount or otherwise touch nsIContent objects in any way.
michael@0 41 * Yet, the off-the-main-thread code needs to have a way to hold onto a
michael@0 42 * particular node and repeatedly operate on the same node.
michael@0 43 *
michael@0 44 * The way this works is that the off-the-main-thread code has an
michael@0 45 * nsIContent** for each DOM node and a given nsIContent** is only ever
michael@0 46 * actually dereferenced into an actual nsIContent* on the main thread.
michael@0 47 * When the off-the-main-thread code requests a new node, it gets an
michael@0 48 * nsIContent** immediately and a tree op is enqueued for later allocating
michael@0 49 * an actual nsIContent object and writing a pointer to it into the memory
michael@0 50 * location pointed to by the nsIContent**.
michael@0 51 *
michael@0 52 * Since tree ops are in a queue, the node creating tree op will always
michael@0 53 * run before tree ops that try to further operate on the node that the
michael@0 54 * nsIContent** is a handle to.
michael@0 55 *
michael@0 56 * On-the-main-thread parts of the parser use nsIContent* instead of
michael@0 57 * nsIContent**. Since both cases share the same parser core, the parser
michael@0 58 * core casts both to nsIContentHandle*.
michael@0 59 */
michael@0 60 nsIContentHandle* AllocateContentHandle();
michael@0 61
michael@0 62 void accumulateCharactersForced(const char16_t* aBuf, int32_t aStart, int32_t aLength)
michael@0 63 {
michael@0 64 accumulateCharacters(aBuf, aStart, aLength);
michael@0 65 }
michael@0 66
michael@0 67 void MarkAsBrokenAndRequestSuspension(nsresult aRv)
michael@0 68 {
michael@0 69 mBuilder->MarkAsBroken(aRv);
michael@0 70 requestSuspension();
michael@0 71 }
michael@0 72
michael@0 73 public:
michael@0 74
michael@0 75 nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder);
michael@0 76
michael@0 77 nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
michael@0 78 nsHtml5TreeOpStage* aStage);
michael@0 79
michael@0 80 ~nsHtml5TreeBuilder();
michael@0 81
michael@0 82 void StartPlainTextViewSource(const nsAutoString& aTitle);
michael@0 83
michael@0 84 void StartPlainText();
michael@0 85
michael@0 86 void StartPlainTextBody();
michael@0 87
michael@0 88 bool HasScript();
michael@0 89
michael@0 90 void SetOpSink(nsAHtml5TreeOpSink* aOpSink)
michael@0 91 {
michael@0 92 mOpSink = aOpSink;
michael@0 93 }
michael@0 94
michael@0 95 void ClearOps()
michael@0 96 {
michael@0 97 mOpQueue.Clear();
michael@0 98 }
michael@0 99
michael@0 100 bool Flush(bool aDiscretionary = false);
michael@0 101
michael@0 102 void FlushLoads();
michael@0 103
michael@0 104 void SetDocumentCharset(nsACString& aCharset, int32_t aCharsetSource);
michael@0 105
michael@0 106 void StreamEnded();
michael@0 107
michael@0 108 void NeedsCharsetSwitchTo(const nsACString& aEncoding,
michael@0 109 int32_t aSource,
michael@0 110 int32_t aLineNumber);
michael@0 111
michael@0 112 void MaybeComplainAboutCharset(const char* aMsgId,
michael@0 113 bool aError,
michael@0 114 int32_t aLineNumber);
michael@0 115
michael@0 116 void AddSnapshotToScript(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine);
michael@0 117
michael@0 118 void DropHandles();
michael@0 119
michael@0 120 void SetPreventScriptExecution(bool aPrevent)
michael@0 121 {
michael@0 122 mPreventScriptExecution = aPrevent;
michael@0 123 }
michael@0 124
michael@0 125 bool HasBuilder()
michael@0 126 {
michael@0 127 return mBuilder;
michael@0 128 }
michael@0 129
michael@0 130 void EnableViewSource(nsHtml5Highlighter* aHighlighter);
michael@0 131
michael@0 132 void errStrayStartTag(nsIAtom* aName);
michael@0 133
michael@0 134 void errStrayEndTag(nsIAtom* aName);
michael@0 135
michael@0 136 void errUnclosedElements(int32_t aIndex, nsIAtom* aName);
michael@0 137
michael@0 138 void errUnclosedElementsImplied(int32_t aIndex, nsIAtom* aName);
michael@0 139
michael@0 140 void errUnclosedElementsCell(int32_t aIndex);
michael@0 141
michael@0 142 void errStrayDoctype();
michael@0 143
michael@0 144 void errAlmostStandardsDoctype();
michael@0 145
michael@0 146 void errQuirkyDoctype();
michael@0 147
michael@0 148 void errNonSpaceInTrailer();
michael@0 149
michael@0 150 void errNonSpaceAfterFrameset();
michael@0 151
michael@0 152 void errNonSpaceInFrameset();
michael@0 153
michael@0 154 void errNonSpaceAfterBody();
michael@0 155
michael@0 156 void errNonSpaceInColgroupInFragment();
michael@0 157
michael@0 158 void errNonSpaceInNoscriptInHead();
michael@0 159
michael@0 160 void errFooBetweenHeadAndBody(nsIAtom* aName);
michael@0 161
michael@0 162 void errStartTagWithoutDoctype();
michael@0 163
michael@0 164 void errNoSelectInTableScope();
michael@0 165
michael@0 166 void errStartSelectWhereEndSelectExpected();
michael@0 167
michael@0 168 void errStartTagWithSelectOpen(nsIAtom* aName);
michael@0 169
michael@0 170 void errBadStartTagInHead(nsIAtom* aName);
michael@0 171
michael@0 172 void errImage();
michael@0 173
michael@0 174 void errIsindex();
michael@0 175
michael@0 176 void errFooSeenWhenFooOpen(nsIAtom* aName);
michael@0 177
michael@0 178 void errHeadingWhenHeadingOpen();
michael@0 179
michael@0 180 void errFramesetStart();
michael@0 181
michael@0 182 void errNoCellToClose();
michael@0 183
michael@0 184 void errStartTagInTable(nsIAtom* aName);
michael@0 185
michael@0 186 void errFormWhenFormOpen();
michael@0 187
michael@0 188 void errTableSeenWhileTableOpen();
michael@0 189
michael@0 190 void errStartTagInTableBody(nsIAtom* aName);
michael@0 191
michael@0 192 void errEndTagSeenWithoutDoctype();
michael@0 193
michael@0 194 void errEndTagAfterBody();
michael@0 195
michael@0 196 void errEndTagSeenWithSelectOpen(nsIAtom* aName);
michael@0 197
michael@0 198 void errGarbageInColgroup();
michael@0 199
michael@0 200 void errEndTagBr();
michael@0 201
michael@0 202 void errNoElementToCloseButEndTagSeen(nsIAtom* aName);
michael@0 203
michael@0 204 void errHtmlStartTagInForeignContext(nsIAtom* aName);
michael@0 205
michael@0 206 void errTableClosedWhileCaptionOpen();
michael@0 207
michael@0 208 void errNoTableRowToClose();
michael@0 209
michael@0 210 void errNonSpaceInTable();
michael@0 211
michael@0 212 void errUnclosedChildrenInRuby();
michael@0 213
michael@0 214 void errStartTagSeenWithoutRuby(nsIAtom* aName);
michael@0 215
michael@0 216 void errSelfClosing();
michael@0 217
michael@0 218 void errNoCheckUnclosedElementsOnStack();
michael@0 219
michael@0 220 void errEndTagDidNotMatchCurrentOpenElement(nsIAtom* aName, nsIAtom* aOther);
michael@0 221
michael@0 222 void errEndTagViolatesNestingRules(nsIAtom* aName);
michael@0 223
michael@0 224 void errEndWithUnclosedElements(nsIAtom* aName);
michael@0 225
michael@0 226 void MarkAsBroken(nsresult aRv);

mercurial