Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/parser/html/./../../../parser/html/nsHtml5Tokenizer.h
Warning:line 60, column 7
Excessive padding in 'class nsHtml5Tokenizer' (34 padding bytes, where 2 is optimal). Optimal fields order: tokenHandler, encodingDeclarationHandler, publicId, systemId, endTagExpectation, tagName, nonInternedTagName, attributeName, nonInternedAttributeName, doctypeName, publicIdentifier, systemIdentifier, attributes, interner, mViewSource, strBuf, charRefBuf, bmpChar, astralChar, endTagExpectationAsArray, stateSave, returnStateSave, index, entCol, firstCharKey, lo, hi, candidate, charRefBufMark, value, cstart, strBufLen, charRefBufLen, line, attributeLine, col, additional, lastCR, forceQuirks, seenDigits, suspendAfterCurrentNonTextToken, endTag, containsHyphen, newAttributesEachTime, shouldSuspend, keepBuffer, confident, viewingXmlSource, nextCharOnNewLine, consider reordering the fields or adding explicit padding members

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_parser_html0.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/parser/html -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/parser/html -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/parser/html -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/parser/html -I /root/firefox-clang/dom/base -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c++ Unified_cpp_parser_html0.cpp
1/*
2 * Copyright (c) 2005-2007 Henri Sivonen
3 * Copyright (c) 2007-2017 Mozilla Foundation
4 * Portions of comments Copyright 2004-2010 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 Tokenizer.java instead and regenerate.
29 */
30
31#ifndef nsHtml5Tokenizer_h
32#define nsHtml5Tokenizer_h
33
34#include "jArray.h"
35#include "nsAHtml5TreeBuilderState.h"
36#include "nsAtom.h"
37#include "nsGkAtoms.h"
38#include "nsHtml5ArrayCopy.h"
39#include "nsHtml5AtomTable.h"
40#include "nsHtml5DocumentMode.h"
41#include "nsHtml5Highlighter.h"
42#include "nsHtml5Macros.h"
43#include "nsHtml5NamedCharacters.h"
44#include "nsHtml5NamedCharactersAccel.h"
45#include "nsHtml5String.h"
46#include "nsHtml5TreeBuilder.h"
47#include "nsIContent.h"
48#include "nsTraceRefcnt.h"
49#include "mozilla/htmlaccel/htmlaccelEnabled.h"
50
51class nsHtml5StreamParser;
52
53class nsHtml5AttributeName;
54class nsHtml5ElementName;
55class nsHtml5TreeBuilder;
56class nsHtml5UTF16Buffer;
57class nsHtml5StateSnapshot;
58class nsHtml5Portability;
59
60class nsHtml5Tokenizer {
Excessive padding in 'class nsHtml5Tokenizer' (34 padding bytes, where 2 is optimal). Optimal fields order: tokenHandler, encodingDeclarationHandler, publicId, systemId, endTagExpectation, tagName, nonInternedTagName, attributeName, nonInternedAttributeName, doctypeName, publicIdentifier, systemIdentifier, attributes, interner, mViewSource, strBuf, charRefBuf, bmpChar, astralChar, endTagExpectationAsArray, stateSave, returnStateSave, index, entCol, firstCharKey, lo, hi, candidate, charRefBufMark, value, cstart, strBufLen, charRefBufLen, line, attributeLine, col, additional, lastCR, forceQuirks, seenDigits, suspendAfterCurrentNonTextToken, endTag, containsHyphen, newAttributesEachTime, shouldSuspend, keepBuffer, confident, viewingXmlSource, nextCharOnNewLine, consider reordering the fields or adding explicit padding members
61 private:
62 static const int32_t DATA_AND_RCDATA_MASK = ~1;
63
64 public:
65 static const int32_t DATA = 0;
66
67 static const int32_t RCDATA = 1;
68
69 static const int32_t SCRIPT_DATA = 2;
70
71 static const int32_t RAWTEXT = 3;
72
73 static const int32_t SCRIPT_DATA_ESCAPED = 4;
74
75 static const int32_t ATTRIBUTE_VALUE_DOUBLE_QUOTED = 5;
76
77 static const int32_t ATTRIBUTE_VALUE_SINGLE_QUOTED = 6;
78
79 static const int32_t ATTRIBUTE_VALUE_UNQUOTED = 7;
80
81 static const int32_t PLAINTEXT = 8;
82
83 static const int32_t TAG_OPEN = 9;
84
85 static const int32_t CLOSE_TAG_OPEN = 10;
86
87 static const int32_t TAG_NAME = 11;
88
89 static const int32_t BEFORE_ATTRIBUTE_NAME = 12;
90
91 static const int32_t ATTRIBUTE_NAME = 13;
92
93 static const int32_t AFTER_ATTRIBUTE_NAME = 14;
94
95 static const int32_t BEFORE_ATTRIBUTE_VALUE = 15;
96
97 static const int32_t AFTER_ATTRIBUTE_VALUE_QUOTED = 16;
98
99 static const int32_t BOGUS_COMMENT = 17;
100
101 static const int32_t MARKUP_DECLARATION_OPEN = 18;
102
103 static const int32_t DOCTYPE = 19;
104
105 static const int32_t BEFORE_DOCTYPE_NAME = 20;
106
107 static const int32_t DOCTYPE_NAME = 21;
108
109 static const int32_t AFTER_DOCTYPE_NAME = 22;
110
111 static const int32_t BEFORE_DOCTYPE_PUBLIC_IDENTIFIER = 23;
112
113 static const int32_t DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED = 24;
114
115 static const int32_t DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED = 25;
116
117 static const int32_t AFTER_DOCTYPE_PUBLIC_IDENTIFIER = 26;
118
119 static const int32_t BEFORE_DOCTYPE_SYSTEM_IDENTIFIER = 27;
120
121 static const int32_t DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED = 28;
122
123 static const int32_t DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED = 29;
124
125 static const int32_t AFTER_DOCTYPE_SYSTEM_IDENTIFIER = 30;
126
127 static const int32_t BOGUS_DOCTYPE = 31;
128
129 static const int32_t COMMENT_START = 32;
130
131 static const int32_t COMMENT_START_DASH = 33;
132
133 static const int32_t COMMENT = 34;
134
135 static const int32_t COMMENT_END_DASH = 35;
136
137 static const int32_t COMMENT_END = 36;
138
139 static const int32_t COMMENT_END_BANG = 37;
140
141 static const int32_t NON_DATA_END_TAG_NAME = 38;
142
143 static const int32_t MARKUP_DECLARATION_HYPHEN = 39;
144
145 static const int32_t MARKUP_DECLARATION_OCTYPE = 40;
146
147 static const int32_t DOCTYPE_UBLIC = 41;
148
149 static const int32_t DOCTYPE_YSTEM = 42;
150
151 static const int32_t AFTER_DOCTYPE_PUBLIC_KEYWORD = 43;
152
153 static const int32_t BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS = 44;
154
155 static const int32_t AFTER_DOCTYPE_SYSTEM_KEYWORD = 45;
156
157 static const int32_t CONSUME_CHARACTER_REFERENCE = 46;
158
159 static const int32_t CONSUME_NCR = 47;
160
161 static const int32_t CHARACTER_REFERENCE_TAIL = 48;
162
163 static const int32_t HEX_NCR_LOOP = 49;
164
165 static const int32_t DECIMAL_NRC_LOOP = 50;
166
167 static const int32_t HANDLE_NCR_VALUE = 51;
168
169 static const int32_t HANDLE_NCR_VALUE_RECONSUME = 52;
170
171 static const int32_t CHARACTER_REFERENCE_HILO_LOOKUP = 53;
172
173 static const int32_t SELF_CLOSING_START_TAG = 54;
174
175 static const int32_t CDATA_START = 55;
176
177 static const int32_t CDATA_SECTION = 56;
178
179 static const int32_t CDATA_RSQB = 57;
180
181 static const int32_t CDATA_RSQB_RSQB = 58;
182
183 static const int32_t SCRIPT_DATA_LESS_THAN_SIGN = 59;
184
185 static const int32_t SCRIPT_DATA_ESCAPE_START = 60;
186
187 static const int32_t SCRIPT_DATA_ESCAPE_START_DASH = 61;
188
189 static const int32_t SCRIPT_DATA_ESCAPED_DASH = 62;
190
191 static const int32_t SCRIPT_DATA_ESCAPED_DASH_DASH = 63;
192
193 static const int32_t BOGUS_COMMENT_HYPHEN = 64;
194
195 static const int32_t RAWTEXT_RCDATA_LESS_THAN_SIGN = 65;
196
197 static const int32_t SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN = 66;
198
199 static const int32_t SCRIPT_DATA_DOUBLE_ESCAPE_START = 67;
200
201 static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED = 68;
202
203 static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN = 69;
204
205 static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED_DASH = 70;
206
207 static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH = 71;
208
209 static const int32_t SCRIPT_DATA_DOUBLE_ESCAPE_END = 72;
210
211 static const int32_t PROCESSING_INSTRUCTION = 73;
212
213 static const int32_t PROCESSING_INSTRUCTION_QUESTION_MARK = 74;
214
215 static const int32_t COMMENT_LESSTHAN = 76;
216
217 static const int32_t COMMENT_LESSTHAN_BANG = 77;
218
219 static const int32_t COMMENT_LESSTHAN_BANG_DASH = 78;
220
221 static const int32_t COMMENT_LESSTHAN_BANG_DASH_DASH = 79;
222
223 private:
224 static const int32_t LEAD_OFFSET = (0xD800 - (0x10000 >> 10));
225
226 static char16_t LT_GT[];
227 static char16_t LT_SOLIDUS[];
228 static char16_t RSQB_RSQB[];
229 static char16_t REPLACEMENT_CHARACTER[];
230 static char16_t LF[];
231 static char16_t CDATA_LSQB[];
232 static char16_t OCTYPE[];
233 static char16_t UBLIC[];
234 static char16_t YSTEM[];
235 static staticJArray<char16_t, int32_t> TITLE_ARR;
236 static staticJArray<char16_t, int32_t> SCRIPT_ARR;
237 static staticJArray<char16_t, int32_t> STYLE_ARR;
238 static staticJArray<char16_t, int32_t> PLAINTEXT_ARR;
239 static staticJArray<char16_t, int32_t> XMP_ARR;
240 static staticJArray<char16_t, int32_t> TEXTAREA_ARR;
241 static staticJArray<char16_t, int32_t> IFRAME_ARR;
242 static staticJArray<char16_t, int32_t> NOEMBED_ARR;
243 static staticJArray<char16_t, int32_t> NOSCRIPT_ARR;
244 static staticJArray<char16_t, int32_t> NOFRAMES_ARR;
245
246 protected:
247 nsHtml5TreeBuilder* tokenHandler;
248 nsHtml5StreamParser* encodingDeclarationHandler;
249 bool lastCR;
250 int32_t stateSave;
251
252 private:
253 int32_t returnStateSave;
254
255 protected:
256 int32_t index;
257
258 private:
259 bool forceQuirks;
260 char16_t additional;
261 int32_t entCol;
262 int32_t firstCharKey;
263 int32_t lo;
264 int32_t hi;
265 int32_t candidate;
266 int32_t charRefBufMark;
267
268 protected:
269 int32_t value;
270
271 private:
272 bool seenDigits;
273 bool suspendAfterCurrentNonTextToken;
274
275 protected:
276 int32_t cstart;
277
278 private:
279 nsHtml5String publicId;
280 nsHtml5String systemId;
281 autoJArray<char16_t, int32_t> strBuf;
282 int32_t strBufLen;
283 autoJArray<char16_t, int32_t> charRefBuf;
284 int32_t charRefBufLen;
285 autoJArray<char16_t, int32_t> bmpChar;
286 autoJArray<char16_t, int32_t> astralChar;
287
288 protected:
289 nsHtml5ElementName* endTagExpectation;
290
291 private:
292 jArray<char16_t, int32_t> endTagExpectationAsArray;
293
294 protected:
295 bool endTag;
296
297 private:
298 bool containsHyphen;
299 nsHtml5ElementName* tagName;
300 nsHtml5ElementName* nonInternedTagName;
301
302 protected:
303 nsHtml5AttributeName* attributeName;
304
305 private:
306 nsHtml5AttributeName* nonInternedAttributeName;
307 RefPtr<nsAtom> doctypeName;
308 nsHtml5String publicIdentifier;
309 nsHtml5String systemIdentifier;
310 nsHtml5HtmlAttributes* attributes;
311 bool newAttributesEachTime;
312 bool shouldSuspend;
313 bool keepBuffer;
314
315 protected:
316 bool confident;
317
318 private:
319 int32_t line;
320 int32_t attributeLine;
321 nsHtml5AtomTable* interner;
322 bool viewingXmlSource;
323
324 public:
325 nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource);
326 void setInterner(nsHtml5AtomTable* interner);
327 void initLocation(nsHtml5String newPublicId, nsHtml5String newSystemId);
328 bool isViewingXmlSource();
329 void setKeepBuffer(bool keepBuffer);
330 bool dropBufferIfLongerThan(int32_t length);
331 void setState(int32_t specialTokenizerState);
332 void setStateAndEndTagExpectation(int32_t specialTokenizerState,
333 nsHtml5ElementName* endTagExpectation);
334
335 private:
336 void endTagExpectationToArray();
337
338 public:
339 void setLineNumber(int32_t line);
340 inline int32_t getLineNumber() { return line; }
341
342 inline nsHtml5HtmlAttributes* emptyAttributes() {
343 return nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES;
344 }
345
346 private:
347 void appendCharRefBuf(char16_t c);
348 void emitOrAppendCharRefBuf(int32_t returnState);
349 inline void clearStrBufAfterUse() { strBufLen = 0; }
350
351 inline void clearStrBufBeforeUse() {
352 MOZ_ASSERT(!strBufLen, "strBufLen not reset after previous use!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!strBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!strBufLen))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("!strBufLen" " (" "strBufLen not reset after previous use!"
")", "./../../../parser/html/nsHtml5Tokenizer.h", 352); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!strBufLen" ") (" "strBufLen not reset after previous use!"
")"); do { MOZ_CrashSequence(__null, 352); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
353 strBufLen = 0;
354 }
355
356 inline void clearStrBufAfterOneHyphen() {
357 MOZ_ASSERT(strBufLen == 1, "strBufLen length not one!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(strBufLen == 1)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(strBufLen == 1))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("strBufLen == 1"
" (" "strBufLen length not one!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 357); AnnotateMozCrashReason("MOZ_ASSERT" "(" "strBufLen == 1"
") (" "strBufLen length not one!" ")"); do { MOZ_CrashSequence
(__null, 357); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
358 MOZ_ASSERT(strBuf[0] == '-', "strBuf does not start with a hyphen!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(strBuf[0] == '-')>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(strBuf[0] == '-'))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("strBuf[0] == '-'"
" (" "strBuf does not start with a hyphen!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 358); AnnotateMozCrashReason("MOZ_ASSERT" "(" "strBuf[0] == '-'"
") (" "strBuf does not start with a hyphen!" ")"); do { MOZ_CrashSequence
(__null, 358); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
359 strBufLen = 0;
360 }
361
362 inline void appendStrBuf(char16_t c) {
363 if (MOZ_UNLIKELY(strBufLen == strBuf.length)(__builtin_expect(!!(strBufLen == strBuf.length), 0))) {
364 EnsureBufferSpaceShouldNeverHappen(1);
365 }
366 strBuf[strBufLen++] = c;
367 }
368
369 protected:
370 inline nsHtml5String strBufToString() {
371 nsHtml5String str = nsHtml5Portability::newStringFromBuffer(
372 strBuf, 0, strBufLen, tokenHandler, nullptr);
373 clearStrBufAfterUse();
374 return str;
375 }
376
377 inline nsHtml5String strBufToAttributeValueString() {
378 nsHtml5String digitAtom = TryAtomizeForSingleDigit();
379 if (digitAtom) {
380 return digitAtom;
381 }
382 nsHtml5String str = nsHtml5Portability::newStringFromBuffer(
383 strBuf, 0, strBufLen, tokenHandler,
384 attributeName->isUseAtom() ? interner : nullptr);
385 clearStrBufAfterUse();
386 return str;
387 }
388
389 private:
390 inline void strBufToDoctypeName() {
391 doctypeName =
392 nsHtml5Portability::newLocalNameFromBuffer(strBuf, strBufLen, interner);
393 clearStrBufAfterUse();
394 }
395
396 inline void emitStrBuf() {
397 if (strBufLen > 0) {
398 tokenHandler->characters(strBuf, 0, strBufLen);
399 clearStrBufAfterUse();
400 }
401 }
402
403 inline void appendSecondHyphenToBogusComment() { appendStrBuf('-'); }
404
405 inline void adjustDoubleHyphenAndAppendToStrBufAndErr(
406 char16_t c, bool reportedConsecutiveHyphens) {
407 appendStrBuf(c);
408 }
409
410 inline void appendStrBuf(char16_t* buffer, int32_t offset, int32_t length) {
411 int32_t newLen = strBufLen + length;
412 if (MOZ_UNLIKELY(strBuf.length < newLen)(__builtin_expect(!!(strBuf.length < newLen), 0))) {
413 EnsureBufferSpaceShouldNeverHappen(length);
414 }
415 nsHtml5ArrayCopy::arraycopy(buffer, offset, strBuf, strBufLen, length);
416 strBufLen = newLen;
417 }
418
419 inline void appendCharRefBufToStrBuf() {
420 appendStrBuf(charRefBuf, 0, charRefBufLen);
421 charRefBufLen = 0;
422 }
423
424 void emitComment(int32_t provisionalHyphens, int32_t pos);
425
426 protected:
427 void flushChars(char16_t* buf, int32_t pos);
428
429 private:
430 void strBufToElementNameString();
431 int32_t emitCurrentTagToken(bool selfClosing, int32_t pos);
432 void attributeNameComplete();
433 void addAttributeWithoutValue();
434 void addAttributeWithValue();
435
436 public:
437 void start();
438 bool tokenizeBuffer(nsHtml5UTF16Buffer* buffer);
439
440 private:
441 template <class P>
442 inline int32_t stateLoop(int32_t state, char16_t c, int32_t pos,
443 char16_t* buf, bool reconsume, int32_t returnState,
444 int32_t endPos) {
445 bool reportedConsecutiveHyphens = false;
446 stateloop:
447 for (;;) {
448 switch (state) {
449 case DATA: {
450 for (;;) {
451 if (reconsume) {
452 reconsume = false;
453 } else {
454 ++pos;
455 pos += P::accelerateAdvancementData(this, buf, pos, endPos);
456 if (pos == endPos) {
457 NS_HTML5_BREAK(stateloop)goto stateloop_end;
458 }
459 c = P::checkChar(this, buf, pos);
460 }
461 switch (c) {
462 case '&': {
463 flushChars(buf, pos);
464 MOZ_ASSERT(!charRefBufLen,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 465); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 465); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
465 "charRefBufLen not reset after previous use!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 465); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 465); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
466 appendCharRefBuf(c);
467 setAdditionalAndRememberAmpersandLocation('\0');
468 returnState = state;
469 state =
470 P::transition(mViewSource.get(),
471 nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
472 reconsume, pos);
473 NS_HTML5_CONTINUE(stateloop)goto stateloop;
474 }
475 case '<': {
476 flushChars(buf, pos);
477 state =
478 P::transition(mViewSource.get(), nsHtml5Tokenizer::TAG_OPEN,
479 reconsume, pos);
480 NS_HTML5_BREAK(dataloop)goto dataloop_end;
481 }
482 case '\0': {
483 maybeEmitReplacementCharacter(buf, pos);
484 continue;
485 }
486 case '\r': {
487 emitCarriageReturn<P>(buf, pos);
488 NS_HTML5_BREAK(stateloop)goto stateloop_end;
489 }
490 case '\n': {
491 P::silentLineFeed(this);
492 [[fallthrough]];
493 }
494 default: {
495 continue;
496 }
497 }
498 }
499 dataloop_end:;
500 [[fallthrough]];
501 }
502 case TAG_OPEN: {
503 for (;;) {
504 if (++pos == endPos) {
505 NS_HTML5_BREAK(stateloop)goto stateloop_end;
506 }
507 c = P::checkChar(this, buf, pos);
508 if (c >= 'A' && c <= 'Z') {
509 endTag = false;
510 clearStrBufBeforeUse();
511 appendStrBuf((char16_t)(c + 0x20));
512 containsHyphen = false;
513 state = P::transition(mViewSource.get(),
514 nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
515 NS_HTML5_BREAK(tagopenloop)goto tagopenloop_end;
516 } else if (c >= 'a' && c <= 'z') {
517 endTag = false;
518 clearStrBufBeforeUse();
519 appendStrBuf(c);
520 containsHyphen = false;
521 state = P::transition(mViewSource.get(),
522 nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
523 NS_HTML5_BREAK(tagopenloop)goto tagopenloop_end;
524 }
525 switch (c) {
526 case '!': {
527 state = P::transition(mViewSource.get(),
528 nsHtml5Tokenizer::MARKUP_DECLARATION_OPEN,
529 reconsume, pos);
530 NS_HTML5_CONTINUE(stateloop)goto stateloop;
531 }
532 case '/': {
533 state = P::transition(mViewSource.get(),
534 nsHtml5Tokenizer::CLOSE_TAG_OPEN,
535 reconsume, pos);
536 NS_HTML5_CONTINUE(stateloop)goto stateloop;
537 }
538 case '\?': {
539 if (viewingXmlSource) {
540 state = P::transition(
541 mViewSource.get(),
542 nsHtml5Tokenizer::PROCESSING_INSTRUCTION, reconsume, pos);
543 NS_HTML5_CONTINUE(stateloop)goto stateloop;
544 }
545 if (P::reportErrors) {
546 errProcessingInstruction();
547 }
548 clearStrBufBeforeUse();
549 appendStrBuf(c);
550 state = P::transition(mViewSource.get(),
551 nsHtml5Tokenizer::BOGUS_COMMENT,
552 reconsume, pos);
553 NS_HTML5_CONTINUE(stateloop)goto stateloop;
554 }
555 case '>': {
556 if (P::reportErrors) {
557 errLtGt();
558 }
559 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 2);
560 cstart = pos + 1;
561 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
562 reconsume, pos);
563 NS_HTML5_CONTINUE(stateloop)goto stateloop;
564 }
565 default: {
566 if (P::reportErrors) {
567 errBadCharAfterLt(c);
568 }
569 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
570 cstart = pos;
571 reconsume = true;
572 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
573 reconsume, pos);
574 NS_HTML5_CONTINUE(stateloop)goto stateloop;
575 }
576 }
577 }
578 tagopenloop_end:;
579 [[fallthrough]];
580 }
581 case TAG_NAME: {
582 for (;;) {
583 if (++pos == endPos) {
584 NS_HTML5_BREAK(stateloop)goto stateloop_end;
585 }
586 c = P::checkChar(this, buf, pos);
587 switch (c) {
588 case '\r': {
589 P::silentCarriageReturn(this);
590 strBufToElementNameString();
591 state = P::transition(mViewSource.get(),
592 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
593 reconsume, pos);
594 NS_HTML5_BREAK(stateloop)goto stateloop_end;
595 }
596 case '\n': {
597 P::silentLineFeed(this);
598 [[fallthrough]];
599 }
600 case ' ':
601 case '\t':
602 case '\f': {
603 strBufToElementNameString();
604 state = P::transition(mViewSource.get(),
605 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
606 reconsume, pos);
607 NS_HTML5_BREAK(tagnameloop)goto tagnameloop_end;
608 }
609 case '/': {
610 strBufToElementNameString();
611 state = P::transition(mViewSource.get(),
612 nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
613 reconsume, pos);
614 NS_HTML5_CONTINUE(stateloop)goto stateloop;
615 }
616 case '>': {
617 strBufToElementNameString();
618 state = P::transition(mViewSource.get(),
619 emitCurrentTagToken(false, pos),
620 reconsume, pos);
621 if (shouldSuspend) {
622 NS_HTML5_BREAK(stateloop)goto stateloop_end;
623 }
624 NS_HTML5_CONTINUE(stateloop)goto stateloop;
625 }
626 case '\0': {
627 c = 0xfffd;
628 [[fallthrough]];
629 }
630 default: {
631 if (c >= 'A' && c <= 'Z') {
632 c += 0x20;
633 } else if (c == '-') {
634 containsHyphen = true;
635 }
636 appendStrBuf(c);
637 continue;
638 }
639 }
640 }
641 tagnameloop_end:;
642 [[fallthrough]];
643 }
644 case BEFORE_ATTRIBUTE_NAME: {
645 for (;;) {
646 if (reconsume) {
647 reconsume = false;
648 } else {
649 if (++pos == endPos) {
650 NS_HTML5_BREAK(stateloop)goto stateloop_end;
651 }
652 c = P::checkChar(this, buf, pos);
653 }
654 switch (c) {
655 case '\r': {
656 P::silentCarriageReturn(this);
657 NS_HTML5_BREAK(stateloop)goto stateloop_end;
658 }
659 case '\n': {
660 P::silentLineFeed(this);
661 [[fallthrough]];
662 }
663 case ' ':
664 case '\t':
665 case '\f': {
666 continue;
667 }
668 case '/': {
669 state = P::transition(mViewSource.get(),
670 nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
671 reconsume, pos);
672 NS_HTML5_CONTINUE(stateloop)goto stateloop;
673 }
674 case '>': {
675 state = P::transition(mViewSource.get(),
676 emitCurrentTagToken(false, pos),
677 reconsume, pos);
678 if (shouldSuspend) {
679 NS_HTML5_BREAK(stateloop)goto stateloop_end;
680 }
681 NS_HTML5_CONTINUE(stateloop)goto stateloop;
682 }
683 case '\0': {
684 c = 0xfffd;
685 [[fallthrough]];
686 }
687 case '\"':
688 case '\'':
689 case '<':
690 case '=': {
691 if (P::reportErrors) {
692 errBadCharBeforeAttributeNameOrNull(c);
693 }
694 [[fallthrough]];
695 }
696 default: {
697 if (c >= 'A' && c <= 'Z') {
698 c += 0x20;
699 }
700 attributeLine = line;
701 clearStrBufBeforeUse();
702 appendStrBuf(c);
703 state = P::transition(mViewSource.get(),
704 nsHtml5Tokenizer::ATTRIBUTE_NAME,
705 reconsume, pos);
706 NS_HTML5_BREAK(beforeattributenameloop)goto beforeattributenameloop_end;
707 }
708 }
709 }
710 beforeattributenameloop_end:;
711 [[fallthrough]];
712 }
713 case ATTRIBUTE_NAME: {
714 for (;;) {
715 if (++pos == endPos) {
716 NS_HTML5_BREAK(stateloop)goto stateloop_end;
717 }
718 c = P::checkChar(this, buf, pos);
719 switch (c) {
720 case '\r': {
721 P::silentCarriageReturn(this);
722 attributeNameComplete();
723 state = P::transition(mViewSource.get(),
724 nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME,
725 reconsume, pos);
726 NS_HTML5_BREAK(stateloop)goto stateloop_end;
727 }
728 case '\n': {
729 P::silentLineFeed(this);
730 [[fallthrough]];
731 }
732 case ' ':
733 case '\t':
734 case '\f': {
735 attributeNameComplete();
736 state = P::transition(mViewSource.get(),
737 nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME,
738 reconsume, pos);
739 NS_HTML5_CONTINUE(stateloop)goto stateloop;
740 }
741 case '/': {
742 attributeNameComplete();
743 addAttributeWithoutValue();
744 state = P::transition(mViewSource.get(),
745 nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
746 reconsume, pos);
747 NS_HTML5_CONTINUE(stateloop)goto stateloop;
748 }
749 case '=': {
750 attributeNameComplete();
751 state = P::transition(mViewSource.get(),
752 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE,
753 reconsume, pos);
754 NS_HTML5_BREAK(attributenameloop)goto attributenameloop_end;
755 }
756 case '>': {
757 attributeNameComplete();
758 addAttributeWithoutValue();
759 state = P::transition(mViewSource.get(),
760 emitCurrentTagToken(false, pos),
761 reconsume, pos);
762 if (shouldSuspend) {
763 NS_HTML5_BREAK(stateloop)goto stateloop_end;
764 }
765 NS_HTML5_CONTINUE(stateloop)goto stateloop;
766 }
767 case '\0': {
768 c = 0xfffd;
769 [[fallthrough]];
770 }
771 case '\"':
772 case '\'':
773 case '<': {
774 if (P::reportErrors) {
775 errQuoteOrLtInAttributeNameOrNull(c);
776 }
777 [[fallthrough]];
778 }
779 default: {
780 if (c >= 'A' && c <= 'Z') {
781 c += 0x20;
782 }
783 appendStrBuf(c);
784 continue;
785 }
786 }
787 }
788 attributenameloop_end:;
789 [[fallthrough]];
790 }
791 case BEFORE_ATTRIBUTE_VALUE: {
792 for (;;) {
793 if (++pos == endPos) {
794 NS_HTML5_BREAK(stateloop)goto stateloop_end;
795 }
796 c = P::checkChar(this, buf, pos);
797 switch (c) {
798 case '\r': {
799 P::silentCarriageReturn(this);
800 NS_HTML5_BREAK(stateloop)goto stateloop_end;
801 }
802 case '\n': {
803 P::silentLineFeed(this);
804 [[fallthrough]];
805 }
806 case ' ':
807 case '\t':
808 case '\f': {
809 continue;
810 }
811 case '\"': {
812 attributeLine = line;
813 clearStrBufBeforeUse();
814 state = P::transition(
815 mViewSource.get(),
816 nsHtml5Tokenizer::ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume,
817 pos);
818 NS_HTML5_BREAK(beforeattributevalueloop)goto beforeattributevalueloop_end;
819 }
820 case '&': {
821 attributeLine = line;
822 clearStrBufBeforeUse();
823 reconsume = true;
824 state = P::transition(
825 mViewSource.get(),
826 nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
827
828 NS_HTML5_CONTINUE(stateloop)goto stateloop;
829 }
830 case '\'': {
831 attributeLine = line;
832 clearStrBufBeforeUse();
833 state = P::transition(
834 mViewSource.get(),
835 nsHtml5Tokenizer::ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume,
836 pos);
837 NS_HTML5_CONTINUE(stateloop)goto stateloop;
838 }
839 case '>': {
840 if (P::reportErrors) {
841 errAttributeValueMissing();
842 }
843 addAttributeWithoutValue();
844 state = P::transition(mViewSource.get(),
845 emitCurrentTagToken(false, pos),
846 reconsume, pos);
847 if (shouldSuspend) {
848 NS_HTML5_BREAK(stateloop)goto stateloop_end;
849 }
850 NS_HTML5_CONTINUE(stateloop)goto stateloop;
851 }
852 case '\0': {
853 c = 0xfffd;
854 [[fallthrough]];
855 }
856 case '<':
857 case '=':
858 case '`': {
859 if (P::reportErrors) {
860 errLtOrEqualsOrGraveInUnquotedAttributeOrNull(c);
861 }
862 [[fallthrough]];
863 }
864 default: {
865 attributeLine = line;
866 clearStrBufBeforeUse();
867 appendStrBuf(c);
868 state = P::transition(
869 mViewSource.get(),
870 nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
871
872 NS_HTML5_CONTINUE(stateloop)goto stateloop;
873 }
874 }
875 }
876 beforeattributevalueloop_end:;
877 [[fallthrough]];
878 }
879 case ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
880 for (;;) {
881 if (reconsume) {
882 reconsume = false;
883 } else {
884 ++pos;
885 pos += P::accelerateAdvancementAttributeValueDoubleQuoted(
886 this, buf, pos, endPos);
887 if (pos == endPos) {
888 NS_HTML5_BREAK(stateloop)goto stateloop_end;
889 }
890 c = P::checkChar(this, buf, pos);
891 }
892 switch (c) {
893 case '\"': {
894 addAttributeWithValue();
895 state = P::transition(
896 mViewSource.get(),
897 nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume,
898 pos);
899 NS_HTML5_BREAK(attributevaluedoublequotedloop)goto attributevaluedoublequotedloop_end;
900 }
901 case '&': {
902 MOZ_ASSERT(!charRefBufLen,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 903); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 903); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
903 "charRefBufLen not reset after previous use!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 903); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 903); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
904 appendCharRefBuf(c);
905 setAdditionalAndRememberAmpersandLocation('\"');
906 returnState = state;
907 state =
908 P::transition(mViewSource.get(),
909 nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
910 reconsume, pos);
911 NS_HTML5_CONTINUE(stateloop)goto stateloop;
912 }
913 case '\r': {
914 appendStrBufCarriageReturn<P>();
915 NS_HTML5_BREAK(stateloop)goto stateloop_end;
916 }
917 case '\n': {
918 appendStrBufLineFeed<P>();
919 continue;
920 }
921 case '\0': {
922 c = 0xfffd;
923 [[fallthrough]];
924 }
925 default: {
926 appendStrBuf(c);
927 continue;
928 }
929 }
930 }
931 attributevaluedoublequotedloop_end:;
932 [[fallthrough]];
933 }
934 case AFTER_ATTRIBUTE_VALUE_QUOTED: {
935 for (;;) {
936 if (++pos == endPos) {
937 NS_HTML5_BREAK(stateloop)goto stateloop_end;
938 }
939 c = P::checkChar(this, buf, pos);
940 switch (c) {
941 case '\r': {
942 P::silentCarriageReturn(this);
943 state = P::transition(mViewSource.get(),
944 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
945 reconsume, pos);
946 NS_HTML5_BREAK(stateloop)goto stateloop_end;
947 }
948 case '\n': {
949 P::silentLineFeed(this);
950 [[fallthrough]];
951 }
952 case ' ':
953 case '\t':
954 case '\f': {
955 state = P::transition(mViewSource.get(),
956 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
957 reconsume, pos);
958 NS_HTML5_CONTINUE(stateloop)goto stateloop;
959 }
960 case '/': {
961 state = P::transition(mViewSource.get(),
962 nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
963 reconsume, pos);
964 NS_HTML5_BREAK(afterattributevaluequotedloop)goto afterattributevaluequotedloop_end;
965 }
966 case '>': {
967 state = P::transition(mViewSource.get(),
968 emitCurrentTagToken(false, pos),
969 reconsume, pos);
970 if (shouldSuspend) {
971 NS_HTML5_BREAK(stateloop)goto stateloop_end;
972 }
973 NS_HTML5_CONTINUE(stateloop)goto stateloop;
974 }
975 default: {
976 if (P::reportErrors) {
977 errNoSpaceBetweenAttributes();
978 }
979 reconsume = true;
980 state = P::transition(mViewSource.get(),
981 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
982 reconsume, pos);
983 NS_HTML5_CONTINUE(stateloop)goto stateloop;
984 }
985 }
986 }
987 afterattributevaluequotedloop_end:;
988 [[fallthrough]];
989 }
990 case SELF_CLOSING_START_TAG: {
991 if (++pos == endPos) {
992 NS_HTML5_BREAK(stateloop)goto stateloop_end;
993 }
994 c = P::checkChar(this, buf, pos);
995 switch (c) {
996 case '>': {
997 state =
998 P::transition(mViewSource.get(),
999 emitCurrentTagToken(true, pos), reconsume, pos);
1000 if (shouldSuspend) {
1001 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1002 }
1003 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1004 }
1005 default: {
1006 if (P::reportErrors) {
1007 errSlashNotFollowedByGt();
1008 }
1009 reconsume = true;
1010 state = P::transition(mViewSource.get(),
1011 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
1012 reconsume, pos);
1013 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1014 }
1015 }
1016 }
1017 case ATTRIBUTE_VALUE_UNQUOTED: {
1018 for (;;) {
1019 if (reconsume) {
1020 reconsume = false;
1021 } else {
1022 if (++pos == endPos) {
1023 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1024 }
1025 c = P::checkChar(this, buf, pos);
1026 }
1027 switch (c) {
1028 case '\r': {
1029 P::silentCarriageReturn(this);
1030 addAttributeWithValue();
1031 state = P::transition(mViewSource.get(),
1032 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
1033 reconsume, pos);
1034 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1035 }
1036 case '\n': {
1037 P::silentLineFeed(this);
1038 [[fallthrough]];
1039 }
1040 case ' ':
1041 case '\t':
1042 case '\f': {
1043 addAttributeWithValue();
1044 state = P::transition(mViewSource.get(),
1045 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
1046 reconsume, pos);
1047 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1048 }
1049 case '&': {
1050 MOZ_ASSERT(!charRefBufLen,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 1051); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 1051); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
1051 "charRefBufLen not reset after previous use!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 1051); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 1051); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
1052 appendCharRefBuf(c);
1053 setAdditionalAndRememberAmpersandLocation('>');
1054 returnState = state;
1055 state =
1056 P::transition(mViewSource.get(),
1057 nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
1058 reconsume, pos);
1059 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1060 }
1061 case '>': {
1062 addAttributeWithValue();
1063 state = P::transition(mViewSource.get(),
1064 emitCurrentTagToken(false, pos),
1065 reconsume, pos);
1066 if (shouldSuspend) {
1067 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1068 }
1069 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1070 }
1071 case '\0': {
1072 c = 0xfffd;
1073 [[fallthrough]];
1074 }
1075 case '<':
1076 case '\"':
1077 case '\'':
1078 case '=':
1079 case '`': {
1080 if (P::reportErrors) {
1081 errUnquotedAttributeValOrNull(c);
1082 }
1083 [[fallthrough]];
1084 }
1085 default: {
1086 appendStrBuf(c);
1087 continue;
1088 }
1089 }
1090 }
1091 }
1092 case AFTER_ATTRIBUTE_NAME: {
1093 for (;;) {
1094 if (++pos == endPos) {
1095 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1096 }
1097 c = P::checkChar(this, buf, pos);
1098 switch (c) {
1099 case '\r': {
1100 P::silentCarriageReturn(this);
1101 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1102 }
1103 case '\n': {
1104 P::silentLineFeed(this);
1105 [[fallthrough]];
1106 }
1107 case ' ':
1108 case '\t':
1109 case '\f': {
1110 continue;
1111 }
1112 case '/': {
1113 addAttributeWithoutValue();
1114 state = P::transition(mViewSource.get(),
1115 nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
1116 reconsume, pos);
1117 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1118 }
1119 case '=': {
1120 state = P::transition(mViewSource.get(),
1121 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE,
1122 reconsume, pos);
1123 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1124 }
1125 case '>': {
1126 addAttributeWithoutValue();
1127 state = P::transition(mViewSource.get(),
1128 emitCurrentTagToken(false, pos),
1129 reconsume, pos);
1130 if (shouldSuspend) {
1131 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1132 }
1133 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1134 }
1135 case '\0': {
1136 c = 0xfffd;
1137 [[fallthrough]];
1138 }
1139 case '\"':
1140 case '\'':
1141 case '<': {
1142 if (P::reportErrors) {
1143 errQuoteOrLtInAttributeNameOrNull(c);
1144 }
1145 [[fallthrough]];
1146 }
1147 default: {
1148 addAttributeWithoutValue();
1149 if (c >= 'A' && c <= 'Z') {
1150 c += 0x20;
1151 }
1152 clearStrBufBeforeUse();
1153 appendStrBuf(c);
1154 state = P::transition(mViewSource.get(),
1155 nsHtml5Tokenizer::ATTRIBUTE_NAME,
1156 reconsume, pos);
1157 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1158 }
1159 }
1160 }
1161 }
1162 case MARKUP_DECLARATION_OPEN: {
1163 for (;;) {
1164 if (++pos == endPos) {
1165 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1166 }
1167 c = P::checkChar(this, buf, pos);
1168 switch (c) {
1169 case '-': {
1170 clearStrBufBeforeUse();
1171 appendStrBuf(c);
1172 state =
1173 P::transition(mViewSource.get(),
1174 nsHtml5Tokenizer::MARKUP_DECLARATION_HYPHEN,
1175 reconsume, pos);
1176 NS_HTML5_BREAK(markupdeclarationopenloop)goto markupdeclarationopenloop_end;
1177 }
1178 case 'd':
1179 case 'D': {
1180 clearStrBufBeforeUse();
1181 appendStrBuf(c);
1182 index = 0;
1183 state =
1184 P::transition(mViewSource.get(),
1185 nsHtml5Tokenizer::MARKUP_DECLARATION_OCTYPE,
1186 reconsume, pos);
1187 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1188 }
1189 case '[': {
1190 if (tokenHandler->cdataSectionAllowed()) {
1191 clearStrBufBeforeUse();
1192 appendStrBuf(c);
1193 index = 0;
1194 state = P::transition(mViewSource.get(),
1195 nsHtml5Tokenizer::CDATA_START,
1196 reconsume, pos);
1197 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1198 }
1199 [[fallthrough]];
1200 }
1201 default: {
1202 if (P::reportErrors) {
1203 errBogusComment();
1204 }
1205 clearStrBufBeforeUse();
1206 reconsume = true;
1207 state = P::transition(mViewSource.get(),
1208 nsHtml5Tokenizer::BOGUS_COMMENT,
1209 reconsume, pos);
1210 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1211 }
1212 }
1213 }
1214 markupdeclarationopenloop_end:;
1215 [[fallthrough]];
1216 }
1217 case MARKUP_DECLARATION_HYPHEN: {
1218 for (;;) {
1219 if (++pos == endPos) {
1220 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1221 }
1222 c = P::checkChar(this, buf, pos);
1223 switch (c) {
1224 case '-': {
1225 clearStrBufAfterOneHyphen();
1226 state = P::transition(mViewSource.get(),
1227 nsHtml5Tokenizer::COMMENT_START,
1228 reconsume, pos);
1229 NS_HTML5_BREAK(markupdeclarationhyphenloop)goto markupdeclarationhyphenloop_end;
1230 }
1231 default: {
1232 if (P::reportErrors) {
1233 errBogusComment();
1234 }
1235 reconsume = true;
1236 state = P::transition(mViewSource.get(),
1237 nsHtml5Tokenizer::BOGUS_COMMENT,
1238 reconsume, pos);
1239 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1240 }
1241 }
1242 }
1243 markupdeclarationhyphenloop_end:;
1244 [[fallthrough]];
1245 }
1246 case COMMENT_START: {
1247 reportedConsecutiveHyphens = false;
1248 for (;;) {
1249 if (++pos == endPos) {
1250 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1251 }
1252 c = P::checkChar(this, buf, pos);
1253 switch (c) {
1254 case '-': {
1255 appendStrBuf(c);
1256 state = P::transition(mViewSource.get(),
1257 nsHtml5Tokenizer::COMMENT_START_DASH,
1258 reconsume, pos);
1259 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1260 }
1261 case '>': {
1262 if (P::reportErrors) {
1263 errPrematureEndOfComment();
1264 }
1265 emitComment(0, pos);
1266 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
1267 reconsume, pos);
1268 if (shouldSuspend) {
1269 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1270 }
1271 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1272 }
1273 case '<': {
1274 appendStrBuf(c);
1275 state = P::transition(mViewSource.get(),
1276 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1277 reconsume, pos);
1278 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1279 }
1280 case '\r': {
1281 appendStrBufCarriageReturn<P>();
1282 state =
1283 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1284 reconsume, pos);
1285 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1286 }
1287 case '\n': {
1288 appendStrBufLineFeed<P>();
1289 state =
1290 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1291 reconsume, pos);
1292 NS_HTML5_BREAK(commentstartloop)goto commentstartloop_end;
1293 }
1294 case '\0': {
1295 c = 0xfffd;
1296 [[fallthrough]];
1297 }
1298 default: {
1299 appendStrBuf(c);
1300 state =
1301 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1302 reconsume, pos);
1303 NS_HTML5_BREAK(commentstartloop)goto commentstartloop_end;
1304 }
1305 }
1306 }
1307 commentstartloop_end:;
1308 [[fallthrough]];
1309 }
1310 case COMMENT: {
1311 for (;;) {
1312 ++pos;
1313 pos += P::accelerateAdvancementComment(this, buf, pos, endPos);
1314 if (pos == endPos) {
1315 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1316 }
1317 c = P::checkChar(this, buf, pos);
1318 switch (c) {
1319 case '-': {
1320 appendStrBuf(c);
1321 state = P::transition(mViewSource.get(),
1322 nsHtml5Tokenizer::COMMENT_END_DASH,
1323 reconsume, pos);
1324 NS_HTML5_BREAK(commentloop)goto commentloop_end;
1325 }
1326 case '<': {
1327 appendStrBuf(c);
1328 state = P::transition(mViewSource.get(),
1329 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1330 reconsume, pos);
1331 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1332 }
1333 case '\r': {
1334 appendStrBufCarriageReturn<P>();
1335 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1336 }
1337 case '\n': {
1338 appendStrBufLineFeed<P>();
1339 continue;
1340 }
1341 case '\0': {
1342 c = 0xfffd;
1343 [[fallthrough]];
1344 }
1345 default: {
1346 appendStrBuf(c);
1347 continue;
1348 }
1349 }
1350 }
1351 commentloop_end:;
1352 [[fallthrough]];
1353 }
1354 case COMMENT_END_DASH: {
1355 for (;;) {
1356 if (++pos == endPos) {
1357 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1358 }
1359 c = P::checkChar(this, buf, pos);
1360 switch (c) {
1361 case '-': {
1362 appendStrBuf(c);
1363 state = P::transition(mViewSource.get(),
1364 nsHtml5Tokenizer::COMMENT_END, reconsume,
1365 pos);
1366 NS_HTML5_BREAK(commentenddashloop)goto commentenddashloop_end;
1367 }
1368 case '<': {
1369 appendStrBuf(c);
1370 state = P::transition(mViewSource.get(),
1371 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1372 reconsume, pos);
1373 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1374 }
1375 case '\r': {
1376 appendStrBufCarriageReturn<P>();
1377 state =
1378 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1379 reconsume, pos);
1380 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1381 }
1382 case '\n': {
1383 appendStrBufLineFeed<P>();
1384 state =
1385 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1386 reconsume, pos);
1387 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1388 }
1389 case '\0': {
1390 c = 0xfffd;
1391 [[fallthrough]];
1392 }
1393 default: {
1394 appendStrBuf(c);
1395 state =
1396 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1397 reconsume, pos);
1398 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1399 }
1400 }
1401 }
1402 commentenddashloop_end:;
1403 [[fallthrough]];
1404 }
1405 case COMMENT_END: {
1406 for (;;) {
1407 if (++pos == endPos) {
1408 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1409 }
1410 c = P::checkChar(this, buf, pos);
1411 switch (c) {
1412 case '>': {
1413 emitComment(2, pos);
1414 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
1415 reconsume, pos);
1416 if (shouldSuspend) {
1417 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1418 }
1419 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1420 }
1421 case '-': {
1422 adjustDoubleHyphenAndAppendToStrBufAndErr(
1423 c, reportedConsecutiveHyphens);
1424 reportedConsecutiveHyphens = true;
1425 continue;
1426 }
1427 case '<': {
1428 appendStrBuf(c);
1429 state = P::transition(mViewSource.get(),
1430 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1431 reconsume, pos);
1432 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1433 }
1434 case '\r': {
1435 adjustDoubleHyphenAndAppendToStrBufCarriageReturn<P>();
1436 state =
1437 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1438 reconsume, pos);
1439 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1440 }
1441 case '\n': {
1442 adjustDoubleHyphenAndAppendToStrBufLineFeed<P>();
1443 state =
1444 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1445 reconsume, pos);
1446 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1447 }
1448 case '!': {
1449 appendStrBuf(c);
1450 state = P::transition(mViewSource.get(),
1451 nsHtml5Tokenizer::COMMENT_END_BANG,
1452 reconsume, pos);
1453 NS_HTML5_BREAK(commentendloop)goto commentendloop_end;
1454 }
1455 case '\0': {
1456 c = 0xfffd;
1457 [[fallthrough]];
1458 }
1459 default: {
1460 adjustDoubleHyphenAndAppendToStrBufAndErr(
1461 c, reportedConsecutiveHyphens);
1462 reportedConsecutiveHyphens = true;
1463 state =
1464 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1465 reconsume, pos);
1466 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1467 }
1468 }
1469 }
1470 commentendloop_end:;
1471 [[fallthrough]];
1472 }
1473 case COMMENT_END_BANG: {
1474 for (;;) {
1475 if (++pos == endPos) {
1476 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1477 }
1478 c = P::checkChar(this, buf, pos);
1479 switch (c) {
1480 case '>': {
1481 emitComment(3, pos);
1482 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
1483 reconsume, pos);
1484 if (shouldSuspend) {
1485 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1486 }
1487 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1488 }
1489 case '-': {
1490 appendStrBuf(c);
1491 state = P::transition(mViewSource.get(),
1492 nsHtml5Tokenizer::COMMENT_END_DASH,
1493 reconsume, pos);
1494 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1495 }
1496 case '\r': {
1497 appendStrBufCarriageReturn<P>();
1498 state =
1499 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1500 reconsume, pos);
1501 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1502 }
1503 case '\n': {
1504 appendStrBufLineFeed<P>();
1505 state =
1506 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1507 reconsume, pos);
1508 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1509 }
1510 case '\0': {
1511 c = 0xfffd;
1512 [[fallthrough]];
1513 }
1514 default: {
1515 appendStrBuf(c);
1516 state =
1517 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1518 reconsume, pos);
1519 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1520 }
1521 }
1522 }
1523 }
1524 case COMMENT_LESSTHAN: {
1525 for (;;) {
1526 if (++pos == endPos) {
1527 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1528 }
1529 c = P::checkChar(this, buf, pos);
1530 switch (c) {
1531 case '!': {
1532 appendStrBuf(c);
1533 state = P::transition(mViewSource.get(),
1534 nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG,
1535 reconsume, pos);
1536 NS_HTML5_BREAK(commentlessthanloop)goto commentlessthanloop_end;
1537 }
1538 case '<': {
1539 appendStrBuf(c);
1540 continue;
1541 }
1542 case '-': {
1543 appendStrBuf(c);
1544 state = P::transition(mViewSource.get(),
1545 nsHtml5Tokenizer::COMMENT_END_DASH,
1546 reconsume, pos);
1547 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1548 }
1549 case '\r': {
1550 appendStrBufCarriageReturn<P>();
1551 state =
1552 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1553 reconsume, pos);
1554 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1555 }
1556 case '\n': {
1557 appendStrBufLineFeed<P>();
1558 state =
1559 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1560 reconsume, pos);
1561 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1562 }
1563 case '\0': {
1564 c = 0xfffd;
1565 [[fallthrough]];
1566 }
1567 default: {
1568 appendStrBuf(c);
1569 state =
1570 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1571 reconsume, pos);
1572 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1573 }
1574 }
1575 }
1576 commentlessthanloop_end:;
1577 [[fallthrough]];
1578 }
1579 case COMMENT_LESSTHAN_BANG: {
1580 for (;;) {
1581 if (++pos == endPos) {
1582 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1583 }
1584 c = P::checkChar(this, buf, pos);
1585 switch (c) {
1586 case '-': {
1587 appendStrBuf(c);
1588 state =
1589 P::transition(mViewSource.get(),
1590 nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG_DASH,
1591 reconsume, pos);
1592 NS_HTML5_BREAK(commentlessthanbangloop)goto commentlessthanbangloop_end;
1593 }
1594 case '<': {
1595 appendStrBuf(c);
1596 state = P::transition(mViewSource.get(),
1597 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1598 reconsume, pos);
1599 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1600 }
1601 case '\r': {
1602 appendStrBufCarriageReturn<P>();
1603 state =
1604 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1605 reconsume, pos);
1606 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1607 }
1608 case '\n': {
1609 appendStrBufLineFeed<P>();
1610 state =
1611 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1612 reconsume, pos);
1613 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1614 }
1615 case '\0': {
1616 c = 0xfffd;
1617 [[fallthrough]];
1618 }
1619 default: {
1620 appendStrBuf(c);
1621 state =
1622 P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
1623 reconsume, pos);
1624 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1625 }
1626 }
1627 }
1628 commentlessthanbangloop_end:;
1629 [[fallthrough]];
1630 }
1631 case COMMENT_LESSTHAN_BANG_DASH: {
1632 if (++pos == endPos) {
1633 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1634 }
1635 c = P::checkChar(this, buf, pos);
1636 switch (c) {
1637 case '-': {
1638 appendStrBuf(c);
1639 state = P::transition(
1640 mViewSource.get(),
1641 nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG_DASH_DASH, reconsume,
1642 pos);
1643 break;
1644 }
1645 case '<': {
1646 appendStrBuf(c);
1647 state = P::transition(mViewSource.get(),
1648 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1649 reconsume, pos);
1650 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1651 }
1652 case '\r': {
1653 appendStrBufCarriageReturn<P>();
1654 state = P::transition(mViewSource.get(),
1655 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1656 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1657 }
1658 case '\n': {
1659 appendStrBufLineFeed<P>();
1660 state = P::transition(mViewSource.get(),
1661 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1662 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1663 }
1664 case '\0': {
1665 c = 0xfffd;
1666 [[fallthrough]];
1667 }
1668 default: {
1669 appendStrBuf(c);
1670 state = P::transition(mViewSource.get(),
1671 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1672 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1673 }
1674 }
1675 [[fallthrough]];
1676 }
1677 case COMMENT_LESSTHAN_BANG_DASH_DASH: {
1678 if (++pos == endPos) {
1679 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1680 }
1681 c = P::checkChar(this, buf, pos);
1682 switch (c) {
1683 case '>': {
1684 appendStrBuf(c);
1685 emitComment(3, pos);
1686 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
1687 reconsume, pos);
1688 if (shouldSuspend) {
1689 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1690 }
1691 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1692 }
1693 case '-': {
1694 if (P::reportErrors) {
1695 errNestedComment();
1696 }
1697 adjustDoubleHyphenAndAppendToStrBufAndErr(
1698 c, reportedConsecutiveHyphens);
1699 reportedConsecutiveHyphens = true;
1700 state =
1701 P::transition(mViewSource.get(),
1702 nsHtml5Tokenizer::COMMENT_END, reconsume, pos);
1703 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1704 }
1705 case '\r': {
1706 c = '\n';
1707 P::silentCarriageReturn(this);
1708 if (P::reportErrors) {
1709 errNestedComment();
1710 }
1711 adjustDoubleHyphenAndAppendToStrBufAndErr(
1712 c, reportedConsecutiveHyphens);
1713 reportedConsecutiveHyphens = true;
1714 state = P::transition(mViewSource.get(),
1715 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1716 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1717 }
1718 case '\n': {
1719 P::silentLineFeed(this);
1720 if (P::reportErrors) {
1721 errNestedComment();
1722 }
1723 adjustDoubleHyphenAndAppendToStrBufAndErr(
1724 c, reportedConsecutiveHyphens);
1725 reportedConsecutiveHyphens = true;
1726 state = P::transition(mViewSource.get(),
1727 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1728 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1729 }
1730 case '!': {
1731 if (P::reportErrors) {
1732 errNestedComment();
1733 }
1734 adjustDoubleHyphenAndAppendToStrBufAndErr(
1735 c, reportedConsecutiveHyphens);
1736 reportedConsecutiveHyphens = true;
1737 state = P::transition(mViewSource.get(),
1738 nsHtml5Tokenizer::COMMENT_END_BANG,
1739 reconsume, pos);
1740 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1741 }
1742 case '\0': {
1743 c = 0xfffd;
1744 [[fallthrough]];
1745 }
1746 default: {
1747 if (P::reportErrors) {
1748 errNestedComment();
1749 }
1750 adjustDoubleHyphenAndAppendToStrBufAndErr(
1751 c, reportedConsecutiveHyphens);
1752 reportedConsecutiveHyphens = true;
1753 state = P::transition(mViewSource.get(),
1754 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1755 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1756 }
1757 }
1758 }
1759 case COMMENT_START_DASH: {
1760 if (++pos == endPos) {
1761 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1762 }
1763 c = P::checkChar(this, buf, pos);
1764 switch (c) {
1765 case '-': {
1766 appendStrBuf(c);
1767 state =
1768 P::transition(mViewSource.get(),
1769 nsHtml5Tokenizer::COMMENT_END, reconsume, pos);
1770 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1771 }
1772 case '>': {
1773 if (P::reportErrors) {
1774 errPrematureEndOfComment();
1775 }
1776 emitComment(1, pos);
1777 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
1778 reconsume, pos);
1779 if (shouldSuspend) {
1780 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1781 }
1782 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1783 }
1784 case '<': {
1785 appendStrBuf(c);
1786 state = P::transition(mViewSource.get(),
1787 nsHtml5Tokenizer::COMMENT_LESSTHAN,
1788 reconsume, pos);
1789 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1790 }
1791 case '\r': {
1792 appendStrBufCarriageReturn<P>();
1793 state = P::transition(mViewSource.get(),
1794 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1795 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1796 }
1797 case '\n': {
1798 appendStrBufLineFeed<P>();
1799 state = P::transition(mViewSource.get(),
1800 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1801 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1802 }
1803 case '\0': {
1804 c = 0xfffd;
1805 [[fallthrough]];
1806 }
1807 default: {
1808 appendStrBuf(c);
1809 state = P::transition(mViewSource.get(),
1810 nsHtml5Tokenizer::COMMENT, reconsume, pos);
1811 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1812 }
1813 }
1814 }
1815 case CDATA_START: {
1816 for (;;) {
1817 if (++pos == endPos) {
1818 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1819 }
1820 c = P::checkChar(this, buf, pos);
1821 if (index < 6) {
1822 if (c == nsHtml5Tokenizer::CDATA_LSQB[index]) {
1823 appendStrBuf(c);
1824 } else {
1825 if (P::reportErrors) {
1826 errBogusComment();
1827 }
1828 reconsume = true;
1829 state = P::transition(mViewSource.get(),
1830 nsHtml5Tokenizer::BOGUS_COMMENT,
1831 reconsume, pos);
1832 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1833 }
1834 index++;
1835 continue;
1836 } else {
1837 clearStrBufAfterUse();
1838 cstart = pos;
1839 reconsume = true;
1840 state = P::transition(mViewSource.get(),
1841 nsHtml5Tokenizer::CDATA_SECTION, reconsume,
1842 pos);
1843 break;
1844 }
1845 }
1846 [[fallthrough]];
1847 }
1848 case CDATA_SECTION: {
1849 for (;;) {
1850 if (reconsume) {
1851 reconsume = false;
1852 } else {
1853 ++pos;
1854 pos +=
1855 P::accelerateAdvancementCdataSection(this, buf, pos, endPos);
1856 if (pos == endPos) {
1857 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1858 }
1859 c = P::checkChar(this, buf, pos);
1860 }
1861 switch (c) {
1862 case ']': {
1863 flushChars(buf, pos);
1864 state =
1865 P::transition(mViewSource.get(),
1866 nsHtml5Tokenizer::CDATA_RSQB, reconsume, pos);
1867 NS_HTML5_BREAK(cdatasectionloop)goto cdatasectionloop_end;
1868 }
1869 case '\0': {
1870 maybeEmitReplacementCharacter(buf, pos);
1871 continue;
1872 }
1873 case '\r': {
1874 emitCarriageReturn<P>(buf, pos);
1875 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1876 }
1877 case '\n': {
1878 P::silentLineFeed(this);
1879 [[fallthrough]];
1880 }
1881 default: {
1882 continue;
1883 }
1884 }
1885 }
1886 cdatasectionloop_end:;
1887 [[fallthrough]];
1888 }
1889 case CDATA_RSQB: {
1890 if (++pos == endPos) {
1891 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1892 }
1893 c = P::checkChar(this, buf, pos);
1894 switch (c) {
1895 case ']': {
1896 state = P::transition(mViewSource.get(),
1897 nsHtml5Tokenizer::CDATA_RSQB_RSQB,
1898 reconsume, pos);
1899 break;
1900 }
1901 default: {
1902 tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
1903 cstart = pos;
1904 reconsume = true;
1905 state = P::transition(mViewSource.get(),
1906 nsHtml5Tokenizer::CDATA_SECTION, reconsume,
1907 pos);
1908 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1909 }
1910 }
1911 [[fallthrough]];
1912 }
1913 case CDATA_RSQB_RSQB: {
1914 for (;;) {
1915 if (++pos == endPos) {
1916 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1917 }
1918 c = P::checkChar(this, buf, pos);
1919 switch (c) {
1920 case ']': {
1921 tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
1922 continue;
1923 }
1924 case '>': {
1925 cstart = pos + 1;
1926 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
1927 reconsume, pos);
1928 suspendIfRequestedAfterCurrentNonTextToken();
1929 if (shouldSuspend) {
1930 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1931 }
1932 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1933 }
1934 default: {
1935 tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2);
1936 cstart = pos;
1937 reconsume = true;
1938 state = P::transition(mViewSource.get(),
1939 nsHtml5Tokenizer::CDATA_SECTION,
1940 reconsume, pos);
1941 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1942 }
1943 }
1944 }
1945 }
1946 case ATTRIBUTE_VALUE_SINGLE_QUOTED: {
1947 for (;;) {
1948 if (reconsume) {
1949 reconsume = false;
1950 } else {
1951 ++pos;
1952 pos += P::accelerateAdvancementAttributeValueSingleQuoted(
1953 this, buf, pos, endPos);
1954 if (pos == endPos) {
1955 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1956 }
1957 c = P::checkChar(this, buf, pos);
1958 }
1959 switch (c) {
1960 case '\'': {
1961 addAttributeWithValue();
1962 state = P::transition(
1963 mViewSource.get(),
1964 nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume,
1965 pos);
1966 NS_HTML5_CONTINUE(stateloop)goto stateloop;
1967 }
1968 case '&': {
1969 MOZ_ASSERT(!charRefBufLen,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 1970); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 1970); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
1970 "charRefBufLen not reset after previous use!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 1970); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 1970); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
1971 appendCharRefBuf(c);
1972 setAdditionalAndRememberAmpersandLocation('\'');
1973 returnState = state;
1974 state =
1975 P::transition(mViewSource.get(),
1976 nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
1977 reconsume, pos);
1978 NS_HTML5_BREAK(attributevaluesinglequotedloop)goto attributevaluesinglequotedloop_end;
1979 }
1980 case '\r': {
1981 appendStrBufCarriageReturn<P>();
1982 NS_HTML5_BREAK(stateloop)goto stateloop_end;
1983 }
1984 case '\n': {
1985 appendStrBufLineFeed<P>();
1986 continue;
1987 }
1988 case '\0': {
1989 c = 0xfffd;
1990 [[fallthrough]];
1991 }
1992 default: {
1993 appendStrBuf(c);
1994 continue;
1995 }
1996 }
1997 }
1998 attributevaluesinglequotedloop_end:;
1999 [[fallthrough]];
2000 }
2001 case CONSUME_CHARACTER_REFERENCE: {
2002 if (++pos == endPos) {
2003 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2004 }
2005 c = P::checkChar(this, buf, pos);
2006 switch (c) {
2007 case ' ':
2008 case '\t':
2009 case '\n':
2010 case '\r':
2011 case '\f':
2012 case '<':
2013 case '&':
2014 case '\0':
2015 case ';': {
2016 emitOrAppendCharRefBuf(returnState);
2017 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2018 cstart = pos;
2019 }
2020 reconsume = true;
2021 state =
2022 P::transition(mViewSource.get(), returnState, reconsume, pos);
2023 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2024 }
2025 case '#': {
2026 appendCharRefBuf('#');
2027 state =
2028 P::transition(mViewSource.get(),
2029 nsHtml5Tokenizer::CONSUME_NCR, reconsume, pos);
2030 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2031 }
2032 default: {
2033 if (c == additional) {
2034 emitOrAppendCharRefBuf(returnState);
2035 reconsume = true;
2036 state = P::transition(mViewSource.get(), returnState, reconsume,
2037 pos);
2038 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2039 }
2040 if (c >= 'a' && c <= 'z') {
2041 firstCharKey = c - 'a' + 26;
2042 } else if (c >= 'A' && c <= 'Z') {
2043 firstCharKey = c - 'A';
2044 } else {
2045 if (c == ';') {
2046 if (P::reportErrors) {
2047 errNoNamedCharacterMatch();
2048 }
2049 }
2050 emitOrAppendCharRefBuf(returnState);
2051 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2052 cstart = pos;
2053 }
2054 reconsume = true;
2055 state = P::transition(mViewSource.get(), returnState, reconsume,
2056 pos);
2057 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2058 }
2059 appendCharRefBuf(c);
2060 state = P::transition(
2061 mViewSource.get(),
2062 nsHtml5Tokenizer::CHARACTER_REFERENCE_HILO_LOOKUP, reconsume,
2063 pos);
2064 break;
2065 }
2066 }
2067 [[fallthrough]];
2068 }
2069 case CHARACTER_REFERENCE_HILO_LOOKUP: {
2070 {
2071 if (++pos == endPos) {
2072 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2073 }
2074 c = P::checkChar(this, buf, pos);
2075 int32_t hilo = 0;
2076 if (c <= 'z') {
2077 const int32_t* row = nsHtml5NamedCharactersAccel::HILO_ACCEL[c];
2078 if (row) {
2079 hilo = row[firstCharKey];
2080 }
2081 }
2082 if (!hilo) {
2083 if (c == ';') {
2084 if (P::reportErrors) {
2085 errNoNamedCharacterMatch();
2086 }
2087 }
2088 emitOrAppendCharRefBuf(returnState);
2089 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2090 cstart = pos;
2091 }
2092 reconsume = true;
2093 state =
2094 P::transition(mViewSource.get(), returnState, reconsume, pos);
2095 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2096 }
2097 appendCharRefBuf(c);
2098 lo = hilo & 0xFFFF;
2099 hi = hilo >> 16;
2100 entCol = -1;
2101 candidate = -1;
2102 charRefBufMark = 0;
2103 state = P::transition(mViewSource.get(),
2104 nsHtml5Tokenizer::CHARACTER_REFERENCE_TAIL,
2105 reconsume, pos);
2106 }
2107 [[fallthrough]];
2108 }
2109 case CHARACTER_REFERENCE_TAIL: {
2110 for (;;) {
2111 if (++pos == endPos) {
2112 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2113 }
2114 c = P::checkChar(this, buf, pos);
2115 entCol++;
2116 for (;;) {
2117 if (hi < lo) {
2118 NS_HTML5_BREAK(outer)goto outer_end;
2119 }
2120 if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) {
2121 candidate = lo;
2122 charRefBufMark = charRefBufLen;
2123 lo++;
2124 } else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) {
2125 NS_HTML5_BREAK(outer)goto outer_end;
2126 } else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) {
2127 lo++;
2128 } else {
2129 NS_HTML5_BREAK(loloop)goto loloop_end;
2130 }
2131 }
2132 loloop_end:;
2133 for (;;) {
2134 if (hi < lo) {
2135 NS_HTML5_BREAK(outer)goto outer_end;
2136 }
2137 if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) {
2138 NS_HTML5_BREAK(hiloop)goto hiloop_end;
2139 }
2140 if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) {
2141 NS_HTML5_BREAK(outer)goto outer_end;
2142 } else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) {
2143 hi--;
2144 } else {
2145 NS_HTML5_BREAK(hiloop)goto hiloop_end;
2146 }
2147 }
2148 hiloop_end:;
2149 if (c == ';') {
2150 if (entCol + 1 == nsHtml5NamedCharacters::NAMES[lo].length()) {
2151 candidate = lo;
2152 charRefBufMark = charRefBufLen;
2153 }
2154 NS_HTML5_BREAK(outer)goto outer_end;
2155 }
2156 if (hi < lo) {
2157 NS_HTML5_BREAK(outer)goto outer_end;
2158 }
2159 appendCharRefBuf(c);
2160 continue;
2161 }
2162 outer_end:;
2163 if (candidate == -1) {
2164 if (c == ';') {
2165 if (P::reportErrors) {
2166 errNoNamedCharacterMatch();
2167 }
2168 }
2169 emitOrAppendCharRefBuf(returnState);
2170 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2171 cstart = pos;
2172 }
2173 reconsume = true;
2174 state =
2175 P::transition(mViewSource.get(), returnState, reconsume, pos);
2176 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2177 } else {
2178 const nsHtml5CharacterName& candidateName =
2179 nsHtml5NamedCharacters::NAMES[candidate];
2180 if (!candidateName.length() ||
2181 candidateName.charAt(candidateName.length() - 1) != ';') {
2182 if ((returnState & DATA_AND_RCDATA_MASK)) {
2183 char16_t ch;
2184 if (charRefBufMark == charRefBufLen) {
2185 ch = c;
2186 } else {
2187 ch = charRefBuf[charRefBufMark];
2188 }
2189 if (ch == '=' || (ch >= '0' && ch <= '9') ||
2190 (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
2191 if (c == ';') {
2192 if (P::reportErrors) {
2193 errNoNamedCharacterMatch();
2194 }
2195 }
2196 appendCharRefBufToStrBuf();
2197 reconsume = true;
2198 state = P::transition(mViewSource.get(), returnState,
2199 reconsume, pos);
2200 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2201 }
2202 }
2203 if ((returnState & DATA_AND_RCDATA_MASK)) {
2204 if (P::reportErrors) {
2205 errUnescapedAmpersandInterpretedAsCharacterReference();
2206 }
2207 } else {
2208 if (P::reportErrors) {
2209 errNotSemicolonTerminated();
2210 }
2211 }
2212 }
2213 P::completedNamedCharacterReference(mViewSource.get());
2214 const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate];
2215 if (!val[1]) {
2216 emitOrAppendOne(val, returnState);
2217 } else {
2218 emitOrAppendTwo(val, returnState);
2219 }
2220 if (charRefBufMark < charRefBufLen) {
2221 if ((returnState & DATA_AND_RCDATA_MASK)) {
2222 appendStrBuf(charRefBuf, charRefBufMark,
2223 charRefBufLen - charRefBufMark);
2224 } else {
2225 tokenHandler->characters(charRefBuf, charRefBufMark,
2226 charRefBufLen - charRefBufMark);
2227 }
2228 }
2229 bool earlyBreak = (c == ';' && charRefBufMark == charRefBufLen);
2230 charRefBufLen = 0;
2231 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2232 cstart = earlyBreak ? pos + 1 : pos;
2233 }
2234 reconsume = !earlyBreak;
2235 state =
2236 P::transition(mViewSource.get(), returnState, reconsume, pos);
2237 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2238 }
2239 }
2240 case CONSUME_NCR: {
2241 if (++pos == endPos) {
2242 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2243 }
2244 c = P::checkChar(this, buf, pos);
2245 value = 0;
2246 seenDigits = false;
2247 switch (c) {
2248 case 'x':
2249 case 'X': {
2250 appendCharRefBuf(c);
2251 state =
2252 P::transition(mViewSource.get(),
2253 nsHtml5Tokenizer::HEX_NCR_LOOP, reconsume, pos);
2254 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2255 }
2256 default: {
2257 reconsume = true;
2258 state = P::transition(mViewSource.get(),
2259 nsHtml5Tokenizer::DECIMAL_NRC_LOOP,
2260 reconsume, pos);
2261 break;
2262 }
2263 }
2264 [[fallthrough]];
2265 }
2266 case DECIMAL_NRC_LOOP: {
2267 for (;;) {
2268 if (reconsume) {
2269 reconsume = false;
2270 } else {
2271 if (++pos == endPos) {
2272 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2273 }
2274 c = P::checkChar(this, buf, pos);
2275 }
2276 MOZ_ASSERT(value >= 0, "value must not become negative.")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(value >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(value >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("value >= 0" " ("
"value must not become negative." ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 2276); AnnotateMozCrashReason("MOZ_ASSERT" "(" "value >= 0"
") (" "value must not become negative." ")"); do { MOZ_CrashSequence
(__null, 2276); __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2277 if (c >= '0' && c <= '9') {
2278 seenDigits = true;
2279 if (value <= 0x10FFFF) {
2280 value *= 10;
2281 value += c - '0';
2282 }
2283 continue;
2284 } else if (c == ';') {
2285 if (seenDigits) {
2286 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2287 cstart = pos + 1;
2288 }
2289 state = P::transition(mViewSource.get(),
2290 nsHtml5Tokenizer::HANDLE_NCR_VALUE,
2291 reconsume, pos);
2292 NS_HTML5_BREAK(decimalloop)goto decimalloop_end;
2293 } else {
2294 if (P::reportErrors) {
2295 errNoDigitsInNCR();
2296 }
2297 appendCharRefBuf(';');
2298 emitOrAppendCharRefBuf(returnState);
2299 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2300 cstart = pos + 1;
2301 }
2302 state = P::transition(mViewSource.get(), returnState, reconsume,
2303 pos);
2304 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2305 }
2306 } else {
2307 if (!seenDigits) {
2308 if (P::reportErrors) {
2309 errNoDigitsInNCR();
2310 }
2311 emitOrAppendCharRefBuf(returnState);
2312 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2313 cstart = pos;
2314 }
2315 reconsume = true;
2316 state = P::transition(mViewSource.get(), returnState, reconsume,
2317 pos);
2318 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2319 } else {
2320 if (P::reportErrors) {
2321 errCharRefLacksSemicolon();
2322 }
2323 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2324 cstart = pos;
2325 }
2326 reconsume = true;
2327 state = P::transition(mViewSource.get(),
2328 nsHtml5Tokenizer::HANDLE_NCR_VALUE,
2329 reconsume, pos);
2330 NS_HTML5_BREAK(decimalloop)goto decimalloop_end;
2331 }
2332 }
2333 }
2334 decimalloop_end:;
2335 [[fallthrough]];
2336 }
2337 case HANDLE_NCR_VALUE: {
2338 charRefBufLen = 0;
2339 handleNcrValue(returnState);
2340 state = P::transition(mViewSource.get(), returnState, reconsume, pos);
2341 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2342 }
2343 case HEX_NCR_LOOP: {
2344 for (;;) {
2345 if (++pos == endPos) {
2346 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2347 }
2348 c = P::checkChar(this, buf, pos);
2349 MOZ_ASSERT(value >= 0, "value must not become negative.")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(value >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(value >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("value >= 0" " ("
"value must not become negative." ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 2349); AnnotateMozCrashReason("MOZ_ASSERT" "(" "value >= 0"
") (" "value must not become negative." ")"); do { MOZ_CrashSequence
(__null, 2349); __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2350 if (c >= '0' && c <= '9') {
2351 seenDigits = true;
2352 if (value <= 0x10FFFF) {
2353 value *= 16;
2354 value += c - '0';
2355 }
2356 continue;
2357 } else if (c >= 'A' && c <= 'F') {
2358 seenDigits = true;
2359 if (value <= 0x10FFFF) {
2360 value *= 16;
2361 value += c - 'A' + 10;
2362 }
2363 continue;
2364 } else if (c >= 'a' && c <= 'f') {
2365 seenDigits = true;
2366 if (value <= 0x10FFFF) {
2367 value *= 16;
2368 value += c - 'a' + 10;
2369 }
2370 continue;
2371 } else if (c == ';') {
2372 if (seenDigits) {
2373 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2374 cstart = pos + 1;
2375 }
2376 state = P::transition(mViewSource.get(),
2377 nsHtml5Tokenizer::HANDLE_NCR_VALUE,
2378 reconsume, pos);
2379 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2380 } else {
2381 if (P::reportErrors) {
2382 errNoDigitsInNCR();
2383 }
2384 appendCharRefBuf(';');
2385 emitOrAppendCharRefBuf(returnState);
2386 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2387 cstart = pos + 1;
2388 }
2389 state = P::transition(mViewSource.get(), returnState, reconsume,
2390 pos);
2391 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2392 }
2393 } else {
2394 if (!seenDigits) {
2395 if (P::reportErrors) {
2396 errNoDigitsInNCR();
2397 }
2398 emitOrAppendCharRefBuf(returnState);
2399 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2400 cstart = pos;
2401 }
2402 reconsume = true;
2403 state = P::transition(mViewSource.get(), returnState, reconsume,
2404 pos);
2405 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2406 } else {
2407 if (P::reportErrors) {
2408 errCharRefLacksSemicolon();
2409 }
2410 if (!(returnState & DATA_AND_RCDATA_MASK)) {
2411 cstart = pos;
2412 }
2413 reconsume = true;
2414 state = P::transition(mViewSource.get(),
2415 nsHtml5Tokenizer::HANDLE_NCR_VALUE,
2416 reconsume, pos);
2417 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2418 }
2419 }
2420 }
2421 }
2422 case PLAINTEXT: {
2423 for (;;) {
2424 if (reconsume) {
2425 reconsume = false;
2426 } else {
2427 ++pos;
2428 pos += P::accelerateAdvancementPlaintext(this, buf, pos, endPos);
2429 if (pos == endPos) {
2430 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2431 }
2432 c = P::checkChar(this, buf, pos);
2433 }
2434 switch (c) {
2435 case '\0': {
2436 emitPlaintextReplacementCharacter(buf, pos);
2437 continue;
2438 }
2439 case '\r': {
2440 emitCarriageReturn<P>(buf, pos);
2441 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2442 }
2443 case '\n': {
2444 P::silentLineFeed(this);
2445 [[fallthrough]];
2446 }
2447 default: {
2448 continue;
2449 }
2450 }
2451 }
2452 }
2453 case CLOSE_TAG_OPEN: {
2454 if (++pos == endPos) {
2455 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2456 }
2457 c = P::checkChar(this, buf, pos);
2458 switch (c) {
2459 case '>': {
2460 if (P::reportErrors) {
2461 errLtSlashGt();
2462 }
2463 cstart = pos + 1;
2464 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
2465 reconsume, pos);
2466 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2467 }
2468 case '\r': {
2469 P::silentCarriageReturn(this);
2470 if (P::reportErrors) {
2471 errGarbageAfterLtSlash();
2472 }
2473 clearStrBufBeforeUse();
2474 appendStrBuf('\n');
2475 state = P::transition(mViewSource.get(),
2476 nsHtml5Tokenizer::BOGUS_COMMENT, reconsume,
2477 pos);
2478 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2479 }
2480 case '\n': {
2481 P::silentLineFeed(this);
2482 if (P::reportErrors) {
2483 errGarbageAfterLtSlash();
2484 }
2485 clearStrBufBeforeUse();
2486 appendStrBuf(c);
2487 state = P::transition(mViewSource.get(),
2488 nsHtml5Tokenizer::BOGUS_COMMENT, reconsume,
2489 pos);
2490 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2491 }
2492 case '\0': {
2493 c = 0xfffd;
2494 [[fallthrough]];
2495 }
2496 default: {
2497 if (c >= 'A' && c <= 'Z') {
2498 c += 0x20;
2499 }
2500 if (c >= 'a' && c <= 'z') {
2501 endTag = true;
2502 clearStrBufBeforeUse();
2503 appendStrBuf(c);
2504 containsHyphen = false;
2505 state =
2506 P::transition(mViewSource.get(), nsHtml5Tokenizer::TAG_NAME,
2507 reconsume, pos);
2508 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2509 } else {
2510 if (P::reportErrors) {
2511 errGarbageAfterLtSlash();
2512 }
2513 clearStrBufBeforeUse();
2514 appendStrBuf(c);
2515 state = P::transition(mViewSource.get(),
2516 nsHtml5Tokenizer::BOGUS_COMMENT,
2517 reconsume, pos);
2518 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2519 }
2520 }
2521 }
2522 }
2523 case RCDATA: {
2524 for (;;) {
2525 if (reconsume) {
2526 reconsume = false;
2527 } else {
2528 ++pos;
2529 pos += P::accelerateAdvancementData(this, buf, pos, endPos);
2530 if (pos == endPos) {
2531 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2532 }
2533 c = P::checkChar(this, buf, pos);
2534 }
2535 switch (c) {
2536 case '&': {
2537 flushChars(buf, pos);
2538 MOZ_ASSERT(!charRefBufLen,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 2539); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 2539); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
2539 "charRefBufLen not reset after previous use!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!charRefBufLen)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!charRefBufLen))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!charRefBufLen"
" (" "charRefBufLen not reset after previous use!" ")", "./../../../parser/html/nsHtml5Tokenizer.h"
, 2539); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!charRefBufLen"
") (" "charRefBufLen not reset after previous use!" ")"); do
{ MOZ_CrashSequence(__null, 2539); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
2540 appendCharRefBuf(c);
2541 setAdditionalAndRememberAmpersandLocation('\0');
2542 returnState = state;
2543 state =
2544 P::transition(mViewSource.get(),
2545 nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
2546 reconsume, pos);
2547 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2548 }
2549 case '<': {
2550 flushChars(buf, pos);
2551 returnState = state;
2552 state = P::transition(
2553 mViewSource.get(),
2554 nsHtml5Tokenizer::RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume,
2555 pos);
2556 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2557 }
2558 case '\0': {
2559 emitReplacementCharacter(buf, pos);
2560 continue;
2561 }
2562 case '\r': {
2563 emitCarriageReturn<P>(buf, pos);
2564 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2565 }
2566 case '\n': {
2567 P::silentLineFeed(this);
2568 [[fallthrough]];
2569 }
2570 default: {
2571 continue;
2572 }
2573 }
2574 }
2575 }
2576 case RAWTEXT: {
2577 for (;;) {
2578 if (reconsume) {
2579 reconsume = false;
2580 } else {
2581 ++pos;
2582 pos += P::accelerateAdvancementRawtext(this, buf, pos, endPos);
2583 if (pos == endPos) {
2584 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2585 }
2586 c = P::checkChar(this, buf, pos);
2587 }
2588 switch (c) {
2589 case '<': {
2590 flushChars(buf, pos);
2591 returnState = state;
2592 state = P::transition(
2593 mViewSource.get(),
2594 nsHtml5Tokenizer::RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume,
2595 pos);
2596 NS_HTML5_BREAK(rawtextloop)goto rawtextloop_end;
2597 }
2598 case '\0': {
2599 emitReplacementCharacter(buf, pos);
2600 continue;
2601 }
2602 case '\r': {
2603 emitCarriageReturn<P>(buf, pos);
2604 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2605 }
2606 case '\n': {
2607 P::silentLineFeed(this);
2608 [[fallthrough]];
2609 }
2610 default: {
2611 continue;
2612 }
2613 }
2614 }
2615 rawtextloop_end:;
2616 [[fallthrough]];
2617 }
2618 case RAWTEXT_RCDATA_LESS_THAN_SIGN: {
2619 for (;;) {
2620 if (++pos == endPos) {
2621 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2622 }
2623 c = P::checkChar(this, buf, pos);
2624 switch (c) {
2625 case '/': {
2626 index = 0;
2627 clearStrBufBeforeUse();
2628 state = P::transition(mViewSource.get(),
2629 nsHtml5Tokenizer::NON_DATA_END_TAG_NAME,
2630 reconsume, pos);
2631 NS_HTML5_BREAK(rawtextrcdatalessthansignloop)goto rawtextrcdatalessthansignloop_end;
2632 }
2633 default: {
2634 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
2635 cstart = pos;
2636 reconsume = true;
2637 state = P::transition(mViewSource.get(), returnState, reconsume,
2638 pos);
2639 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2640 }
2641 }
2642 }
2643 rawtextrcdatalessthansignloop_end:;
2644 [[fallthrough]];
2645 }
2646 case NON_DATA_END_TAG_NAME: {
2647 for (;;) {
2648 if (++pos == endPos) {
2649 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2650 }
2651 c = P::checkChar(this, buf, pos);
2652 if (!endTagExpectationAsArray) {
2653 tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
2654 cstart = pos;
2655 reconsume = true;
2656 state =
2657 P::transition(mViewSource.get(), returnState, reconsume, pos);
2658 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2659 } else if (index < endTagExpectationAsArray.length) {
2660 char16_t e = endTagExpectationAsArray[index];
2661 char16_t folded = c;
2662 if (c >= 'A' && c <= 'Z') {
2663 folded += 0x20;
2664 }
2665 if (folded != e) {
2666 tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
2667 emitStrBuf();
2668 cstart = pos;
2669 reconsume = true;
2670 state = P::transition(mViewSource.get(), returnState, reconsume,
2671 pos);
2672 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2673 }
2674 appendStrBuf(c);
2675 index++;
2676 continue;
2677 } else {
2678 endTag = true;
2679 tagName = endTagExpectation;
2680 switch (c) {
2681 case '\r': {
2682 P::silentCarriageReturn(this);
2683 clearStrBufAfterUse();
2684 state = P::transition(mViewSource.get(),
2685 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
2686 reconsume, pos);
2687 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2688 }
2689 case '\n': {
2690 P::silentLineFeed(this);
2691 [[fallthrough]];
2692 }
2693 case ' ':
2694 case '\t':
2695 case '\f': {
2696 clearStrBufAfterUse();
2697 state = P::transition(mViewSource.get(),
2698 nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
2699 reconsume, pos);
2700 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2701 }
2702 case '/': {
2703 clearStrBufAfterUse();
2704 state = P::transition(
2705 mViewSource.get(),
2706 nsHtml5Tokenizer::SELF_CLOSING_START_TAG, reconsume, pos);
2707 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2708 }
2709 case '>': {
2710 clearStrBufAfterUse();
2711 state = P::transition(mViewSource.get(),
2712 emitCurrentTagToken(false, pos),
2713 reconsume, pos);
2714 if (shouldSuspend) {
2715 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2716 }
2717 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2718 }
2719 default: {
2720 tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
2721 emitStrBuf();
2722 cstart = pos;
2723 reconsume = true;
2724 state = P::transition(mViewSource.get(), returnState,
2725 reconsume, pos);
2726 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2727 }
2728 }
2729 }
2730 }
2731 }
2732 case BOGUS_COMMENT: {
2733 for (;;) {
2734 if (reconsume) {
2735 reconsume = false;
2736 } else {
2737 if (++pos == endPos) {
2738 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2739 }
2740 c = P::checkChar(this, buf, pos);
2741 }
2742 switch (c) {
2743 case '>': {
2744 emitComment(0, pos);
2745 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
2746 reconsume, pos);
2747 if (shouldSuspend) {
2748 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2749 }
2750 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2751 }
2752 case '-': {
2753 appendStrBuf(c);
2754 state = P::transition(mViewSource.get(),
2755 nsHtml5Tokenizer::BOGUS_COMMENT_HYPHEN,
2756 reconsume, pos);
2757 NS_HTML5_BREAK(boguscommentloop)goto boguscommentloop_end;
2758 }
2759 case '\r': {
2760 appendStrBufCarriageReturn<P>();
2761 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2762 }
2763 case '\n': {
2764 appendStrBufLineFeed<P>();
2765 continue;
2766 }
2767 case '\0': {
2768 c = 0xfffd;
2769 [[fallthrough]];
2770 }
2771 default: {
2772 appendStrBuf(c);
2773 continue;
2774 }
2775 }
2776 }
2777 boguscommentloop_end:;
2778 [[fallthrough]];
2779 }
2780 case BOGUS_COMMENT_HYPHEN: {
2781 boguscommenthyphenloop:
2782 for (;;) {
2783 if (++pos == endPos) {
2784 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2785 }
2786 c = P::checkChar(this, buf, pos);
2787 switch (c) {
2788 case '>': {
2789 emitComment(0, pos);
2790 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
2791 reconsume, pos);
2792 if (shouldSuspend) {
2793 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2794 }
2795 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2796 }
2797 case '-': {
2798 appendSecondHyphenToBogusComment();
2799 NS_HTML5_CONTINUE(boguscommenthyphenloop)goto boguscommenthyphenloop;
2800 }
2801 case '\r': {
2802 appendStrBufCarriageReturn<P>();
2803 state = P::transition(mViewSource.get(),
2804 nsHtml5Tokenizer::BOGUS_COMMENT,
2805 reconsume, pos);
2806 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2807 }
2808 case '\n': {
2809 appendStrBufLineFeed<P>();
2810 state = P::transition(mViewSource.get(),
2811 nsHtml5Tokenizer::BOGUS_COMMENT,
2812 reconsume, pos);
2813 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2814 }
2815 case '\0': {
2816 c = 0xfffd;
2817 [[fallthrough]];
2818 }
2819 default: {
2820 appendStrBuf(c);
2821 state = P::transition(mViewSource.get(),
2822 nsHtml5Tokenizer::BOGUS_COMMENT,
2823 reconsume, pos);
2824 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2825 }
2826 }
2827 }
2828 }
2829 case SCRIPT_DATA: {
2830 for (;;) {
2831 if (reconsume) {
2832 reconsume = false;
2833 } else {
2834 ++pos;
2835 pos += P::accelerateAdvancementRawtext(this, buf, pos, endPos);
2836 if (pos == endPos) {
2837 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2838 }
2839 c = P::checkChar(this, buf, pos);
2840 }
2841 switch (c) {
2842 case '<': {
2843 flushChars(buf, pos);
2844 returnState = state;
2845 state =
2846 P::transition(mViewSource.get(),
2847 nsHtml5Tokenizer::SCRIPT_DATA_LESS_THAN_SIGN,
2848 reconsume, pos);
2849 NS_HTML5_BREAK(scriptdataloop)goto scriptdataloop_end;
2850 }
2851 case '\0': {
2852 emitReplacementCharacter(buf, pos);
2853 continue;
2854 }
2855 case '\r': {
2856 emitCarriageReturn<P>(buf, pos);
2857 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2858 }
2859 case '\n': {
2860 P::silentLineFeed(this);
2861 [[fallthrough]];
2862 }
2863 default: {
2864 continue;
2865 }
2866 }
2867 }
2868 scriptdataloop_end:;
2869 [[fallthrough]];
2870 }
2871 case SCRIPT_DATA_LESS_THAN_SIGN: {
2872 for (;;) {
2873 if (++pos == endPos) {
2874 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2875 }
2876 c = P::checkChar(this, buf, pos);
2877 switch (c) {
2878 case '/': {
2879 index = 0;
2880 clearStrBufBeforeUse();
2881 state = P::transition(mViewSource.get(),
2882 nsHtml5Tokenizer::NON_DATA_END_TAG_NAME,
2883 reconsume, pos);
2884 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2885 }
2886 case '!': {
2887 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
2888 cstart = pos;
2889 state = P::transition(
2890 mViewSource.get(),
2891 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPE_START, reconsume, pos);
2892 NS_HTML5_BREAK(scriptdatalessthansignloop)goto scriptdatalessthansignloop_end;
2893 }
2894 default: {
2895 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
2896 cstart = pos;
2897 reconsume = true;
2898 state = P::transition(mViewSource.get(),
2899 nsHtml5Tokenizer::SCRIPT_DATA, reconsume,
2900 pos);
2901 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2902 }
2903 }
2904 }
2905 scriptdatalessthansignloop_end:;
2906 [[fallthrough]];
2907 }
2908 case SCRIPT_DATA_ESCAPE_START: {
2909 for (;;) {
2910 if (++pos == endPos) {
2911 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2912 }
2913 c = P::checkChar(this, buf, pos);
2914 switch (c) {
2915 case '-': {
2916 state = P::transition(
2917 mViewSource.get(),
2918 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPE_START_DASH, reconsume,
2919 pos);
2920 NS_HTML5_BREAK(scriptdataescapestartloop)goto scriptdataescapestartloop_end;
2921 }
2922 default: {
2923 reconsume = true;
2924 state = P::transition(mViewSource.get(),
2925 nsHtml5Tokenizer::SCRIPT_DATA, reconsume,
2926 pos);
2927 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2928 }
2929 }
2930 }
2931 scriptdataescapestartloop_end:;
2932 [[fallthrough]];
2933 }
2934 case SCRIPT_DATA_ESCAPE_START_DASH: {
2935 for (;;) {
2936 if (++pos == endPos) {
2937 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2938 }
2939 c = P::checkChar(this, buf, pos);
2940 switch (c) {
2941 case '-': {
2942 state = P::transition(
2943 mViewSource.get(),
2944 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume,
2945 pos);
2946 NS_HTML5_BREAK(scriptdataescapestartdashloop)goto scriptdataescapestartdashloop_end;
2947 }
2948 default: {
2949 reconsume = true;
2950 state = P::transition(mViewSource.get(),
2951 nsHtml5Tokenizer::SCRIPT_DATA, reconsume,
2952 pos);
2953 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2954 }
2955 }
2956 }
2957 scriptdataescapestartdashloop_end:;
2958 [[fallthrough]];
2959 }
2960 case SCRIPT_DATA_ESCAPED_DASH_DASH: {
2961 for (;;) {
2962 if (++pos == endPos) {
2963 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2964 }
2965 c = P::checkChar(this, buf, pos);
2966 switch (c) {
2967 case '-': {
2968 continue;
2969 }
2970 case '<': {
2971 flushChars(buf, pos);
2972 state = P::transition(
2973 mViewSource.get(),
2974 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
2975 reconsume, pos);
2976 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2977 }
2978 case '>': {
2979 state = P::transition(mViewSource.get(),
2980 nsHtml5Tokenizer::SCRIPT_DATA, reconsume,
2981 pos);
2982 NS_HTML5_CONTINUE(stateloop)goto stateloop;
2983 }
2984 case '\0': {
2985 emitReplacementCharacter(buf, pos);
2986 state = P::transition(mViewSource.get(),
2987 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
2988 reconsume, pos);
2989 NS_HTML5_BREAK(scriptdataescapeddashdashloop)goto scriptdataescapeddashdashloop_end;
2990 }
2991 case '\r': {
2992 emitCarriageReturn<P>(buf, pos);
2993 state = P::transition(mViewSource.get(),
2994 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
2995 reconsume, pos);
2996 NS_HTML5_BREAK(stateloop)goto stateloop_end;
2997 }
2998 case '\n': {
2999 P::silentLineFeed(this);
3000 [[fallthrough]];
3001 }
3002 default: {
3003 state = P::transition(mViewSource.get(),
3004 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3005 reconsume, pos);
3006 NS_HTML5_BREAK(scriptdataescapeddashdashloop)goto scriptdataescapeddashdashloop_end;
3007 }
3008 }
3009 }
3010 scriptdataescapeddashdashloop_end:;
3011 [[fallthrough]];
3012 }
3013 case SCRIPT_DATA_ESCAPED: {
3014 for (;;) {
3015 if (reconsume) {
3016 reconsume = false;
3017 } else {
3018 ++pos;
3019 pos += P::accelerateAdvancementScriptDataEscaped(this, buf, pos,
3020 endPos);
3021 if (pos == endPos) {
3022 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3023 }
3024 c = P::checkChar(this, buf, pos);
3025 }
3026 switch (c) {
3027 case '-': {
3028 state = P::transition(
3029 mViewSource.get(),
3030 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH, reconsume, pos);
3031 NS_HTML5_BREAK(scriptdataescapedloop)goto scriptdataescapedloop_end;
3032 }
3033 case '<': {
3034 flushChars(buf, pos);
3035 state = P::transition(
3036 mViewSource.get(),
3037 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
3038 reconsume, pos);
3039 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3040 }
3041 case '\0': {
3042 emitReplacementCharacter(buf, pos);
3043 continue;
3044 }
3045 case '\r': {
3046 emitCarriageReturn<P>(buf, pos);
3047 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3048 }
3049 case '\n': {
3050 P::silentLineFeed(this);
3051 [[fallthrough]];
3052 }
3053 default: {
3054 continue;
3055 }
3056 }
3057 }
3058 scriptdataescapedloop_end:;
3059 [[fallthrough]];
3060 }
3061 case SCRIPT_DATA_ESCAPED_DASH: {
3062 for (;;) {
3063 if (++pos == endPos) {
3064 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3065 }
3066 c = P::checkChar(this, buf, pos);
3067 switch (c) {
3068 case '-': {
3069 state = P::transition(
3070 mViewSource.get(),
3071 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume,
3072 pos);
3073 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3074 }
3075 case '<': {
3076 flushChars(buf, pos);
3077 state = P::transition(
3078 mViewSource.get(),
3079 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
3080 reconsume, pos);
3081 NS_HTML5_BREAK(scriptdataescapeddashloop)goto scriptdataescapeddashloop_end;
3082 }
3083 case '\0': {
3084 emitReplacementCharacter(buf, pos);
3085 state = P::transition(mViewSource.get(),
3086 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3087 reconsume, pos);
3088 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3089 }
3090 case '\r': {
3091 emitCarriageReturn<P>(buf, pos);
3092 state = P::transition(mViewSource.get(),
3093 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3094 reconsume, pos);
3095 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3096 }
3097 case '\n': {
3098 P::silentLineFeed(this);
3099 [[fallthrough]];
3100 }
3101 default: {
3102 state = P::transition(mViewSource.get(),
3103 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3104 reconsume, pos);
3105 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3106 }
3107 }
3108 }
3109 scriptdataescapeddashloop_end:;
3110 [[fallthrough]];
3111 }
3112 case SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
3113 for (;;) {
3114 if (++pos == endPos) {
3115 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3116 }
3117 c = P::checkChar(this, buf, pos);
3118 switch (c) {
3119 case '/': {
3120 index = 0;
3121 clearStrBufBeforeUse();
3122 returnState = nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED;
3123 state = P::transition(mViewSource.get(),
3124 nsHtml5Tokenizer::NON_DATA_END_TAG_NAME,
3125 reconsume, pos);
3126 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3127 }
3128 case 'S':
3129 case 's': {
3130 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
3131 cstart = pos;
3132 index = 1;
3133 state = P::transition(
3134 mViewSource.get(),
3135 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPE_START,
3136 reconsume, pos);
3137 NS_HTML5_BREAK(scriptdataescapedlessthanloop)goto scriptdataescapedlessthanloop_end;
3138 }
3139 default: {
3140 tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
3141 cstart = pos;
3142 reconsume = true;
3143 state = P::transition(mViewSource.get(),
3144 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3145 reconsume, pos);
3146 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3147 }
3148 }
3149 }
3150 scriptdataescapedlessthanloop_end:;
3151 [[fallthrough]];
3152 }
3153 case SCRIPT_DATA_DOUBLE_ESCAPE_START: {
3154 for (;;) {
3155 if (++pos == endPos) {
3156 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3157 }
3158 c = P::checkChar(this, buf, pos);
3159 MOZ_ASSERT(index > 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index > 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index > 0", "./../../../parser/html/nsHtml5Tokenizer.h"
, 3159); AnnotateMozCrashReason("MOZ_ASSERT" "(" "index > 0"
")"); do { MOZ_CrashSequence(__null, 3159); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3160 if (index < 6) {
3161 char16_t folded = c;
3162 if (c >= 'A' && c <= 'Z') {
3163 folded += 0x20;
3164 }
3165 if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) {
3166 reconsume = true;
3167 state = P::transition(mViewSource.get(),
3168 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3169 reconsume, pos);
3170 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3171 }
3172 index++;
3173 continue;
3174 }
3175 switch (c) {
3176 case '\r': {
3177 emitCarriageReturn<P>(buf, pos);
3178 state =
3179 P::transition(mViewSource.get(),
3180 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3181 reconsume, pos);
3182 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3183 }
3184 case '\n': {
3185 P::silentLineFeed(this);
3186 [[fallthrough]];
3187 }
3188 case ' ':
3189 case '\t':
3190 case '\f':
3191 case '/':
3192 case '>': {
3193 state =
3194 P::transition(mViewSource.get(),
3195 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3196 reconsume, pos);
3197 NS_HTML5_BREAK(scriptdatadoubleescapestartloop)goto scriptdatadoubleescapestartloop_end;
3198 }
3199 default: {
3200 reconsume = true;
3201 state = P::transition(mViewSource.get(),
3202 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3203 reconsume, pos);
3204 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3205 }
3206 }
3207 }
3208 scriptdatadoubleescapestartloop_end:;
3209 [[fallthrough]];
3210 }
3211 case SCRIPT_DATA_DOUBLE_ESCAPED: {
3212 for (;;) {
3213 if (reconsume) {
3214 reconsume = false;
3215 } else {
3216 if (++pos == endPos) {
3217 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3218 }
3219 c = P::checkChar(this, buf, pos);
3220 }
3221 switch (c) {
3222 case '-': {
3223 state = P::transition(
3224 mViewSource.get(),
3225 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_DASH,
3226 reconsume, pos);
3227 NS_HTML5_BREAK(scriptdatadoubleescapedloop)goto scriptdatadoubleescapedloop_end;
3228 }
3229 case '<': {
3230 state = P::transition(
3231 mViewSource.get(),
3232 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
3233 reconsume, pos);
3234 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3235 }
3236 case '\0': {
3237 emitReplacementCharacter(buf, pos);
3238 continue;
3239 }
3240 case '\r': {
3241 emitCarriageReturn<P>(buf, pos);
3242 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3243 }
3244 case '\n': {
3245 P::silentLineFeed(this);
3246 [[fallthrough]];
3247 }
3248 default: {
3249 continue;
3250 }
3251 }
3252 }
3253 scriptdatadoubleescapedloop_end:;
3254 [[fallthrough]];
3255 }
3256 case SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
3257 for (;;) {
3258 if (++pos == endPos) {
3259 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3260 }
3261 c = P::checkChar(this, buf, pos);
3262 switch (c) {
3263 case '-': {
3264 state = P::transition(
3265 mViewSource.get(),
3266 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,
3267 reconsume, pos);
3268 NS_HTML5_BREAK(scriptdatadoubleescapeddashloop)goto scriptdatadoubleescapeddashloop_end;
3269 }
3270 case '<': {
3271 state = P::transition(
3272 mViewSource.get(),
3273 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
3274 reconsume, pos);
3275 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3276 }
3277 case '\0': {
3278 emitReplacementCharacter(buf, pos);
3279 state =
3280 P::transition(mViewSource.get(),
3281 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3282 reconsume, pos);
3283 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3284 }
3285 case '\r': {
3286 emitCarriageReturn<P>(buf, pos);
3287 state =
3288 P::transition(mViewSource.get(),
3289 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3290 reconsume, pos);
3291 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3292 }
3293 case '\n': {
3294 P::silentLineFeed(this);
3295 [[fallthrough]];
3296 }
3297 default: {
3298 state =
3299 P::transition(mViewSource.get(),
3300 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3301 reconsume, pos);
3302 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3303 }
3304 }
3305 }
3306 scriptdatadoubleescapeddashloop_end:;
3307 [[fallthrough]];
3308 }
3309 case SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
3310 for (;;) {
3311 if (++pos == endPos) {
3312 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3313 }
3314 c = P::checkChar(this, buf, pos);
3315 switch (c) {
3316 case '-': {
3317 continue;
3318 }
3319 case '<': {
3320 state = P::transition(
3321 mViewSource.get(),
3322 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
3323 reconsume, pos);
3324 NS_HTML5_BREAK(scriptdatadoubleescapeddashdashloop)goto scriptdatadoubleescapeddashdashloop_end;
3325 }
3326 case '>': {
3327 state = P::transition(mViewSource.get(),
3328 nsHtml5Tokenizer::SCRIPT_DATA, reconsume,
3329 pos);
3330 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3331 }
3332 case '\0': {
3333 emitReplacementCharacter(buf, pos);
3334 state =
3335 P::transition(mViewSource.get(),
3336 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3337 reconsume, pos);
3338 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3339 }
3340 case '\r': {
3341 emitCarriageReturn<P>(buf, pos);
3342 state =
3343 P::transition(mViewSource.get(),
3344 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3345 reconsume, pos);
3346 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3347 }
3348 case '\n': {
3349 P::silentLineFeed(this);
3350 [[fallthrough]];
3351 }
3352 default: {
3353 state =
3354 P::transition(mViewSource.get(),
3355 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3356 reconsume, pos);
3357 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3358 }
3359 }
3360 }
3361 scriptdatadoubleescapeddashdashloop_end:;
3362 [[fallthrough]];
3363 }
3364 case SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
3365 for (;;) {
3366 if (++pos == endPos) {
3367 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3368 }
3369 c = P::checkChar(this, buf, pos);
3370 switch (c) {
3371 case '/': {
3372 index = 0;
3373 state = P::transition(
3374 mViewSource.get(),
3375 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPE_END, reconsume,
3376 pos);
3377 NS_HTML5_BREAK(scriptdatadoubleescapedlessthanloop)goto scriptdatadoubleescapedlessthanloop_end;
3378 }
3379 default: {
3380 reconsume = true;
3381 state =
3382 P::transition(mViewSource.get(),
3383 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3384 reconsume, pos);
3385 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3386 }
3387 }
3388 }
3389 scriptdatadoubleescapedlessthanloop_end:;
3390 [[fallthrough]];
3391 }
3392 case SCRIPT_DATA_DOUBLE_ESCAPE_END: {
3393 for (;;) {
3394 if (++pos == endPos) {
3395 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3396 }
3397 c = P::checkChar(this, buf, pos);
3398 if (index < 6) {
3399 char16_t folded = c;
3400 if (c >= 'A' && c <= 'Z') {
3401 folded += 0x20;
3402 }
3403 if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) {
3404 reconsume = true;
3405 state =
3406 P::transition(mViewSource.get(),
3407 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3408 reconsume, pos);
3409 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3410 }
3411 index++;
3412 continue;
3413 }
3414 switch (c) {
3415 case '\r': {
3416 emitCarriageReturn<P>(buf, pos);
3417 state = P::transition(mViewSource.get(),
3418 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3419 reconsume, pos);
3420 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3421 }
3422 case '\n': {
3423 P::silentLineFeed(this);
3424 [[fallthrough]];
3425 }
3426 case ' ':
3427 case '\t':
3428 case '\f':
3429 case '/':
3430 case '>': {
3431 state = P::transition(mViewSource.get(),
3432 nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
3433 reconsume, pos);
3434 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3435 }
3436 default: {
3437 reconsume = true;
3438 state =
3439 P::transition(mViewSource.get(),
3440 nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
3441 reconsume, pos);
3442 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3443 }
3444 }
3445 }
3446 }
3447 case MARKUP_DECLARATION_OCTYPE: {
3448 for (;;) {
3449 if (++pos == endPos) {
3450 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3451 }
3452 c = P::checkChar(this, buf, pos);
3453 if (index < 6) {
3454 char16_t folded = c;
3455 if (c >= 'A' && c <= 'Z') {
3456 folded += 0x20;
3457 }
3458 if (folded == nsHtml5Tokenizer::OCTYPE[index]) {
3459 appendStrBuf(c);
3460 } else {
3461 if (P::reportErrors) {
3462 errBogusComment();
3463 }
3464 reconsume = true;
3465 state = P::transition(mViewSource.get(),
3466 nsHtml5Tokenizer::BOGUS_COMMENT,
3467 reconsume, pos);
3468 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3469 }
3470 index++;
3471 continue;
3472 } else {
3473 reconsume = true;
3474 state = P::transition(mViewSource.get(),
3475 nsHtml5Tokenizer::DOCTYPE, reconsume, pos);
3476 NS_HTML5_BREAK(markupdeclarationdoctypeloop)goto markupdeclarationdoctypeloop_end;
3477 }
3478 }
3479 markupdeclarationdoctypeloop_end:;
3480 [[fallthrough]];
3481 }
3482 case DOCTYPE: {
3483 for (;;) {
3484 if (reconsume) {
3485 reconsume = false;
3486 } else {
3487 if (++pos == endPos) {
3488 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3489 }
3490 c = P::checkChar(this, buf, pos);
3491 }
3492 initDoctypeFields();
3493 switch (c) {
3494 case '\r': {
3495 P::silentCarriageReturn(this);
3496 state = P::transition(mViewSource.get(),
3497 nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME,
3498 reconsume, pos);
3499 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3500 }
3501 case '\n': {
3502 P::silentLineFeed(this);
3503 [[fallthrough]];
3504 }
3505 case ' ':
3506 case '\t':
3507 case '\f': {
3508 state = P::transition(mViewSource.get(),
3509 nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME,
3510 reconsume, pos);
3511 NS_HTML5_BREAK(doctypeloop)goto doctypeloop_end;
3512 }
3513 default: {
3514 if (P::reportErrors) {
3515 errMissingSpaceBeforeDoctypeName();
3516 }
3517 reconsume = true;
3518 state = P::transition(mViewSource.get(),
3519 nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME,
3520 reconsume, pos);
3521 NS_HTML5_BREAK(doctypeloop)goto doctypeloop_end;
3522 }
3523 }
3524 }
3525 doctypeloop_end:;
3526 [[fallthrough]];
3527 }
3528 case BEFORE_DOCTYPE_NAME: {
3529 for (;;) {
3530 if (reconsume) {
3531 reconsume = false;
3532 } else {
3533 if (++pos == endPos) {
3534 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3535 }
3536 c = P::checkChar(this, buf, pos);
3537 }
3538 switch (c) {
3539 case '\r': {
3540 P::silentCarriageReturn(this);
3541 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3542 }
3543 case '\n': {
3544 P::silentLineFeed(this);
3545 [[fallthrough]];
3546 }
3547 case ' ':
3548 case '\t':
3549 case '\f': {
3550 continue;
3551 }
3552 case '>': {
3553 if (P::reportErrors) {
3554 errNamelessDoctype();
3555 }
3556 forceQuirks = true;
3557 emitDoctypeToken(pos);
3558 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3559 reconsume, pos);
3560 if (shouldSuspend) {
3561 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3562 }
3563 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3564 }
3565 case '\0': {
3566 c = 0xfffd;
3567 [[fallthrough]];
3568 }
3569 default: {
3570 if (c >= 'A' && c <= 'Z') {
3571 c += 0x20;
3572 }
3573 clearStrBufBeforeUse();
3574 appendStrBuf(c);
3575 state = P::transition(mViewSource.get(),
3576 nsHtml5Tokenizer::DOCTYPE_NAME, reconsume,
3577 pos);
3578 NS_HTML5_BREAK(beforedoctypenameloop)goto beforedoctypenameloop_end;
3579 }
3580 }
3581 }
3582 beforedoctypenameloop_end:;
3583 [[fallthrough]];
3584 }
3585 case DOCTYPE_NAME: {
3586 for (;;) {
3587 if (++pos == endPos) {
3588 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3589 }
3590 c = P::checkChar(this, buf, pos);
3591 switch (c) {
3592 case '\r': {
3593 P::silentCarriageReturn(this);
3594 strBufToDoctypeName();
3595 state = P::transition(mViewSource.get(),
3596 nsHtml5Tokenizer::AFTER_DOCTYPE_NAME,
3597 reconsume, pos);
3598 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3599 }
3600 case '\n': {
3601 P::silentLineFeed(this);
3602 [[fallthrough]];
3603 }
3604 case ' ':
3605 case '\t':
3606 case '\f': {
3607 strBufToDoctypeName();
3608 state = P::transition(mViewSource.get(),
3609 nsHtml5Tokenizer::AFTER_DOCTYPE_NAME,
3610 reconsume, pos);
3611 NS_HTML5_BREAK(doctypenameloop)goto doctypenameloop_end;
3612 }
3613 case '>': {
3614 strBufToDoctypeName();
3615 emitDoctypeToken(pos);
3616 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3617 reconsume, pos);
3618 if (shouldSuspend) {
3619 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3620 }
3621 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3622 }
3623 case '\0': {
3624 c = 0xfffd;
3625 [[fallthrough]];
3626 }
3627 default: {
3628 if (c >= 'A' && c <= 'Z') {
3629 c += 0x0020;
3630 }
3631 appendStrBuf(c);
3632 continue;
3633 }
3634 }
3635 }
3636 doctypenameloop_end:;
3637 [[fallthrough]];
3638 }
3639 case AFTER_DOCTYPE_NAME: {
3640 for (;;) {
3641 if (++pos == endPos) {
3642 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3643 }
3644 c = P::checkChar(this, buf, pos);
3645 switch (c) {
3646 case '\r': {
3647 P::silentCarriageReturn(this);
3648 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3649 }
3650 case '\n': {
3651 P::silentLineFeed(this);
3652 [[fallthrough]];
3653 }
3654 case ' ':
3655 case '\t':
3656 case '\f': {
3657 continue;
3658 }
3659 case '>': {
3660 emitDoctypeToken(pos);
3661 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3662 reconsume, pos);
3663 if (shouldSuspend) {
3664 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3665 }
3666 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3667 }
3668 case 'p':
3669 case 'P': {
3670 index = 0;
3671 state = P::transition(mViewSource.get(),
3672 nsHtml5Tokenizer::DOCTYPE_UBLIC,
3673 reconsume, pos);
3674 NS_HTML5_BREAK(afterdoctypenameloop)goto afterdoctypenameloop_end;
3675 }
3676 case 's':
3677 case 'S': {
3678 index = 0;
3679 state = P::transition(mViewSource.get(),
3680 nsHtml5Tokenizer::DOCTYPE_YSTEM,
3681 reconsume, pos);
3682 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3683 }
3684 default: {
3685 bogusDoctype();
3686 state = P::transition(mViewSource.get(),
3687 nsHtml5Tokenizer::BOGUS_DOCTYPE,
3688 reconsume, pos);
3689 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3690 }
3691 }
3692 }
3693 afterdoctypenameloop_end:;
3694 [[fallthrough]];
3695 }
3696 case DOCTYPE_UBLIC: {
3697 for (;;) {
3698 if (++pos == endPos) {
3699 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3700 }
3701 c = P::checkChar(this, buf, pos);
3702 if (index < 5) {
3703 char16_t folded = c;
3704 if (c >= 'A' && c <= 'Z') {
3705 folded += 0x20;
3706 }
3707 if (folded != nsHtml5Tokenizer::UBLIC[index]) {
3708 bogusDoctype();
3709 reconsume = true;
3710 state = P::transition(mViewSource.get(),
3711 nsHtml5Tokenizer::BOGUS_DOCTYPE,
3712 reconsume, pos);
3713 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3714 }
3715 index++;
3716 continue;
3717 } else {
3718 reconsume = true;
3719 state =
3720 P::transition(mViewSource.get(),
3721 nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_KEYWORD,
3722 reconsume, pos);
3723 NS_HTML5_BREAK(doctypeublicloop)goto doctypeublicloop_end;
3724 }
3725 }
3726 doctypeublicloop_end:;
3727 [[fallthrough]];
3728 }
3729 case AFTER_DOCTYPE_PUBLIC_KEYWORD: {
3730 for (;;) {
3731 if (reconsume) {
3732 reconsume = false;
3733 } else {
3734 if (++pos == endPos) {
3735 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3736 }
3737 c = P::checkChar(this, buf, pos);
3738 }
3739 switch (c) {
3740 case '\r': {
3741 P::silentCarriageReturn(this);
3742 state = P::transition(
3743 mViewSource.get(),
3744 nsHtml5Tokenizer::BEFORE_DOCTYPE_PUBLIC_IDENTIFIER,
3745 reconsume, pos);
3746 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3747 }
3748 case '\n': {
3749 P::silentLineFeed(this);
3750 [[fallthrough]];
3751 }
3752 case ' ':
3753 case '\t':
3754 case '\f': {
3755 state = P::transition(
3756 mViewSource.get(),
3757 nsHtml5Tokenizer::BEFORE_DOCTYPE_PUBLIC_IDENTIFIER,
3758 reconsume, pos);
3759 NS_HTML5_BREAK(afterdoctypepublickeywordloop)goto afterdoctypepublickeywordloop_end;
3760 }
3761 case '\"': {
3762 if (P::reportErrors) {
3763 errNoSpaceBetweenDoctypePublicKeywordAndQuote();
3764 }
3765 clearStrBufBeforeUse();
3766 state = P::transition(
3767 mViewSource.get(),
3768 nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED,
3769 reconsume, pos);
3770 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3771 }
3772 case '\'': {
3773 if (P::reportErrors) {
3774 errNoSpaceBetweenDoctypePublicKeywordAndQuote();
3775 }
3776 clearStrBufBeforeUse();
3777 state = P::transition(
3778 mViewSource.get(),
3779 nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED,
3780 reconsume, pos);
3781 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3782 }
3783 case '>': {
3784 if (P::reportErrors) {
3785 errExpectedPublicId();
3786 }
3787 forceQuirks = true;
3788 emitDoctypeToken(pos);
3789 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3790 reconsume, pos);
3791 if (shouldSuspend) {
3792 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3793 }
3794 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3795 }
3796 default: {
3797 bogusDoctype();
3798 state = P::transition(mViewSource.get(),
3799 nsHtml5Tokenizer::BOGUS_DOCTYPE,
3800 reconsume, pos);
3801 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3802 }
3803 }
3804 }
3805 afterdoctypepublickeywordloop_end:;
3806 [[fallthrough]];
3807 }
3808 case BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
3809 for (;;) {
3810 if (++pos == endPos) {
3811 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3812 }
3813 c = P::checkChar(this, buf, pos);
3814 switch (c) {
3815 case '\r': {
3816 P::silentCarriageReturn(this);
3817 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3818 }
3819 case '\n': {
3820 P::silentLineFeed(this);
3821 [[fallthrough]];
3822 }
3823 case ' ':
3824 case '\t':
3825 case '\f': {
3826 continue;
3827 }
3828 case '\"': {
3829 clearStrBufBeforeUse();
3830 state = P::transition(
3831 mViewSource.get(),
3832 nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED,
3833 reconsume, pos);
3834 NS_HTML5_BREAK(beforedoctypepublicidentifierloop)goto beforedoctypepublicidentifierloop_end;
3835 }
3836 case '\'': {
3837 clearStrBufBeforeUse();
3838 state = P::transition(
3839 mViewSource.get(),
3840 nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED,
3841 reconsume, pos);
3842 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3843 }
3844 case '>': {
3845 if (P::reportErrors) {
3846 errExpectedPublicId();
3847 }
3848 forceQuirks = true;
3849 emitDoctypeToken(pos);
3850 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3851 reconsume, pos);
3852 if (shouldSuspend) {
3853 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3854 }
3855 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3856 }
3857 default: {
3858 bogusDoctype();
3859 state = P::transition(mViewSource.get(),
3860 nsHtml5Tokenizer::BOGUS_DOCTYPE,
3861 reconsume, pos);
3862 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3863 }
3864 }
3865 }
3866 beforedoctypepublicidentifierloop_end:;
3867 [[fallthrough]];
3868 }
3869 case DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
3870 for (;;) {
3871 if (++pos == endPos) {
3872 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3873 }
3874 c = P::checkChar(this, buf, pos);
3875 switch (c) {
3876 case '\"': {
3877 publicIdentifier = strBufToString();
3878 state = P::transition(
3879 mViewSource.get(),
3880 nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_IDENTIFIER,
3881 reconsume, pos);
3882 NS_HTML5_BREAK(doctypepublicidentifierdoublequotedloop)goto doctypepublicidentifierdoublequotedloop_end;
3883 }
3884 case '>': {
3885 if (P::reportErrors) {
3886 errGtInPublicId();
3887 }
3888 forceQuirks = true;
3889 publicIdentifier = strBufToString();
3890 emitDoctypeToken(pos);
3891 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3892 reconsume, pos);
3893 if (shouldSuspend) {
3894 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3895 }
3896 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3897 }
3898 case '\r': {
3899 appendStrBufCarriageReturn<P>();
3900 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3901 }
3902 case '\n': {
3903 appendStrBufLineFeed<P>();
3904 continue;
3905 }
3906 case '\0': {
3907 c = 0xfffd;
3908 [[fallthrough]];
3909 }
3910 default: {
3911 appendStrBuf(c);
3912 continue;
3913 }
3914 }
3915 }
3916 doctypepublicidentifierdoublequotedloop_end:;
3917 [[fallthrough]];
3918 }
3919 case AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
3920 for (;;) {
3921 if (++pos == endPos) {
3922 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3923 }
3924 c = P::checkChar(this, buf, pos);
3925 switch (c) {
3926 case '\r': {
3927 P::silentCarriageReturn(this);
3928 state = P::transition(
3929 mViewSource.get(),
3930 nsHtml5Tokenizer::
3931 BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS,
3932 reconsume, pos);
3933 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3934 }
3935 case '\n': {
3936 P::silentLineFeed(this);
3937 [[fallthrough]];
3938 }
3939 case ' ':
3940 case '\t':
3941 case '\f': {
3942 state = P::transition(
3943 mViewSource.get(),
3944 nsHtml5Tokenizer::
3945 BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS,
3946 reconsume, pos);
3947 NS_HTML5_BREAK(afterdoctypepublicidentifierloop)goto afterdoctypepublicidentifierloop_end;
3948 }
3949 case '>': {
3950 emitDoctypeToken(pos);
3951 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
3952 reconsume, pos);
3953 if (shouldSuspend) {
3954 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3955 }
3956 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3957 }
3958 case '\"': {
3959 if (P::reportErrors) {
3960 errNoSpaceBetweenPublicAndSystemIds();
3961 }
3962 clearStrBufBeforeUse();
3963 state = P::transition(
3964 mViewSource.get(),
3965 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
3966 reconsume, pos);
3967 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3968 }
3969 case '\'': {
3970 if (P::reportErrors) {
3971 errNoSpaceBetweenPublicAndSystemIds();
3972 }
3973 clearStrBufBeforeUse();
3974 state = P::transition(
3975 mViewSource.get(),
3976 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
3977 reconsume, pos);
3978 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3979 }
3980 default: {
3981 bogusDoctype();
3982 state = P::transition(mViewSource.get(),
3983 nsHtml5Tokenizer::BOGUS_DOCTYPE,
3984 reconsume, pos);
3985 NS_HTML5_CONTINUE(stateloop)goto stateloop;
3986 }
3987 }
3988 }
3989 afterdoctypepublicidentifierloop_end:;
3990 [[fallthrough]];
3991 }
3992 case BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
3993 for (;;) {
3994 if (++pos == endPos) {
3995 NS_HTML5_BREAK(stateloop)goto stateloop_end;
3996 }
3997 c = P::checkChar(this, buf, pos);
3998 switch (c) {
3999 case '\r': {
4000 P::silentCarriageReturn(this);
4001 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4002 }
4003 case '\n': {
4004 P::silentLineFeed(this);
4005 [[fallthrough]];
4006 }
4007 case ' ':
4008 case '\t':
4009 case '\f': {
4010 continue;
4011 }
4012 case '>': {
4013 emitDoctypeToken(pos);
4014 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4015 reconsume, pos);
4016 if (shouldSuspend) {
4017 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4018 }
4019 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4020 }
4021 case '\"': {
4022 clearStrBufBeforeUse();
4023 state = P::transition(
4024 mViewSource.get(),
4025 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
4026 reconsume, pos);
4027 NS_HTML5_BREAK(betweendoctypepublicandsystemidentifiersloop)goto betweendoctypepublicandsystemidentifiersloop_end;
4028 }
4029 case '\'': {
4030 clearStrBufBeforeUse();
4031 state = P::transition(
4032 mViewSource.get(),
4033 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
4034 reconsume, pos);
4035 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4036 }
4037 default: {
4038 bogusDoctype();
4039 state = P::transition(mViewSource.get(),
4040 nsHtml5Tokenizer::BOGUS_DOCTYPE,
4041 reconsume, pos);
4042 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4043 }
4044 }
4045 }
4046 betweendoctypepublicandsystemidentifiersloop_end:;
4047 [[fallthrough]];
4048 }
4049 case DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
4050 for (;;) {
4051 if (++pos == endPos) {
4052 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4053 }
4054 c = P::checkChar(this, buf, pos);
4055 switch (c) {
4056 case '\"': {
4057 systemIdentifier = strBufToString();
4058 state = P::transition(
4059 mViewSource.get(),
4060 nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_IDENTIFIER,
4061 reconsume, pos);
4062 NS_HTML5_BREAK(doctypesystemidentifierdoublequotedloop)goto doctypesystemidentifierdoublequotedloop_end;
4063 }
4064 case '>': {
4065 if (P::reportErrors) {
4066 errGtInSystemId();
4067 }
4068 forceQuirks = true;
4069 systemIdentifier = strBufToString();
4070 emitDoctypeToken(pos);
4071 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4072 reconsume, pos);
4073 if (shouldSuspend) {
4074 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4075 }
4076 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4077 }
4078 case '\r': {
4079 appendStrBufCarriageReturn<P>();
4080 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4081 }
4082 case '\n': {
4083 appendStrBufLineFeed<P>();
4084 continue;
4085 }
4086 case '\0': {
4087 c = 0xfffd;
4088 [[fallthrough]];
4089 }
4090 default: {
4091 appendStrBuf(c);
4092 continue;
4093 }
4094 }
4095 }
4096 doctypesystemidentifierdoublequotedloop_end:;
4097 [[fallthrough]];
4098 }
4099 case AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
4100 for (;;) {
4101 if (++pos == endPos) {
4102 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4103 }
4104 c = P::checkChar(this, buf, pos);
4105 switch (c) {
4106 case '\r': {
4107 P::silentCarriageReturn(this);
4108 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4109 }
4110 case '\n': {
4111 P::silentLineFeed(this);
4112 [[fallthrough]];
4113 }
4114 case ' ':
4115 case '\t':
4116 case '\f': {
4117 continue;
4118 }
4119 case '>': {
4120 emitDoctypeToken(pos);
4121 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4122 reconsume, pos);
4123 if (shouldSuspend) {
4124 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4125 }
4126 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4127 }
4128 default: {
4129 bogusDoctypeWithoutQuirks();
4130 state = P::transition(mViewSource.get(),
4131 nsHtml5Tokenizer::BOGUS_DOCTYPE,
4132 reconsume, pos);
4133 NS_HTML5_BREAK(afterdoctypesystemidentifierloop)goto afterdoctypesystemidentifierloop_end;
4134 }
4135 }
4136 }
4137 afterdoctypesystemidentifierloop_end:;
4138 [[fallthrough]];
4139 }
4140 case BOGUS_DOCTYPE: {
4141 for (;;) {
4142 if (reconsume) {
4143 reconsume = false;
4144 } else {
4145 if (++pos == endPos) {
4146 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4147 }
4148 c = P::checkChar(this, buf, pos);
4149 }
4150 switch (c) {
4151 case '>': {
4152 emitDoctypeToken(pos);
4153 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4154 reconsume, pos);
4155 if (shouldSuspend) {
4156 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4157 }
4158 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4159 }
4160 case '\r': {
4161 P::silentCarriageReturn(this);
4162 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4163 }
4164 case '\n': {
4165 P::silentLineFeed(this);
4166 [[fallthrough]];
4167 }
4168 default: {
4169 continue;
4170 }
4171 }
4172 }
4173 }
4174 case DOCTYPE_YSTEM: {
4175 for (;;) {
4176 if (++pos == endPos) {
4177 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4178 }
4179 c = P::checkChar(this, buf, pos);
4180 if (index < 5) {
4181 char16_t folded = c;
4182 if (c >= 'A' && c <= 'Z') {
4183 folded += 0x20;
4184 }
4185 if (folded != nsHtml5Tokenizer::YSTEM[index]) {
4186 bogusDoctype();
4187 reconsume = true;
4188 state = P::transition(mViewSource.get(),
4189 nsHtml5Tokenizer::BOGUS_DOCTYPE,
4190 reconsume, pos);
4191 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4192 }
4193 index++;
4194 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4195 } else {
4196 reconsume = true;
4197 state =
4198 P::transition(mViewSource.get(),
4199 nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_KEYWORD,
4200 reconsume, pos);
4201 NS_HTML5_BREAK(doctypeystemloop)goto doctypeystemloop_end;
4202 }
4203 }
4204 doctypeystemloop_end:;
4205 [[fallthrough]];
4206 }
4207 case AFTER_DOCTYPE_SYSTEM_KEYWORD: {
4208 for (;;) {
4209 if (reconsume) {
4210 reconsume = false;
4211 } else {
4212 if (++pos == endPos) {
4213 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4214 }
4215 c = P::checkChar(this, buf, pos);
4216 }
4217 switch (c) {
4218 case '\r': {
4219 P::silentCarriageReturn(this);
4220 state = P::transition(
4221 mViewSource.get(),
4222 nsHtml5Tokenizer::BEFORE_DOCTYPE_SYSTEM_IDENTIFIER,
4223 reconsume, pos);
4224 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4225 }
4226 case '\n': {
4227 P::silentLineFeed(this);
4228 [[fallthrough]];
4229 }
4230 case ' ':
4231 case '\t':
4232 case '\f': {
4233 state = P::transition(
4234 mViewSource.get(),
4235 nsHtml5Tokenizer::BEFORE_DOCTYPE_SYSTEM_IDENTIFIER,
4236 reconsume, pos);
4237 NS_HTML5_BREAK(afterdoctypesystemkeywordloop)goto afterdoctypesystemkeywordloop_end;
4238 }
4239 case '\"': {
4240 if (P::reportErrors) {
4241 errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
4242 }
4243 clearStrBufBeforeUse();
4244 state = P::transition(
4245 mViewSource.get(),
4246 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
4247 reconsume, pos);
4248 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4249 }
4250 case '\'': {
4251 if (P::reportErrors) {
4252 errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
4253 }
4254 clearStrBufBeforeUse();
4255 state = P::transition(
4256 mViewSource.get(),
4257 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
4258 reconsume, pos);
4259 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4260 }
4261 case '>': {
4262 if (P::reportErrors) {
4263 errExpectedPublicId();
4264 }
4265 forceQuirks = true;
4266 emitDoctypeToken(pos);
4267 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4268 reconsume, pos);
4269 if (shouldSuspend) {
4270 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4271 }
4272 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4273 }
4274 default: {
4275 bogusDoctype();
4276 state = P::transition(mViewSource.get(),
4277 nsHtml5Tokenizer::BOGUS_DOCTYPE,
4278 reconsume, pos);
4279 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4280 }
4281 }
4282 }
4283 afterdoctypesystemkeywordloop_end:;
4284 [[fallthrough]];
4285 }
4286 case BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
4287 for (;;) {
4288 if (++pos == endPos) {
4289 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4290 }
4291 c = P::checkChar(this, buf, pos);
4292 switch (c) {
4293 case '\r': {
4294 P::silentCarriageReturn(this);
4295 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4296 }
4297 case '\n': {
4298 P::silentLineFeed(this);
4299 [[fallthrough]];
4300 }
4301 case ' ':
4302 case '\t':
4303 case '\f': {
4304 continue;
4305 }
4306 case '\"': {
4307 clearStrBufBeforeUse();
4308 state = P::transition(
4309 mViewSource.get(),
4310 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
4311 reconsume, pos);
4312 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4313 }
4314 case '\'': {
4315 clearStrBufBeforeUse();
4316 state = P::transition(
4317 mViewSource.get(),
4318 nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
4319 reconsume, pos);
4320 NS_HTML5_BREAK(beforedoctypesystemidentifierloop)goto beforedoctypesystemidentifierloop_end;
4321 }
4322 case '>': {
4323 if (P::reportErrors) {
4324 errExpectedSystemId();
4325 }
4326 forceQuirks = true;
4327 emitDoctypeToken(pos);
4328 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4329 reconsume, pos);
4330 if (shouldSuspend) {
4331 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4332 }
4333 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4334 }
4335 default: {
4336 bogusDoctype();
4337 state = P::transition(mViewSource.get(),
4338 nsHtml5Tokenizer::BOGUS_DOCTYPE,
4339 reconsume, pos);
4340 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4341 }
4342 }
4343 }
4344 beforedoctypesystemidentifierloop_end:;
4345 [[fallthrough]];
4346 }
4347 case DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
4348 for (;;) {
4349 if (++pos == endPos) {
4350 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4351 }
4352 c = P::checkChar(this, buf, pos);
4353 switch (c) {
4354 case '\'': {
4355 systemIdentifier = strBufToString();
4356 state = P::transition(
4357 mViewSource.get(),
4358 nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_IDENTIFIER,
4359 reconsume, pos);
4360 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4361 }
4362 case '>': {
4363 if (P::reportErrors) {
4364 errGtInSystemId();
4365 }
4366 forceQuirks = true;
4367 systemIdentifier = strBufToString();
4368 emitDoctypeToken(pos);
4369 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4370 reconsume, pos);
4371 if (shouldSuspend) {
4372 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4373 }
4374 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4375 }
4376 case '\r': {
4377 appendStrBufCarriageReturn<P>();
4378 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4379 }
4380 case '\n': {
4381 appendStrBufLineFeed<P>();
4382 continue;
4383 }
4384 case '\0': {
4385 c = 0xfffd;
4386 [[fallthrough]];
4387 }
4388 default: {
4389 appendStrBuf(c);
4390 continue;
4391 }
4392 }
4393 }
4394 }
4395 case DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
4396 for (;;) {
4397 if (++pos == endPos) {
4398 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4399 }
4400 c = P::checkChar(this, buf, pos);
4401 switch (c) {
4402 case '\'': {
4403 publicIdentifier = strBufToString();
4404 state = P::transition(
4405 mViewSource.get(),
4406 nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_IDENTIFIER,
4407 reconsume, pos);
4408 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4409 }
4410 case '>': {
4411 if (P::reportErrors) {
4412 errGtInPublicId();
4413 }
4414 forceQuirks = true;
4415 publicIdentifier = strBufToString();
4416 emitDoctypeToken(pos);
4417 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4418 reconsume, pos);
4419 if (shouldSuspend) {
4420 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4421 }
4422 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4423 }
4424 case '\r': {
4425 appendStrBufCarriageReturn<P>();
4426 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4427 }
4428 case '\n': {
4429 appendStrBufLineFeed<P>();
4430 continue;
4431 }
4432 case '\0': {
4433 c = 0xfffd;
4434 [[fallthrough]];
4435 }
4436 default: {
4437 appendStrBuf(c);
4438 continue;
4439 }
4440 }
4441 }
4442 }
4443 case PROCESSING_INSTRUCTION: {
4444 for (;;) {
4445 if (++pos == endPos) {
4446 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4447 }
4448 c = P::checkChar(this, buf, pos);
4449 switch (c) {
4450 case '\?': {
4451 state = P::transition(
4452 mViewSource.get(),
4453 nsHtml5Tokenizer::PROCESSING_INSTRUCTION_QUESTION_MARK,
4454 reconsume, pos);
4455 NS_HTML5_BREAK(processinginstructionloop)goto processinginstructionloop_end;
4456 }
4457 default: {
4458 continue;
4459 }
4460 }
4461 }
4462 processinginstructionloop_end:;
4463 [[fallthrough]];
4464 }
4465 case PROCESSING_INSTRUCTION_QUESTION_MARK: {
4466 if (++pos == endPos) {
4467 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4468 }
4469 c = P::checkChar(this, buf, pos);
4470 switch (c) {
4471 case '>': {
4472 state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
4473 reconsume, pos);
4474 suspendIfRequestedAfterCurrentNonTextToken();
4475 if (shouldSuspend) {
4476 NS_HTML5_BREAK(stateloop)goto stateloop_end;
4477 }
4478 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4479 }
4480 default: {
4481 state = P::transition(mViewSource.get(),
4482 nsHtml5Tokenizer::PROCESSING_INSTRUCTION,
4483 reconsume, pos);
4484 NS_HTML5_CONTINUE(stateloop)goto stateloop;
4485 }
4486 }
4487 }
4488 }
4489 }
4490 stateloop_end:;
4491 flushChars(buf, pos);
4492 stateSave = state;
4493 returnStateSave = returnState;
4494 return pos;
4495 }
4496
4497 void initDoctypeFields();
4498 template <class P>
4499 inline void adjustDoubleHyphenAndAppendToStrBufCarriageReturn() {
4500 P::silentCarriageReturn(this);
4501 adjustDoubleHyphenAndAppendToStrBufAndErr('\n', false);
4502 }
4503
4504 template <class P>
4505 inline void adjustDoubleHyphenAndAppendToStrBufLineFeed() {
4506 P::silentLineFeed(this);
4507 adjustDoubleHyphenAndAppendToStrBufAndErr('\n', false);
4508 }
4509
4510 template <class P>
4511 inline void appendStrBufLineFeed() {
4512 P::silentLineFeed(this);
4513 appendStrBuf('\n');
4514 }
4515
4516 template <class P>
4517 inline void appendStrBufCarriageReturn() {
4518 P::silentCarriageReturn(this);
4519 appendStrBuf('\n');
4520 }
4521
4522 template <class P>
4523 inline void emitCarriageReturn(char16_t* buf, int32_t pos) {
4524 P::silentCarriageReturn(this);
4525 flushChars(buf, pos);
4526 tokenHandler->characters(nsHtml5Tokenizer::LF, 0, 1);
4527 cstart = INT32_MAX(2147483647);
4528 }
4529
4530 void emitReplacementCharacter(char16_t* buf, int32_t pos);
4531 void maybeEmitReplacementCharacter(char16_t* buf, int32_t pos);
4532 void emitPlaintextReplacementCharacter(char16_t* buf, int32_t pos);
4533 inline void setAdditionalAndRememberAmpersandLocation(char16_t add) {
4534 additional = add;
4535 }
4536
4537 void bogusDoctype();
4538 void bogusDoctypeWithoutQuirks();
4539 void handleNcrValue(int32_t returnState);
4540
4541 public:
4542 void eof();
4543
4544 private:
4545 void emitDoctypeToken(int32_t pos);
4546 inline void suspendIfRequestedAfterCurrentNonTextToken() {
4547 if (suspendAfterCurrentNonTextToken) {
4548 suspendAfterCurrentNonTextToken = false;
4549 shouldSuspend = true;
4550 }
4551 }
4552
4553 void suspendAfterCurrentTokenIfNotInText();
4554 bool suspensionAfterCurrentNonTextTokenPending();
4555
4556 public:
4557 bool internalEncodingDeclaration(nsHtml5String internalCharset);
4558
4559 private:
4560 inline void emitOrAppendTwo(const char16_t* val, int32_t returnState) {
4561 if ((returnState & DATA_AND_RCDATA_MASK)) {
4562 appendStrBuf(val[0]);
4563 appendStrBuf(val[1]);
4564 } else {
4565 tokenHandler->characters(val, 0, 2);
4566 }
4567 }
4568
4569 inline void emitOrAppendOne(const char16_t* val, int32_t returnState) {
4570 if ((returnState & DATA_AND_RCDATA_MASK)) {
4571 appendStrBuf(val[0]);
4572 } else {
4573 tokenHandler->characters(val, 0, 1);
4574 }
4575 }
4576
4577 public:
4578 void end();
4579 inline void requestSuspension() { shouldSuspend = true; }
4580
4581 inline bool isInDataState() { return (stateSave == DATA); }
4582
4583 void resetToDataState();
4584 void loadState(nsHtml5Tokenizer* other);
4585 void initializeWithoutStarting();
4586 void setEncodingDeclarationHandler(
4587 nsHtml5StreamParser* encodingDeclarationHandler);
4588 ~nsHtml5Tokenizer();
4589 static void initializeStatics();
4590 static void releaseStatics();
4591
4592#include "nsHtml5TokenizerHSupplement.h"
4593};
4594
4595#endif