1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 friend struct nsHtml5ViewSourcePolicy
;
6 friend struct nsHtml5LineColPolicy
;
7 friend struct nsHtml5FastestPolicy
;
11 bool nextCharOnNewLine
;
14 inline int32_t getColumnNumber() { return col
; }
16 inline void setColumnNumberAndResetNextLine(int32_t aCol
) {
18 // The restored position only ever points to the position of
19 // script tag's > character, so we can unconditionally use
21 nextCharOnNewLine
= false;
24 inline nsHtml5HtmlAttributes
* GetAttributes() { return attributes
; }
27 * Makes sure the buffers are large enough to be able to tokenize aLength
28 * UTF-16 code units before having to make the buffers larger.
30 * @param aLength the number of UTF-16 code units to be tokenized before the
31 * next call to this method.
32 * @return true if successful; false if out of memory
34 bool EnsureBufferSpace(int32_t aLength
);
36 bool TemplatePushedOrHeadPopped();
38 void RememberGt(int32_t aPos
);
40 void AtKilobyteBoundary() { suspendAfterCurrentTokenIfNotInText(); }
42 bool IsInTokenStartedAtKilobyteBoundary() {
43 return suspensionAfterCurrentNonTextTokenPending();
46 mozilla::UniquePtr
<nsHtml5Highlighter
> mViewSource
;
49 * Starts handling text/plain. This is a one-way initialization. There is
50 * no corresponding EndPlainText() call.
52 void StartPlainText();
54 void EnableViewSource(nsHtml5Highlighter
* aHighlighter
);
56 bool ShouldFlushViewSource();
58 mozilla::Result
<bool, nsresult
> FlushViewSource();
60 void StartViewSource(const nsAutoString
& aTitle
);
62 void StartViewSourceBodyContents();
64 [[nodiscard
]] bool EndViewSource();
66 void RewindViewSource();
68 void SetViewSourceOpSink(nsAHtml5TreeOpSink
* aOpSink
);
70 void errGarbageAfterLtSlash();
74 void errWarnLtSlashInRcdata();
76 void errCharRefLacksSemicolon();
78 void errNoDigitsInNCR();
80 void errGtInSystemId();
82 void errGtInPublicId();
84 void errNamelessDoctype();
86 void errConsecutiveHyphens();
88 void errPrematureEndOfComment();
90 void errBogusComment();
92 void errUnquotedAttributeValOrNull(char16_t c
);
94 void errSlashNotFollowedByGt();
96 void errNoSpaceBetweenAttributes();
98 void errLtOrEqualsOrGraveInUnquotedAttributeOrNull(char16_t c
);
100 void errAttributeValueMissing();
102 void errBadCharBeforeAttributeNameOrNull(char16_t c
);
104 void errEqualsSignBeforeAttributeName();
106 void errBadCharAfterLt(char16_t c
);
110 void errProcessingInstruction();
112 void errUnescapedAmpersandInterpretedAsCharacterReference();
114 void errNotSemicolonTerminated();
116 void errNoNamedCharacterMatch();
118 void errQuoteBeforeAttributeName(char16_t c
);
120 void errQuoteOrLtInAttributeNameOrNull(char16_t c
);
122 void errExpectedPublicId();
124 void errBogusDoctype();
126 void maybeErrAttributesOnEndTag(nsHtml5HtmlAttributes
* attrs
);
128 void maybeErrSlashInEndTag(bool selfClosing
);
130 void errNcrSurrogate();
132 void errNcrInC1Range();
134 void errEofInPublicId();
136 void errEofInComment();
138 void errEofInDoctype();
140 void errEofInAttributeValue();
142 void errEofInAttributeName();
144 void errEofWithoutGt();
146 void errEofInTagName();
148 void errEofInEndTag();
150 void errEofAfterLt();
152 void errNcrOutOfRange();
154 void errNcrUnassigned();
156 void errDuplicateAttribute();
158 void errEofInSystemId();
160 void errExpectedSystemId();
162 void errMissingSpaceBeforeDoctypeName();
164 void errNestedComment();
168 void errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
170 void errNoSpaceBetweenPublicAndSystemIds();
172 void errNoSpaceBetweenDoctypePublicKeywordAndQuote();