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