parser/html/nsHtml5TreeBuilderHSupplement.h

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

mercurial