2009-06-29 02:44:22 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Henri Sivonen
|
2010-04-09 19:48:29 +04:00
|
|
|
* Copyright (c) 2008-2010 Mozilla Foundation
|
2009-06-29 02:44:22 +04:00
|
|
|
*
|
|
|
|
* 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 MetaScanner.java instead and regenerate.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define nsHtml5MetaScanner_cpp__
|
|
|
|
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsIAtom.h"
|
2009-09-21 15:43:43 +04:00
|
|
|
#include "nsHtml5AtomTable.h"
|
2009-06-29 02:44:22 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
#include "jArray.h"
|
|
|
|
#include "nsHtml5DocumentMode.h"
|
|
|
|
#include "nsHtml5ArrayCopy.h"
|
|
|
|
#include "nsHtml5NamedCharacters.h"
|
2010-06-24 12:54:33 +04:00
|
|
|
#include "nsHtml5NamedCharactersAccel.h"
|
2009-06-29 02:44:22 +04:00
|
|
|
#include "nsHtml5Atoms.h"
|
|
|
|
#include "nsHtml5ByteReadable.h"
|
2009-09-18 13:21:47 +04:00
|
|
|
#include "nsIUnicodeDecoder.h"
|
2009-09-21 17:18:20 +04:00
|
|
|
#include "nsAHtml5TreeBuilderState.h"
|
2010-04-19 17:25:13 +04:00
|
|
|
#include "nsHtml5Macros.h"
|
2009-06-29 02:44:22 +04:00
|
|
|
|
|
|
|
#include "nsHtml5Tokenizer.h"
|
|
|
|
#include "nsHtml5TreeBuilder.h"
|
|
|
|
#include "nsHtml5AttributeName.h"
|
|
|
|
#include "nsHtml5ElementName.h"
|
|
|
|
#include "nsHtml5HtmlAttributes.h"
|
|
|
|
#include "nsHtml5StackNode.h"
|
|
|
|
#include "nsHtml5UTF16Buffer.h"
|
|
|
|
#include "nsHtml5StateSnapshot.h"
|
|
|
|
#include "nsHtml5Portability.h"
|
|
|
|
|
|
|
|
#include "nsHtml5MetaScanner.h"
|
|
|
|
|
2010-09-28 11:32:31 +04:00
|
|
|
PRUnichar nsHtml5MetaScanner::CHARSET[] = { 'c', 'h', 'a', 'r', 's', 'e', 't' };
|
|
|
|
PRUnichar nsHtml5MetaScanner::CONTENT[] = { 'c', 'o', 'n', 't', 'e', 'n', 't' };
|
2009-06-29 02:44:22 +04:00
|
|
|
void
|
|
|
|
nsHtml5MetaScanner::stateLoop(PRInt32 state)
|
|
|
|
{
|
|
|
|
PRInt32 c = -1;
|
|
|
|
PRBool reconsume = PR_FALSE;
|
|
|
|
stateloop: for (; ; ) {
|
|
|
|
switch(state) {
|
|
|
|
case NS_HTML5META_SCANNER_DATA: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
c = read();
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '<': {
|
|
|
|
state = NS_HTML5META_SCANNER_TAG_OPEN;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(dataloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dataloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_TAG_OPEN: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case 'm':
|
|
|
|
case 'M': {
|
|
|
|
metaState = NS_HTML5META_SCANNER_M;
|
|
|
|
state = NS_HTML5META_SCANNER_TAG_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(tagopenloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '!': {
|
|
|
|
state = NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '\?':
|
|
|
|
case '/': {
|
|
|
|
state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
|
|
|
|
metaState = NS_HTML5META_SCANNER_NO;
|
|
|
|
state = NS_HTML5META_SCANNER_TAG_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(tagopenloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
|
|
|
reconsume = PR_TRUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tagopenloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_TAG_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(tagnameloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case 'e':
|
|
|
|
case 'E': {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_M) {
|
|
|
|
metaState = NS_HTML5META_SCANNER_E;
|
|
|
|
} else {
|
|
|
|
metaState = NS_HTML5META_SCANNER_NO;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case 't':
|
|
|
|
case 'T': {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_E) {
|
|
|
|
metaState = NS_HTML5META_SCANNER_T;
|
|
|
|
} else {
|
|
|
|
metaState = NS_HTML5META_SCANNER_NO;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case 'a':
|
|
|
|
case 'A': {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_T) {
|
|
|
|
metaState = NS_HTML5META_SCANNER_A;
|
|
|
|
} else {
|
|
|
|
metaState = NS_HTML5META_SCANNER_NO;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
metaState = NS_HTML5META_SCANNER_NO;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tagnameloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
c = read();
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case 'c':
|
|
|
|
case 'C': {
|
|
|
|
contentIndex = 0;
|
|
|
|
charsetIndex = 0;
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(beforeattributenameloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
contentIndex = -1;
|
|
|
|
charsetIndex = -1;
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(beforeattributenameloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
beforeattributenameloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_ATTRIBUTE_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '=': {
|
|
|
|
strBufLen = 0;
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(attributenameloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_A) {
|
|
|
|
if (c >= 'A' && c <= 'Z') {
|
|
|
|
c += 0x20;
|
|
|
|
}
|
|
|
|
if (contentIndex == 6) {
|
|
|
|
contentIndex = -1;
|
|
|
|
} else if (contentIndex > -1 && contentIndex < 6 && (c == CONTENT[contentIndex + 1])) {
|
|
|
|
contentIndex++;
|
|
|
|
}
|
|
|
|
if (charsetIndex == 6) {
|
|
|
|
charsetIndex = -1;
|
|
|
|
} else if (charsetIndex > -1 && charsetIndex < 6 && (c == CHARSET[charsetIndex + 1])) {
|
|
|
|
charsetIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attributenameloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '\"': {
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(beforeattributevalueloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '\'': {
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (charsetIndex == 6 || contentIndex == 6) {
|
|
|
|
addToBuffer(c);
|
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
beforeattributevalueloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
c = read();
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '\"': {
|
|
|
|
if (tryCharset()) {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(attributevaluedoublequotedloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_A && (contentIndex == 6 || charsetIndex == 6)) {
|
|
|
|
addToBuffer(c);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attributevaluedoublequotedloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(afterattributevaluequotedloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
|
|
|
|
reconsume = PR_TRUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
afterattributevaluequotedloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG: {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
|
|
|
|
reconsume = PR_TRUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
c = read();
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
if (tryCharset()) {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
if (tryCharset()) {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_A && (contentIndex == 6 || charsetIndex == 6)) {
|
|
|
|
addToBuffer(c);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
case '\f': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case '/': {
|
|
|
|
if (tryCharset()) {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '=': {
|
|
|
|
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
if (tryCharset()) {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case 'c':
|
|
|
|
case 'C': {
|
|
|
|
contentIndex = 0;
|
|
|
|
charsetIndex = 0;
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
contentIndex = -1;
|
|
|
|
charsetIndex = -1;
|
|
|
|
state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
state = NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(markupdeclarationopenloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT;
|
|
|
|
reconsume = PR_TRUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
markupdeclarationopenloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT_START;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(markupdeclarationhyphenloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT;
|
|
|
|
reconsume = PR_TRUE;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
markupdeclarationhyphenloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_COMMENT_START: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT_START_DASH;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(commentstartloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commentstartloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_COMMENT: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT_END_DASH;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(commentloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commentloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_COMMENT_END_DASH: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT_END;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(commentenddashloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commentenddashloop_end: ;
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_COMMENT_END: {
|
|
|
|
for (; ; ) {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_COMMENT_START_DASH: {
|
|
|
|
c = read();
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '-': {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT_END;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
state = NS_HTML5META_SCANNER_COMMENT;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
c = read();
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '\'': {
|
|
|
|
if (tryCharset()) {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
if (metaState == NS_HTML5META_SCANNER_A && (contentIndex == 6 || charsetIndex == 6)) {
|
|
|
|
addToBuffer(c);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NS_HTML5META_SCANNER_SCAN_UNTIL_GT: {
|
|
|
|
for (; ; ) {
|
|
|
|
if (reconsume) {
|
|
|
|
reconsume = PR_FALSE;
|
|
|
|
} else {
|
|
|
|
c = read();
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case -1: {
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_BREAK(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
case '>': {
|
|
|
|
state = NS_HTML5META_SCANNER_DATA;
|
2010-04-19 17:25:13 +04:00
|
|
|
NS_HTML5_CONTINUE(stateloop);
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stateloop_end: ;
|
|
|
|
stateSave = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5MetaScanner::addToBuffer(PRInt32 c)
|
|
|
|
{
|
|
|
|
if (strBufLen == strBuf.length) {
|
2010-09-28 11:32:31 +04:00
|
|
|
jArray<PRUnichar,PRInt32> newBuf = jArray<PRUnichar,PRInt32>::newJArray(strBuf.length + (strBuf.length << 1));
|
2009-06-29 02:44:22 +04:00
|
|
|
nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length);
|
|
|
|
strBuf = newBuf;
|
|
|
|
}
|
|
|
|
strBuf[strBufLen++] = (PRUnichar) c;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsHtml5MetaScanner::tryCharset()
|
|
|
|
{
|
|
|
|
if (metaState != NS_HTML5META_SCANNER_A || !(contentIndex == 6 || charsetIndex == 6)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
nsString* attVal = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen);
|
|
|
|
nsString* candidateEncoding;
|
|
|
|
if (contentIndex == 6) {
|
|
|
|
candidateEncoding = nsHtml5TreeBuilder::extractCharsetFromContent(attVal);
|
|
|
|
nsHtml5Portability::releaseString(attVal);
|
|
|
|
} else {
|
|
|
|
candidateEncoding = attVal;
|
|
|
|
}
|
|
|
|
if (!candidateEncoding) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2009-07-15 15:30:33 +04:00
|
|
|
PRBool success = tryCharset(candidateEncoding);
|
2009-06-29 02:44:22 +04:00
|
|
|
nsHtml5Portability::releaseString(candidateEncoding);
|
|
|
|
contentIndex = -1;
|
|
|
|
charsetIndex = -1;
|
2009-07-15 15:30:33 +04:00
|
|
|
return success;
|
2009-06-29 02:44:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5MetaScanner::initializeStatics()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5MetaScanner::releaseStatics()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsHtml5MetaScannerCppSupplement.h"
|
|
|
|
|