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