/* * Copyright (c) 2005-2007 Henri Sivonen * Copyright (c) 2007-2017 Mozilla Foundation * Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla * Foundation, and Opera Software ASA. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE.
*/
/* * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. * Please edit Tokenizer.java instead and regenerate.
*/
void nsHtml5Tokenizer::addAttributeWithValue() { if (attributeName) {
nsHtml5String val = strBufToString(); if (mViewSource) {
mViewSource->MaybeLinkifyAttributeValue(attributeName, val);
}
attributes->addAttribute(attributeName, val, attributeLine);
attributeName = nullptr;
} else {
clearStrBufAfterUse();
}
}
void nsHtml5Tokenizer::start() {
initializeWithoutStarting();
tokenHandler->startTokenization(this); if (mViewSource) {
line = 1;
col = -1;
nextCharOnNewLine = false;
} elseif (tokenHandler->WantsLineAndColumn()) {
line = 0;
col = 1;
nextCharOnNewLine = true;
} else {
line = -1;
col = -1;
nextCharOnNewLine = false;
}
}
bool nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer* buffer) {
int32_t state = stateSave;
int32_t returnState = returnStateSave;
char16_t c = '\0';
shouldSuspend = false;
lastCR = false;
int32_t start = buffer->getStart();
int32_t end = buffer->getEnd();
int32_t pos = start - 1; switch (state) { case DATA: case RCDATA: case SCRIPT_DATA: case PLAINTEXT: case RAWTEXT: case CDATA_SECTION: case SCRIPT_DATA_ESCAPED: case SCRIPT_DATA_ESCAPE_START: case SCRIPT_DATA_ESCAPE_START_DASH: case SCRIPT_DATA_ESCAPED_DASH: case SCRIPT_DATA_ESCAPED_DASH_DASH: case SCRIPT_DATA_DOUBLE_ESCAPE_START: case SCRIPT_DATA_DOUBLE_ESCAPED: case SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: case SCRIPT_DATA_DOUBLE_ESCAPED_DASH: case SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: case SCRIPT_DATA_DOUBLE_ESCAPE_END: {
cstart = start; break;
} default: {
cstart = INT32_MAX; break;
}
} if (mViewSource) {
mViewSource->SetBuffer(buffer);
pos = stateLoop<nsHtml5ViewSourcePolicy>(state, c, pos, buffer->getBuffer(), false, returnState,
buffer->getEnd());
mViewSource->DropBuffer((pos == buffer->getEnd()) ? pos : pos + 1);
} elseif (tokenHandler->WantsLineAndColumn()) {
pos = stateLoop<nsHtml5LineColPolicy>(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd());
} else {
pos = stateLoop<nsHtml5FastestPolicy>(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd());
} if (pos == end) {
buffer->setStart(pos);
} else {
buffer->setStart(pos + 1);
} return lastCR;
}
template <class P>
int32_t nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos,
char16_t* buf, bool reconsume,
int32_t returnState, int32_t endPos) { bool reportedConsecutiveHyphens = false;
stateloop: for (;;) { switch (state) { case DATA: { for (;;) { if (reconsume) {
reconsume = false;
} else { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos);
} switch (c) { case'&': {
flushChars(buf, pos);
MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
appendCharRefBuf(c);
setAdditionalAndRememberAmpersandLocation('\0');
returnState = state;
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'<': {
flushChars(buf, pos);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::TAG_OPEN, reconsume, pos);
NS_HTML5_BREAK(dataloop);
} case'\0': {
maybeEmitReplacementCharacter(buf, pos); continue;
} case'\r': {
emitCarriageReturn<P>(buf, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} default: { continue;
}
}
}
dataloop_end:;
[[fallthrough]];
} case TAG_OPEN: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); if (c >= 'A' && c <= 'Z') {
endTag = false;
clearStrBufBeforeUse();
appendStrBuf((char16_t)(c + 0x20));
containsHyphen = false;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::TAG_NAME,
reconsume, pos);
NS_HTML5_BREAK(tagopenloop);
} elseif (c >= 'a' && c <= 'z') {
endTag = false;
clearStrBufBeforeUse();
appendStrBuf(c);
containsHyphen = false;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::TAG_NAME,
reconsume, pos);
NS_HTML5_BREAK(tagopenloop);
} switch (c) { case'!': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::MARKUP_DECLARATION_OPEN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'/': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::CLOSE_TAG_OPEN, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
} case'\?': { if (viewingXmlSource) {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::PROCESSING_INSTRUCTION,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} if (P::reportErrors) {
errProcessingInstruction();
}
clearStrBufBeforeUse();
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BOGUS_COMMENT, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': { if (P::reportErrors) {
errLtGt();
}
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 2);
cstart = pos + 1;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} default: { if (P::reportErrors) {
errBadCharAfterLt(c);
}
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
cstart = pos;
reconsume = true;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
tagopenloop_end:;
[[fallthrough]];
} case TAG_NAME: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'\r': {
P::silentCarriageReturn(this);
strBufToElementNameString();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': {
strBufToElementNameString();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_BREAK(tagnameloop);
} case'/': {
strBufToElementNameString();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': {
strBufToElementNameString();
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: { if (c >= 'A' && c <= 'Z') {
c += 0x20;
} elseif (c == '-') {
containsHyphen = true;
}
appendStrBuf(c); continue;
}
}
}
tagnameloop_end:;
[[fallthrough]];
} case BEFORE_ATTRIBUTE_NAME: { for (;;) { if (reconsume) {
reconsume = false;
} else { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos);
} switch (c) { case'\r': {
P::silentCarriageReturn(this);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': { continue;
} case'/': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': {
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} case'\"': case'\'': case'<': case'=': { if (P::reportErrors) {
errBadCharBeforeAttributeNameOrNull(c);
}
[[fallthrough]];
} default: { if (c >= 'A' && c <= 'Z') {
c += 0x20;
}
attributeLine = line;
clearStrBufBeforeUse();
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::ATTRIBUTE_NAME, reconsume,
pos);
NS_HTML5_BREAK(beforeattributenameloop);
}
}
}
beforeattributenameloop_end:;
[[fallthrough]];
} case ATTRIBUTE_NAME: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'\r': {
P::silentCarriageReturn(this);
attributeNameComplete();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': {
attributeNameComplete();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'/': {
attributeNameComplete();
addAttributeWithoutValue();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'=': {
attributeNameComplete();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE,
reconsume, pos);
NS_HTML5_BREAK(attributenameloop);
} case'>': {
attributeNameComplete();
addAttributeWithoutValue();
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} case'\"': case'\'': case'<': { if (P::reportErrors) {
errQuoteOrLtInAttributeNameOrNull(c);
}
[[fallthrough]];
} default: { if (c >= 'A' && c <= 'Z') {
c += 0x20;
}
appendStrBuf(c); continue;
}
}
}
attributenameloop_end:;
[[fallthrough]];
} case BEFORE_ATTRIBUTE_VALUE: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'\r': {
P::silentCarriageReturn(this);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': { continue;
} case'\"': {
attributeLine = line;
clearStrBufBeforeUse();
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::ATTRIBUTE_VALUE_DOUBLE_QUOTED,
reconsume, pos);
NS_HTML5_BREAK(beforeattributevalueloop);
} case'&': {
attributeLine = line;
clearStrBufBeforeUse();
reconsume = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\'': {
attributeLine = line;
clearStrBufBeforeUse();
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::ATTRIBUTE_VALUE_SINGLE_QUOTED,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': { if (P::reportErrors) {
errAttributeValueMissing();
}
addAttributeWithoutValue();
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} case'<': case'=': case'`': { if (P::reportErrors) {
errLtOrEqualsOrGraveInUnquotedAttributeOrNull(c);
}
[[fallthrough]];
} default: {
attributeLine = line;
clearStrBufBeforeUse();
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
beforeattributevalueloop_end:;
[[fallthrough]];
} case ATTRIBUTE_VALUE_DOUBLE_QUOTED: { for (;;) { if (reconsume) {
reconsume = false;
} else { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos);
} switch (c) { case'\"': {
addAttributeWithValue();
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED,
reconsume, pos);
NS_HTML5_BREAK(attributevaluedoublequotedloop);
} case'&': {
MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
appendCharRefBuf(c);
setAdditionalAndRememberAmpersandLocation('\"');
returnState = state;
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>(); continue;
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c); continue;
}
}
}
attributevaluedoublequotedloop_end:;
[[fallthrough]];
} case AFTER_ATTRIBUTE_VALUE_QUOTED: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'\r': {
P::silentCarriageReturn(this);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'/': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
reconsume, pos);
NS_HTML5_BREAK(afterattributevaluequotedloop);
} case'>': {
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} default: { if (P::reportErrors) {
errNoSpaceBetweenAttributes();
}
reconsume = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
afterattributevaluequotedloop_end:;
[[fallthrough]];
} case SELF_CLOSING_START_TAG: { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'>': {
state =
P::transition(mViewSource.get(), emitCurrentTagToken(true, pos),
reconsume, pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} default: { if (P::reportErrors) {
errSlashNotFollowedByGt();
}
reconsume = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
} case ATTRIBUTE_VALUE_UNQUOTED: { for (;;) { if (reconsume) {
reconsume = false;
} else { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos);
} switch (c) { case'\r': {
P::silentCarriageReturn(this);
addAttributeWithValue();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': {
addAttributeWithValue();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'&': {
MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
appendCharRefBuf(c);
setAdditionalAndRememberAmpersandLocation('>');
returnState = state;
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': {
addAttributeWithValue();
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} case'<': case'\"': case'\'': case'=': case'`': { if (P::reportErrors) {
errUnquotedAttributeValOrNull(c);
}
[[fallthrough]];
} default: {
appendStrBuf(c); continue;
}
}
}
} case AFTER_ATTRIBUTE_NAME: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'\r': {
P::silentCarriageReturn(this);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} case' ': case'\t': case'\f': { continue;
} case'/': {
addAttributeWithoutValue();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'=': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': {
addAttributeWithoutValue();
state = P::transition(mViewSource.get(),
emitCurrentTagToken(false, pos), reconsume,
pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} case'\"': case'\'': case'<': { if (P::reportErrors) {
errQuoteOrLtInAttributeNameOrNull(c);
}
[[fallthrough]];
} default: {
addAttributeWithoutValue(); if (c >= 'A' && c <= 'Z') {
c += 0x20;
}
clearStrBufBeforeUse();
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::ATTRIBUTE_NAME, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
} case MARKUP_DECLARATION_OPEN: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
clearStrBufBeforeUse();
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::MARKUP_DECLARATION_HYPHEN,
reconsume, pos);
NS_HTML5_BREAK(markupdeclarationopenloop);
} case'd': case'D': {
clearStrBufBeforeUse();
appendStrBuf(c);
index = 0;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::MARKUP_DECLARATION_OCTYPE,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'[': { if (tokenHandler->cdataSectionAllowed()) {
clearStrBufBeforeUse();
appendStrBuf(c);
index = 0;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::CDATA_START, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
}
[[fallthrough]];
} default: { if (P::reportErrors) {
errBogusComment();
}
clearStrBufBeforeUse();
reconsume = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BOGUS_COMMENT, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
markupdeclarationopenloop_end:;
[[fallthrough]];
} case MARKUP_DECLARATION_HYPHEN: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
clearStrBufAfterOneHyphen();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_START, reconsume,
pos);
NS_HTML5_BREAK(markupdeclarationhyphenloop);
} default: { if (P::reportErrors) {
errBogusComment();
}
reconsume = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BOGUS_COMMENT, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
markupdeclarationhyphenloop_end:;
[[fallthrough]];
} case COMMENT_START: {
reportedConsecutiveHyphens = false; for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_START_DASH,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': { if (P::reportErrors) {
errPrematureEndOfComment();
}
emitComment(0, pos);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(commentstartloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(commentstartloop);
}
}
}
commentstartloop_end:;
[[fallthrough]];
} case COMMENT: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_END_DASH,
reconsume, pos);
NS_HTML5_BREAK(commentloop);
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>(); continue;
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c); continue;
}
}
}
commentloop_end:;
[[fallthrough]];
} case COMMENT_END_DASH: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
appendStrBuf(c);
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_END, reconsume, pos);
NS_HTML5_BREAK(commentenddashloop);
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
commentenddashloop_end:;
[[fallthrough]];
} case COMMENT_END: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'>': {
emitComment(2, pos);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'-': {
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true; continue;
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
adjustDoubleHyphenAndAppendToStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
adjustDoubleHyphenAndAppendToStrBufLineFeed<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'!': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_END_BANG,
reconsume, pos);
NS_HTML5_BREAK(commentendloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
commentendloop_end:;
[[fallthrough]];
} case COMMENT_END_BANG: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'>': {
emitComment(3, pos);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'-': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_END_DASH,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
} case COMMENT_LESSTHAN: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'!': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG,
reconsume, pos);
NS_HTML5_BREAK(commentlessthanloop);
} case'<': {
appendStrBuf(c); continue;
} case'-': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_END_DASH,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
commentlessthanloop_end:;
[[fallthrough]];
} case COMMENT_LESSTHAN_BANG: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
appendStrBuf(c);
state = P::transition(
mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG_DASH, reconsume, pos);
NS_HTML5_BREAK(commentlessthanbangloop);
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
}
commentlessthanbangloop_end:;
[[fallthrough]];
} case COMMENT_LESSTHAN_BANG_DASH: { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
appendStrBuf(c);
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN_BANG_DASH_DASH,
reconsume, pos); break;
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
[[fallthrough]];
} case COMMENT_LESSTHAN_BANG_DASH_DASH: { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'>': {
appendStrBuf(c);
emitComment(3, pos);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'-': { if (P::reportErrors) {
errNestedComment();
}
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true;
state =
P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT_END,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
c = '\n';
P::silentCarriageReturn(this); if (P::reportErrors) {
errNestedComment();
}
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this); if (P::reportErrors) {
errNestedComment();
}
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'!': { if (P::reportErrors) {
errNestedComment();
}
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_END_BANG, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: { if (P::reportErrors) {
errNestedComment();
}
adjustDoubleHyphenAndAppendToStrBufAndErr(
c, reportedConsecutiveHyphens);
reportedConsecutiveHyphens = true;
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
} case COMMENT_START_DASH: { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case'-': {
appendStrBuf(c);
state =
P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT_END,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'>': { if (P::reportErrors) {
errPrematureEndOfComment();
}
emitComment(1, pos);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::DATA,
reconsume, pos); if (shouldSuspend) {
NS_HTML5_BREAK(stateloop);
}
NS_HTML5_CONTINUE(stateloop);
} case'<': {
appendStrBuf(c);
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::COMMENT_LESSTHAN, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
} case'\r': {
appendStrBufCarriageReturn<P>();
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
appendStrBufLineFeed<P>();
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
} case'\0': {
c = 0xfffd;
[[fallthrough]];
} default: {
appendStrBuf(c);
state = P::transition(mViewSource.get(), nsHtml5Tokenizer::COMMENT,
reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
} case CDATA_START: { for (;;) { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); if (index < 6) { if (c == nsHtml5Tokenizer::CDATA_LSQB[index]) {
appendStrBuf(c);
} else { if (P::reportErrors) {
errBogusComment();
}
reconsume = true;
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::BOGUS_COMMENT, reconsume,
pos);
NS_HTML5_CONTINUE(stateloop);
}
index++; continue;
} else {
clearStrBufAfterUse();
cstart = pos;
reconsume = true;
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::CDATA_SECTION, reconsume, pos); break;
}
}
[[fallthrough]];
} case CDATA_SECTION: { for (;;) { if (reconsume) {
reconsume = false;
} else { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos);
} switch (c) { case']': {
flushChars(buf, pos);
state =
P::transition(mViewSource.get(), nsHtml5Tokenizer::CDATA_RSQB,
reconsume, pos);
NS_HTML5_BREAK(cdatasectionloop);
} case'\0': {
maybeEmitReplacementCharacter(buf, pos); continue;
} case'\r': {
emitCarriageReturn<P>(buf, pos);
NS_HTML5_BREAK(stateloop);
} case'\n': {
P::silentLineFeed(this);
[[fallthrough]];
} default: { continue;
}
}
}
cdatasectionloop_end:;
[[fallthrough]];
} case CDATA_RSQB: { if (++pos == endPos) {
NS_HTML5_BREAK(stateloop);
}
c = P::checkChar(this, buf, pos); switch (c) { case']': {
state = P::transition(mViewSource.get(),
nsHtml5Tokenizer::CDATA_RSQB_RSQB, reconsume,
pos); break;
} default: {
tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
cstart = pos;
reconsume = true;
state =
P::transition(mViewSource.get(),
nsHtml5Tokenizer::CDATA_SECTION, reconsume, pos);
NS_HTML5_CONTINUE(stateloop);
}
}
[[fallthrough]];
} case CDATA_RSQB_RSQB: { for (;;) {
--> --------------------
--> maximum size reached
--> --------------------
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.