2012-05-29 19:52:43 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-30 14:15:38 +04:00
|
|
|
|
2017-12-05 00:09:15 +03:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
|
|
|
|
2016-10-14 11:47:17 +03:00
|
|
|
// INT32_MAX is (2^31)-1. Therefore, the highest power-of-two that fits
|
|
|
|
// is 2^30. Note that this is counting char16_t units. The underlying
|
|
|
|
// bytes will be twice that, but they fit even in 32-bit size_t even
|
|
|
|
// if a contiguous chunk of memory of that size is pretty unlikely to
|
|
|
|
// be available on a 32-bit system.
|
|
|
|
#define MAX_POWER_OF_TWO_IN_INT32 0x40000000
|
|
|
|
|
2015-08-25 18:05:45 +03:00
|
|
|
bool nsHtml5Tokenizer::EnsureBufferSpace(int32_t aLength) {
|
2016-10-14 11:47:17 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aLength >= 0, "Negative length.");
|
|
|
|
if (aLength > MAX_POWER_OF_TWO_IN_INT32) {
|
|
|
|
// Can't happen when loading from network.
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-05 00:09:15 +03:00
|
|
|
mozilla::CheckedInt<int32_t> worstCase(strBufLen);
|
2016-10-14 11:47:17 +03:00
|
|
|
worstCase += aLength;
|
|
|
|
worstCase += charRefBufLen;
|
2015-08-25 18:05:45 +03:00
|
|
|
// Add 2 to account for emissions of LT_GT, LT_SOLIDUS and RSQB_RSQB.
|
|
|
|
// Adding to the general worst case instead of only the
|
|
|
|
// TreeBuilder-exposed worst case to avoid re-introducing a bug when
|
|
|
|
// unifying the tokenizer and tree builder buffers in the future.
|
2016-10-14 11:47:17 +03:00
|
|
|
worstCase += 2;
|
|
|
|
if (!worstCase.isValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (worstCase.value() > MAX_POWER_OF_TWO_IN_INT32) {
|
2015-08-25 18:05:45 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// TODO: Unify nsHtml5Tokenizer::strBuf and nsHtml5TreeBuilder::charBuffer
|
|
|
|
// so that the call below becomes unnecessary.
|
2016-10-14 11:47:17 +03:00
|
|
|
if (!tokenHandler->EnsureBufferSpace(worstCase.value())) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-08-25 18:05:45 +03:00
|
|
|
if (!strBuf) {
|
2016-10-14 11:47:17 +03:00
|
|
|
if (worstCase.value() < MAX_POWER_OF_TWO_IN_INT32) {
|
|
|
|
// Add one to round to the next power of two to avoid immediate
|
|
|
|
// reallocation once there are a few characters in the buffer.
|
|
|
|
worstCase += 1;
|
|
|
|
}
|
2018-03-16 18:26:06 +03:00
|
|
|
strBuf = jArray<char16_t, int32_t>::newFallibleJArray(
|
|
|
|
mozilla::RoundUpPow2(worstCase.value()));
|
2015-08-25 18:05:45 +03:00
|
|
|
if (!strBuf) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-10-14 11:47:17 +03:00
|
|
|
} else if (worstCase.value() > strBuf.length) {
|
2018-03-16 18:26:06 +03:00
|
|
|
jArray<char16_t, int32_t> newBuf =
|
|
|
|
jArray<char16_t, int32_t>::newFallibleJArray(
|
|
|
|
mozilla::RoundUpPow2(worstCase.value()));
|
2015-08-25 18:05:45 +03:00
|
|
|
if (!newBuf) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-10-14 11:47:17 +03:00
|
|
|
memcpy(newBuf, strBuf, sizeof(char16_t) * size_t(strBufLen));
|
2015-08-25 18:05:45 +03:00
|
|
|
strBuf = newBuf;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 1701828 - meta charset rewrite. r=smaug
Implements https://github.com/whatwg/html/issues/6962 . Improves performance
when <meta charset> occurs in head but after the first kilobyte and aligns
behavior better with WebKit and Blink.
The main change is to avoid reloads when meta appears within head but
after the first kilobyte. Prior to this change, Gecko reloaded in that
case (in compliance with the spec!) even though WebKit and Blink did not.
Differences from WebKit and Blink:
* WebKit and Blink honor <meta charset> in <noscript>. This implementation
does not.
* WebKit and Blink look for meta as if the tree builder was unaware of
foreign content. This implementation is foreign content-aware. This
makes a difference for CDATA sections that contain a > before the meta
as well as style and script elements within foreign content. This could
happen if the CDATA section that has mysteriously been introduced around
a what looks like a meta tag also contains another prior tag-looking
run of text.
* This implementation processes rel=preload and speculative loads that are
seen before <meta charset> has been seen. WebKit and Blink instead first
look for the meta and rewind before starting speculative parsing.
* Unlike WebKit, if there is neither an honored meta nor syntax resembling
an XML declaration, detection from content takes place (as in Blink).
* Unlike Blink, if there is neither an honored meta nor syntax resembling
an XML declaration, the detection from content is not dependent of network
buffer boundaries.
* Unlike Blink, detection from content can trigger a reload at the end of
the stream if the guess made at that point differs from the first guess.
(See below for the definition of the input to the first guess.)
Differences from the old spec and Gecko previously:
* Meta inside script and RCDATA elements is no longer honored.
* Late meta is now ignored and no longer triggers a reload.
* Later meta counts as early enough meta: In addition to the previous
meta within the first 1024 bytes, now a meta that started within the first
1024 bytes counts as early enough. Additionally, if by then there hasn't
been a template start tag and head hasn't ended, meta occurring before the
earlier of the end of the head or a template start tag counts as early
enough.
* Meta now counts as not-late even if the encoding label has numeric
character reference escapes.
* Syntax resembling an XML declaration longer than a kilobyte is honored if
there is no honored meta.
* If there is neither an honored meta nor syntax resembling an XML declaration,
the initial chardetng scan is potentially longer than before: the first 1024
bytes, the token spanning the 1024-byte boundary if there is such a token,
and, if by then head hasn't ended and there hasn't been a template start tag
until the end of the template start tag or the end of the token that causes
head to end, ever comes first. However, if the token implying the end of the
head is a text token, bytes only to the end of the previous non-text token is
considered. (This definition avoids depending on network buffer boundaries.)
* XML View Source now uses the code for syntax resembling an XML declaration
instead of expat for extracting the internal encoding label.
Reftest are added as both WPT and Gecko reftests in order to test both http:
and file: URL scenarios. The Gecko tests retain the WPT <link> tags in order
to use the exact same bytes.
An encoding declaration has been added to a number of old tests that didn't
intend to test the new speculation behavior especially in the context of
https://bugzilla.mozilla.org/show_bug.cgi?id=1727750 .
Differential Revision: https://phabricator.services.mozilla.com/D125808
2021-12-08 14:34:20 +03:00
|
|
|
bool nsHtml5Tokenizer::TemplatePushedOrHeadPopped() {
|
|
|
|
if (encodingDeclarationHandler) {
|
|
|
|
return encodingDeclarationHandler->TemplatePushedOrHeadPopped();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::RememberGt(int32_t aPos) {
|
|
|
|
if (encodingDeclarationHandler) {
|
|
|
|
return encodingDeclarationHandler->RememberGt(aPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-01 19:27:36 +04:00
|
|
|
void nsHtml5Tokenizer::StartPlainText() {
|
2017-04-20 10:34:32 +03:00
|
|
|
stateSave = nsHtml5Tokenizer::PLAINTEXT;
|
2011-11-01 19:27:36 +04:00
|
|
|
}
|
|
|
|
|
2010-07-30 14:15:38 +04:00
|
|
|
void nsHtml5Tokenizer::EnableViewSource(nsHtml5Highlighter* aHighlighter) {
|
2020-02-28 23:49:06 +03:00
|
|
|
mViewSource = WrapUnique(aHighlighter);
|
2010-07-30 14:15:38 +04:00
|
|
|
}
|
|
|
|
|
2022-04-19 14:41:03 +03:00
|
|
|
bool nsHtml5Tokenizer::FlushViewSource() { return mViewSource->FlushOps(); }
|
2010-07-30 14:15:38 +04:00
|
|
|
|
2011-11-30 21:44:31 +04:00
|
|
|
void nsHtml5Tokenizer::StartViewSource(const nsAutoString& aTitle) {
|
|
|
|
mViewSource->Start(aTitle);
|
2010-07-30 14:15:38 +04:00
|
|
|
}
|
|
|
|
|
Bug 1701828 - meta charset rewrite. r=smaug
Implements https://github.com/whatwg/html/issues/6962 . Improves performance
when <meta charset> occurs in head but after the first kilobyte and aligns
behavior better with WebKit and Blink.
The main change is to avoid reloads when meta appears within head but
after the first kilobyte. Prior to this change, Gecko reloaded in that
case (in compliance with the spec!) even though WebKit and Blink did not.
Differences from WebKit and Blink:
* WebKit and Blink honor <meta charset> in <noscript>. This implementation
does not.
* WebKit and Blink look for meta as if the tree builder was unaware of
foreign content. This implementation is foreign content-aware. This
makes a difference for CDATA sections that contain a > before the meta
as well as style and script elements within foreign content. This could
happen if the CDATA section that has mysteriously been introduced around
a what looks like a meta tag also contains another prior tag-looking
run of text.
* This implementation processes rel=preload and speculative loads that are
seen before <meta charset> has been seen. WebKit and Blink instead first
look for the meta and rewind before starting speculative parsing.
* Unlike WebKit, if there is neither an honored meta nor syntax resembling
an XML declaration, detection from content takes place (as in Blink).
* Unlike Blink, if there is neither an honored meta nor syntax resembling
an XML declaration, the detection from content is not dependent of network
buffer boundaries.
* Unlike Blink, detection from content can trigger a reload at the end of
the stream if the guess made at that point differs from the first guess.
(See below for the definition of the input to the first guess.)
Differences from the old spec and Gecko previously:
* Meta inside script and RCDATA elements is no longer honored.
* Late meta is now ignored and no longer triggers a reload.
* Later meta counts as early enough meta: In addition to the previous
meta within the first 1024 bytes, now a meta that started within the first
1024 bytes counts as early enough. Additionally, if by then there hasn't
been a template start tag and head hasn't ended, meta occurring before the
earlier of the end of the head or a template start tag counts as early
enough.
* Meta now counts as not-late even if the encoding label has numeric
character reference escapes.
* Syntax resembling an XML declaration longer than a kilobyte is honored if
there is no honored meta.
* If there is neither an honored meta nor syntax resembling an XML declaration,
the initial chardetng scan is potentially longer than before: the first 1024
bytes, the token spanning the 1024-byte boundary if there is such a token,
and, if by then head hasn't ended and there hasn't been a template start tag
until the end of the template start tag or the end of the token that causes
head to end, ever comes first. However, if the token implying the end of the
head is a text token, bytes only to the end of the previous non-text token is
considered. (This definition avoids depending on network buffer boundaries.)
* XML View Source now uses the code for syntax resembling an XML declaration
instead of expat for extracting the internal encoding label.
Reftest are added as both WPT and Gecko reftests in order to test both http:
and file: URL scenarios. The Gecko tests retain the WPT <link> tags in order
to use the exact same bytes.
An encoding declaration has been added to a number of old tests that didn't
intend to test the new speculation behavior especially in the context of
https://bugzilla.mozilla.org/show_bug.cgi?id=1727750 .
Differential Revision: https://phabricator.services.mozilla.com/D125808
2021-12-08 14:34:20 +03:00
|
|
|
void nsHtml5Tokenizer::StartViewSourceCharacters() {
|
|
|
|
mViewSource->StartCharacters();
|
|
|
|
}
|
|
|
|
|
2022-04-19 14:41:03 +03:00
|
|
|
void nsHtml5Tokenizer::EndViewSource() { mViewSource->End(); }
|
2011-11-01 15:33:11 +04:00
|
|
|
|
Bug 1701828 - meta charset rewrite. r=smaug
Implements https://github.com/whatwg/html/issues/6962 . Improves performance
when <meta charset> occurs in head but after the first kilobyte and aligns
behavior better with WebKit and Blink.
The main change is to avoid reloads when meta appears within head but
after the first kilobyte. Prior to this change, Gecko reloaded in that
case (in compliance with the spec!) even though WebKit and Blink did not.
Differences from WebKit and Blink:
* WebKit and Blink honor <meta charset> in <noscript>. This implementation
does not.
* WebKit and Blink look for meta as if the tree builder was unaware of
foreign content. This implementation is foreign content-aware. This
makes a difference for CDATA sections that contain a > before the meta
as well as style and script elements within foreign content. This could
happen if the CDATA section that has mysteriously been introduced around
a what looks like a meta tag also contains another prior tag-looking
run of text.
* This implementation processes rel=preload and speculative loads that are
seen before <meta charset> has been seen. WebKit and Blink instead first
look for the meta and rewind before starting speculative parsing.
* Unlike WebKit, if there is neither an honored meta nor syntax resembling
an XML declaration, detection from content takes place (as in Blink).
* Unlike Blink, if there is neither an honored meta nor syntax resembling
an XML declaration, the detection from content is not dependent of network
buffer boundaries.
* Unlike Blink, detection from content can trigger a reload at the end of
the stream if the guess made at that point differs from the first guess.
(See below for the definition of the input to the first guess.)
Differences from the old spec and Gecko previously:
* Meta inside script and RCDATA elements is no longer honored.
* Late meta is now ignored and no longer triggers a reload.
* Later meta counts as early enough meta: In addition to the previous
meta within the first 1024 bytes, now a meta that started within the first
1024 bytes counts as early enough. Additionally, if by then there hasn't
been a template start tag and head hasn't ended, meta occurring before the
earlier of the end of the head or a template start tag counts as early
enough.
* Meta now counts as not-late even if the encoding label has numeric
character reference escapes.
* Syntax resembling an XML declaration longer than a kilobyte is honored if
there is no honored meta.
* If there is neither an honored meta nor syntax resembling an XML declaration,
the initial chardetng scan is potentially longer than before: the first 1024
bytes, the token spanning the 1024-byte boundary if there is such a token,
and, if by then head hasn't ended and there hasn't been a template start tag
until the end of the template start tag or the end of the token that causes
head to end, ever comes first. However, if the token implying the end of the
head is a text token, bytes only to the end of the previous non-text token is
considered. (This definition avoids depending on network buffer boundaries.)
* XML View Source now uses the code for syntax resembling an XML declaration
instead of expat for extracting the internal encoding label.
Reftest are added as both WPT and Gecko reftests in order to test both http:
and file: URL scenarios. The Gecko tests retain the WPT <link> tags in order
to use the exact same bytes.
An encoding declaration has been added to a number of old tests that didn't
intend to test the new speculation behavior especially in the context of
https://bugzilla.mozilla.org/show_bug.cgi?id=1727750 .
Differential Revision: https://phabricator.services.mozilla.com/D125808
2021-12-08 14:34:20 +03:00
|
|
|
void nsHtml5Tokenizer::SetViewSourceOpSink(nsAHtml5TreeOpSink* aOpSink) {
|
|
|
|
mViewSource->SetOpSink(aOpSink);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::RewindViewSource() { mViewSource->Rewind(); }
|
|
|
|
|
2011-11-01 15:33:11 +04:00
|
|
|
void nsHtml5Tokenizer::errWarnLtSlashInRcdata() {}
|
|
|
|
|
2012-10-26 17:32:10 +04:00
|
|
|
// The null checks below annotated MOZ_LIKELY are not actually necessary.
|
2011-11-01 15:33:11 +04:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void nsHtml5Tokenizer::errUnquotedAttributeValOrNull(char16_t c) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
switch (c) {
|
|
|
|
case '<':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeLt");
|
|
|
|
return;
|
|
|
|
case '`':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeGrave");
|
|
|
|
return;
|
|
|
|
case '\'':
|
|
|
|
case '"':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeQuote");
|
|
|
|
return;
|
|
|
|
case '=':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeEquals");
|
|
|
|
return;
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void nsHtml5Tokenizer::errLtOrEqualsOrGraveInUnquotedAttributeOrNull(
|
|
|
|
char16_t c) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
switch (c) {
|
|
|
|
case '=':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeStartEquals");
|
|
|
|
return;
|
|
|
|
case '<':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeStartLt");
|
|
|
|
return;
|
|
|
|
case '`':
|
|
|
|
mViewSource->AddErrorToCurrentNode("errUnquotedAttributeStartGrave");
|
|
|
|
return;
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void nsHtml5Tokenizer::errBadCharBeforeAttributeNameOrNull(char16_t c) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
if (c == '<') {
|
|
|
|
mViewSource->AddErrorToCurrentNode("errBadCharBeforeAttributeNameLt");
|
|
|
|
} else if (c == '=') {
|
|
|
|
errEqualsSignBeforeAttributeName();
|
|
|
|
} else if (c != 0xFFFD) {
|
|
|
|
errQuoteBeforeAttributeName(c);
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void nsHtml5Tokenizer::errBadCharAfterLt(char16_t c) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errBadCharAfterLt");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void nsHtml5Tokenizer::errQuoteOrLtInAttributeNameOrNull(char16_t c) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
if (c == '<') {
|
|
|
|
mViewSource->AddErrorToCurrentNode("errLtInAttributeName");
|
|
|
|
} else if (c != 0xFFFD) {
|
|
|
|
mViewSource->AddErrorToCurrentNode("errQuoteInAttributeName");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::maybeErrAttributesOnEndTag(
|
|
|
|
nsHtml5HtmlAttributes* attrs) {
|
|
|
|
if (mViewSource && attrs->getLength() != 0) {
|
|
|
|
/*
|
|
|
|
* When an end tag token is emitted with attributes, that is a parse
|
|
|
|
* error.
|
|
|
|
*/
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("maybeErrAttributesOnEndTag");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::maybeErrSlashInEndTag(bool selfClosing) {
|
|
|
|
if (mViewSource && selfClosing && endTag) {
|
|
|
|
mViewSource->AddErrorToCurrentSlash("maybeErrSlashInEndTag");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t nsHtml5Tokenizer::errNcrNonCharacter(char16_t ch) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrNonCharacter");
|
|
|
|
}
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsHtml5Tokenizer::errAstralNonCharacter(int32_t ch) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-04 17:36:29 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrNonCharacter");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t nsHtml5Tokenizer::errNcrControlChar(char16_t ch) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrControlChar");
|
|
|
|
}
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errGarbageAfterLtSlash() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errGarbageAfterLtSlash");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errLtSlashGt() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errLtSlashGt");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errCharRefLacksSemicolon() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errCharRefLacksSemicolon");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNoDigitsInNCR() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNoDigitsInNCR");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errGtInSystemId() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errGtInSystemId");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errGtInPublicId() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errGtInPublicId");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNamelessDoctype() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNamelessDoctype");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errConsecutiveHyphens() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errConsecutiveHyphens");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errPrematureEndOfComment() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errPrematureEndOfComment");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errBogusComment() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errBogusComment");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errSlashNotFollowedByGt() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentSlash("errSlashNotFollowedByGt");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNoSpaceBetweenAttributes() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNoSpaceBetweenAttributes");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errAttributeValueMissing() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errAttributeValueMissing");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEqualsSignBeforeAttributeName() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errEqualsSignBeforeAttributeName");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errLtGt() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errLtGt");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errProcessingInstruction() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errProcessingInstruction");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errUnescapedAmpersandInterpretedAsCharacterReference() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2018-03-16 18:26:06 +03:00
|
|
|
mViewSource->AddErrorToCurrentAmpersand(
|
|
|
|
"errUnescapedAmpersandInterpretedAsCharacterReference");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNotSemicolonTerminated() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNotSemicolonTerminated");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNoNamedCharacterMatch() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentAmpersand("errNoNamedCharacterMatch");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void nsHtml5Tokenizer::errQuoteBeforeAttributeName(char16_t c) {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errQuoteBeforeAttributeName");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errExpectedPublicId() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errExpectedPublicId");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errBogusDoctype() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errBogusDoctype");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrSurrogate() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrSurrogate");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrCr() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrCr");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrInC1Range() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrInC1Range");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInPublicId() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInPublicId");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInComment() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInComment");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInDoctype() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInDoctype");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInAttributeValue() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInAttributeValue");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInAttributeName() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInAttributeName");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofWithoutGt() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofWithoutGt");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInTagName() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInTagName");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInEndTag() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInEndTag");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofAfterLt() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofAfterLt");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrOutOfRange() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrOutOfRange");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrUnassigned() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrUnassigned");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errDuplicateAttribute() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errDuplicateAttribute");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errEofInSystemId() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentRun("errEofInSystemId");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errExpectedSystemId() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errExpectedSystemId");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errMissingSpaceBeforeDoctypeName() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errMissingSpaceBeforeDoctypeName");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
2021-08-16 08:01:09 +03:00
|
|
|
void nsHtml5Tokenizer::errNestedComment() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2021-08-16 08:01:09 +03:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNestedComment");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrControlChar() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrControlChar");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNcrZero() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNcrZero");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNoSpaceBetweenDoctypeSystemKeywordAndQuote() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2018-03-16 18:26:06 +03:00
|
|
|
mViewSource->AddErrorToCurrentNode(
|
|
|
|
"errNoSpaceBetweenDoctypeSystemKeywordAndQuote");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNoSpaceBetweenPublicAndSystemIds() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2011-11-01 15:33:11 +04:00
|
|
|
mViewSource->AddErrorToCurrentNode("errNoSpaceBetweenPublicAndSystemIds");
|
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHtml5Tokenizer::errNoSpaceBetweenDoctypePublicKeywordAndQuote() {
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_LIKELY(mViewSource)) {
|
2018-03-16 18:26:06 +03:00
|
|
|
mViewSource->AddErrorToCurrentNode(
|
|
|
|
"errNoSpaceBetweenDoctypePublicKeywordAndQuote");
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|
2011-11-01 15:33:11 +04:00
|
|
|
}
|