michael@0: /* michael@0: * Copyright (c) 2007 Henri Sivonen michael@0: * Copyright (c) 2008-2010 Mozilla Foundation michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice shall be included in michael@0: * all copies or substantial portions of the Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: */ michael@0: michael@0: /* michael@0: * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. michael@0: * Please edit MetaScanner.java instead and regenerate. michael@0: */ michael@0: michael@0: #define nsHtml5MetaScanner_cpp__ michael@0: michael@0: #include "nsIAtom.h" michael@0: #include "nsHtml5AtomTable.h" michael@0: #include "nsString.h" michael@0: #include "nsNameSpaceManager.h" michael@0: #include "nsIContent.h" michael@0: #include "nsTraceRefcnt.h" michael@0: #include "jArray.h" michael@0: #include "nsHtml5ArrayCopy.h" michael@0: #include "nsAHtml5TreeBuilderState.h" michael@0: #include "nsHtml5Atoms.h" michael@0: #include "nsHtml5ByteReadable.h" michael@0: #include "nsIUnicodeDecoder.h" michael@0: #include "nsHtml5Macros.h" michael@0: #include "nsIContentHandle.h" michael@0: michael@0: #include "nsHtml5Tokenizer.h" michael@0: #include "nsHtml5TreeBuilder.h" michael@0: #include "nsHtml5AttributeName.h" michael@0: #include "nsHtml5ElementName.h" michael@0: #include "nsHtml5HtmlAttributes.h" michael@0: #include "nsHtml5StackNode.h" michael@0: #include "nsHtml5UTF16Buffer.h" michael@0: #include "nsHtml5StateSnapshot.h" michael@0: #include "nsHtml5Portability.h" michael@0: michael@0: #include "nsHtml5MetaScanner.h" michael@0: michael@0: static char16_t const CHARSET_DATA[] = { 'h', 'a', 'r', 's', 'e', 't' }; michael@0: staticJArray nsHtml5MetaScanner::CHARSET = { CHARSET_DATA, MOZ_ARRAY_LENGTH(CHARSET_DATA) }; michael@0: static char16_t const CONTENT_DATA[] = { 'o', 'n', 't', 'e', 'n', 't' }; michael@0: staticJArray nsHtml5MetaScanner::CONTENT = { CONTENT_DATA, MOZ_ARRAY_LENGTH(CONTENT_DATA) }; michael@0: static char16_t const HTTP_EQUIV_DATA[] = { 't', 't', 'p', '-', 'e', 'q', 'u', 'i', 'v' }; michael@0: staticJArray nsHtml5MetaScanner::HTTP_EQUIV = { HTTP_EQUIV_DATA, MOZ_ARRAY_LENGTH(HTTP_EQUIV_DATA) }; michael@0: static char16_t const CONTENT_TYPE_DATA[] = { 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p', 'e' }; michael@0: staticJArray nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE_DATA, MOZ_ARRAY_LENGTH(CONTENT_TYPE_DATA) }; michael@0: michael@0: nsHtml5MetaScanner::nsHtml5MetaScanner() michael@0: : readable(nullptr), michael@0: metaState(NS_HTML5META_SCANNER_NO), michael@0: contentIndex(INT32_MAX), michael@0: charsetIndex(INT32_MAX), michael@0: httpEquivIndex(INT32_MAX), michael@0: contentTypeIndex(INT32_MAX), michael@0: stateSave(NS_HTML5META_SCANNER_DATA), michael@0: strBufLen(0), michael@0: strBuf(jArray::newJArray(36)), michael@0: content(nullptr), michael@0: charset(nullptr), michael@0: httpEquivState(NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN) michael@0: { michael@0: MOZ_COUNT_CTOR(nsHtml5MetaScanner); michael@0: } michael@0: michael@0: michael@0: nsHtml5MetaScanner::~nsHtml5MetaScanner() michael@0: { michael@0: MOZ_COUNT_DTOR(nsHtml5MetaScanner); michael@0: nsHtml5Portability::releaseString(content); michael@0: nsHtml5Portability::releaseString(charset); michael@0: } michael@0: michael@0: void michael@0: nsHtml5MetaScanner::stateLoop(int32_t state) michael@0: { michael@0: int32_t c = -1; michael@0: bool reconsume = false; michael@0: stateloop: for (; ; ) { michael@0: switch(state) { michael@0: case NS_HTML5META_SCANNER_DATA: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: c = read(); michael@0: } michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '<': { michael@0: state = NS_HTML5META_SCANNER_TAG_OPEN; michael@0: NS_HTML5_BREAK(dataloop); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: dataloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_TAG_OPEN: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case 'm': michael@0: case 'M': { michael@0: metaState = NS_HTML5META_SCANNER_M; michael@0: state = NS_HTML5META_SCANNER_TAG_NAME; michael@0: NS_HTML5_BREAK(tagopenloop); michael@0: } michael@0: case '!': { michael@0: state = NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '\?': michael@0: case '/': { michael@0: state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { michael@0: metaState = NS_HTML5META_SCANNER_NO; michael@0: state = NS_HTML5META_SCANNER_TAG_NAME; michael@0: NS_HTML5_BREAK(tagopenloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: reconsume = true; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: tagopenloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_TAG_NAME: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME; michael@0: NS_HTML5_BREAK(tagnameloop); michael@0: } michael@0: case '/': { michael@0: state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case 'e': michael@0: case 'E': { michael@0: if (metaState == NS_HTML5META_SCANNER_M) { michael@0: metaState = NS_HTML5META_SCANNER_E; michael@0: } else { michael@0: metaState = NS_HTML5META_SCANNER_NO; michael@0: } michael@0: continue; michael@0: } michael@0: case 't': michael@0: case 'T': { michael@0: if (metaState == NS_HTML5META_SCANNER_E) { michael@0: metaState = NS_HTML5META_SCANNER_T; michael@0: } else { michael@0: metaState = NS_HTML5META_SCANNER_NO; michael@0: } michael@0: continue; michael@0: } michael@0: case 'a': michael@0: case 'A': { michael@0: if (metaState == NS_HTML5META_SCANNER_T) { michael@0: metaState = NS_HTML5META_SCANNER_A; michael@0: } else { michael@0: metaState = NS_HTML5META_SCANNER_NO; michael@0: } michael@0: continue; michael@0: } michael@0: default: { michael@0: metaState = NS_HTML5META_SCANNER_NO; michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: tagnameloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: c = read(); michael@0: } michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '/': { michael@0: state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case 'c': michael@0: case 'C': { michael@0: contentIndex = 0; michael@0: charsetIndex = 0; michael@0: httpEquivIndex = INT32_MAX; michael@0: contentTypeIndex = INT32_MAX; michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME; michael@0: NS_HTML5_BREAK(beforeattributenameloop); michael@0: } michael@0: case 'h': michael@0: case 'H': { michael@0: contentIndex = INT32_MAX; michael@0: charsetIndex = INT32_MAX; michael@0: httpEquivIndex = 0; michael@0: contentTypeIndex = INT32_MAX; michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME; michael@0: NS_HTML5_BREAK(beforeattributenameloop); michael@0: } michael@0: default: { michael@0: contentIndex = INT32_MAX; michael@0: charsetIndex = INT32_MAX; michael@0: httpEquivIndex = INT32_MAX; michael@0: contentTypeIndex = INT32_MAX; michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME; michael@0: NS_HTML5_BREAK(beforeattributenameloop); michael@0: } michael@0: } michael@0: } michael@0: beforeattributenameloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_ATTRIBUTE_NAME: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '/': { michael@0: state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '=': { michael@0: strBufLen = 0; michael@0: contentTypeIndex = 0; michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE; michael@0: NS_HTML5_BREAK(attributenameloop); michael@0: } michael@0: case '>': { michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: if (metaState == NS_HTML5META_SCANNER_A) { michael@0: if (c >= 'A' && c <= 'Z') { michael@0: c += 0x20; michael@0: } michael@0: if (contentIndex < CONTENT.length && c == CONTENT[contentIndex]) { michael@0: ++contentIndex; michael@0: } else { michael@0: contentIndex = INT32_MAX; michael@0: } michael@0: if (charsetIndex < CHARSET.length && c == CHARSET[charsetIndex]) { michael@0: ++charsetIndex; michael@0: } else { michael@0: charsetIndex = INT32_MAX; michael@0: } michael@0: if (httpEquivIndex < HTTP_EQUIV.length && c == HTTP_EQUIV[httpEquivIndex]) { michael@0: ++httpEquivIndex; michael@0: } else { michael@0: httpEquivIndex = INT32_MAX; michael@0: } michael@0: } michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: attributenameloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '\"': { michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED; michael@0: NS_HTML5_BREAK(beforeattributevalueloop); michael@0: } michael@0: case '\'': { michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: handleCharInAttributeValue(c); michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: beforeattributevalueloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: c = read(); michael@0: } michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\"': { michael@0: handleAttributeValue(); michael@0: state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED; michael@0: NS_HTML5_BREAK(attributevaluedoublequotedloop); michael@0: } michael@0: default: { michael@0: handleCharInAttributeValue(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: attributevaluedoublequotedloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '/': { michael@0: state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG; michael@0: NS_HTML5_BREAK(afterattributevaluequotedloop); michael@0: } michael@0: case '>': { michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME; michael@0: reconsume = true; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: afterattributevaluequotedloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG: { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '>': { michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME; michael@0: reconsume = true; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: c = read(); michael@0: } michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: handleAttributeValue(); michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: handleAttributeValue(); michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: handleCharInAttributeValue(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case ' ': michael@0: case '\t': michael@0: case '\n': michael@0: case '\f': { michael@0: continue; michael@0: } michael@0: case '/': { michael@0: handleAttributeValue(); michael@0: state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '=': { michael@0: strBufLen = 0; michael@0: contentTypeIndex = 0; michael@0: state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: handleAttributeValue(); michael@0: if (handleTag()) { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case 'c': michael@0: case 'C': { michael@0: contentIndex = 0; michael@0: charsetIndex = 0; michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: contentIndex = INT32_MAX; michael@0: charsetIndex = INT32_MAX; michael@0: state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: state = NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN; michael@0: NS_HTML5_BREAK(markupdeclarationopenloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT; michael@0: reconsume = true; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: markupdeclarationopenloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: state = NS_HTML5META_SCANNER_COMMENT_START; michael@0: NS_HTML5_BREAK(markupdeclarationhyphenloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT; michael@0: reconsume = true; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: markupdeclarationhyphenloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_COMMENT_START: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: state = NS_HTML5META_SCANNER_COMMENT_START_DASH; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_COMMENT; michael@0: NS_HTML5_BREAK(commentstartloop); michael@0: } michael@0: } michael@0: } michael@0: commentstartloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_COMMENT: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: state = NS_HTML5META_SCANNER_COMMENT_END_DASH; michael@0: NS_HTML5_BREAK(commentloop); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: commentloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_COMMENT_END_DASH: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: state = NS_HTML5META_SCANNER_COMMENT_END; michael@0: NS_HTML5_BREAK(commentenddashloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_COMMENT; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: commentenddashloop_end: ; michael@0: } michael@0: case NS_HTML5META_SCANNER_COMMENT_END: { michael@0: for (; ; ) { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '>': { michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '-': { michael@0: continue; michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_COMMENT; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5META_SCANNER_COMMENT_START_DASH: { michael@0: c = read(); michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '-': { michael@0: state = NS_HTML5META_SCANNER_COMMENT_END; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: case '>': { michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: state = NS_HTML5META_SCANNER_COMMENT; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: c = read(); michael@0: } michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '\'': { michael@0: handleAttributeValue(); michael@0: state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: handleCharInAttributeValue(c); michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: case NS_HTML5META_SCANNER_SCAN_UNTIL_GT: { michael@0: for (; ; ) { michael@0: if (reconsume) { michael@0: reconsume = false; michael@0: } else { michael@0: c = read(); michael@0: } michael@0: switch(c) { michael@0: case -1: { michael@0: NS_HTML5_BREAK(stateloop); michael@0: } michael@0: case '>': { michael@0: state = NS_HTML5META_SCANNER_DATA; michael@0: NS_HTML5_CONTINUE(stateloop); michael@0: } michael@0: default: { michael@0: continue; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: } michael@0: } michael@0: stateloop_end: ; michael@0: stateSave = state; michael@0: } michael@0: michael@0: void michael@0: nsHtml5MetaScanner::handleCharInAttributeValue(int32_t c) michael@0: { michael@0: if (metaState == NS_HTML5META_SCANNER_A) { michael@0: if (contentIndex == CONTENT.length || charsetIndex == CHARSET.length) { michael@0: addToBuffer(c); michael@0: } else if (httpEquivIndex == HTTP_EQUIV.length) { michael@0: if (contentTypeIndex < CONTENT_TYPE.length && toAsciiLowerCase(c) == CONTENT_TYPE[contentTypeIndex]) { michael@0: ++contentTypeIndex; michael@0: } else { michael@0: contentTypeIndex = INT32_MAX; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: void michael@0: nsHtml5MetaScanner::addToBuffer(int32_t c) michael@0: { michael@0: if (strBufLen == strBuf.length) { michael@0: jArray newBuf = jArray::newJArray(strBuf.length + (strBuf.length << 1)); michael@0: nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length); michael@0: strBuf = newBuf; michael@0: } michael@0: strBuf[strBufLen++] = (char16_t) c; michael@0: } michael@0: michael@0: void michael@0: nsHtml5MetaScanner::handleAttributeValue() michael@0: { michael@0: if (metaState != NS_HTML5META_SCANNER_A) { michael@0: return; michael@0: } michael@0: if (contentIndex == CONTENT.length && !content) { michael@0: content = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen); michael@0: return; michael@0: } michael@0: if (charsetIndex == CHARSET.length && !charset) { michael@0: charset = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen); michael@0: return; michael@0: } michael@0: if (httpEquivIndex == HTTP_EQUIV.length && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN) { michael@0: httpEquivState = (contentTypeIndex == CONTENT_TYPE.length) ? NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE : NS_HTML5META_SCANNER_HTTP_EQUIV_OTHER; michael@0: return; michael@0: } michael@0: } michael@0: michael@0: bool michael@0: nsHtml5MetaScanner::handleTag() michael@0: { michael@0: bool stop = handleTagInner(); michael@0: nsHtml5Portability::releaseString(content); michael@0: content = nullptr; michael@0: nsHtml5Portability::releaseString(charset); michael@0: charset = nullptr; michael@0: httpEquivState = NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN; michael@0: return stop; michael@0: } michael@0: michael@0: bool michael@0: nsHtml5MetaScanner::handleTagInner() michael@0: { michael@0: if (!!charset && tryCharset(charset)) { michael@0: return true; michael@0: } michael@0: if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) { michael@0: nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content); michael@0: if (!extract) { michael@0: return false; michael@0: } michael@0: bool success = tryCharset(extract); michael@0: nsHtml5Portability::releaseString(extract); michael@0: return success; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: void michael@0: nsHtml5MetaScanner::initializeStatics() michael@0: { michael@0: } michael@0: michael@0: void michael@0: nsHtml5MetaScanner::releaseStatics() michael@0: { michael@0: } michael@0: michael@0: michael@0: #include "nsHtml5MetaScannerCppSupplement.h" michael@0: