2009-06-28 22:44:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005-2007 Henri Sivonen
|
2010-02-10 09:23:35 +00:00
|
|
|
* Copyright (c) 2007-2010 Mozilla Foundation
|
2010-06-02 11:01:57 +00:00
|
|
|
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
|
2009-06-28 22:44:22 +00: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 11:43:43 +00:00
|
|
|
#include "nsHtml5AtomTable.h"
|
2009-06-28 22:44:22 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
#include "jArray.h"
|
|
|
|
#include "nsHtml5DocumentMode.h"
|
|
|
|
#include "nsHtml5ArrayCopy.h"
|
|
|
|
#include "nsHtml5NamedCharacters.h"
|
2010-06-24 08:54:33 +00:00
|
|
|
#include "nsHtml5NamedCharactersAccel.h"
|
2009-06-28 22:44:22 +00:00
|
|
|
#include "nsHtml5Atoms.h"
|
2009-09-21 13:18:20 +00:00
|
|
|
#include "nsAHtml5TreeBuilderState.h"
|
2010-04-19 13:25:13 +00:00
|
|
|
#include "nsHtml5Macros.h"
|
2010-07-30 10:15:38 +00:00
|
|
|
#include "nsHtml5Highlighter.h"
|
2011-11-01 11:33:11 +00:00
|
|
|
#include "nsHtml5TokenizerLoopPolicies.h"
|
2009-06-28 22:44:22 +00: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 07:32:31 +00: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-28 22:44:22 +00:00
|
|
|
static PRUnichar const TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, NS_ARRAY_LENGTH(TITLE_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, NS_ARRAY_LENGTH(SCRIPT_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, NS_ARRAY_LENGTH(STYLE_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, NS_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const XMP_ARR_DATA[] = { 'x', 'm', 'p' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, NS_ARRAY_LENGTH(XMP_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, NS_ARRAY_LENGTH(TEXTAREA_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, NS_ARRAY_LENGTH(IFRAME_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, NS_ARRAY_LENGTH(NOEMBED_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, NS_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
static PRUnichar const NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' };
|
2012-08-22 15:56:38 +00:00
|
|
|
staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, NS_ARRAY_LENGTH(NOFRAMES_ARR_DATA) };
|
2009-06-28 22:44:22 +00:00
|
|
|
|
2011-11-01 11:33:11 +00:00
|
|
|
nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource)
|
2009-06-28 22:44:22 +00:00
|
|
|
: tokenHandler(tokenHandler),
|
2012-07-30 14:20:58 +00:00
|
|
|
encodingDeclarationHandler(nullptr),
|
2012-08-22 15:56:38 +00:00
|
|
|
bmpChar(jArray<PRUnichar,int32_t>::newJArray(1)),
|
|
|
|
astralChar(jArray<PRUnichar,int32_t>::newJArray(2)),
|
2012-07-30 14:20:58 +00:00
|
|
|
tagName(nullptr),
|
|
|
|
attributeName(nullptr),
|
|
|
|
doctypeName(nullptr),
|
|
|
|
publicIdentifier(nullptr),
|
|
|
|
systemIdentifier(nullptr),
|
|
|
|
attributes(nullptr),
|
2011-11-01 11:33:11 +00:00
|
|
|
viewingXmlSource(viewingXmlSource)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsHtml5Tokenizer);
|
|
|
|
}
|
|
|
|
|
2009-09-21 11:43:43 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner)
|
|
|
|
{
|
|
|
|
this->interner = interner;
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::initLocation(nsString* newPublicId, nsString* newSystemId)
|
|
|
|
{
|
|
|
|
this->systemId = newSystemId;
|
|
|
|
this->publicId = newPublicId;
|
|
|
|
}
|
|
|
|
|
2011-11-01 11:33:11 +00:00
|
|
|
bool
|
|
|
|
nsHtml5Tokenizer::isViewingXmlSource()
|
|
|
|
{
|
|
|
|
return viewingXmlSource;
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsIAtom* endTagExpectation)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2010-04-16 10:52:06 +00:00
|
|
|
this->stateSave = specialTokenizerState;
|
|
|
|
if (specialTokenizerState == NS_HTML5TOKENIZER_DATA) {
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
autoJArray<PRUnichar,int32_t> asArray = nsHtml5Portability::newCharArrayFromLocal(endTagExpectation);
|
2010-04-16 10:52:06 +00:00
|
|
|
this->endTagExpectation = nsHtml5ElementName::elementNameByBuffer(asArray, 0, asArray.length, interner);
|
|
|
|
endTagExpectationToArray();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsHtml5ElementName* endTagExpectation)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2010-04-16 10:52:06 +00:00
|
|
|
this->stateSave = specialTokenizerState;
|
|
|
|
this->endTagExpectation = endTagExpectation;
|
|
|
|
endTagExpectationToArray();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-04-16 10:52:06 +00:00
|
|
|
nsHtml5Tokenizer::endTagExpectationToArray()
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2010-12-09 09:27:57 +00:00
|
|
|
switch(endTagExpectation->getGroup()) {
|
2009-06-28 22:44:22 +00:00
|
|
|
case NS_HTML5TREE_BUILDER_TITLE: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = TITLE_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_SCRIPT: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = SCRIPT_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_STYLE: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = STYLE_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_PLAINTEXT: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = PLAINTEXT_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_XMP: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = XMP_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_TEXTAREA: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = TEXTAREA_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_IFRAME: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = IFRAME_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_NOEMBED: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = NOEMBED_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_NOSCRIPT: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = NOSCRIPT_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case NS_HTML5TREE_BUILDER_NOFRAMES: {
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectationAsArray = NOFRAMES_ARR;
|
2009-06-28 22:44:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::setLineNumber(int32_t line)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
this->line = line;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHtml5HtmlAttributes*
|
|
|
|
nsHtml5Tokenizer::emptyAttributes()
|
|
|
|
{
|
|
|
|
return nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES;
|
|
|
|
}
|
|
|
|
|
2010-03-30 08:21:36 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::appendStrBuf(PRUnichar c)
|
|
|
|
{
|
|
|
|
if (strBufLen == strBuf.length) {
|
2012-08-22 15:56:38 +00:00
|
|
|
jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(strBuf.length + NS_HTML5TOKENIZER_BUFFER_GROW_BY);
|
2010-03-30 08:21:36 +00:00
|
|
|
nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length);
|
|
|
|
strBuf = newBuf;
|
|
|
|
}
|
|
|
|
strBuf[strBufLen++] = c;
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
nsString*
|
|
|
|
nsHtml5Tokenizer::strBufToString()
|
|
|
|
{
|
|
|
|
return nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::strBufToDoctypeName()
|
|
|
|
{
|
2009-09-21 11:43:43 +00:00
|
|
|
doctypeName = nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::emitStrBuf()
|
|
|
|
{
|
|
|
|
if (strBufLen > 0) {
|
|
|
|
tokenHandler->characters(strBuf, 0, strBufLen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-30 08:21:36 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::appendLongStrBuf(PRUnichar c)
|
|
|
|
{
|
|
|
|
if (longStrBufLen == longStrBuf.length) {
|
2012-08-22 15:56:38 +00:00
|
|
|
jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(longStrBufLen + (longStrBufLen >> 1));
|
2010-03-30 08:21:36 +00:00
|
|
|
nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length);
|
|
|
|
longStrBuf = newBuf;
|
|
|
|
}
|
|
|
|
longStrBuf[longStrBufLen++] = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::appendLongStrBuf(PRUnichar* buffer, int32_t offset, int32_t length)
|
2010-03-30 08:21:36 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t reqLen = longStrBufLen + length;
|
2010-03-30 08:21:36 +00:00
|
|
|
if (longStrBuf.length < reqLen) {
|
2012-08-22 15:56:38 +00:00
|
|
|
jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(reqLen + (reqLen >> 1));
|
2010-03-30 08:21:36 +00:00
|
|
|
nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length);
|
|
|
|
longStrBuf = newBuf;
|
|
|
|
}
|
|
|
|
nsHtml5ArrayCopy::arraycopy(buffer, offset, longStrBuf, longStrBufLen, length);
|
|
|
|
longStrBufLen = reqLen;
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
nsString*
|
|
|
|
nsHtml5Tokenizer::longStrBufToString()
|
|
|
|
{
|
|
|
|
return nsHtml5Portability::newStringFromBuffer(longStrBuf, 0, longStrBufLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitComment(int32_t provisionalHyphens, int32_t pos)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
tokenHandler->comment(longStrBuf, 0, longStrBufLen - provisionalHyphens);
|
|
|
|
cstart = pos + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::flushChars(PRUnichar* buf, int32_t pos)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
if (pos > cstart) {
|
|
|
|
tokenHandler->characters(buf, cstart, pos - cstart);
|
|
|
|
}
|
2012-09-28 06:57:33 +00:00
|
|
|
cstart = INT32_MAX;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
2010-03-30 08:21:36 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::resetAttributes()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
attributes = nullptr;
|
2010-03-30 08:21:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::strBufToElementNameString()
|
|
|
|
{
|
2009-09-21 11:43:43 +00:00
|
|
|
tagName = nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t
|
|
|
|
nsHtml5Tokenizer::emitCurrentTagToken(bool selfClosing, int32_t pos)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
cstart = pos + 1;
|
2011-11-01 11:33:11 +00:00
|
|
|
maybeErrSlashInEndTag(selfClosing);
|
2009-06-28 22:44:22 +00:00
|
|
|
stateSave = NS_HTML5TOKENIZER_DATA;
|
|
|
|
nsHtml5HtmlAttributes* attrs = (!attributes ? nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES : attributes);
|
|
|
|
if (endTag) {
|
2011-11-01 11:33:11 +00:00
|
|
|
maybeErrAttributesOnEndTag(attrs);
|
2011-11-01 11:33:11 +00:00
|
|
|
if (!viewingXmlSource) {
|
|
|
|
tokenHandler->endTag(tagName);
|
|
|
|
}
|
2009-12-11 00:27:48 +00:00
|
|
|
delete attributes;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (viewingXmlSource) {
|
|
|
|
delete attributes;
|
|
|
|
} else {
|
|
|
|
tokenHandler->startTag(tagName, attrs, selfClosing);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2009-09-21 11:43:43 +00:00
|
|
|
tagName->release();
|
2012-07-30 14:20:58 +00:00
|
|
|
tagName = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
resetAttributes();
|
|
|
|
return stateSave;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::attributeNameComplete()
|
|
|
|
{
|
2009-09-21 11:43:43 +00:00
|
|
|
attributeName = nsHtml5AttributeName::nameByBuffer(strBuf, 0, strBufLen, interner);
|
|
|
|
if (!attributes) {
|
|
|
|
attributes = new nsHtml5HtmlAttributes(0);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
if (attributes->contains(attributeName)) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errDuplicateAttribute();
|
2009-06-28 22:44:22 +00:00
|
|
|
attributeName->release();
|
2012-07-30 14:20:58 +00:00
|
|
|
attributeName = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::addAttributeWithoutValue()
|
|
|
|
{
|
2009-09-21 07:00:10 +00:00
|
|
|
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributeName) {
|
2009-06-28 22:44:22 +00:00
|
|
|
attributes->addAttribute(attributeName, nsHtml5Portability::newEmptyString());
|
2012-07-30 14:20:58 +00:00
|
|
|
attributeName = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::addAttributeWithValue()
|
|
|
|
{
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributeName) {
|
2009-12-15 13:19:09 +00:00
|
|
|
nsString* val = longStrBufToString();
|
2010-07-30 10:15:38 +00:00
|
|
|
if (mViewSource) {
|
|
|
|
mViewSource->MaybeLinkifyAttributeValue(attributeName, val);
|
|
|
|
}
|
2009-12-15 13:19:09 +00:00
|
|
|
attributes->addAttribute(attributeName, val);
|
2012-07-30 14:20:58 +00:00
|
|
|
attributeName = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::start()
|
|
|
|
{
|
2009-09-21 13:18:20 +00:00
|
|
|
initializeWithoutStarting();
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->startTokenization(this);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-06-28 22:44:22 +00:00
|
|
|
nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer* buffer)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t state = stateSave;
|
|
|
|
int32_t returnState = returnStateSave;
|
2009-06-28 22:44:22 +00:00
|
|
|
PRUnichar c = '\0';
|
2011-10-17 14:59:28 +00:00
|
|
|
shouldSuspend = false;
|
|
|
|
lastCR = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t start = buffer->getStart();
|
|
|
|
int32_t pos = start - 1;
|
2009-06-28 22:44:22 +00:00
|
|
|
switch(state) {
|
|
|
|
case NS_HTML5TOKENIZER_DATA:
|
|
|
|
case NS_HTML5TOKENIZER_RCDATA:
|
2009-11-30 15:34:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA:
|
2009-06-28 22:44:22 +00:00
|
|
|
case NS_HTML5TOKENIZER_PLAINTEXT:
|
2009-11-30 15:34:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_RAWTEXT:
|
2009-06-28 22:44:22 +00:00
|
|
|
case NS_HTML5TOKENIZER_CDATA_SECTION:
|
2009-11-30 15:34:51 +00: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 13:35:34 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:
|
2009-11-30 15:34:51 +00: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-28 22:44:22 +00:00
|
|
|
cstart = start;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2012-09-28 06:57:33 +00:00
|
|
|
cstart = INT32_MAX;
|
2009-06-28 22:44:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-07-30 10:15:38 +00:00
|
|
|
if (mViewSource) {
|
|
|
|
mViewSource->SetBuffer(buffer);
|
2011-11-01 11:33:11 +00:00
|
|
|
pos = stateLoop<nsHtml5ViewSourcePolicy>(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd());
|
2010-07-30 10:15:38 +00:00
|
|
|
mViewSource->DropBuffer((pos == buffer->getEnd()) ? pos : pos + 1);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
pos = stateLoop<nsHtml5SilentPolicy>(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd());
|
2010-07-30 10:15:38 +00:00
|
|
|
}
|
|
|
|
if (pos == buffer->getEnd()) {
|
|
|
|
buffer->setStart(pos);
|
|
|
|
} else {
|
|
|
|
buffer->setStart(pos + 1);
|
|
|
|
}
|
|
|
|
return lastCR;
|
|
|
|
}
|
|
|
|
|
2011-11-01 11:33:11 +00:00
|
|
|
template<class P>
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t
|
|
|
|
nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar* buf, bool reconsume, int32_t returnState, int32_t endPos)
|
2010-07-30 10:15:38 +00:00
|
|
|
{
|
|
|
|
stateloop: for (; ; ) {
|
|
|
|
switch(state) {
|
|
|
|
case NS_HTML5TOKENIZER_DATA: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = false;
|
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '&': {
|
|
|
|
flushChars(buf, pos);
|
|
|
|
clearStrBufAndAppend(c);
|
|
|
|
setAdditionalAndRememberAmpersandLocation('\0');
|
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
|
2010-07-30 10:15:38 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '<': {
|
|
|
|
flushChars(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_OPEN, reconsume, pos);
|
2010-07-30 10:15:38 +00:00
|
|
|
NS_HTML5_BREAK(dataloop);
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dataloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_TAG_OPEN: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
endTag = false;
|
|
|
|
clearStrBufAndAppend((PRUnichar) (c + 0x20));
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
|
2010-07-30 10:15:38 +00:00
|
|
|
NS_HTML5_BREAK(tagopenloop);
|
|
|
|
} else if (c >= 'a' && c <= 'z') {
|
|
|
|
endTag = false;
|
|
|
|
clearStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
|
2010-07-30 10:15:38 +00:00
|
|
|
NS_HTML5_BREAK(tagopenloop);
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '!': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN, reconsume, pos);
|
2010-07-30 10:15:38 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '/': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CLOSE_TAG_OPEN, reconsume, pos);
|
2010-07-30 10:15:38 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\?': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (viewingXmlSource) {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errProcessingInstruction();
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errLtGt();
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 2);
|
|
|
|
cstart = pos + 1;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBadCharAfterLt(c);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tagopenloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_TAG_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
|
|
|
strBufToElementNameString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
strBufToElementNameString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(tagnameloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
strBufToElementNameString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
strBufToElementNameString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00: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) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '/': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
case '\"':
|
|
|
|
case '\'':
|
2009-07-15 11:31:57 +00:00
|
|
|
case '<':
|
2011-11-01 11:33:11 +00:00
|
|
|
case '=': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBadCharBeforeAttributeNameOrNull(c);
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
c += 0x20;
|
|
|
|
}
|
2010-04-16 10:52:06 +00:00
|
|
|
clearStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(beforeattributenameloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
beforeattributenameloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
|
|
|
attributeNameComplete();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
attributeNameComplete();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
attributeNameComplete();
|
|
|
|
addAttributeWithoutValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '=': {
|
|
|
|
attributeNameComplete();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(attributenameloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
attributeNameComplete();
|
|
|
|
addAttributeWithoutValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
case '\"':
|
|
|
|
case '\'':
|
2011-11-01 11:33:11 +00:00
|
|
|
case '<': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errQuoteOrLtInAttributeNameOrNull(c);
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00: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 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\"': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(beforeattributevalueloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '&': {
|
|
|
|
clearLongStrBuf();
|
2011-11-30 13:11:37 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
|
2009-09-21 07:00:10 +00:00
|
|
|
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\'': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errAttributeValueMissing();
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
addAttributeWithoutValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
2009-07-15 11:31:57 +00:00
|
|
|
case '<':
|
2009-06-28 22:44:22 +00:00
|
|
|
case '=':
|
2011-11-01 11:33:11 +00:00
|
|
|
case '`': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errLtOrEqualsOrGraveInUnquotedAttributeOrNull(c);
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
|
2009-09-21 07:00:10 +00:00
|
|
|
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
beforeattributevalueloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '\"': {
|
|
|
|
addAttributeWithValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(attributevaluedoublequotedloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '&': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearStrBufAndAppend(c);
|
|
|
|
setAdditionalAndRememberAmpersandLocation('\"');
|
2009-06-28 22:44:22 +00:00
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00: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 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '/': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(afterattributevaluequotedloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenAttributes();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
afterattributevaluequotedloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(true, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errSlashNotFollowedByGt();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
|
|
|
addAttributeWithValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
addAttributeWithValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '&': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearStrBufAndAppend(c);
|
|
|
|
setAdditionalAndRememberAmpersandLocation('>');
|
2009-06-28 22:44:22 +00:00
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
addAttributeWithValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
case '<':
|
|
|
|
case '\"':
|
|
|
|
case '\'':
|
|
|
|
case '=':
|
2011-11-01 11:33:11 +00:00
|
|
|
case '`': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errUnquotedAttributeValOrNull(c);
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
|
|
|
|
|
|
|
appendLongStrBuf(c);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
addAttributeWithoutValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '=': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
addAttributeWithoutValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
if (shouldSuspend) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
case '\"':
|
|
|
|
case '\'':
|
2011-11-01 11:33:11 +00:00
|
|
|
case '<': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errQuoteOrLtInAttributeNameOrNull(c);
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
|
|
|
addAttributeWithoutValue();
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
c += 0x20;
|
|
|
|
}
|
2010-04-16 10:52:06 +00:00
|
|
|
clearStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '-': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(markupdeclarationopenloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case 'd':
|
|
|
|
case 'D': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBufAndAppend(c);
|
2009-06-28 22:44:22 +00:00
|
|
|
index = 0;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '[': {
|
2010-09-15 08:37:55 +00:00
|
|
|
if (tokenHandler->cdataSectionAllowed()) {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBufAndAppend(c);
|
2009-06-28 22:44:22 +00:00
|
|
|
index = 0;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_START, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
clearLongStrBuf();
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
markupdeclarationopenloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\0': {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '-': {
|
2010-04-16 10:52:06 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(markupdeclarationhyphenloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
markupdeclarationhyphenloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_START: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '-': {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START_DASH, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errPrematureEndOfComment();
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(0, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(commentstartloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(commentstartloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commentstartloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '-': {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(commentloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00: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 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '-': {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(commentenddashloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commentenddashloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_END: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '>': {
|
|
|
|
emitComment(2, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '-': {
|
2009-07-15 11:31:57 +00:00
|
|
|
adjustDoubleHyphenAndAppendToLongStrBufAndErr(c);
|
2009-06-28 22:44:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
adjustDoubleHyphenAndAppendToLongStrBufCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
adjustDoubleHyphenAndAppendToLongStrBufLineFeed();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-06-19 06:38:41 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
case '!': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errHyphenHyphenBang();
|
|
|
|
}
|
2009-07-15 11:31:57 +00:00
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_BANG, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
adjustDoubleHyphenAndAppendToLongStrBufAndErr(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-19 06:38:41 +00:00
|
|
|
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_END_BANG: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '>': {
|
|
|
|
emitComment(3, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_START_DASH: {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '-': {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errPrematureEndOfComment();
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(1, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CDATA_START: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
if (index < 6) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (c == nsHtml5Tokenizer::CDATA_LSQB[index]) {
|
2009-06-28 22:44:22 +00:00
|
|
|
appendLongStrBuf(c);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
} else {
|
2010-07-26 13:13:51 +00:00
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
break;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CDATA_SECTION: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case ']': {
|
|
|
|
flushChars(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(cdatasectionloop);
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00: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 ']': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB_RSQB, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(cdatarsqb);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
|
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
cdatarsqb_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '>': {
|
|
|
|
cstart = pos + 1;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2);
|
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\'': {
|
|
|
|
addAttributeWithValue();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '&': {
|
|
|
|
clearStrBufAndAppend(c);
|
|
|
|
setAdditionalAndRememberAmpersandLocation('\'');
|
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(attributevaluesinglequotedloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBufCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBufLineFeed();
|
2009-06-28 22:44:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00: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;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '#': {
|
|
|
|
appendStrBuf('#');
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_NCR, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (c == additional) {
|
|
|
|
emitOrAppendStrBuf(returnState);
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
if (c >= 'a' && c <= 'z') {
|
|
|
|
firstCharKey = c - 'a' + 26;
|
|
|
|
} else if (c >= 'A' && c <= 'Z') {
|
|
|
|
firstCharKey = c - 'A';
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
appendStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP, reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: {
|
|
|
|
{
|
2009-06-28 22:44:22 +00:00
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
if (c == '\0') {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t hilo = 0;
|
2010-07-26 13:13:51 +00:00
|
|
|
if (c <= 'z') {
|
2012-08-22 15:56:38 +00:00
|
|
|
const int32_t* row = nsHtml5NamedCharactersAccel::HILO_ACCEL[c];
|
2010-07-26 13:13:51 +00:00
|
|
|
if (row) {
|
|
|
|
hilo = row[firstCharKey];
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
if (!hilo) {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
appendStrBuf(c);
|
|
|
|
lo = hilo & 0xFFFF;
|
|
|
|
hi = hilo >> 16;
|
|
|
|
entCol = -1;
|
|
|
|
candidate = -1;
|
|
|
|
strBufMark = 0;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL, reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
if (c == '\0') {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
entCol++;
|
|
|
|
for (; ; ) {
|
|
|
|
if (hi < lo) {
|
|
|
|
NS_HTML5_BREAK(outer);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-09-28 07:32:31 +00:00
|
|
|
if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) {
|
2010-07-26 13:13:51 +00:00
|
|
|
candidate = lo;
|
|
|
|
strBufMark = strBufLen;
|
|
|
|
lo++;
|
2010-09-28 07:32:31 +00:00
|
|
|
} else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) {
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(outer);
|
2010-09-28 07:32:31 +00:00
|
|
|
} else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) {
|
2010-07-26 13:13:51 +00:00
|
|
|
lo++;
|
|
|
|
} else {
|
|
|
|
NS_HTML5_BREAK(loloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
loloop_end: ;
|
|
|
|
for (; ; ) {
|
|
|
|
if (hi < lo) {
|
|
|
|
NS_HTML5_BREAK(outer);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-09-28 07:32:31 +00:00
|
|
|
if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) {
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(hiloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-09-28 07:32:31 +00:00
|
|
|
if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) {
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(outer);
|
2010-09-28 07:32:31 +00:00
|
|
|
} else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) {
|
2010-07-26 13:13:51 +00:00
|
|
|
hi--;
|
|
|
|
} else {
|
|
|
|
NS_HTML5_BREAK(hiloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
hiloop_end: ;
|
2011-11-30 13:11:37 +00:00
|
|
|
if (c == ';') {
|
|
|
|
if (entCol + 1 == nsHtml5NamedCharacters::NAMES[lo].length()) {
|
|
|
|
candidate = lo;
|
|
|
|
strBufMark = strBufLen;
|
|
|
|
}
|
|
|
|
NS_HTML5_BREAK(outer);
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (hi < lo) {
|
|
|
|
NS_HTML5_BREAK(outer);
|
|
|
|
}
|
|
|
|
appendStrBuf(c);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
outer_end: ;
|
|
|
|
if (candidate == -1) {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
} else {
|
2010-09-28 07:32:31 +00:00
|
|
|
const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate];
|
|
|
|
if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') {
|
2010-07-26 13:13:51 +00: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')) {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
appendStrBufToLongStrBuf();
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errUnescapedAmpersandInterpretedAsCharacterReference();
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNotSemicolonTerminated();
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
P::completedNamedCharacterReference(mViewSource);
|
2010-07-26 13:13:51 +00:00
|
|
|
const PRUnichar* val = nsHtml5NamedCharacters::VALUES[candidate];
|
2010-11-23 11:49:27 +00:00
|
|
|
if (!val[1]) {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitOrAppendOne(val, returnState);
|
2010-11-23 11:49:27 +00:00
|
|
|
} else {
|
|
|
|
emitOrAppendTwo(val, returnState);
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
if (strBufMark < strBufLen) {
|
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = strBufMark; i < strBufLen; i++) {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBuf(strBuf[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tokenHandler->characters(strBuf, strBufMark, strBufLen - strBufMark);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-30 13:11:37 +00:00
|
|
|
bool earlyBreak = (c == ';' && strBufMark == strBufLen);
|
2010-07-26 13:13:51 +00:00
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2011-11-30 13:11:37 +00:00
|
|
|
cstart = earlyBreak ? pos + 1 : pos;
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
2011-11-30 13:11:37 +00:00
|
|
|
reconsume = !earlyBreak;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CONSUME_NCR: {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
prevValue = -1;
|
|
|
|
value = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
seenDigits = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
switch(c) {
|
|
|
|
case 'x':
|
|
|
|
case 'X': {
|
|
|
|
appendStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_HEX_NCR_LOOP, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
default: {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP, reconsume, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (value < prevValue) {
|
|
|
|
value = 0x110000;
|
|
|
|
}
|
|
|
|
prevValue = value;
|
|
|
|
if (c >= '0' && c <= '9') {
|
2011-10-17 14:59:28 +00:00
|
|
|
seenDigits = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
value *= 10;
|
|
|
|
value += c - '0';
|
|
|
|
continue;
|
|
|
|
} else if (c == ';') {
|
|
|
|
if (seenDigits) {
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos + 1;
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(decimalloop);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoDigitsInNCR();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
appendStrBuf(';');
|
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos + 1;
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (!seenDigits) {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoDigitsInNCR();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errCharRefLacksSemicolon();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(decimalloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
decimalloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_HANDLE_NCR_VALUE: {
|
|
|
|
handleNcrValue(returnState);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
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') {
|
2011-10-17 14:59:28 +00:00
|
|
|
seenDigits = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
value *= 16;
|
|
|
|
value += c - '0';
|
|
|
|
continue;
|
|
|
|
} else if (c >= 'A' && c <= 'F') {
|
2011-10-17 14:59:28 +00:00
|
|
|
seenDigits = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
value *= 16;
|
|
|
|
value += c - 'A' + 10;
|
|
|
|
continue;
|
|
|
|
} else if (c >= 'a' && c <= 'f') {
|
2011-10-17 14:59:28 +00:00
|
|
|
seenDigits = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
value *= 16;
|
|
|
|
value += c - 'a' + 10;
|
|
|
|
continue;
|
|
|
|
} else if (c == ';') {
|
|
|
|
if (seenDigits) {
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos + 1;
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoDigitsInNCR();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
appendStrBuf(';');
|
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos + 1;
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (!seenDigits) {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoDigitsInNCR();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errCharRefLacksSemicolon();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
cstart = pos;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_PLAINTEXT: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
2010-12-09 09:27:58 +00:00
|
|
|
emitPlaintextReplacementCharacter(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
default: {
|
2009-06-28 22:44:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errLtSlashGt();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
cstart = pos + 1;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGarbageAfterLtSlash();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBufAndAppend('\n');
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGarbageAfterLtSlash();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBufAndAppend('\n');
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
c += 0x20;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (c >= 'a' && c <= 'z') {
|
2011-10-17 14:59:28 +00:00
|
|
|
endTag = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
clearStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGarbageAfterLtSlash();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_RCDATA: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '&': {
|
|
|
|
flushChars(buf, pos);
|
|
|
|
clearStrBufAndAppend(c);
|
|
|
|
additional = '\0';
|
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '<': {
|
|
|
|
flushChars(buf, pos);
|
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentLineFeed();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_RAWTEXT: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '<': {
|
|
|
|
flushChars(buf, pos);
|
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(rawtextloop);
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
default: {
|
|
|
|
continue;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
rawtextloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '/': {
|
|
|
|
index = 0;
|
|
|
|
clearStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(rawtextrcdatalessthansignloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
rawtextrcdatalessthansignloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00: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;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
appendStrBuf(c);
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
endTag = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
tagName = endTagExpectation;
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '/': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, returnState, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_BOGUS_COMMENT: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2009-06-28 22:44:22 +00:00
|
|
|
case '>': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitComment(0, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(boguscommentloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
boguscommentloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: {
|
|
|
|
boguscommenthyphenloop: for (; ; ) {
|
2009-06-28 22:44:22 +00:00
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
|
|
|
emitComment(0, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
appendSecondHyphenToBogusComment();
|
|
|
|
NS_HTML5_CONTINUE(boguscommenthyphenloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBufCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBufLineFeed();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBuf(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '<': {
|
|
|
|
flushChars(buf, pos);
|
|
|
|
returnState = state;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataloop);
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
switch(c) {
|
|
|
|
case '/': {
|
|
|
|
index = 0;
|
|
|
|
clearStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '!': {
|
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
|
|
|
cstart = pos;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdatalessthansignloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdatalessthansignloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
c = checkChar(buf, pos);
|
2009-11-30 15:34:51 +00:00
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapestartloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataescapestartloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapestartdashloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataescapestartdashloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '<': {
|
|
|
|
flushChars(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapeddashdashloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentLineFeed();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapeddashdashloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataescapeddashdashloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapedloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '<': {
|
|
|
|
flushChars(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentLineFeed();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataescapedloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
switch(c) {
|
|
|
|
case '-': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '<': {
|
2009-06-28 22:44:22 +00:00
|
|
|
flushChars(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapeddashloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataescapeddashloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '/': {
|
|
|
|
index = 0;
|
|
|
|
clearStrBuf();
|
|
|
|
returnState = NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case 'S':
|
|
|
|
case 's': {
|
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
|
|
|
cstart = pos;
|
|
|
|
index = 1;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdataescapedlessthanloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
2009-06-28 22:44:22 +00:00
|
|
|
cstart = pos;
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdataescapedlessthanloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
|
2010-07-26 13:13:51 +00:00
|
|
|
if (index < 6) {
|
|
|
|
PRUnichar folded = c;
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
folded += 0x20;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2010-07-26 13:13:51 +00:00
|
|
|
}
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f':
|
|
|
|
case '/':
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdatadoubleescapestartloop);
|
|
|
|
}
|
|
|
|
default: {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdatadoubleescapestartloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdatadoubleescapedloop);
|
|
|
|
}
|
|
|
|
case '<': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdatadoubleescapedloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
c = checkChar(buf, pos);
|
2009-06-28 22:44:22 +00:00
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdatadoubleescapeddashloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '<': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdatadoubleescapeddashloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '-': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '<': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdatadoubleescapeddashdashloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
|
|
|
emitReplacementCharacter(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdatadoubleescapeddashdashloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '/': {
|
|
|
|
index = 0;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(scriptdatadoubleescapedlessthanloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
scriptdatadoubleescapedlessthanloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
if (index < 6) {
|
|
|
|
PRUnichar folded = c;
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
folded += 0x20;
|
|
|
|
}
|
|
|
|
if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
emitCarriageReturn(buf, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f':
|
|
|
|
case '/':
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
if (index < 6) {
|
|
|
|
PRUnichar folded = c;
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
folded += 0x20;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (folded == nsHtml5Tokenizer::OCTYPE[index]) {
|
|
|
|
appendLongStrBuf(c);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
index++;
|
|
|
|
continue;
|
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(markupdeclarationdoctypeloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
markupdeclarationdoctypeloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
initDoctypeFields();
|
|
|
|
switch(c) {
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(doctypeloop);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errMissingSpaceBeforeDoctypeName();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(doctypeloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
doctypeloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-11-30 15:34:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2009-11-30 15:34:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNamelessDoctype();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
c += 0x20;
|
|
|
|
}
|
|
|
|
clearStrBufAndAppend(c);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(beforedoctypenameloop);
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
beforedoctypenameloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_NAME: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2009-11-30 15:34:51 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
|
|
|
strBufToDoctypeName();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
strBufToDoctypeName();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(doctypenameloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
strBufToDoctypeName();
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
c += 0x0020;
|
|
|
|
}
|
|
|
|
appendStrBuf(c);
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
doctypenameloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case 'p':
|
|
|
|
case 'P': {
|
|
|
|
index = 0;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_UBLIC, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(afterdoctypenameloop);
|
|
|
|
}
|
|
|
|
case 's':
|
|
|
|
case 'S': {
|
|
|
|
index = 0;
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_YSTEM, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
afterdoctypenameloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_UBLIC: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
if (index < 5) {
|
2009-11-30 15:34:51 +00:00
|
|
|
PRUnichar folded = c;
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
folded += 0x20;
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
if (folded != nsHtml5Tokenizer::UBLIC[index]) {
|
|
|
|
bogusDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
index++;
|
|
|
|
continue;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(doctypeublicloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doctypeublicloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2010-07-26 13:13:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\f': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(afterdoctypepublickeywordloop);
|
|
|
|
}
|
|
|
|
case '\"': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenDoctypePublicKeywordAndQuote();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\'': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenDoctypePublicKeywordAndQuote();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errExpectedPublicId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
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();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(beforedoctypepublicidentifierloop);
|
|
|
|
}
|
|
|
|
case '\'': {
|
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errExpectedPublicId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
beforedoctypepublicidentifierloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
2010-07-26 13:13:51 +00:00
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
c = checkChar(buf, pos);
|
2009-11-30 15:34:51 +00:00
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\"': {
|
|
|
|
publicIdentifier = longStrBufToString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(doctypepublicidentifierdoublequotedloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGtInPublicId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
publicIdentifier = longStrBufToString();
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBufCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBufLineFeed();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
appendLongStrBuf(c);
|
2009-06-28 22:44:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
doctypepublicidentifierdoublequotedloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(afterdoctypepublicidentifierloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\"': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenPublicAndSystemIds();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\'': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenPublicAndSystemIds();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
afterdoctypepublicidentifierloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\"': {
|
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(betweendoctypepublicandsystemidentifiersloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\'': {
|
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
betweendoctypepublicandsystemidentifiersloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\"': {
|
|
|
|
systemIdentifier = longStrBufToString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGtInSystemId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
systemIdentifier = longStrBufToString();
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
case '>': {
|
2010-07-26 13:13:51 +00:00
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
default: {
|
2010-07-26 13:13:51 +00:00
|
|
|
bogusDoctypeWithoutQuirks();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(afterdoctypesystemidentifierloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
afterdoctypesystemidentifierloop_end: ;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00: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();
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = true;
|
2011-11-30 13:11:37 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(doctypeystemloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doctypeystemloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reconsume = false;
|
2009-11-30 15:34:51 +00:00
|
|
|
} else {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
}
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
silentCarriageReturn();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(afterdoctypesystemkeywordloop);
|
|
|
|
}
|
|
|
|
case '\"': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\'': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errExpectedPublicId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00: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 15:34:51 +00:00
|
|
|
case '\r': {
|
2010-07-26 13:13:51 +00:00
|
|
|
silentCarriageReturn();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
silentLineFeed();
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\f': {
|
2009-11-30 15:34:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\"': {
|
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
case '\'': {
|
|
|
|
clearLongStrBuf();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_BREAK(beforedoctypesystemidentifierloop);
|
|
|
|
}
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errExpectedSystemId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
bogusDoctype();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
beforedoctypesystemidentifierloop_end: ;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\'': {
|
|
|
|
systemIdentifier = longStrBufToString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGtInSystemId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
systemIdentifier = longStrBufToString();
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
|
2009-11-30 15:34:51 +00:00
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
switch(c) {
|
|
|
|
case '\'': {
|
|
|
|
publicIdentifier = longStrBufToString();
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
|
2010-07-26 13:13:51 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
if (P::reportErrors) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errGtInPublicId();
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2010-07-26 13:13:51 +00:00
|
|
|
publicIdentifier = longStrBufToString();
|
|
|
|
emitDoctypeToken(pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
2010-07-26 13:13:51 +00:00
|
|
|
case '\r': {
|
|
|
|
appendLongStrBufCarriageReturn();
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
case '\n': {
|
|
|
|
appendLongStrBufLineFeed();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\0': {
|
|
|
|
c = 0xfffd;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
appendLongStrBuf(c);
|
|
|
|
continue;
|
2009-11-30 15:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '\?': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK, reconsume, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
NS_HTML5_BREAK(processinginstructionloop);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
processinginstructionloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK: {
|
|
|
|
if (++pos == endPos) {
|
|
|
|
NS_HTML5_BREAK(stateloop);
|
|
|
|
}
|
|
|
|
c = checkChar(buf, pos);
|
|
|
|
switch(c) {
|
|
|
|
case '>': {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
default: {
|
2011-11-01 11:33:11 +00:00
|
|
|
state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos);
|
2011-11-01 11:33:11 +00:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stateloop_end: ;
|
|
|
|
flushChars(buf, pos);
|
|
|
|
stateSave = state;
|
|
|
|
returnStateSave = returnState;
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2009-09-21 13:18:20 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::initDoctypeFields()
|
|
|
|
{
|
|
|
|
doctypeName = nsHtml5Atoms::emptystring;
|
2010-04-19 13:25:13 +00:00
|
|
|
if (systemIdentifier) {
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5Portability::releaseString(systemIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
systemIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (publicIdentifier) {
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5Portability::releaseString(publicIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
publicIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = false;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitCarriageReturn(PRUnichar* buf, int32_t pos)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
silentCarriageReturn();
|
|
|
|
flushChars(buf, pos);
|
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LF, 0, 1);
|
2012-09-28 06:57:33 +00:00
|
|
|
cstart = INT32_MAX;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitReplacementCharacter(PRUnichar* buf, int32_t pos)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
flushChars(buf, pos);
|
2010-06-09 06:45:32 +00:00
|
|
|
tokenHandler->zeroOriginatingReplacementCharacter();
|
2010-05-27 13:08:19 +00:00
|
|
|
cstart = pos + 1;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 09:27:58 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitPlaintextReplacementCharacter(PRUnichar* buf, int32_t pos)
|
2010-12-09 09:27:58 +00:00
|
|
|
{
|
|
|
|
flushChars(buf, pos);
|
|
|
|
tokenHandler->characters(REPLACEMENT_CHARACTER, 0, 1);
|
|
|
|
cstart = pos + 1;
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
2010-04-16 10:52:06 +00:00
|
|
|
nsHtml5Tokenizer::setAdditionalAndRememberAmpersandLocation(PRUnichar add)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
additional = add;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::bogusDoctype()
|
|
|
|
{
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::bogusDoctypeWithoutQuirks()
|
|
|
|
{
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = false;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitOrAppendStrBuf(int32_t returnState)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2010-04-16 10:52:06 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2009-06-28 22:44:22 +00:00
|
|
|
appendStrBufToLongStrBuf();
|
|
|
|
} else {
|
|
|
|
emitStrBuf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::handleNcrValue(int32_t returnState)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2009-12-11 00:27:48 +00:00
|
|
|
if (value <= 0xFFFF) {
|
|
|
|
if (value >= 0x80 && value <= 0x9f) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNcrInC1Range();
|
2009-12-11 00:27:48 +00:00
|
|
|
PRUnichar* val = nsHtml5NamedCharacters::WINDOWS_1252[value - 0x80];
|
|
|
|
emitOrAppendOne(val, returnState);
|
|
|
|
} else if (value == 0x0) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNcrZero();
|
2009-12-11 00:27:48 +00:00
|
|
|
emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState);
|
|
|
|
} else if ((value & 0xF800) == 0xD800) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNcrSurrogate();
|
2009-12-11 00:27:48 +00:00
|
|
|
emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState);
|
|
|
|
} else {
|
|
|
|
PRUnichar ch = (PRUnichar) value;
|
|
|
|
bmpChar[0] = ch;
|
|
|
|
emitOrAppendOne(bmpChar, returnState);
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
} else if (value <= 0x10FFFF) {
|
|
|
|
astralChar[0] = (PRUnichar) (NS_HTML5TOKENIZER_LEAD_OFFSET + (value >> 10));
|
|
|
|
astralChar[1] = (PRUnichar) (0xDC00 + (value & 0x3FF));
|
2010-02-10 09:23:35 +00:00
|
|
|
emitOrAppendTwo(astralChar, returnState);
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNcrOutOfRange();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::eof()
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t state = stateSave;
|
|
|
|
int32_t returnState = returnStateSave;
|
2009-06-28 22:44:22 +00:00
|
|
|
eofloop: for (; ; ) {
|
|
|
|
switch(state) {
|
2009-12-16 13:35:34 +00:00
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN:
|
|
|
|
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_TAG_OPEN: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofAfterLt();
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2009-12-16 13:35:34 +00:00
|
|
|
case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: {
|
2009-12-16 12:14:02 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-12-16 12:14:02 +00:00
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: {
|
2009-12-16 12:14:02 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
|
|
|
|
emitStrBuf();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2009-11-30 15:34:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofAfterLt();
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_TAG_NAME: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInTagName();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED:
|
|
|
|
case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofWithoutGt();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInAttributeName();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME:
|
|
|
|
case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofWithoutGt();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED:
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED:
|
|
|
|
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInAttributeValue();
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_BOGUS_COMMENT: {
|
|
|
|
emitComment(0, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: {
|
|
|
|
emitComment(0, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
2009-06-28 22:44:22 +00:00
|
|
|
clearLongStrBuf();
|
|
|
|
emitComment(0, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(0, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: {
|
|
|
|
if (index < 6) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errBogusComment();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(0, 0);
|
|
|
|
} else {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInDoctype();
|
2009-06-28 22:44:22 +00:00
|
|
|
doctypeName = nsHtml5Atoms::emptystring;
|
2010-04-19 13:25:13 +00:00
|
|
|
if (systemIdentifier) {
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5Portability::releaseString(systemIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
systemIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (publicIdentifier) {
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5Portability::releaseString(publicIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
publicIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_START:
|
2010-10-25 09:22:59 +00:00
|
|
|
case NS_HTML5TOKENIZER_COMMENT: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInComment();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(0, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_END: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInComment();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(2, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_END_DASH:
|
|
|
|
case NS_HTML5TOKENIZER_COMMENT_START_DASH: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInComment();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitComment(1, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2009-07-15 11:31:57 +00:00
|
|
|
case NS_HTML5TOKENIZER_COMMENT_END_BANG: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInComment();
|
2009-07-15 11:31:57 +00:00
|
|
|
emitComment(3, 0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-07-15 11:31:57 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE:
|
|
|
|
case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_NAME: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInDoctype();
|
2009-06-28 22:44:22 +00:00
|
|
|
strBufToDoctypeName();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_UBLIC:
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_YSTEM:
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME:
|
2009-11-30 15:34:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD:
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD:
|
2009-06-28 22:44:22 +00:00
|
|
|
case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInPublicId();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
publicIdentifier = longStrBufToString();
|
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
|
2009-11-30 15:34:51 +00:00
|
|
|
case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
|
|
|
|
case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
|
|
|
|
case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInSystemId();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
systemIdentifier = longStrBufToString();
|
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errEofInDoctype();
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: {
|
|
|
|
emitDoctypeToken(0);
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: {
|
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
state = returnState;
|
|
|
|
continue;
|
|
|
|
}
|
2010-02-10 09:23:35 +00:00
|
|
|
case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
2010-02-10 09:23:35 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
state = returnState;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: {
|
2009-06-28 22:44:22 +00:00
|
|
|
for (; ; ) {
|
|
|
|
PRUnichar c = '\0';
|
|
|
|
entCol++;
|
|
|
|
for (; ; ) {
|
|
|
|
if (hi == -1) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(hiloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-09-28 07:32:31 +00:00
|
|
|
if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(hiloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-09-28 07:32:31 +00:00
|
|
|
if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(outer);
|
2010-09-28 07:32:31 +00:00
|
|
|
} else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) {
|
2009-06-28 22:44:22 +00:00
|
|
|
hi--;
|
|
|
|
} else {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(hiloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
hiloop_end: ;
|
|
|
|
for (; ; ) {
|
|
|
|
if (hi < lo) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(outer);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-09-28 07:32:31 +00:00
|
|
|
if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) {
|
2009-06-28 22:44:22 +00:00
|
|
|
candidate = lo;
|
|
|
|
strBufMark = strBufLen;
|
|
|
|
lo++;
|
2010-09-28 07:32:31 +00:00
|
|
|
} else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(outer);
|
2010-09-28 07:32:31 +00:00
|
|
|
} else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) {
|
2009-06-28 22:44:22 +00:00
|
|
|
lo++;
|
|
|
|
} else {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(loloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
loloop_end: ;
|
|
|
|
if (hi < lo) {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(outer);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
outer_end: ;
|
|
|
|
if (candidate == -1) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
state = returnState;
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
2010-09-28 07:32:31 +00:00
|
|
|
const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate];
|
|
|
|
if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') {
|
2010-04-16 10:52:06 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2009-06-28 22:44:22 +00: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')) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoNamedCharacterMatch();
|
2009-06-28 22:44:22 +00:00
|
|
|
appendStrBufToLongStrBuf();
|
|
|
|
state = returnState;
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-01 11:33:11 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
|
|
|
errUnescapedAmpersandInterpretedAsCharacterReference();
|
|
|
|
} else {
|
|
|
|
errNotSemicolonTerminated();
|
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2010-02-10 09:23:35 +00:00
|
|
|
const PRUnichar* val = nsHtml5NamedCharacters::VALUES[candidate];
|
2010-11-23 11:49:27 +00:00
|
|
|
if (!val[1]) {
|
2010-02-10 09:23:35 +00:00
|
|
|
emitOrAppendOne(val, returnState);
|
2010-11-23 11:49:27 +00:00
|
|
|
} else {
|
|
|
|
emitOrAppendTwo(val, returnState);
|
2010-02-10 09:23:35 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
if (strBufMark < strBufLen) {
|
2010-04-16 10:52:06 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = strBufMark; i < strBufLen; i++) {
|
2009-06-28 22:44:22 +00:00
|
|
|
appendLongStrBuf(strBuf[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tokenHandler->characters(strBuf, strBufMark, strBufLen - strBufMark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
state = returnState;
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_CONTINUE(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5TOKENIZER_CONSUME_NCR:
|
|
|
|
case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP:
|
|
|
|
case NS_HTML5TOKENIZER_HEX_NCR_LOOP: {
|
|
|
|
if (!seenDigits) {
|
2011-11-01 11:33:11 +00:00
|
|
|
errNoDigitsInNCR();
|
2009-06-28 22:44:22 +00:00
|
|
|
emitOrAppendStrBuf(returnState);
|
|
|
|
state = returnState;
|
|
|
|
continue;
|
2011-11-01 11:33:11 +00:00
|
|
|
} else {
|
|
|
|
errCharRefLacksSemicolon();
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
handleNcrValue(returnState);
|
|
|
|
state = returnState;
|
|
|
|
continue;
|
|
|
|
}
|
2010-10-07 07:27:16 +00: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-28 22:44:22 +00:00
|
|
|
case NS_HTML5TOKENIZER_DATA:
|
|
|
|
default: {
|
2010-04-19 13:25:13 +00:00
|
|
|
NS_HTML5_BREAK(eofloop);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eofloop_end: ;
|
|
|
|
tokenHandler->eof();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitDoctypeToken(int32_t pos)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
cstart = pos + 1;
|
|
|
|
tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks);
|
2012-07-30 14:20:58 +00:00
|
|
|
doctypeName = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
nsHtml5Portability::releaseString(publicIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
publicIdentifier = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
nsHtml5Portability::releaseString(systemIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
systemIdentifier = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-06-28 22:44:22 +00:00
|
|
|
nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset)
|
|
|
|
{
|
2010-04-19 13:25:13 +00:00
|
|
|
if (encodingDeclarationHandler) {
|
2010-12-08 12:37:19 +00:00
|
|
|
return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitOrAppendTwo(const PRUnichar* val, int32_t returnState)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2010-04-16 10:52:06 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2010-02-10 09:23:35 +00:00
|
|
|
appendLongStrBuf(val[0]);
|
|
|
|
appendLongStrBuf(val[1]);
|
2009-06-28 22:44:22 +00:00
|
|
|
} else {
|
2010-02-10 09:23:35 +00:00
|
|
|
tokenHandler->characters(val, 0, 2);
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHtml5Tokenizer::emitOrAppendOne(const PRUnichar* val, int32_t returnState)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
2010-04-16 10:52:06 +00:00
|
|
|
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
|
2009-06-28 22:44:22 +00:00
|
|
|
appendLongStrBuf(val[0]);
|
|
|
|
} else {
|
|
|
|
tokenHandler->characters(val, 0, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::end()
|
|
|
|
{
|
2012-07-20 11:16:17 +00:00
|
|
|
strBuf = 0;
|
|
|
|
longStrBuf = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
doctypeName = nullptr;
|
2010-04-19 13:25:13 +00:00
|
|
|
if (systemIdentifier) {
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5Portability::releaseString(systemIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
systemIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (publicIdentifier) {
|
2009-09-21 13:18:20 +00:00
|
|
|
nsHtml5Portability::releaseString(publicIdentifier);
|
2012-07-30 14:20:58 +00:00
|
|
|
publicIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (tagName) {
|
2009-09-21 11:43:43 +00:00
|
|
|
tagName->release();
|
2012-07-30 14:20:58 +00:00
|
|
|
tagName = nullptr;
|
2009-09-21 11:43:43 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributeName) {
|
2009-09-21 11:43:43 +00:00
|
|
|
attributeName->release();
|
2012-07-30 14:20:58 +00:00
|
|
|
attributeName = nullptr;
|
2009-09-21 11:43:43 +00:00
|
|
|
}
|
2009-06-28 22:44:22 +00:00
|
|
|
tokenHandler->endTokenization();
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributes) {
|
2009-06-28 22:44:22 +00:00
|
|
|
attributes->clear(0);
|
|
|
|
delete attributes;
|
2012-07-30 14:20:58 +00:00
|
|
|
attributes = nullptr;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::requestSuspension()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
shouldSuspend = true;
|
2009-06-28 22:44:22 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-06-28 22:44:22 +00:00
|
|
|
nsHtml5Tokenizer::isInDataState()
|
|
|
|
{
|
|
|
|
return (stateSave == NS_HTML5TOKENIZER_DATA);
|
|
|
|
}
|
|
|
|
|
2009-09-21 13:18:20 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::resetToDataState()
|
|
|
|
{
|
|
|
|
strBufLen = 0;
|
|
|
|
longStrBufLen = 0;
|
|
|
|
stateSave = NS_HTML5TOKENIZER_DATA;
|
2011-10-17 14:59:28 +00:00
|
|
|
lastCR = false;
|
2009-09-21 13:18:20 +00:00
|
|
|
index = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
forceQuirks = false;
|
2009-09-21 13:18:20 +00:00
|
|
|
additional = '\0';
|
|
|
|
entCol = -1;
|
2010-02-10 09:23:35 +00:00
|
|
|
firstCharKey = -1;
|
2009-09-21 13:18:20 +00:00
|
|
|
lo = 0;
|
2010-09-28 07:32:31 +00:00
|
|
|
hi = 0;
|
2009-09-21 13:18:20 +00:00
|
|
|
candidate = -1;
|
|
|
|
strBufMark = 0;
|
|
|
|
prevValue = -1;
|
|
|
|
value = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
seenDigits = false;
|
|
|
|
endTag = false;
|
|
|
|
shouldSuspend = false;
|
2009-09-21 13:18:20 +00:00
|
|
|
initDoctypeFields();
|
2010-04-19 13:25:13 +00:00
|
|
|
if (tagName) {
|
2009-09-21 13:18:20 +00:00
|
|
|
tagName->release();
|
2012-07-30 14:20:58 +00:00
|
|
|
tagName = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributeName) {
|
2009-09-21 13:18:20 +00:00
|
|
|
attributeName->release();
|
2012-07-30 14:20:58 +00:00
|
|
|
attributeName = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributes) {
|
2009-09-21 13:18:20 +00:00
|
|
|
delete attributes;
|
2012-07-30 14:20:58 +00:00
|
|
|
attributes = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
|
|
|
|
{
|
|
|
|
strBufLen = other->strBufLen;
|
|
|
|
if (strBufLen > strBuf.length) {
|
2012-08-22 15:56:38 +00:00
|
|
|
strBuf = jArray<PRUnichar,int32_t>::newJArray(strBufLen);
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
|
|
|
nsHtml5ArrayCopy::arraycopy(other->strBuf, strBuf, strBufLen);
|
|
|
|
longStrBufLen = other->longStrBufLen;
|
|
|
|
if (longStrBufLen > longStrBuf.length) {
|
2012-08-22 15:56:38 +00:00
|
|
|
longStrBuf = jArray<PRUnichar,int32_t>::newJArray(longStrBufLen);
|
2009-09-21 13:18:20 +00:00
|
|
|
}
|
|
|
|
nsHtml5ArrayCopy::arraycopy(other->longStrBuf, longStrBuf, longStrBufLen);
|
|
|
|
stateSave = other->stateSave;
|
2009-12-17 10:15:08 +00:00
|
|
|
returnStateSave = other->returnStateSave;
|
2010-04-16 10:52:06 +00:00
|
|
|
endTagExpectation = other->endTagExpectation;
|
|
|
|
endTagExpectationAsArray = other->endTagExpectationAsArray;
|
2009-09-21 13:18:20 +00:00
|
|
|
lastCR = other->lastCR;
|
|
|
|
index = other->index;
|
|
|
|
forceQuirks = other->forceQuirks;
|
|
|
|
additional = other->additional;
|
|
|
|
entCol = other->entCol;
|
2010-02-10 09:23:35 +00:00
|
|
|
firstCharKey = other->firstCharKey;
|
2009-09-21 13:18:20 +00: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 10:27:15 +00:00
|
|
|
endTag = other->endTag;
|
2011-10-17 14:59:28 +00:00
|
|
|
shouldSuspend = false;
|
2009-09-21 13:18:20 +00:00
|
|
|
if (!other->doctypeName) {
|
2012-07-30 14:20:58 +00:00
|
|
|
doctypeName = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
} else {
|
|
|
|
doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner);
|
|
|
|
}
|
|
|
|
nsHtml5Portability::releaseString(systemIdentifier);
|
|
|
|
if (!other->systemIdentifier) {
|
2012-07-30 14:20:58 +00:00
|
|
|
systemIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
} else {
|
|
|
|
systemIdentifier = nsHtml5Portability::newStringFromString(other->systemIdentifier);
|
|
|
|
}
|
|
|
|
nsHtml5Portability::releaseString(publicIdentifier);
|
|
|
|
if (!other->publicIdentifier) {
|
2012-07-30 14:20:58 +00:00
|
|
|
publicIdentifier = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
} else {
|
|
|
|
publicIdentifier = nsHtml5Portability::newStringFromString(other->publicIdentifier);
|
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (tagName) {
|
2009-09-21 13:18:20 +00:00
|
|
|
tagName->release();
|
|
|
|
}
|
|
|
|
if (!other->tagName) {
|
2012-07-30 14:20:58 +00:00
|
|
|
tagName = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
} else {
|
|
|
|
tagName = other->tagName->cloneElementName(interner);
|
|
|
|
}
|
2010-04-19 13:25:13 +00:00
|
|
|
if (attributeName) {
|
2009-09-21 13:18:20 +00:00
|
|
|
attributeName->release();
|
|
|
|
}
|
|
|
|
if (!other->attributeName) {
|
2012-07-30 14:20:58 +00:00
|
|
|
attributeName = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
} else {
|
|
|
|
attributeName = other->attributeName->cloneAttributeName(interner);
|
|
|
|
}
|
2011-05-17 14:01:36 +00:00
|
|
|
delete attributes;
|
2009-09-21 13:18:20 +00:00
|
|
|
if (!other->attributes) {
|
2012-07-30 14:20:58 +00:00
|
|
|
attributes = nullptr;
|
2009-09-21 13:18:20 +00:00
|
|
|
} else {
|
|
|
|
attributes = other->attributes->cloneAttributes(interner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::initializeWithoutStarting()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
confident = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
strBuf = jArray<PRUnichar,int32_t>::newJArray(64);
|
|
|
|
longStrBuf = jArray<PRUnichar,int32_t>::newJArray(1024);
|
2009-10-12 13:08:04 +00:00
|
|
|
line = 1;
|
2009-09-21 13:18:20 +00:00
|
|
|
resetToDataState();
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
2010-04-16 10:52:06 +00:00
|
|
|
nsHtml5Tokenizer::setEncodingDeclarationHandler(nsHtml5StreamParser* encodingDeclarationHandler)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
this->encodingDeclarationHandler = encodingDeclarationHandler;
|
|
|
|
}
|
|
|
|
|
2010-11-10 10:03:48 +00:00
|
|
|
|
|
|
|
nsHtml5Tokenizer::~nsHtml5Tokenizer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsHtml5Tokenizer);
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:44:22 +00:00
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::initializeStatics()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5Tokenizer::releaseStatics()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-30 10:15:38 +00:00
|
|
|
#include "nsHtml5TokenizerCppSupplement.h"
|
|
|
|
|