michael@0: /* michael@0: * Copyright (c) 2005-2007 Henri Sivonen michael@0: * Copyright (c) 2007-2013 Mozilla Foundation michael@0: * Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla michael@0: * Foundation, and Opera Software ASA. michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice shall be included in michael@0: * all copies or substantial portions of the Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: */ michael@0: michael@0: /* michael@0: * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. michael@0: * Please edit Tokenizer.java instead and regenerate. michael@0: */ michael@0: michael@0: #define nsHtml5Tokenizer_cpp__ michael@0: michael@0: #include "nsIAtom.h" michael@0: #include "nsHtml5AtomTable.h" michael@0: #include "nsString.h" michael@0: #include "nsIContent.h" michael@0: #include "nsTraceRefcnt.h" michael@0: #include "jArray.h" michael@0: #include "nsHtml5DocumentMode.h" michael@0: #include "nsHtml5ArrayCopy.h" michael@0: #include "nsHtml5NamedCharacters.h" michael@0: #include "nsHtml5NamedCharactersAccel.h" michael@0: #include "nsHtml5Atoms.h" michael@0: #include "nsAHtml5TreeBuilderState.h" michael@0: #include "nsHtml5Macros.h" michael@0: #include "nsHtml5Highlighter.h" michael@0: #include "nsHtml5TokenizerLoopPolicies.h" michael@0: michael@0: #include "nsHtml5TreeBuilder.h" michael@0: #include "nsHtml5MetaScanner.h" michael@0: #include "nsHtml5AttributeName.h" michael@0: #include "nsHtml5ElementName.h" michael@0: #include "nsHtml5HtmlAttributes.h" michael@0: #include "nsHtml5StackNode.h" michael@0: #include "nsHtml5UTF16Buffer.h" michael@0: #include "nsHtml5StateSnapshot.h" michael@0: #include "nsHtml5Portability.h" michael@0: michael@0: #include "nsHtml5Tokenizer.h" michael@0: michael@0: char16_t nsHtml5Tokenizer::LT_GT[] = { '<', '>' }; michael@0: char16_t nsHtml5Tokenizer::LT_SOLIDUS[] = { '<', '/' }; michael@0: char16_t nsHtml5Tokenizer::RSQB_RSQB[] = { ']', ']' }; michael@0: char16_t nsHtml5Tokenizer::REPLACEMENT_CHARACTER[] = { 0xfffd }; michael@0: char16_t nsHtml5Tokenizer::LF[] = { '\n' }; michael@0: char16_t nsHtml5Tokenizer::CDATA_LSQB[] = { 'C', 'D', 'A', 'T', 'A', '[' }; michael@0: char16_t nsHtml5Tokenizer::OCTYPE[] = { 'o', 'c', 't', 'y', 'p', 'e' }; michael@0: char16_t nsHtml5Tokenizer::UBLIC[] = { 'u', 'b', 'l', 'i', 'c' }; michael@0: char16_t nsHtml5Tokenizer::YSTEM[] = { 'y', 's', 't', 'e', 'm' }; michael@0: static char16_t const TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' }; michael@0: staticJArray nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, MOZ_ARRAY_LENGTH(TITLE_ARR_DATA) }; michael@0: static char16_t const SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' }; michael@0: staticJArray nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(SCRIPT_ARR_DATA) }; michael@0: static char16_t const STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' }; michael@0: staticJArray nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, MOZ_ARRAY_LENGTH(STYLE_ARR_DATA) }; michael@0: static char16_t const PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' }; michael@0: staticJArray nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, MOZ_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) }; michael@0: static char16_t const XMP_ARR_DATA[] = { 'x', 'm', 'p' }; michael@0: staticJArray nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, MOZ_ARRAY_LENGTH(XMP_ARR_DATA) }; michael@0: static char16_t const TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' }; michael@0: staticJArray nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, MOZ_ARRAY_LENGTH(TEXTAREA_ARR_DATA) }; michael@0: static char16_t const IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' }; michael@0: staticJArray nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, MOZ_ARRAY_LENGTH(IFRAME_ARR_DATA) }; michael@0: static char16_t const NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' }; michael@0: staticJArray nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, MOZ_ARRAY_LENGTH(NOEMBED_ARR_DATA) }; michael@0: static char16_t const NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' }; michael@0: staticJArray nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) }; michael@0: static char16_t const NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' }; michael@0: staticJArray nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, MOZ_ARRAY_LENGTH(NOFRAMES_ARR_DATA) }; michael@0: michael@0: nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource) michael@0: : tokenHandler(tokenHandler), michael@0: encodingDeclarationHandler(nullptr), michael@0: bmpChar(jArray::newJArray(1)), michael@0: astralChar(jArray::newJArray(2)), michael@0: tagName(nullptr), michael@0: attributeName(nullptr), michael@0: doctypeName(nullptr), michael@0: publicIdentifier(nullptr), michael@0: systemIdentifier(nullptr), michael@0: attributes(tokenHandler->HasBuilder() ? new nsHtml5HtmlAttributes(0) : nullptr), michael@0: newAttributesEachTime(!tokenHandler->HasBuilder()), michael@0: viewingXmlSource(viewingXmlSource) michael@0: { michael@0: MOZ_COUNT_CTOR(nsHtml5Tokenizer); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner) michael@0: { michael@0: this->interner = interner; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::initLocation(nsString* newPublicId, nsString* newSystemId) michael@0: { michael@0: this->systemId = newSystemId; michael@0: this->publicId = newPublicId; michael@0: } michael@0: michael@0: bool michael@0: nsHtml5Tokenizer::isViewingXmlSource() michael@0: { michael@0: return viewingXmlSource; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsIAtom* endTagExpectation) michael@0: { michael@0: this->stateSave = specialTokenizerState; michael@0: if (specialTokenizerState == NS_HTML5TOKENIZER_DATA) { michael@0: return; michael@0: } michael@0: autoJArray asArray = nsHtml5Portability::newCharArrayFromLocal(endTagExpectation); michael@0: this->endTagExpectation = nsHtml5ElementName::elementNameByBuffer(asArray, 0, asArray.length, interner); michael@0: endTagExpectationToArray(); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsHtml5ElementName* endTagExpectation) michael@0: { michael@0: this->stateSave = specialTokenizerState; michael@0: this->endTagExpectation = endTagExpectation; michael@0: endTagExpectationToArray(); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::endTagExpectationToArray() michael@0: { michael@0: switch(endTagExpectation->getGroup()) { michael@0: case NS_HTML5TREE_BUILDER_TITLE: { michael@0: endTagExpectationAsArray = TITLE_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_SCRIPT: { michael@0: endTagExpectationAsArray = SCRIPT_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_STYLE: { michael@0: endTagExpectationAsArray = STYLE_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_PLAINTEXT: { michael@0: endTagExpectationAsArray = PLAINTEXT_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_XMP: { michael@0: endTagExpectationAsArray = XMP_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_TEXTAREA: { michael@0: endTagExpectationAsArray = TEXTAREA_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_IFRAME: { michael@0: endTagExpectationAsArray = IFRAME_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_NOEMBED: { michael@0: endTagExpectationAsArray = NOEMBED_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_NOSCRIPT: { michael@0: endTagExpectationAsArray = NOSCRIPT_ARR; michael@0: return; michael@0: } michael@0: case NS_HTML5TREE_BUILDER_NOFRAMES: { michael@0: endTagExpectationAsArray = NOFRAMES_ARR; michael@0: return; michael@0: } michael@0: default: { michael@0: MOZ_ASSERT(false, "Bad end tag expectation."); michael@0: return; michael@0: } michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::setLineNumber(int32_t line) michael@0: { michael@0: this->line = line; michael@0: } michael@0: michael@0: nsHtml5HtmlAttributes* michael@0: nsHtml5Tokenizer::emptyAttributes() michael@0: { michael@0: return nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::appendStrBuf(char16_t c) michael@0: { michael@0: if (strBufLen == strBuf.length) { michael@0: jArray newBuf = jArray::newJArray(strBuf.length + NS_HTML5TOKENIZER_BUFFER_GROW_BY); michael@0: nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length); michael@0: strBuf = newBuf; michael@0: } michael@0: strBuf[strBufLen++] = c; michael@0: } michael@0: michael@0: nsString* michael@0: nsHtml5Tokenizer::strBufToString() michael@0: { michael@0: return nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::strBufToDoctypeName() michael@0: { michael@0: doctypeName = nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitStrBuf() michael@0: { michael@0: if (strBufLen > 0) { michael@0: tokenHandler->characters(strBuf, 0, strBufLen); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::appendLongStrBuf(char16_t c) michael@0: { michael@0: if (longStrBufLen == longStrBuf.length) { michael@0: jArray newBuf = jArray::newJArray(longStrBufLen + (longStrBufLen >> 1)); michael@0: nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length); michael@0: longStrBuf = newBuf; michael@0: } michael@0: longStrBuf[longStrBufLen++] = c; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::appendLongStrBuf(char16_t* buffer, int32_t offset, int32_t length) michael@0: { michael@0: int32_t reqLen = longStrBufLen + length; michael@0: if (longStrBuf.length < reqLen) { michael@0: jArray newBuf = jArray::newJArray(reqLen + (reqLen >> 1)); michael@0: nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length); michael@0: longStrBuf = newBuf; michael@0: } michael@0: nsHtml5ArrayCopy::arraycopy(buffer, offset, longStrBuf, longStrBufLen, length); michael@0: longStrBufLen = reqLen; michael@0: } michael@0: michael@0: nsString* michael@0: nsHtml5Tokenizer::longStrBufToString() michael@0: { michael@0: return nsHtml5Portability::newStringFromBuffer(longStrBuf, 0, longStrBufLen); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitComment(int32_t provisionalHyphens, int32_t pos) michael@0: { michael@0: tokenHandler->comment(longStrBuf, 0, longStrBufLen - provisionalHyphens); michael@0: cstart = pos + 1; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::flushChars(char16_t* buf, int32_t pos) michael@0: { michael@0: if (pos > cstart) { michael@0: tokenHandler->characters(buf, cstart, pos - cstart); michael@0: } michael@0: cstart = INT32_MAX; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::strBufToElementNameString() michael@0: { michael@0: tagName = nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner); michael@0: } michael@0: michael@0: int32_t michael@0: nsHtml5Tokenizer::emitCurrentTagToken(bool selfClosing, int32_t pos) michael@0: { michael@0: cstart = pos + 1; michael@0: maybeErrSlashInEndTag(selfClosing); michael@0: stateSave = NS_HTML5TOKENIZER_DATA; michael@0: nsHtml5HtmlAttributes* attrs = (!attributes ? nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES : attributes); michael@0: if (endTag) { michael@0: maybeErrAttributesOnEndTag(attrs); michael@0: if (!viewingXmlSource) { michael@0: tokenHandler->endTag(tagName); michael@0: } michael@0: if (newAttributesEachTime) { michael@0: delete attributes; michael@0: attributes = nullptr; michael@0: } michael@0: } else { michael@0: if (viewingXmlSource) { michael@0: MOZ_ASSERT(newAttributesEachTime); michael@0: delete attributes; michael@0: attributes = nullptr; michael@0: } else { michael@0: tokenHandler->startTag(tagName, attrs, selfClosing); michael@0: } michael@0: } michael@0: tagName->release(); michael@0: tagName = nullptr; michael@0: if (newAttributesEachTime) { michael@0: attributes = nullptr; michael@0: } else { michael@0: attributes->clear(0); michael@0: } michael@0: return stateSave; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::attributeNameComplete() michael@0: { michael@0: attributeName = nsHtml5AttributeName::nameByBuffer(strBuf, 0, strBufLen, interner); michael@0: if (!attributes) { michael@0: attributes = new nsHtml5HtmlAttributes(0); michael@0: } michael@0: if (attributes->contains(attributeName)) { michael@0: errDuplicateAttribute(); michael@0: attributeName->release(); michael@0: attributeName = nullptr; michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::addAttributeWithoutValue() michael@0: { michael@0: michael@0: if (attributeName) { michael@0: attributes->addAttribute(attributeName, nsHtml5Portability::newEmptyString()); michael@0: attributeName = nullptr; michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::addAttributeWithValue() michael@0: { michael@0: if (attributeName) { michael@0: nsString* val = longStrBufToString(); michael@0: if (mViewSource) { michael@0: mViewSource->MaybeLinkifyAttributeValue(attributeName, val); michael@0: } michael@0: attributes->addAttribute(attributeName, val); michael@0: attributeName = nullptr; michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::start() michael@0: { michael@0: initializeWithoutStarting(); michael@0: tokenHandler->startTokenization(this); michael@0: } michael@0: michael@0: bool michael@0: nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer* buffer) michael@0: { michael@0: int32_t state = stateSave; michael@0: int32_t returnState = returnStateSave; michael@0: char16_t c = '\0'; michael@0: shouldSuspend = false; michael@0: lastCR = false; michael@0: int32_t start = buffer->getStart(); michael@0: int32_t pos = start - 1; michael@0: switch(state) { michael@0: case NS_HTML5TOKENIZER_DATA: michael@0: case NS_HTML5TOKENIZER_RCDATA: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA: michael@0: case NS_HTML5TOKENIZER_PLAINTEXT: michael@0: case NS_HTML5TOKENIZER_RAWTEXT: michael@0: case NS_HTML5TOKENIZER_CDATA_SECTION: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: { michael@0: cstart = start; michael@0: break; michael@0: } michael@0: default: { michael@0: cstart = INT32_MAX; michael@0: break; michael@0: } michael@0: } michael@0: if (mViewSource) { michael@0: mViewSource->SetBuffer(buffer); michael@0: pos = stateLoop(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd()); michael@0: mViewSource->DropBuffer((pos == buffer->getEnd()) ? pos : pos + 1); michael@0: } else { michael@0: pos = stateLoop(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd()); michael@0: } michael@0: if (pos == buffer->getEnd()) { michael@0: buffer->setStart(pos); michael@0: } else { michael@0: buffer->setStart(pos + 1); michael@0: } michael@0: return lastCR; michael@0: } michael@0: michael@0: template michael@0: int32_t michael@0: nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* buf, bool reconsume, int32_t returnState, int32_t endPos) michael@0: { michael@0: stateloop: for (; ; ) { michael@0: switch(state) { michael@0: case NS_HTML5TOKENIZER_DATA: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '&': { michael@0: flushChars(buf, pos); michael@0: clearStrBufAndAppend(c); michael@0: setAdditionalAndRememberAmpersandLocation('\0'); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_OPEN, reconsume, pos); michael@0: NS_HTML5_BREAK(dataloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: dataloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_TAG_OPEN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (c >= 'A' && c <= 'Z') { michael@0: endTag = false; michael@0: clearStrBufAndAppend((char16_t) (c + 0x20)); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(tagopenloop); michael@0: } else if (c >= 'a' && c <= 'z') { michael@0: endTag = false; michael@0: clearStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(tagopenloop); michael@0: } michael@0: switch(c) { michael@0: case '!': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '/': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CLOSE_TAG_OPEN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\?': { michael@0: if (viewingXmlSource) { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: if (P::reportErrors) { michael@0: errProcessingInstruction(); michael@0: } michael@0: clearLongStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errLtGt(); michael@0: } michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 2); michael@0: cstart = pos + 1; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: if (P::reportErrors) { michael@0: errBadCharAfterLt(c); michael@0: } michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: tagopenloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_TAG_NAME: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: strBufToElementNameString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: strBufToElementNameString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(tagnameloop); michael@0: } michael@0: case '/': { michael@0: strBufToElementNameString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: strBufToElementNameString(); michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: appendStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: tagnameloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '/': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: case '\"': michael@0: case '\'': michael@0: case '<': michael@0: case '=': { michael@0: if (P::reportErrors) { michael@0: errBadCharBeforeAttributeNameOrNull(c); michael@0: } michael@0: } michael@0: default: { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: clearStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(beforeattributenameloop); michael@0: } michael@0: } michael@0: } michael@0: beforeattributenameloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: attributeNameComplete(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: attributeNameComplete(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '/': { michael@0: attributeNameComplete(); michael@0: addAttributeWithoutValue(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '=': { michael@0: attributeNameComplete(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos); michael@0: NS_HTML5_BREAK(attributenameloop); michael@0: } michael@0: case '>': { michael@0: attributeNameComplete(); michael@0: addAttributeWithoutValue(); michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: case '\"': michael@0: case '\'': michael@0: case '<': { michael@0: if (P::reportErrors) { michael@0: errQuoteOrLtInAttributeNameOrNull(c); michael@0: } michael@0: } michael@0: default: { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: appendStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: attributenameloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '\"': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_BREAK(beforeattributevalueloop); michael@0: } michael@0: case '&': { michael@0: clearLongStrBuf(); michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); michael@0: michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\'': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errAttributeValueMissing(); michael@0: } michael@0: addAttributeWithoutValue(); michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: case '<': michael@0: case '=': michael@0: case '`': { michael@0: if (P::reportErrors) { michael@0: errLtOrEqualsOrGraveInUnquotedAttributeOrNull(c); michael@0: } michael@0: } michael@0: default: { michael@0: clearLongStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); michael@0: michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: beforeattributevalueloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\"': { michael@0: addAttributeWithValue(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos); michael@0: NS_HTML5_BREAK(attributevaluedoublequotedloop); michael@0: } michael@0: case '&': { michael@0: clearStrBufAndAppend(c); michael@0: setAdditionalAndRememberAmpersandLocation('\"'); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: attributevaluedoublequotedloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '/': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); michael@0: NS_HTML5_BREAK(afterattributevaluequotedloop); michael@0: } michael@0: case '>': { michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenAttributes(); michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: afterattributevaluequotedloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '>': { michael@0: state = P::transition(mViewSource, emitCurrentTagToken(true, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: if (P::reportErrors) { michael@0: errSlashNotFollowedByGt(); michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: addAttributeWithValue(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: addAttributeWithValue(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '&': { michael@0: clearStrBufAndAppend(c); michael@0: setAdditionalAndRememberAmpersandLocation('>'); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: addAttributeWithValue(); michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: case '<': michael@0: case '\"': michael@0: case '\'': michael@0: case '=': michael@0: case '`': { michael@0: if (P::reportErrors) { michael@0: errUnquotedAttributeValOrNull(c); michael@0: } michael@0: } michael@0: default: { michael@0: michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '/': { michael@0: addAttributeWithoutValue(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '=': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: addAttributeWithoutValue(); michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: case '\"': michael@0: case '\'': michael@0: case '<': { michael@0: if (P::reportErrors) { michael@0: errQuoteOrLtInAttributeNameOrNull(c); michael@0: } michael@0: } michael@0: default: { michael@0: addAttributeWithoutValue(); michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: clearStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: clearLongStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN, reconsume, pos); michael@0: NS_HTML5_BREAK(markupdeclarationopenloop); michael@0: } michael@0: case 'd': michael@0: case 'D': { michael@0: clearLongStrBufAndAppend(c); michael@0: index = 0; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '[': { michael@0: if (tokenHandler->cdataSectionAllowed()) { michael@0: clearLongStrBufAndAppend(c); michael@0: index = 0; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_START, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: default: { michael@0: if (P::reportErrors) { michael@0: errBogusComment(); michael@0: } michael@0: clearLongStrBuf(); michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: markupdeclarationopenloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\0': { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START, reconsume, pos); michael@0: NS_HTML5_BREAK(markupdeclarationhyphenloop); michael@0: } michael@0: default: { michael@0: if (P::reportErrors) { michael@0: errBogusComment(); michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: markupdeclarationhyphenloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_START: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START_DASH, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errPrematureEndOfComment(); michael@0: } michael@0: emitComment(0, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(commentstartloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(commentstartloop); michael@0: } michael@0: } michael@0: } michael@0: commentstartloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos); michael@0: NS_HTML5_BREAK(commentloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: commentloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_END_DASH: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos); michael@0: NS_HTML5_BREAK(commentenddashloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: commentenddashloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_END: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '>': { michael@0: emitComment(2, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '-': { michael@0: adjustDoubleHyphenAndAppendToLongStrBufAndErr(c); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: adjustDoubleHyphenAndAppendToLongStrBufCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: adjustDoubleHyphenAndAppendToLongStrBufLineFeed(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '!': { michael@0: if (P::reportErrors) { michael@0: errHyphenHyphenBang(); michael@0: } michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_BANG, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: adjustDoubleHyphenAndAppendToLongStrBufAndErr(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_END_BANG: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '>': { michael@0: emitComment(3, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '-': { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_START_DASH: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errPrematureEndOfComment(); michael@0: } michael@0: emitComment(1, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_CDATA_START: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (index < 6) { michael@0: if (c == nsHtml5Tokenizer::CDATA_LSQB[index]) { michael@0: appendLongStrBuf(c); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errBogusComment(); michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: index++; michael@0: continue; michael@0: } else { michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos); michael@0: break; michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_CDATA_SECTION: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case ']': { michael@0: flushChars(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB, reconsume, pos); michael@0: NS_HTML5_BREAK(cdatasectionloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: cdatasectionloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_CDATA_RSQB: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case ']': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB_RSQB, reconsume, pos); michael@0: NS_HTML5_BREAK(cdatarsqb); michael@0: } michael@0: default: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: cdatarsqb_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case ']': { michael@0: tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1); michael@0: continue; michael@0: } michael@0: case '>': { michael@0: cstart = pos + 1; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\'': { michael@0: addAttributeWithValue(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '&': { michael@0: clearStrBufAndAppend(c); michael@0: setAdditionalAndRememberAmpersandLocation('\''); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); michael@0: NS_HTML5_BREAK(attributevaluesinglequotedloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: attributevaluesinglequotedloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (c == '\0') { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: switch(c) { michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\r': michael@0: case '\f': michael@0: case '<': michael@0: case '&': { michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '#': { michael@0: appendStrBuf('#'); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_NCR, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: if (c == additional) { michael@0: emitOrAppendStrBuf(returnState); michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: if (c >= 'a' && c <= 'z') { michael@0: firstCharKey = c - 'a' + 26; michael@0: } else if (c >= 'A' && c <= 'Z') { michael@0: firstCharKey = c - 'A'; michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errNoNamedCharacterMatch(); michael@0: } michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: appendStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP, reconsume, pos); michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: { michael@0: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (c == '\0') { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: int32_t hilo = 0; michael@0: if (c <= 'z') { michael@0: const int32_t* row = nsHtml5NamedCharactersAccel::HILO_ACCEL[c]; michael@0: if (row) { michael@0: hilo = row[firstCharKey]; michael@0: } michael@0: } michael@0: if (!hilo) { michael@0: if (P::reportErrors) { michael@0: errNoNamedCharacterMatch(); michael@0: } michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: appendStrBuf(c); michael@0: lo = hilo & 0xFFFF; michael@0: hi = hilo >> 16; michael@0: entCol = -1; michael@0: candidate = -1; michael@0: strBufMark = 0; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL, reconsume, pos); michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (c == '\0') { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: entCol++; michael@0: for (; ; ) { michael@0: if (hi < lo) { michael@0: NS_HTML5_BREAK(outer); michael@0: } michael@0: if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) { michael@0: candidate = lo; michael@0: strBufMark = strBufLen; michael@0: lo++; michael@0: } else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) { michael@0: NS_HTML5_BREAK(outer); michael@0: } else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) { michael@0: lo++; michael@0: } else { michael@0: NS_HTML5_BREAK(loloop); michael@0: } michael@0: } michael@0: loloop_end: ; michael@0: for (; ; ) { michael@0: if (hi < lo) { michael@0: NS_HTML5_BREAK(outer); michael@0: } michael@0: if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) { michael@0: NS_HTML5_BREAK(hiloop); michael@0: } michael@0: if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) { michael@0: NS_HTML5_BREAK(outer); michael@0: } else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) { michael@0: hi--; michael@0: } else { michael@0: NS_HTML5_BREAK(hiloop); michael@0: } michael@0: } michael@0: hiloop_end: ; michael@0: if (c == ';') { michael@0: if (entCol + 1 == nsHtml5NamedCharacters::NAMES[lo].length()) { michael@0: candidate = lo; michael@0: strBufMark = strBufLen; michael@0: } michael@0: NS_HTML5_BREAK(outer); michael@0: } michael@0: if (hi < lo) { michael@0: NS_HTML5_BREAK(outer); michael@0: } michael@0: appendStrBuf(c); michael@0: continue; michael@0: } michael@0: outer_end: ; michael@0: if (candidate == -1) { michael@0: if (P::reportErrors) { michael@0: errNoNamedCharacterMatch(); michael@0: } michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } else { michael@0: const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate]; michael@0: if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: char16_t ch; michael@0: if (strBufMark == strBufLen) { michael@0: ch = c; michael@0: } else { michael@0: ch = strBuf[strBufMark]; michael@0: } michael@0: if (ch == '=' || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { michael@0: if (P::reportErrors) { michael@0: errNoNamedCharacterMatch(); michael@0: } michael@0: appendStrBufToLongStrBuf(); michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: if (P::reportErrors) { michael@0: errUnescapedAmpersandInterpretedAsCharacterReference(); michael@0: } michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errNotSemicolonTerminated(); michael@0: } michael@0: } michael@0: } michael@0: P::completedNamedCharacterReference(mViewSource); michael@0: const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate]; michael@0: if (!val[1]) { michael@0: emitOrAppendOne(val, returnState); michael@0: } else { michael@0: emitOrAppendTwo(val, returnState); michael@0: } michael@0: if (strBufMark < strBufLen) { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: for (int32_t i = strBufMark; i < strBufLen; i++) { michael@0: appendLongStrBuf(strBuf[i]); michael@0: } michael@0: } else { michael@0: tokenHandler->characters(strBuf, strBufMark, strBufLen - strBufMark); michael@0: } michael@0: } michael@0: bool earlyBreak = (c == ';' && strBufMark == strBufLen); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = earlyBreak ? pos + 1 : pos; michael@0: } michael@0: reconsume = !earlyBreak; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_CONSUME_NCR: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: prevValue = -1; michael@0: value = 0; michael@0: seenDigits = false; michael@0: switch(c) { michael@0: case 'x': michael@0: case 'X': { michael@0: appendStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_HEX_NCR_LOOP, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP, reconsume, pos); michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: if (value < prevValue) { michael@0: value = 0x110000; michael@0: } michael@0: prevValue = value; michael@0: if (c >= '0' && c <= '9') { michael@0: seenDigits = true; michael@0: value *= 10; michael@0: value += c - '0'; michael@0: continue; michael@0: } else if (c == ';') { michael@0: if (seenDigits) { michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos + 1; michael@0: } michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); michael@0: NS_HTML5_BREAK(decimalloop); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errNoDigitsInNCR(); michael@0: } michael@0: appendStrBuf(';'); michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos + 1; michael@0: } michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } else { michael@0: if (!seenDigits) { michael@0: if (P::reportErrors) { michael@0: errNoDigitsInNCR(); michael@0: } michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errCharRefLacksSemicolon(); michael@0: } michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); michael@0: NS_HTML5_BREAK(decimalloop); michael@0: } michael@0: } michael@0: } michael@0: decimalloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_HANDLE_NCR_VALUE: { michael@0: handleNcrValue(returnState); michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_HEX_NCR_LOOP: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (value < prevValue) { michael@0: value = 0x110000; michael@0: } michael@0: prevValue = value; michael@0: if (c >= '0' && c <= '9') { michael@0: seenDigits = true; michael@0: value *= 16; michael@0: value += c - '0'; michael@0: continue; michael@0: } else if (c >= 'A' && c <= 'F') { michael@0: seenDigits = true; michael@0: value *= 16; michael@0: value += c - 'A' + 10; michael@0: continue; michael@0: } else if (c >= 'a' && c <= 'f') { michael@0: seenDigits = true; michael@0: value *= 16; michael@0: value += c - 'a' + 10; michael@0: continue; michael@0: } else if (c == ';') { michael@0: if (seenDigits) { michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos + 1; michael@0: } michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errNoDigitsInNCR(); michael@0: } michael@0: appendStrBuf(';'); michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos + 1; michael@0: } michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } else { michael@0: if (!seenDigits) { michael@0: if (P::reportErrors) { michael@0: errNoDigitsInNCR(); michael@0: } michael@0: emitOrAppendStrBuf(returnState); michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errCharRefLacksSemicolon(); michael@0: } michael@0: if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: cstart = pos; michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_PLAINTEXT: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\0': { michael@0: emitPlaintextReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errLtSlashGt(); michael@0: } michael@0: cstart = pos + 1; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: if (P::reportErrors) { michael@0: errGarbageAfterLtSlash(); michael@0: } michael@0: clearLongStrBufAndAppend('\n'); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: if (P::reportErrors) { michael@0: errGarbageAfterLtSlash(); michael@0: } michael@0: clearLongStrBufAndAppend('\n'); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: if (c >= 'a' && c <= 'z') { michael@0: endTag = true; michael@0: clearStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errGarbageAfterLtSlash(); michael@0: } michael@0: clearLongStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_RCDATA: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '&': { michael@0: flushChars(buf, pos); michael@0: clearStrBufAndAppend(c); michael@0: additional = '\0'; michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_RAWTEXT: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_BREAK(rawtextloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: rawtextloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '/': { michael@0: index = 0; michael@0: clearStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(rawtextrcdatalessthansignloop); michael@0: } michael@0: default: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: rawtextrcdatalessthansignloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (index < endTagExpectationAsArray.length) { michael@0: char16_t e = endTagExpectationAsArray[index]; michael@0: char16_t folded = c; michael@0: if (c >= 'A' && c <= 'Z') { michael@0: folded += 0x20; michael@0: } michael@0: if (folded != e) { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); michael@0: emitStrBuf(); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: appendStrBuf(c); michael@0: index++; michael@0: continue; michael@0: } else { michael@0: endTag = true; michael@0: tagName = endTagExpectation; michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '/': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); michael@0: if (shouldSuspend) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); michael@0: emitStrBuf(); michael@0: if (c == '\0') { michael@0: emitReplacementCharacter(buf, pos); michael@0: } else { michael@0: cstart = pos; michael@0: } michael@0: state = P::transition(mViewSource, returnState, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_BOGUS_COMMENT: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '>': { michael@0: emitComment(0, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '-': { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN, reconsume, pos); michael@0: NS_HTML5_BREAK(boguscommentloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: boguscommentloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: { michael@0: boguscommenthyphenloop: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '>': { michael@0: emitComment(0, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '-': { michael@0: appendSecondHyphenToBogusComment(); michael@0: NS_HTML5_CONTINUE(boguscommenthyphenloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: returnState = state; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: scriptdataloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '/': { michael@0: index = 0; michael@0: clearStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '!': { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: cstart = pos; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdatalessthansignloop); michael@0: } michael@0: default: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdatalessthansignloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapestartloop); michael@0: } michael@0: default: { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdataescapestartloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapestartdashloop); michael@0: } michael@0: default: { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdataescapestartdashloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: continue; michael@0: } michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapeddashdashloop); michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapeddashdashloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdataescapeddashdashloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '-': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapedloop); michael@0: } michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: scriptdataescapedloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '<': { michael@0: flushChars(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapeddashloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdataescapeddashloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '/': { michael@0: index = 0; michael@0: clearStrBuf(); michael@0: returnState = NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case 'S': michael@0: case 's': { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: cstart = pos; michael@0: index = 1; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdataescapedlessthanloop); michael@0: } michael@0: default: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: cstart = pos; michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdataescapedlessthanloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: MOZ_ASSERT(index > 0); michael@0: if (index < 6) { michael@0: char16_t folded = c; michael@0: if (c >= 'A' && c <= 'Z') { michael@0: folded += 0x20; michael@0: } michael@0: if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: index++; michael@0: continue; michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': michael@0: case '/': michael@0: case '>': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdatadoubleescapestartloop); michael@0: } michael@0: default: { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdatadoubleescapestartloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '-': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdatadoubleescapedloop); michael@0: } michael@0: case '<': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: continue; michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: scriptdatadoubleescapedloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdatadoubleescapeddashloop); michael@0: } michael@0: case '<': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdatadoubleescapeddashloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '-': { michael@0: continue; michael@0: } michael@0: case '<': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdatadoubleescapeddashdashloop); michael@0: } michael@0: case '>': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: emitReplacementCharacter(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdatadoubleescapeddashdashloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '/': { michael@0: index = 0; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END, reconsume, pos); michael@0: NS_HTML5_BREAK(scriptdatadoubleescapedlessthanloop); michael@0: } michael@0: default: { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: scriptdatadoubleescapedlessthanloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (index < 6) { michael@0: char16_t folded = c; michael@0: if (c >= 'A' && c <= 'Z') { michael@0: folded += 0x20; michael@0: } michael@0: if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: index++; michael@0: continue; michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: emitCarriageReturn(buf, pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': michael@0: case '/': michael@0: case '>': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (index < 6) { michael@0: char16_t folded = c; michael@0: if (c >= 'A' && c <= 'Z') { michael@0: folded += 0x20; michael@0: } michael@0: if (folded == nsHtml5Tokenizer::OCTYPE[index]) { michael@0: appendLongStrBuf(c); michael@0: } else { michael@0: if (P::reportErrors) { michael@0: errBogusComment(); michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: index++; michael@0: continue; michael@0: } else { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_BREAK(markupdeclarationdoctypeloop); michael@0: } michael@0: } michael@0: markupdeclarationdoctypeloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: initDoctypeFields(); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(doctypeloop); michael@0: } michael@0: default: { michael@0: if (P::reportErrors) { michael@0: errMissingSpaceBeforeDoctypeName(); michael@0: } michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(doctypeloop); michael@0: } michael@0: } michael@0: } michael@0: doctypeloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errNamelessDoctype(); michael@0: } michael@0: forceQuirks = true; michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: clearStrBufAndAppend(c); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(beforedoctypenameloop); michael@0: } michael@0: } michael@0: } michael@0: beforedoctypenameloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_NAME: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: strBufToDoctypeName(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: strBufToDoctypeName(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos); michael@0: NS_HTML5_BREAK(doctypenameloop); michael@0: } michael@0: case '>': { michael@0: strBufToDoctypeName(); michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x0020; michael@0: } michael@0: appendStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: doctypenameloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '>': { michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case 'p': michael@0: case 'P': { michael@0: index = 0; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_UBLIC, reconsume, pos); michael@0: NS_HTML5_BREAK(afterdoctypenameloop); michael@0: } michael@0: case 's': michael@0: case 'S': { michael@0: index = 0; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_YSTEM, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: afterdoctypenameloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_UBLIC: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (index < 5) { michael@0: char16_t folded = c; michael@0: if (c >= 'A' && c <= 'Z') { michael@0: folded += 0x20; michael@0: } michael@0: if (folded != nsHtml5Tokenizer::UBLIC[index]) { michael@0: bogusDoctype(); michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: index++; michael@0: continue; michael@0: } else { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD, reconsume, pos); michael@0: NS_HTML5_BREAK(doctypeublicloop); michael@0: } michael@0: } michael@0: doctypeublicloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_BREAK(afterdoctypepublickeywordloop); michael@0: } michael@0: case '\"': { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenDoctypePublicKeywordAndQuote(); michael@0: } michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\'': { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenDoctypePublicKeywordAndQuote(); michael@0: } michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errExpectedPublicId(); michael@0: } michael@0: forceQuirks = true; michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: afterdoctypepublickeywordloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '\"': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_BREAK(beforedoctypepublicidentifierloop); michael@0: } michael@0: case '\'': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errExpectedPublicId(); michael@0: } michael@0: forceQuirks = true; michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: beforedoctypepublicidentifierloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\"': { michael@0: publicIdentifier = longStrBufToString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_BREAK(doctypepublicidentifierdoublequotedloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errGtInPublicId(); michael@0: } michael@0: forceQuirks = true; michael@0: publicIdentifier = longStrBufToString(); michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: doctypepublicidentifierdoublequotedloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos); michael@0: NS_HTML5_BREAK(afterdoctypepublicidentifierloop); michael@0: } michael@0: case '>': { michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\"': { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenPublicAndSystemIds(); michael@0: } michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\'': { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenPublicAndSystemIds(); michael@0: } michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: afterdoctypepublicidentifierloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '>': { michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\"': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_BREAK(betweendoctypepublicandsystemidentifiersloop); michael@0: } michael@0: case '\'': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: betweendoctypepublicandsystemidentifiersloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\"': { michael@0: systemIdentifier = longStrBufToString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errGtInSystemId(); michael@0: } michael@0: forceQuirks = true; michael@0: systemIdentifier = longStrBufToString(); michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '>': { michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctypeWithoutQuirks(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_BREAK(afterdoctypesystemidentifierloop); michael@0: } michael@0: } michael@0: } michael@0: afterdoctypesystemidentifierloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '>': { michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_YSTEM: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: if (index < 5) { michael@0: char16_t folded = c; michael@0: if (c >= 'A' && c <= 'Z') { michael@0: folded += 0x20; michael@0: } michael@0: if (folded != nsHtml5Tokenizer::YSTEM[index]) { michael@0: bogusDoctype(); michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: index++; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } else { michael@0: reconsume = true; michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD, reconsume, pos); michael@0: NS_HTML5_BREAK(doctypeystemloop); michael@0: } michael@0: } michael@0: doctypeystemloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: } michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_BREAK(afterdoctypesystemkeywordloop); michael@0: } michael@0: case '\"': { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenDoctypeSystemKeywordAndQuote(); michael@0: } michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\'': { michael@0: if (P::reportErrors) { michael@0: errNoSpaceBetweenDoctypeSystemKeywordAndQuote(); michael@0: } michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errExpectedPublicId(); michael@0: } michael@0: forceQuirks = true; michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: afterdoctypesystemkeywordloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\r': { michael@0: silentCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: silentLineFeed(); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '\"': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\'': { michael@0: clearLongStrBuf(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); michael@0: NS_HTML5_BREAK(beforedoctypesystemidentifierloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errExpectedSystemId(); michael@0: } michael@0: forceQuirks = true; michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: bogusDoctype(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: beforedoctypesystemidentifierloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\'': { michael@0: systemIdentifier = longStrBufToString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errGtInSystemId(); michael@0: } michael@0: forceQuirks = true; michael@0: systemIdentifier = longStrBufToString(); michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\'': { michael@0: publicIdentifier = longStrBufToString(); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (P::reportErrors) { michael@0: errGtInPublicId(); michael@0: } michael@0: forceQuirks = true; michael@0: publicIdentifier = longStrBufToString(); michael@0: emitDoctypeToken(pos); michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\r': { michael@0: appendLongStrBufCarriageReturn(); michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\n': { michael@0: appendLongStrBufLineFeed(); michael@0: continue; michael@0: } michael@0: case '\0': { michael@0: c = 0xfffd; michael@0: } michael@0: default: { michael@0: appendLongStrBuf(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION: { michael@0: for (; ; ) { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '\?': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK, reconsume, pos); michael@0: NS_HTML5_BREAK(processinginstructionloop); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: processinginstructionloop_end: ; michael@0: } michael@0: case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK: { michael@0: if (++pos == endPos) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: c = checkChar(buf, pos); michael@0: switch(c) { michael@0: case '>': { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos); michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: } michael@0: stateloop_end: ; michael@0: flushChars(buf, pos); michael@0: stateSave = state; michael@0: returnStateSave = returnState; michael@0: return pos; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::initDoctypeFields() michael@0: { michael@0: doctypeName = nsHtml5Atoms::emptystring; michael@0: if (systemIdentifier) { michael@0: nsHtml5Portability::releaseString(systemIdentifier); michael@0: systemIdentifier = nullptr; michael@0: } michael@0: if (publicIdentifier) { michael@0: nsHtml5Portability::releaseString(publicIdentifier); michael@0: publicIdentifier = nullptr; michael@0: } michael@0: forceQuirks = false; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitCarriageReturn(char16_t* buf, int32_t pos) michael@0: { michael@0: silentCarriageReturn(); michael@0: flushChars(buf, pos); michael@0: tokenHandler->characters(nsHtml5Tokenizer::LF, 0, 1); michael@0: cstart = INT32_MAX; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitReplacementCharacter(char16_t* buf, int32_t pos) michael@0: { michael@0: flushChars(buf, pos); michael@0: tokenHandler->zeroOriginatingReplacementCharacter(); michael@0: cstart = pos + 1; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitPlaintextReplacementCharacter(char16_t* buf, int32_t pos) michael@0: { michael@0: flushChars(buf, pos); michael@0: tokenHandler->characters(REPLACEMENT_CHARACTER, 0, 1); michael@0: cstart = pos + 1; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::setAdditionalAndRememberAmpersandLocation(char16_t add) michael@0: { michael@0: additional = add; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::bogusDoctype() michael@0: { michael@0: errBogusDoctype(); michael@0: forceQuirks = true; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::bogusDoctypeWithoutQuirks() michael@0: { michael@0: errBogusDoctype(); michael@0: forceQuirks = false; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitOrAppendStrBuf(int32_t returnState) michael@0: { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: appendStrBufToLongStrBuf(); michael@0: } else { michael@0: emitStrBuf(); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::handleNcrValue(int32_t returnState) michael@0: { michael@0: if (value <= 0xFFFF) { michael@0: if (value >= 0x80 && value <= 0x9f) { michael@0: errNcrInC1Range(); michael@0: char16_t* val = nsHtml5NamedCharacters::WINDOWS_1252[value - 0x80]; michael@0: emitOrAppendOne(val, returnState); michael@0: } else if (value == 0x0) { michael@0: errNcrZero(); michael@0: emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState); michael@0: } else if ((value & 0xF800) == 0xD800) { michael@0: errNcrSurrogate(); michael@0: emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState); michael@0: } else { michael@0: char16_t ch = (char16_t) value; michael@0: bmpChar[0] = ch; michael@0: emitOrAppendOne(bmpChar, returnState); michael@0: } michael@0: } else if (value <= 0x10FFFF) { michael@0: astralChar[0] = (char16_t) (NS_HTML5TOKENIZER_LEAD_OFFSET + (value >> 10)); michael@0: astralChar[1] = (char16_t) (0xDC00 + (value & 0x3FF)); michael@0: emitOrAppendTwo(astralChar, returnState); michael@0: } else { michael@0: errNcrOutOfRange(); michael@0: emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::eof() michael@0: { michael@0: int32_t state = stateSave; michael@0: int32_t returnState = returnStateSave; michael@0: eofloop: for (; ; ) { michael@0: switch(state) { michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN: michael@0: case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_TAG_OPEN: { michael@0: errEofAfterLt(); michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); michael@0: emitStrBuf(); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: { michael@0: errEofAfterLt(); michael@0: tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_TAG_NAME: { michael@0: errEofInTagName(); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME: michael@0: case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED: michael@0: case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: { michael@0: errEofWithoutGt(); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: { michael@0: errEofInAttributeName(); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME: michael@0: case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: { michael@0: errEofWithoutGt(); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED: michael@0: case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: { michael@0: errEofInAttributeValue(); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_BOGUS_COMMENT: { michael@0: emitComment(0, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: { michael@0: emitComment(0, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: { michael@0: errBogusComment(); michael@0: clearLongStrBuf(); michael@0: emitComment(0, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: { michael@0: errBogusComment(); michael@0: emitComment(0, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: { michael@0: if (index < 6) { michael@0: errBogusComment(); michael@0: emitComment(0, 0); michael@0: } else { michael@0: errEofInDoctype(); michael@0: doctypeName = nsHtml5Atoms::emptystring; michael@0: if (systemIdentifier) { michael@0: nsHtml5Portability::releaseString(systemIdentifier); michael@0: systemIdentifier = nullptr; michael@0: } michael@0: if (publicIdentifier) { michael@0: nsHtml5Portability::releaseString(publicIdentifier); michael@0: publicIdentifier = nullptr; michael@0: } michael@0: forceQuirks = true; michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_START: michael@0: case NS_HTML5TOKENIZER_COMMENT: { michael@0: errEofInComment(); michael@0: emitComment(0, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_END: { michael@0: errEofInComment(); michael@0: emitComment(2, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_END_DASH: michael@0: case NS_HTML5TOKENIZER_COMMENT_START_DASH: { michael@0: errEofInComment(); michael@0: emitComment(1, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_COMMENT_END_BANG: { michael@0: errEofInComment(); michael@0: emitComment(3, 0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE: michael@0: case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: { michael@0: errEofInDoctype(); michael@0: forceQuirks = true; michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_NAME: { michael@0: errEofInDoctype(); michael@0: strBufToDoctypeName(); michael@0: forceQuirks = true; michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_UBLIC: michael@0: case NS_HTML5TOKENIZER_DOCTYPE_YSTEM: michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME: michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD: michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD: michael@0: case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: { michael@0: errEofInDoctype(); michael@0: forceQuirks = true; michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: michael@0: case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: { michael@0: errEofInPublicId(); michael@0: forceQuirks = true; michael@0: publicIdentifier = longStrBufToString(); michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER: michael@0: case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: michael@0: case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: { michael@0: errEofInDoctype(); michael@0: forceQuirks = true; michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: michael@0: case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: { michael@0: errEofInSystemId(); michael@0: forceQuirks = true; michael@0: systemIdentifier = longStrBufToString(); michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: { michael@0: errEofInDoctype(); michael@0: forceQuirks = true; michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: { michael@0: emitDoctypeToken(0); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: { michael@0: emitOrAppendStrBuf(returnState); michael@0: state = returnState; michael@0: continue; michael@0: } michael@0: case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: { michael@0: errNoNamedCharacterMatch(); michael@0: emitOrAppendStrBuf(returnState); michael@0: state = returnState; michael@0: continue; michael@0: } michael@0: case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: { michael@0: for (; ; ) { michael@0: char16_t c = '\0'; michael@0: entCol++; michael@0: for (; ; ) { michael@0: if (hi == -1) { michael@0: NS_HTML5_BREAK(hiloop); michael@0: } michael@0: if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) { michael@0: NS_HTML5_BREAK(hiloop); michael@0: } michael@0: if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) { michael@0: NS_HTML5_BREAK(outer); michael@0: } else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) { michael@0: hi--; michael@0: } else { michael@0: NS_HTML5_BREAK(hiloop); michael@0: } michael@0: } michael@0: hiloop_end: ; michael@0: for (; ; ) { michael@0: if (hi < lo) { michael@0: NS_HTML5_BREAK(outer); michael@0: } michael@0: if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) { michael@0: candidate = lo; michael@0: strBufMark = strBufLen; michael@0: lo++; michael@0: } else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) { michael@0: NS_HTML5_BREAK(outer); michael@0: } else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) { michael@0: lo++; michael@0: } else { michael@0: NS_HTML5_BREAK(loloop); michael@0: } michael@0: } michael@0: loloop_end: ; michael@0: if (hi < lo) { michael@0: NS_HTML5_BREAK(outer); michael@0: } michael@0: continue; michael@0: } michael@0: outer_end: ; michael@0: if (candidate == -1) { michael@0: errNoNamedCharacterMatch(); michael@0: emitOrAppendStrBuf(returnState); michael@0: state = returnState; michael@0: NS_HTML5_CONTINUE(eofloop); michael@0: } else { michael@0: const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate]; michael@0: if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: char16_t ch; michael@0: if (strBufMark == strBufLen) { michael@0: ch = '\0'; michael@0: } else { michael@0: ch = strBuf[strBufMark]; michael@0: } michael@0: if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { michael@0: errNoNamedCharacterMatch(); michael@0: appendStrBufToLongStrBuf(); michael@0: state = returnState; michael@0: NS_HTML5_CONTINUE(eofloop); michael@0: } michael@0: } michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: errUnescapedAmpersandInterpretedAsCharacterReference(); michael@0: } else { michael@0: errNotSemicolonTerminated(); michael@0: } michael@0: } michael@0: const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate]; michael@0: if (!val[1]) { michael@0: emitOrAppendOne(val, returnState); michael@0: } else { michael@0: emitOrAppendTwo(val, returnState); michael@0: } michael@0: if (strBufMark < strBufLen) { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: for (int32_t i = strBufMark; i < strBufLen; i++) { michael@0: appendLongStrBuf(strBuf[i]); michael@0: } michael@0: } else { michael@0: tokenHandler->characters(strBuf, strBufMark, strBufLen - strBufMark); michael@0: } michael@0: } michael@0: state = returnState; michael@0: NS_HTML5_CONTINUE(eofloop); michael@0: } michael@0: } michael@0: case NS_HTML5TOKENIZER_CONSUME_NCR: michael@0: case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP: michael@0: case NS_HTML5TOKENIZER_HEX_NCR_LOOP: { michael@0: if (!seenDigits) { michael@0: errNoDigitsInNCR(); michael@0: emitOrAppendStrBuf(returnState); michael@0: state = returnState; michael@0: continue; michael@0: } else { michael@0: errCharRefLacksSemicolon(); michael@0: } michael@0: handleNcrValue(returnState); michael@0: state = returnState; michael@0: continue; michael@0: } michael@0: case NS_HTML5TOKENIZER_CDATA_RSQB: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: { michael@0: tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2); michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: case NS_HTML5TOKENIZER_DATA: michael@0: default: { michael@0: NS_HTML5_BREAK(eofloop); michael@0: } michael@0: } michael@0: } michael@0: eofloop_end: ; michael@0: tokenHandler->eof(); michael@0: return; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitDoctypeToken(int32_t pos) michael@0: { michael@0: cstart = pos + 1; michael@0: tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks); michael@0: doctypeName = nullptr; michael@0: nsHtml5Portability::releaseString(publicIdentifier); michael@0: publicIdentifier = nullptr; michael@0: nsHtml5Portability::releaseString(systemIdentifier); michael@0: systemIdentifier = nullptr; michael@0: } michael@0: michael@0: bool michael@0: nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset) michael@0: { michael@0: if (encodingDeclarationHandler) { michael@0: return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset); michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitOrAppendTwo(const char16_t* val, int32_t returnState) michael@0: { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: appendLongStrBuf(val[0]); michael@0: appendLongStrBuf(val[1]); michael@0: } else { michael@0: tokenHandler->characters(val, 0, 2); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::emitOrAppendOne(const char16_t* val, int32_t returnState) michael@0: { michael@0: if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { michael@0: appendLongStrBuf(val[0]); michael@0: } else { michael@0: tokenHandler->characters(val, 0, 1); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::end() michael@0: { michael@0: strBuf = nullptr; michael@0: longStrBuf = nullptr; michael@0: doctypeName = nullptr; michael@0: if (systemIdentifier) { michael@0: nsHtml5Portability::releaseString(systemIdentifier); michael@0: systemIdentifier = nullptr; michael@0: } michael@0: if (publicIdentifier) { michael@0: nsHtml5Portability::releaseString(publicIdentifier); michael@0: publicIdentifier = nullptr; michael@0: } michael@0: if (tagName) { michael@0: tagName->release(); michael@0: tagName = nullptr; michael@0: } michael@0: if (attributeName) { michael@0: attributeName->release(); michael@0: attributeName = nullptr; michael@0: } michael@0: tokenHandler->endTokenization(); michael@0: if (attributes) { michael@0: attributes->clear(0); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::requestSuspension() michael@0: { michael@0: shouldSuspend = true; michael@0: } michael@0: michael@0: bool michael@0: nsHtml5Tokenizer::isInDataState() michael@0: { michael@0: return (stateSave == NS_HTML5TOKENIZER_DATA); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::resetToDataState() michael@0: { michael@0: strBufLen = 0; michael@0: longStrBufLen = 0; michael@0: stateSave = NS_HTML5TOKENIZER_DATA; michael@0: lastCR = false; michael@0: index = 0; michael@0: forceQuirks = false; michael@0: additional = '\0'; michael@0: entCol = -1; michael@0: firstCharKey = -1; michael@0: lo = 0; michael@0: hi = 0; michael@0: candidate = -1; michael@0: strBufMark = 0; michael@0: prevValue = -1; michael@0: value = 0; michael@0: seenDigits = false; michael@0: endTag = false; michael@0: shouldSuspend = false; michael@0: initDoctypeFields(); michael@0: if (tagName) { michael@0: tagName->release(); michael@0: tagName = nullptr; michael@0: } michael@0: if (attributeName) { michael@0: attributeName->release(); michael@0: attributeName = nullptr; michael@0: } michael@0: if (newAttributesEachTime) { michael@0: if (attributes) { michael@0: delete attributes; michael@0: attributes = nullptr; michael@0: } michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other) michael@0: { michael@0: strBufLen = other->strBufLen; michael@0: if (strBufLen > strBuf.length) { michael@0: strBuf = jArray::newJArray(strBufLen); michael@0: } michael@0: nsHtml5ArrayCopy::arraycopy(other->strBuf, strBuf, strBufLen); michael@0: longStrBufLen = other->longStrBufLen; michael@0: if (longStrBufLen > longStrBuf.length) { michael@0: longStrBuf = jArray::newJArray(longStrBufLen); michael@0: } michael@0: nsHtml5ArrayCopy::arraycopy(other->longStrBuf, longStrBuf, longStrBufLen); michael@0: stateSave = other->stateSave; michael@0: returnStateSave = other->returnStateSave; michael@0: endTagExpectation = other->endTagExpectation; michael@0: endTagExpectationAsArray = other->endTagExpectationAsArray; michael@0: lastCR = other->lastCR; michael@0: index = other->index; michael@0: forceQuirks = other->forceQuirks; michael@0: additional = other->additional; michael@0: entCol = other->entCol; michael@0: firstCharKey = other->firstCharKey; michael@0: lo = other->lo; michael@0: hi = other->hi; michael@0: candidate = other->candidate; michael@0: strBufMark = other->strBufMark; michael@0: prevValue = other->prevValue; michael@0: value = other->value; michael@0: seenDigits = other->seenDigits; michael@0: endTag = other->endTag; michael@0: shouldSuspend = false; michael@0: if (!other->doctypeName) { michael@0: doctypeName = nullptr; michael@0: } else { michael@0: doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner); michael@0: } michael@0: nsHtml5Portability::releaseString(systemIdentifier); michael@0: if (!other->systemIdentifier) { michael@0: systemIdentifier = nullptr; michael@0: } else { michael@0: systemIdentifier = nsHtml5Portability::newStringFromString(other->systemIdentifier); michael@0: } michael@0: nsHtml5Portability::releaseString(publicIdentifier); michael@0: if (!other->publicIdentifier) { michael@0: publicIdentifier = nullptr; michael@0: } else { michael@0: publicIdentifier = nsHtml5Portability::newStringFromString(other->publicIdentifier); michael@0: } michael@0: if (tagName) { michael@0: tagName->release(); michael@0: } michael@0: if (!other->tagName) { michael@0: tagName = nullptr; michael@0: } else { michael@0: tagName = other->tagName->cloneElementName(interner); michael@0: } michael@0: if (attributeName) { michael@0: attributeName->release(); michael@0: } michael@0: if (!other->attributeName) { michael@0: attributeName = nullptr; michael@0: } else { michael@0: attributeName = other->attributeName->cloneAttributeName(interner); michael@0: } michael@0: delete attributes; michael@0: if (!other->attributes) { michael@0: attributes = nullptr; michael@0: } else { michael@0: attributes = other->attributes->cloneAttributes(interner); michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::initializeWithoutStarting() michael@0: { michael@0: confident = false; michael@0: strBuf = jArray::newJArray(64); michael@0: longStrBuf = jArray::newJArray(1024); michael@0: line = 1; michael@0: resetToDataState(); michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::setEncodingDeclarationHandler(nsHtml5StreamParser* encodingDeclarationHandler) michael@0: { michael@0: this->encodingDeclarationHandler = encodingDeclarationHandler; michael@0: } michael@0: michael@0: michael@0: nsHtml5Tokenizer::~nsHtml5Tokenizer() michael@0: { michael@0: MOZ_COUNT_DTOR(nsHtml5Tokenizer); michael@0: delete attributes; michael@0: attributes = nullptr; michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::initializeStatics() michael@0: { michael@0: } michael@0: michael@0: void michael@0: nsHtml5Tokenizer::releaseStatics() michael@0: { michael@0: } michael@0: michael@0: michael@0: #include "nsHtml5TokenizerCppSupplement.h" michael@0: