Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2005-2007 Henri Sivonen |
michael@0 | 3 | * Copyright (c) 2007-2013 Mozilla Foundation |
michael@0 | 4 | * Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla |
michael@0 | 5 | * Foundation, and Opera Software ASA. |
michael@0 | 6 | * |
michael@0 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
michael@0 | 8 | * copy of this software and associated documentation files (the "Software"), |
michael@0 | 9 | * to deal in the Software without restriction, including without limitation |
michael@0 | 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
michael@0 | 11 | * and/or sell copies of the Software, and to permit persons to whom the |
michael@0 | 12 | * Software is furnished to do so, subject to the following conditions: |
michael@0 | 13 | * |
michael@0 | 14 | * The above copyright notice and this permission notice shall be included in |
michael@0 | 15 | * all copies or substantial portions of the Software. |
michael@0 | 16 | * |
michael@0 | 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
michael@0 | 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
michael@0 | 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
michael@0 | 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
michael@0 | 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
michael@0 | 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
michael@0 | 23 | * DEALINGS IN THE SOFTWARE. |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | /* |
michael@0 | 27 | * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. |
michael@0 | 28 | * Please edit Tokenizer.java instead and regenerate. |
michael@0 | 29 | */ |
michael@0 | 30 | |
michael@0 | 31 | #define nsHtml5Tokenizer_cpp__ |
michael@0 | 32 | |
michael@0 | 33 | #include "nsIAtom.h" |
michael@0 | 34 | #include "nsHtml5AtomTable.h" |
michael@0 | 35 | #include "nsString.h" |
michael@0 | 36 | #include "nsIContent.h" |
michael@0 | 37 | #include "nsTraceRefcnt.h" |
michael@0 | 38 | #include "jArray.h" |
michael@0 | 39 | #include "nsHtml5DocumentMode.h" |
michael@0 | 40 | #include "nsHtml5ArrayCopy.h" |
michael@0 | 41 | #include "nsHtml5NamedCharacters.h" |
michael@0 | 42 | #include "nsHtml5NamedCharactersAccel.h" |
michael@0 | 43 | #include "nsHtml5Atoms.h" |
michael@0 | 44 | #include "nsAHtml5TreeBuilderState.h" |
michael@0 | 45 | #include "nsHtml5Macros.h" |
michael@0 | 46 | #include "nsHtml5Highlighter.h" |
michael@0 | 47 | #include "nsHtml5TokenizerLoopPolicies.h" |
michael@0 | 48 | |
michael@0 | 49 | #include "nsHtml5TreeBuilder.h" |
michael@0 | 50 | #include "nsHtml5MetaScanner.h" |
michael@0 | 51 | #include "nsHtml5AttributeName.h" |
michael@0 | 52 | #include "nsHtml5ElementName.h" |
michael@0 | 53 | #include "nsHtml5HtmlAttributes.h" |
michael@0 | 54 | #include "nsHtml5StackNode.h" |
michael@0 | 55 | #include "nsHtml5UTF16Buffer.h" |
michael@0 | 56 | #include "nsHtml5StateSnapshot.h" |
michael@0 | 57 | #include "nsHtml5Portability.h" |
michael@0 | 58 | |
michael@0 | 59 | #include "nsHtml5Tokenizer.h" |
michael@0 | 60 | |
michael@0 | 61 | char16_t nsHtml5Tokenizer::LT_GT[] = { '<', '>' }; |
michael@0 | 62 | char16_t nsHtml5Tokenizer::LT_SOLIDUS[] = { '<', '/' }; |
michael@0 | 63 | char16_t nsHtml5Tokenizer::RSQB_RSQB[] = { ']', ']' }; |
michael@0 | 64 | char16_t nsHtml5Tokenizer::REPLACEMENT_CHARACTER[] = { 0xfffd }; |
michael@0 | 65 | char16_t nsHtml5Tokenizer::LF[] = { '\n' }; |
michael@0 | 66 | char16_t nsHtml5Tokenizer::CDATA_LSQB[] = { 'C', 'D', 'A', 'T', 'A', '[' }; |
michael@0 | 67 | char16_t nsHtml5Tokenizer::OCTYPE[] = { 'o', 'c', 't', 'y', 'p', 'e' }; |
michael@0 | 68 | char16_t nsHtml5Tokenizer::UBLIC[] = { 'u', 'b', 'l', 'i', 'c' }; |
michael@0 | 69 | char16_t nsHtml5Tokenizer::YSTEM[] = { 'y', 's', 't', 'e', 'm' }; |
michael@0 | 70 | static char16_t const TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' }; |
michael@0 | 71 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, MOZ_ARRAY_LENGTH(TITLE_ARR_DATA) }; |
michael@0 | 72 | static char16_t const SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' }; |
michael@0 | 73 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(SCRIPT_ARR_DATA) }; |
michael@0 | 74 | static char16_t const STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' }; |
michael@0 | 75 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, MOZ_ARRAY_LENGTH(STYLE_ARR_DATA) }; |
michael@0 | 76 | static char16_t const PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' }; |
michael@0 | 77 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, MOZ_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) }; |
michael@0 | 78 | static char16_t const XMP_ARR_DATA[] = { 'x', 'm', 'p' }; |
michael@0 | 79 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, MOZ_ARRAY_LENGTH(XMP_ARR_DATA) }; |
michael@0 | 80 | static char16_t const TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' }; |
michael@0 | 81 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, MOZ_ARRAY_LENGTH(TEXTAREA_ARR_DATA) }; |
michael@0 | 82 | static char16_t const IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' }; |
michael@0 | 83 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, MOZ_ARRAY_LENGTH(IFRAME_ARR_DATA) }; |
michael@0 | 84 | static char16_t const NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' }; |
michael@0 | 85 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, MOZ_ARRAY_LENGTH(NOEMBED_ARR_DATA) }; |
michael@0 | 86 | static char16_t const NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' }; |
michael@0 | 87 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) }; |
michael@0 | 88 | static char16_t const NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' }; |
michael@0 | 89 | staticJArray<char16_t,int32_t> nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, MOZ_ARRAY_LENGTH(NOFRAMES_ARR_DATA) }; |
michael@0 | 90 | |
michael@0 | 91 | nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource) |
michael@0 | 92 | : tokenHandler(tokenHandler), |
michael@0 | 93 | encodingDeclarationHandler(nullptr), |
michael@0 | 94 | bmpChar(jArray<char16_t,int32_t>::newJArray(1)), |
michael@0 | 95 | astralChar(jArray<char16_t,int32_t>::newJArray(2)), |
michael@0 | 96 | tagName(nullptr), |
michael@0 | 97 | attributeName(nullptr), |
michael@0 | 98 | doctypeName(nullptr), |
michael@0 | 99 | publicIdentifier(nullptr), |
michael@0 | 100 | systemIdentifier(nullptr), |
michael@0 | 101 | attributes(tokenHandler->HasBuilder() ? new nsHtml5HtmlAttributes(0) : nullptr), |
michael@0 | 102 | newAttributesEachTime(!tokenHandler->HasBuilder()), |
michael@0 | 103 | viewingXmlSource(viewingXmlSource) |
michael@0 | 104 | { |
michael@0 | 105 | MOZ_COUNT_CTOR(nsHtml5Tokenizer); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | void |
michael@0 | 109 | nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner) |
michael@0 | 110 | { |
michael@0 | 111 | this->interner = interner; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | void |
michael@0 | 115 | nsHtml5Tokenizer::initLocation(nsString* newPublicId, nsString* newSystemId) |
michael@0 | 116 | { |
michael@0 | 117 | this->systemId = newSystemId; |
michael@0 | 118 | this->publicId = newPublicId; |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | bool |
michael@0 | 122 | nsHtml5Tokenizer::isViewingXmlSource() |
michael@0 | 123 | { |
michael@0 | 124 | return viewingXmlSource; |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | void |
michael@0 | 128 | nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsIAtom* endTagExpectation) |
michael@0 | 129 | { |
michael@0 | 130 | this->stateSave = specialTokenizerState; |
michael@0 | 131 | if (specialTokenizerState == NS_HTML5TOKENIZER_DATA) { |
michael@0 | 132 | return; |
michael@0 | 133 | } |
michael@0 | 134 | autoJArray<char16_t,int32_t> asArray = nsHtml5Portability::newCharArrayFromLocal(endTagExpectation); |
michael@0 | 135 | this->endTagExpectation = nsHtml5ElementName::elementNameByBuffer(asArray, 0, asArray.length, interner); |
michael@0 | 136 | endTagExpectationToArray(); |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | void |
michael@0 | 140 | nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsHtml5ElementName* endTagExpectation) |
michael@0 | 141 | { |
michael@0 | 142 | this->stateSave = specialTokenizerState; |
michael@0 | 143 | this->endTagExpectation = endTagExpectation; |
michael@0 | 144 | endTagExpectationToArray(); |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | void |
michael@0 | 148 | nsHtml5Tokenizer::endTagExpectationToArray() |
michael@0 | 149 | { |
michael@0 | 150 | switch(endTagExpectation->getGroup()) { |
michael@0 | 151 | case NS_HTML5TREE_BUILDER_TITLE: { |
michael@0 | 152 | endTagExpectationAsArray = TITLE_ARR; |
michael@0 | 153 | return; |
michael@0 | 154 | } |
michael@0 | 155 | case NS_HTML5TREE_BUILDER_SCRIPT: { |
michael@0 | 156 | endTagExpectationAsArray = SCRIPT_ARR; |
michael@0 | 157 | return; |
michael@0 | 158 | } |
michael@0 | 159 | case NS_HTML5TREE_BUILDER_STYLE: { |
michael@0 | 160 | endTagExpectationAsArray = STYLE_ARR; |
michael@0 | 161 | return; |
michael@0 | 162 | } |
michael@0 | 163 | case NS_HTML5TREE_BUILDER_PLAINTEXT: { |
michael@0 | 164 | endTagExpectationAsArray = PLAINTEXT_ARR; |
michael@0 | 165 | return; |
michael@0 | 166 | } |
michael@0 | 167 | case NS_HTML5TREE_BUILDER_XMP: { |
michael@0 | 168 | endTagExpectationAsArray = XMP_ARR; |
michael@0 | 169 | return; |
michael@0 | 170 | } |
michael@0 | 171 | case NS_HTML5TREE_BUILDER_TEXTAREA: { |
michael@0 | 172 | endTagExpectationAsArray = TEXTAREA_ARR; |
michael@0 | 173 | return; |
michael@0 | 174 | } |
michael@0 | 175 | case NS_HTML5TREE_BUILDER_IFRAME: { |
michael@0 | 176 | endTagExpectationAsArray = IFRAME_ARR; |
michael@0 | 177 | return; |
michael@0 | 178 | } |
michael@0 | 179 | case NS_HTML5TREE_BUILDER_NOEMBED: { |
michael@0 | 180 | endTagExpectationAsArray = NOEMBED_ARR; |
michael@0 | 181 | return; |
michael@0 | 182 | } |
michael@0 | 183 | case NS_HTML5TREE_BUILDER_NOSCRIPT: { |
michael@0 | 184 | endTagExpectationAsArray = NOSCRIPT_ARR; |
michael@0 | 185 | return; |
michael@0 | 186 | } |
michael@0 | 187 | case NS_HTML5TREE_BUILDER_NOFRAMES: { |
michael@0 | 188 | endTagExpectationAsArray = NOFRAMES_ARR; |
michael@0 | 189 | return; |
michael@0 | 190 | } |
michael@0 | 191 | default: { |
michael@0 | 192 | MOZ_ASSERT(false, "Bad end tag expectation."); |
michael@0 | 193 | return; |
michael@0 | 194 | } |
michael@0 | 195 | } |
michael@0 | 196 | } |
michael@0 | 197 | |
michael@0 | 198 | void |
michael@0 | 199 | nsHtml5Tokenizer::setLineNumber(int32_t line) |
michael@0 | 200 | { |
michael@0 | 201 | this->line = line; |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | nsHtml5HtmlAttributes* |
michael@0 | 205 | nsHtml5Tokenizer::emptyAttributes() |
michael@0 | 206 | { |
michael@0 | 207 | return nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES; |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | void |
michael@0 | 211 | nsHtml5Tokenizer::appendStrBuf(char16_t c) |
michael@0 | 212 | { |
michael@0 | 213 | if (strBufLen == strBuf.length) { |
michael@0 | 214 | jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(strBuf.length + NS_HTML5TOKENIZER_BUFFER_GROW_BY); |
michael@0 | 215 | nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length); |
michael@0 | 216 | strBuf = newBuf; |
michael@0 | 217 | } |
michael@0 | 218 | strBuf[strBufLen++] = c; |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | nsString* |
michael@0 | 222 | nsHtml5Tokenizer::strBufToString() |
michael@0 | 223 | { |
michael@0 | 224 | return nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen); |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | void |
michael@0 | 228 | nsHtml5Tokenizer::strBufToDoctypeName() |
michael@0 | 229 | { |
michael@0 | 230 | doctypeName = nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner); |
michael@0 | 231 | } |
michael@0 | 232 | |
michael@0 | 233 | void |
michael@0 | 234 | nsHtml5Tokenizer::emitStrBuf() |
michael@0 | 235 | { |
michael@0 | 236 | if (strBufLen > 0) { |
michael@0 | 237 | tokenHandler->characters(strBuf, 0, strBufLen); |
michael@0 | 238 | } |
michael@0 | 239 | } |
michael@0 | 240 | |
michael@0 | 241 | void |
michael@0 | 242 | nsHtml5Tokenizer::appendLongStrBuf(char16_t c) |
michael@0 | 243 | { |
michael@0 | 244 | if (longStrBufLen == longStrBuf.length) { |
michael@0 | 245 | jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(longStrBufLen + (longStrBufLen >> 1)); |
michael@0 | 246 | nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length); |
michael@0 | 247 | longStrBuf = newBuf; |
michael@0 | 248 | } |
michael@0 | 249 | longStrBuf[longStrBufLen++] = c; |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | void |
michael@0 | 253 | nsHtml5Tokenizer::appendLongStrBuf(char16_t* buffer, int32_t offset, int32_t length) |
michael@0 | 254 | { |
michael@0 | 255 | int32_t reqLen = longStrBufLen + length; |
michael@0 | 256 | if (longStrBuf.length < reqLen) { |
michael@0 | 257 | jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(reqLen + (reqLen >> 1)); |
michael@0 | 258 | nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length); |
michael@0 | 259 | longStrBuf = newBuf; |
michael@0 | 260 | } |
michael@0 | 261 | nsHtml5ArrayCopy::arraycopy(buffer, offset, longStrBuf, longStrBufLen, length); |
michael@0 | 262 | longStrBufLen = reqLen; |
michael@0 | 263 | } |
michael@0 | 264 | |
michael@0 | 265 | nsString* |
michael@0 | 266 | nsHtml5Tokenizer::longStrBufToString() |
michael@0 | 267 | { |
michael@0 | 268 | return nsHtml5Portability::newStringFromBuffer(longStrBuf, 0, longStrBufLen); |
michael@0 | 269 | } |
michael@0 | 270 | |
michael@0 | 271 | void |
michael@0 | 272 | nsHtml5Tokenizer::emitComment(int32_t provisionalHyphens, int32_t pos) |
michael@0 | 273 | { |
michael@0 | 274 | tokenHandler->comment(longStrBuf, 0, longStrBufLen - provisionalHyphens); |
michael@0 | 275 | cstart = pos + 1; |
michael@0 | 276 | } |
michael@0 | 277 | |
michael@0 | 278 | void |
michael@0 | 279 | nsHtml5Tokenizer::flushChars(char16_t* buf, int32_t pos) |
michael@0 | 280 | { |
michael@0 | 281 | if (pos > cstart) { |
michael@0 | 282 | tokenHandler->characters(buf, cstart, pos - cstart); |
michael@0 | 283 | } |
michael@0 | 284 | cstart = INT32_MAX; |
michael@0 | 285 | } |
michael@0 | 286 | |
michael@0 | 287 | void |
michael@0 | 288 | nsHtml5Tokenizer::strBufToElementNameString() |
michael@0 | 289 | { |
michael@0 | 290 | tagName = nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner); |
michael@0 | 291 | } |
michael@0 | 292 | |
michael@0 | 293 | int32_t |
michael@0 | 294 | nsHtml5Tokenizer::emitCurrentTagToken(bool selfClosing, int32_t pos) |
michael@0 | 295 | { |
michael@0 | 296 | cstart = pos + 1; |
michael@0 | 297 | maybeErrSlashInEndTag(selfClosing); |
michael@0 | 298 | stateSave = NS_HTML5TOKENIZER_DATA; |
michael@0 | 299 | nsHtml5HtmlAttributes* attrs = (!attributes ? nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES : attributes); |
michael@0 | 300 | if (endTag) { |
michael@0 | 301 | maybeErrAttributesOnEndTag(attrs); |
michael@0 | 302 | if (!viewingXmlSource) { |
michael@0 | 303 | tokenHandler->endTag(tagName); |
michael@0 | 304 | } |
michael@0 | 305 | if (newAttributesEachTime) { |
michael@0 | 306 | delete attributes; |
michael@0 | 307 | attributes = nullptr; |
michael@0 | 308 | } |
michael@0 | 309 | } else { |
michael@0 | 310 | if (viewingXmlSource) { |
michael@0 | 311 | MOZ_ASSERT(newAttributesEachTime); |
michael@0 | 312 | delete attributes; |
michael@0 | 313 | attributes = nullptr; |
michael@0 | 314 | } else { |
michael@0 | 315 | tokenHandler->startTag(tagName, attrs, selfClosing); |
michael@0 | 316 | } |
michael@0 | 317 | } |
michael@0 | 318 | tagName->release(); |
michael@0 | 319 | tagName = nullptr; |
michael@0 | 320 | if (newAttributesEachTime) { |
michael@0 | 321 | attributes = nullptr; |
michael@0 | 322 | } else { |
michael@0 | 323 | attributes->clear(0); |
michael@0 | 324 | } |
michael@0 | 325 | return stateSave; |
michael@0 | 326 | } |
michael@0 | 327 | |
michael@0 | 328 | void |
michael@0 | 329 | nsHtml5Tokenizer::attributeNameComplete() |
michael@0 | 330 | { |
michael@0 | 331 | attributeName = nsHtml5AttributeName::nameByBuffer(strBuf, 0, strBufLen, interner); |
michael@0 | 332 | if (!attributes) { |
michael@0 | 333 | attributes = new nsHtml5HtmlAttributes(0); |
michael@0 | 334 | } |
michael@0 | 335 | if (attributes->contains(attributeName)) { |
michael@0 | 336 | errDuplicateAttribute(); |
michael@0 | 337 | attributeName->release(); |
michael@0 | 338 | attributeName = nullptr; |
michael@0 | 339 | } |
michael@0 | 340 | } |
michael@0 | 341 | |
michael@0 | 342 | void |
michael@0 | 343 | nsHtml5Tokenizer::addAttributeWithoutValue() |
michael@0 | 344 | { |
michael@0 | 345 | |
michael@0 | 346 | if (attributeName) { |
michael@0 | 347 | attributes->addAttribute(attributeName, nsHtml5Portability::newEmptyString()); |
michael@0 | 348 | attributeName = nullptr; |
michael@0 | 349 | } |
michael@0 | 350 | } |
michael@0 | 351 | |
michael@0 | 352 | void |
michael@0 | 353 | nsHtml5Tokenizer::addAttributeWithValue() |
michael@0 | 354 | { |
michael@0 | 355 | if (attributeName) { |
michael@0 | 356 | nsString* val = longStrBufToString(); |
michael@0 | 357 | if (mViewSource) { |
michael@0 | 358 | mViewSource->MaybeLinkifyAttributeValue(attributeName, val); |
michael@0 | 359 | } |
michael@0 | 360 | attributes->addAttribute(attributeName, val); |
michael@0 | 361 | attributeName = nullptr; |
michael@0 | 362 | } |
michael@0 | 363 | } |
michael@0 | 364 | |
michael@0 | 365 | void |
michael@0 | 366 | nsHtml5Tokenizer::start() |
michael@0 | 367 | { |
michael@0 | 368 | initializeWithoutStarting(); |
michael@0 | 369 | tokenHandler->startTokenization(this); |
michael@0 | 370 | } |
michael@0 | 371 | |
michael@0 | 372 | bool |
michael@0 | 373 | nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer* buffer) |
michael@0 | 374 | { |
michael@0 | 375 | int32_t state = stateSave; |
michael@0 | 376 | int32_t returnState = returnStateSave; |
michael@0 | 377 | char16_t c = '\0'; |
michael@0 | 378 | shouldSuspend = false; |
michael@0 | 379 | lastCR = false; |
michael@0 | 380 | int32_t start = buffer->getStart(); |
michael@0 | 381 | int32_t pos = start - 1; |
michael@0 | 382 | switch(state) { |
michael@0 | 383 | case NS_HTML5TOKENIZER_DATA: |
michael@0 | 384 | case NS_HTML5TOKENIZER_RCDATA: |
michael@0 | 385 | case NS_HTML5TOKENIZER_SCRIPT_DATA: |
michael@0 | 386 | case NS_HTML5TOKENIZER_PLAINTEXT: |
michael@0 | 387 | case NS_HTML5TOKENIZER_RAWTEXT: |
michael@0 | 388 | case NS_HTML5TOKENIZER_CDATA_SECTION: |
michael@0 | 389 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED: |
michael@0 | 390 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START: |
michael@0 | 391 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH: |
michael@0 | 392 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH: |
michael@0 | 393 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH: |
michael@0 | 394 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START: |
michael@0 | 395 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED: |
michael@0 | 396 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: |
michael@0 | 397 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH: |
michael@0 | 398 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: |
michael@0 | 399 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: { |
michael@0 | 400 | cstart = start; |
michael@0 | 401 | break; |
michael@0 | 402 | } |
michael@0 | 403 | default: { |
michael@0 | 404 | cstart = INT32_MAX; |
michael@0 | 405 | break; |
michael@0 | 406 | } |
michael@0 | 407 | } |
michael@0 | 408 | if (mViewSource) { |
michael@0 | 409 | mViewSource->SetBuffer(buffer); |
michael@0 | 410 | pos = stateLoop<nsHtml5ViewSourcePolicy>(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd()); |
michael@0 | 411 | mViewSource->DropBuffer((pos == buffer->getEnd()) ? pos : pos + 1); |
michael@0 | 412 | } else { |
michael@0 | 413 | pos = stateLoop<nsHtml5SilentPolicy>(state, c, pos, buffer->getBuffer(), false, returnState, buffer->getEnd()); |
michael@0 | 414 | } |
michael@0 | 415 | if (pos == buffer->getEnd()) { |
michael@0 | 416 | buffer->setStart(pos); |
michael@0 | 417 | } else { |
michael@0 | 418 | buffer->setStart(pos + 1); |
michael@0 | 419 | } |
michael@0 | 420 | return lastCR; |
michael@0 | 421 | } |
michael@0 | 422 | |
michael@0 | 423 | template<class P> |
michael@0 | 424 | int32_t |
michael@0 | 425 | nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* buf, bool reconsume, int32_t returnState, int32_t endPos) |
michael@0 | 426 | { |
michael@0 | 427 | stateloop: for (; ; ) { |
michael@0 | 428 | switch(state) { |
michael@0 | 429 | case NS_HTML5TOKENIZER_DATA: { |
michael@0 | 430 | for (; ; ) { |
michael@0 | 431 | if (reconsume) { |
michael@0 | 432 | reconsume = false; |
michael@0 | 433 | } else { |
michael@0 | 434 | if (++pos == endPos) { |
michael@0 | 435 | NS_HTML5_BREAK(stateloop); |
michael@0 | 436 | } |
michael@0 | 437 | c = checkChar(buf, pos); |
michael@0 | 438 | } |
michael@0 | 439 | switch(c) { |
michael@0 | 440 | case '&': { |
michael@0 | 441 | flushChars(buf, pos); |
michael@0 | 442 | clearStrBufAndAppend(c); |
michael@0 | 443 | setAdditionalAndRememberAmpersandLocation('\0'); |
michael@0 | 444 | returnState = state; |
michael@0 | 445 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); |
michael@0 | 446 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 447 | } |
michael@0 | 448 | case '<': { |
michael@0 | 449 | flushChars(buf, pos); |
michael@0 | 450 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_OPEN, reconsume, pos); |
michael@0 | 451 | NS_HTML5_BREAK(dataloop); |
michael@0 | 452 | } |
michael@0 | 453 | case '\0': { |
michael@0 | 454 | emitReplacementCharacter(buf, pos); |
michael@0 | 455 | continue; |
michael@0 | 456 | } |
michael@0 | 457 | case '\r': { |
michael@0 | 458 | emitCarriageReturn(buf, pos); |
michael@0 | 459 | NS_HTML5_BREAK(stateloop); |
michael@0 | 460 | } |
michael@0 | 461 | case '\n': { |
michael@0 | 462 | silentLineFeed(); |
michael@0 | 463 | } |
michael@0 | 464 | default: { |
michael@0 | 465 | continue; |
michael@0 | 466 | } |
michael@0 | 467 | } |
michael@0 | 468 | } |
michael@0 | 469 | dataloop_end: ; |
michael@0 | 470 | } |
michael@0 | 471 | case NS_HTML5TOKENIZER_TAG_OPEN: { |
michael@0 | 472 | for (; ; ) { |
michael@0 | 473 | if (++pos == endPos) { |
michael@0 | 474 | NS_HTML5_BREAK(stateloop); |
michael@0 | 475 | } |
michael@0 | 476 | c = checkChar(buf, pos); |
michael@0 | 477 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 478 | endTag = false; |
michael@0 | 479 | clearStrBufAndAppend((char16_t) (c + 0x20)); |
michael@0 | 480 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos); |
michael@0 | 481 | NS_HTML5_BREAK(tagopenloop); |
michael@0 | 482 | } else if (c >= 'a' && c <= 'z') { |
michael@0 | 483 | endTag = false; |
michael@0 | 484 | clearStrBufAndAppend(c); |
michael@0 | 485 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos); |
michael@0 | 486 | NS_HTML5_BREAK(tagopenloop); |
michael@0 | 487 | } |
michael@0 | 488 | switch(c) { |
michael@0 | 489 | case '!': { |
michael@0 | 490 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN, reconsume, pos); |
michael@0 | 491 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 492 | } |
michael@0 | 493 | case '/': { |
michael@0 | 494 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CLOSE_TAG_OPEN, reconsume, pos); |
michael@0 | 495 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 496 | } |
michael@0 | 497 | case '\?': { |
michael@0 | 498 | if (viewingXmlSource) { |
michael@0 | 499 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos); |
michael@0 | 500 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 501 | } |
michael@0 | 502 | if (P::reportErrors) { |
michael@0 | 503 | errProcessingInstruction(); |
michael@0 | 504 | } |
michael@0 | 505 | clearLongStrBufAndAppend(c); |
michael@0 | 506 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 507 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 508 | } |
michael@0 | 509 | case '>': { |
michael@0 | 510 | if (P::reportErrors) { |
michael@0 | 511 | errLtGt(); |
michael@0 | 512 | } |
michael@0 | 513 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 2); |
michael@0 | 514 | cstart = pos + 1; |
michael@0 | 515 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 516 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 517 | } |
michael@0 | 518 | default: { |
michael@0 | 519 | if (P::reportErrors) { |
michael@0 | 520 | errBadCharAfterLt(c); |
michael@0 | 521 | } |
michael@0 | 522 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 523 | cstart = pos; |
michael@0 | 524 | reconsume = true; |
michael@0 | 525 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 526 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 527 | } |
michael@0 | 528 | } |
michael@0 | 529 | } |
michael@0 | 530 | tagopenloop_end: ; |
michael@0 | 531 | } |
michael@0 | 532 | case NS_HTML5TOKENIZER_TAG_NAME: { |
michael@0 | 533 | for (; ; ) { |
michael@0 | 534 | if (++pos == endPos) { |
michael@0 | 535 | NS_HTML5_BREAK(stateloop); |
michael@0 | 536 | } |
michael@0 | 537 | c = checkChar(buf, pos); |
michael@0 | 538 | switch(c) { |
michael@0 | 539 | case '\r': { |
michael@0 | 540 | silentCarriageReturn(); |
michael@0 | 541 | strBufToElementNameString(); |
michael@0 | 542 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 543 | NS_HTML5_BREAK(stateloop); |
michael@0 | 544 | } |
michael@0 | 545 | case '\n': { |
michael@0 | 546 | silentLineFeed(); |
michael@0 | 547 | } |
michael@0 | 548 | case ' ': |
michael@0 | 549 | case '\t': |
michael@0 | 550 | case '\f': { |
michael@0 | 551 | strBufToElementNameString(); |
michael@0 | 552 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 553 | NS_HTML5_BREAK(tagnameloop); |
michael@0 | 554 | } |
michael@0 | 555 | case '/': { |
michael@0 | 556 | strBufToElementNameString(); |
michael@0 | 557 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); |
michael@0 | 558 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 559 | } |
michael@0 | 560 | case '>': { |
michael@0 | 561 | strBufToElementNameString(); |
michael@0 | 562 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 563 | if (shouldSuspend) { |
michael@0 | 564 | NS_HTML5_BREAK(stateloop); |
michael@0 | 565 | } |
michael@0 | 566 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 567 | } |
michael@0 | 568 | case '\0': { |
michael@0 | 569 | c = 0xfffd; |
michael@0 | 570 | } |
michael@0 | 571 | default: { |
michael@0 | 572 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 573 | c += 0x20; |
michael@0 | 574 | } |
michael@0 | 575 | appendStrBuf(c); |
michael@0 | 576 | continue; |
michael@0 | 577 | } |
michael@0 | 578 | } |
michael@0 | 579 | } |
michael@0 | 580 | tagnameloop_end: ; |
michael@0 | 581 | } |
michael@0 | 582 | case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME: { |
michael@0 | 583 | for (; ; ) { |
michael@0 | 584 | if (reconsume) { |
michael@0 | 585 | reconsume = false; |
michael@0 | 586 | } else { |
michael@0 | 587 | if (++pos == endPos) { |
michael@0 | 588 | NS_HTML5_BREAK(stateloop); |
michael@0 | 589 | } |
michael@0 | 590 | c = checkChar(buf, pos); |
michael@0 | 591 | } |
michael@0 | 592 | switch(c) { |
michael@0 | 593 | case '\r': { |
michael@0 | 594 | silentCarriageReturn(); |
michael@0 | 595 | NS_HTML5_BREAK(stateloop); |
michael@0 | 596 | } |
michael@0 | 597 | case '\n': { |
michael@0 | 598 | silentLineFeed(); |
michael@0 | 599 | } |
michael@0 | 600 | case ' ': |
michael@0 | 601 | case '\t': |
michael@0 | 602 | case '\f': { |
michael@0 | 603 | continue; |
michael@0 | 604 | } |
michael@0 | 605 | case '/': { |
michael@0 | 606 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); |
michael@0 | 607 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 608 | } |
michael@0 | 609 | case '>': { |
michael@0 | 610 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 611 | if (shouldSuspend) { |
michael@0 | 612 | NS_HTML5_BREAK(stateloop); |
michael@0 | 613 | } |
michael@0 | 614 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 615 | } |
michael@0 | 616 | case '\0': { |
michael@0 | 617 | c = 0xfffd; |
michael@0 | 618 | } |
michael@0 | 619 | case '\"': |
michael@0 | 620 | case '\'': |
michael@0 | 621 | case '<': |
michael@0 | 622 | case '=': { |
michael@0 | 623 | if (P::reportErrors) { |
michael@0 | 624 | errBadCharBeforeAttributeNameOrNull(c); |
michael@0 | 625 | } |
michael@0 | 626 | } |
michael@0 | 627 | default: { |
michael@0 | 628 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 629 | c += 0x20; |
michael@0 | 630 | } |
michael@0 | 631 | clearStrBufAndAppend(c); |
michael@0 | 632 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 633 | NS_HTML5_BREAK(beforeattributenameloop); |
michael@0 | 634 | } |
michael@0 | 635 | } |
michael@0 | 636 | } |
michael@0 | 637 | beforeattributenameloop_end: ; |
michael@0 | 638 | } |
michael@0 | 639 | case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: { |
michael@0 | 640 | for (; ; ) { |
michael@0 | 641 | if (++pos == endPos) { |
michael@0 | 642 | NS_HTML5_BREAK(stateloop); |
michael@0 | 643 | } |
michael@0 | 644 | c = checkChar(buf, pos); |
michael@0 | 645 | switch(c) { |
michael@0 | 646 | case '\r': { |
michael@0 | 647 | silentCarriageReturn(); |
michael@0 | 648 | attributeNameComplete(); |
michael@0 | 649 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 650 | NS_HTML5_BREAK(stateloop); |
michael@0 | 651 | } |
michael@0 | 652 | case '\n': { |
michael@0 | 653 | silentLineFeed(); |
michael@0 | 654 | } |
michael@0 | 655 | case ' ': |
michael@0 | 656 | case '\t': |
michael@0 | 657 | case '\f': { |
michael@0 | 658 | attributeNameComplete(); |
michael@0 | 659 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 660 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 661 | } |
michael@0 | 662 | case '/': { |
michael@0 | 663 | attributeNameComplete(); |
michael@0 | 664 | addAttributeWithoutValue(); |
michael@0 | 665 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); |
michael@0 | 666 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 667 | } |
michael@0 | 668 | case '=': { |
michael@0 | 669 | attributeNameComplete(); |
michael@0 | 670 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos); |
michael@0 | 671 | NS_HTML5_BREAK(attributenameloop); |
michael@0 | 672 | } |
michael@0 | 673 | case '>': { |
michael@0 | 674 | attributeNameComplete(); |
michael@0 | 675 | addAttributeWithoutValue(); |
michael@0 | 676 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 677 | if (shouldSuspend) { |
michael@0 | 678 | NS_HTML5_BREAK(stateloop); |
michael@0 | 679 | } |
michael@0 | 680 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 681 | } |
michael@0 | 682 | case '\0': { |
michael@0 | 683 | c = 0xfffd; |
michael@0 | 684 | } |
michael@0 | 685 | case '\"': |
michael@0 | 686 | case '\'': |
michael@0 | 687 | case '<': { |
michael@0 | 688 | if (P::reportErrors) { |
michael@0 | 689 | errQuoteOrLtInAttributeNameOrNull(c); |
michael@0 | 690 | } |
michael@0 | 691 | } |
michael@0 | 692 | default: { |
michael@0 | 693 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 694 | c += 0x20; |
michael@0 | 695 | } |
michael@0 | 696 | appendStrBuf(c); |
michael@0 | 697 | continue; |
michael@0 | 698 | } |
michael@0 | 699 | } |
michael@0 | 700 | } |
michael@0 | 701 | attributenameloop_end: ; |
michael@0 | 702 | } |
michael@0 | 703 | case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: { |
michael@0 | 704 | for (; ; ) { |
michael@0 | 705 | if (++pos == endPos) { |
michael@0 | 706 | NS_HTML5_BREAK(stateloop); |
michael@0 | 707 | } |
michael@0 | 708 | c = checkChar(buf, pos); |
michael@0 | 709 | switch(c) { |
michael@0 | 710 | case '\r': { |
michael@0 | 711 | silentCarriageReturn(); |
michael@0 | 712 | NS_HTML5_BREAK(stateloop); |
michael@0 | 713 | } |
michael@0 | 714 | case '\n': { |
michael@0 | 715 | silentLineFeed(); |
michael@0 | 716 | } |
michael@0 | 717 | case ' ': |
michael@0 | 718 | case '\t': |
michael@0 | 719 | case '\f': { |
michael@0 | 720 | continue; |
michael@0 | 721 | } |
michael@0 | 722 | case '\"': { |
michael@0 | 723 | clearLongStrBuf(); |
michael@0 | 724 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 725 | NS_HTML5_BREAK(beforeattributevalueloop); |
michael@0 | 726 | } |
michael@0 | 727 | case '&': { |
michael@0 | 728 | clearLongStrBuf(); |
michael@0 | 729 | reconsume = true; |
michael@0 | 730 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); |
michael@0 | 731 | |
michael@0 | 732 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 733 | } |
michael@0 | 734 | case '\'': { |
michael@0 | 735 | clearLongStrBuf(); |
michael@0 | 736 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 737 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 738 | } |
michael@0 | 739 | case '>': { |
michael@0 | 740 | if (P::reportErrors) { |
michael@0 | 741 | errAttributeValueMissing(); |
michael@0 | 742 | } |
michael@0 | 743 | addAttributeWithoutValue(); |
michael@0 | 744 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 745 | if (shouldSuspend) { |
michael@0 | 746 | NS_HTML5_BREAK(stateloop); |
michael@0 | 747 | } |
michael@0 | 748 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 749 | } |
michael@0 | 750 | case '\0': { |
michael@0 | 751 | c = 0xfffd; |
michael@0 | 752 | } |
michael@0 | 753 | case '<': |
michael@0 | 754 | case '=': |
michael@0 | 755 | case '`': { |
michael@0 | 756 | if (P::reportErrors) { |
michael@0 | 757 | errLtOrEqualsOrGraveInUnquotedAttributeOrNull(c); |
michael@0 | 758 | } |
michael@0 | 759 | } |
michael@0 | 760 | default: { |
michael@0 | 761 | clearLongStrBufAndAppend(c); |
michael@0 | 762 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); |
michael@0 | 763 | |
michael@0 | 764 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 765 | } |
michael@0 | 766 | } |
michael@0 | 767 | } |
michael@0 | 768 | beforeattributevalueloop_end: ; |
michael@0 | 769 | } |
michael@0 | 770 | case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: { |
michael@0 | 771 | for (; ; ) { |
michael@0 | 772 | if (reconsume) { |
michael@0 | 773 | reconsume = false; |
michael@0 | 774 | } else { |
michael@0 | 775 | if (++pos == endPos) { |
michael@0 | 776 | NS_HTML5_BREAK(stateloop); |
michael@0 | 777 | } |
michael@0 | 778 | c = checkChar(buf, pos); |
michael@0 | 779 | } |
michael@0 | 780 | switch(c) { |
michael@0 | 781 | case '\"': { |
michael@0 | 782 | addAttributeWithValue(); |
michael@0 | 783 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos); |
michael@0 | 784 | NS_HTML5_BREAK(attributevaluedoublequotedloop); |
michael@0 | 785 | } |
michael@0 | 786 | case '&': { |
michael@0 | 787 | clearStrBufAndAppend(c); |
michael@0 | 788 | setAdditionalAndRememberAmpersandLocation('\"'); |
michael@0 | 789 | returnState = state; |
michael@0 | 790 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); |
michael@0 | 791 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 792 | } |
michael@0 | 793 | case '\r': { |
michael@0 | 794 | appendLongStrBufCarriageReturn(); |
michael@0 | 795 | NS_HTML5_BREAK(stateloop); |
michael@0 | 796 | } |
michael@0 | 797 | case '\n': { |
michael@0 | 798 | appendLongStrBufLineFeed(); |
michael@0 | 799 | continue; |
michael@0 | 800 | } |
michael@0 | 801 | case '\0': { |
michael@0 | 802 | c = 0xfffd; |
michael@0 | 803 | } |
michael@0 | 804 | default: { |
michael@0 | 805 | appendLongStrBuf(c); |
michael@0 | 806 | continue; |
michael@0 | 807 | } |
michael@0 | 808 | } |
michael@0 | 809 | } |
michael@0 | 810 | attributevaluedoublequotedloop_end: ; |
michael@0 | 811 | } |
michael@0 | 812 | case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED: { |
michael@0 | 813 | for (; ; ) { |
michael@0 | 814 | if (++pos == endPos) { |
michael@0 | 815 | NS_HTML5_BREAK(stateloop); |
michael@0 | 816 | } |
michael@0 | 817 | c = checkChar(buf, pos); |
michael@0 | 818 | switch(c) { |
michael@0 | 819 | case '\r': { |
michael@0 | 820 | silentCarriageReturn(); |
michael@0 | 821 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 822 | NS_HTML5_BREAK(stateloop); |
michael@0 | 823 | } |
michael@0 | 824 | case '\n': { |
michael@0 | 825 | silentLineFeed(); |
michael@0 | 826 | } |
michael@0 | 827 | case ' ': |
michael@0 | 828 | case '\t': |
michael@0 | 829 | case '\f': { |
michael@0 | 830 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 831 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 832 | } |
michael@0 | 833 | case '/': { |
michael@0 | 834 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); |
michael@0 | 835 | NS_HTML5_BREAK(afterattributevaluequotedloop); |
michael@0 | 836 | } |
michael@0 | 837 | case '>': { |
michael@0 | 838 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 839 | if (shouldSuspend) { |
michael@0 | 840 | NS_HTML5_BREAK(stateloop); |
michael@0 | 841 | } |
michael@0 | 842 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 843 | } |
michael@0 | 844 | default: { |
michael@0 | 845 | if (P::reportErrors) { |
michael@0 | 846 | errNoSpaceBetweenAttributes(); |
michael@0 | 847 | } |
michael@0 | 848 | reconsume = true; |
michael@0 | 849 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 850 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 851 | } |
michael@0 | 852 | } |
michael@0 | 853 | } |
michael@0 | 854 | afterattributevaluequotedloop_end: ; |
michael@0 | 855 | } |
michael@0 | 856 | case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: { |
michael@0 | 857 | if (++pos == endPos) { |
michael@0 | 858 | NS_HTML5_BREAK(stateloop); |
michael@0 | 859 | } |
michael@0 | 860 | c = checkChar(buf, pos); |
michael@0 | 861 | switch(c) { |
michael@0 | 862 | case '>': { |
michael@0 | 863 | state = P::transition(mViewSource, emitCurrentTagToken(true, pos), reconsume, pos); |
michael@0 | 864 | if (shouldSuspend) { |
michael@0 | 865 | NS_HTML5_BREAK(stateloop); |
michael@0 | 866 | } |
michael@0 | 867 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 868 | } |
michael@0 | 869 | default: { |
michael@0 | 870 | if (P::reportErrors) { |
michael@0 | 871 | errSlashNotFollowedByGt(); |
michael@0 | 872 | } |
michael@0 | 873 | reconsume = true; |
michael@0 | 874 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 875 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 876 | } |
michael@0 | 877 | } |
michael@0 | 878 | } |
michael@0 | 879 | case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: { |
michael@0 | 880 | for (; ; ) { |
michael@0 | 881 | if (reconsume) { |
michael@0 | 882 | reconsume = false; |
michael@0 | 883 | } else { |
michael@0 | 884 | if (++pos == endPos) { |
michael@0 | 885 | NS_HTML5_BREAK(stateloop); |
michael@0 | 886 | } |
michael@0 | 887 | c = checkChar(buf, pos); |
michael@0 | 888 | } |
michael@0 | 889 | switch(c) { |
michael@0 | 890 | case '\r': { |
michael@0 | 891 | silentCarriageReturn(); |
michael@0 | 892 | addAttributeWithValue(); |
michael@0 | 893 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 894 | NS_HTML5_BREAK(stateloop); |
michael@0 | 895 | } |
michael@0 | 896 | case '\n': { |
michael@0 | 897 | silentLineFeed(); |
michael@0 | 898 | } |
michael@0 | 899 | case ' ': |
michael@0 | 900 | case '\t': |
michael@0 | 901 | case '\f': { |
michael@0 | 902 | addAttributeWithValue(); |
michael@0 | 903 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 904 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 905 | } |
michael@0 | 906 | case '&': { |
michael@0 | 907 | clearStrBufAndAppend(c); |
michael@0 | 908 | setAdditionalAndRememberAmpersandLocation('>'); |
michael@0 | 909 | returnState = state; |
michael@0 | 910 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); |
michael@0 | 911 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 912 | } |
michael@0 | 913 | case '>': { |
michael@0 | 914 | addAttributeWithValue(); |
michael@0 | 915 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 916 | if (shouldSuspend) { |
michael@0 | 917 | NS_HTML5_BREAK(stateloop); |
michael@0 | 918 | } |
michael@0 | 919 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 920 | } |
michael@0 | 921 | case '\0': { |
michael@0 | 922 | c = 0xfffd; |
michael@0 | 923 | } |
michael@0 | 924 | case '<': |
michael@0 | 925 | case '\"': |
michael@0 | 926 | case '\'': |
michael@0 | 927 | case '=': |
michael@0 | 928 | case '`': { |
michael@0 | 929 | if (P::reportErrors) { |
michael@0 | 930 | errUnquotedAttributeValOrNull(c); |
michael@0 | 931 | } |
michael@0 | 932 | } |
michael@0 | 933 | default: { |
michael@0 | 934 | |
michael@0 | 935 | appendLongStrBuf(c); |
michael@0 | 936 | continue; |
michael@0 | 937 | } |
michael@0 | 938 | } |
michael@0 | 939 | } |
michael@0 | 940 | } |
michael@0 | 941 | case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME: { |
michael@0 | 942 | for (; ; ) { |
michael@0 | 943 | if (++pos == endPos) { |
michael@0 | 944 | NS_HTML5_BREAK(stateloop); |
michael@0 | 945 | } |
michael@0 | 946 | c = checkChar(buf, pos); |
michael@0 | 947 | switch(c) { |
michael@0 | 948 | case '\r': { |
michael@0 | 949 | silentCarriageReturn(); |
michael@0 | 950 | NS_HTML5_BREAK(stateloop); |
michael@0 | 951 | } |
michael@0 | 952 | case '\n': { |
michael@0 | 953 | silentLineFeed(); |
michael@0 | 954 | } |
michael@0 | 955 | case ' ': |
michael@0 | 956 | case '\t': |
michael@0 | 957 | case '\f': { |
michael@0 | 958 | continue; |
michael@0 | 959 | } |
michael@0 | 960 | case '/': { |
michael@0 | 961 | addAttributeWithoutValue(); |
michael@0 | 962 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); |
michael@0 | 963 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 964 | } |
michael@0 | 965 | case '=': { |
michael@0 | 966 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos); |
michael@0 | 967 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 968 | } |
michael@0 | 969 | case '>': { |
michael@0 | 970 | addAttributeWithoutValue(); |
michael@0 | 971 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 972 | if (shouldSuspend) { |
michael@0 | 973 | NS_HTML5_BREAK(stateloop); |
michael@0 | 974 | } |
michael@0 | 975 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 976 | } |
michael@0 | 977 | case '\0': { |
michael@0 | 978 | c = 0xfffd; |
michael@0 | 979 | } |
michael@0 | 980 | case '\"': |
michael@0 | 981 | case '\'': |
michael@0 | 982 | case '<': { |
michael@0 | 983 | if (P::reportErrors) { |
michael@0 | 984 | errQuoteOrLtInAttributeNameOrNull(c); |
michael@0 | 985 | } |
michael@0 | 986 | } |
michael@0 | 987 | default: { |
michael@0 | 988 | addAttributeWithoutValue(); |
michael@0 | 989 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 990 | c += 0x20; |
michael@0 | 991 | } |
michael@0 | 992 | clearStrBufAndAppend(c); |
michael@0 | 993 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 994 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 995 | } |
michael@0 | 996 | } |
michael@0 | 997 | } |
michael@0 | 998 | } |
michael@0 | 999 | case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: { |
michael@0 | 1000 | for (; ; ) { |
michael@0 | 1001 | if (++pos == endPos) { |
michael@0 | 1002 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1003 | } |
michael@0 | 1004 | c = checkChar(buf, pos); |
michael@0 | 1005 | switch(c) { |
michael@0 | 1006 | case '-': { |
michael@0 | 1007 | clearLongStrBufAndAppend(c); |
michael@0 | 1008 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN, reconsume, pos); |
michael@0 | 1009 | NS_HTML5_BREAK(markupdeclarationopenloop); |
michael@0 | 1010 | } |
michael@0 | 1011 | case 'd': |
michael@0 | 1012 | case 'D': { |
michael@0 | 1013 | clearLongStrBufAndAppend(c); |
michael@0 | 1014 | index = 0; |
michael@0 | 1015 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE, reconsume, pos); |
michael@0 | 1016 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1017 | } |
michael@0 | 1018 | case '[': { |
michael@0 | 1019 | if (tokenHandler->cdataSectionAllowed()) { |
michael@0 | 1020 | clearLongStrBufAndAppend(c); |
michael@0 | 1021 | index = 0; |
michael@0 | 1022 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_START, reconsume, pos); |
michael@0 | 1023 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1024 | } |
michael@0 | 1025 | } |
michael@0 | 1026 | default: { |
michael@0 | 1027 | if (P::reportErrors) { |
michael@0 | 1028 | errBogusComment(); |
michael@0 | 1029 | } |
michael@0 | 1030 | clearLongStrBuf(); |
michael@0 | 1031 | reconsume = true; |
michael@0 | 1032 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 1033 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1034 | } |
michael@0 | 1035 | } |
michael@0 | 1036 | } |
michael@0 | 1037 | markupdeclarationopenloop_end: ; |
michael@0 | 1038 | } |
michael@0 | 1039 | case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: { |
michael@0 | 1040 | for (; ; ) { |
michael@0 | 1041 | if (++pos == endPos) { |
michael@0 | 1042 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1043 | } |
michael@0 | 1044 | c = checkChar(buf, pos); |
michael@0 | 1045 | switch(c) { |
michael@0 | 1046 | case '\0': { |
michael@0 | 1047 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1048 | } |
michael@0 | 1049 | case '-': { |
michael@0 | 1050 | clearLongStrBuf(); |
michael@0 | 1051 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START, reconsume, pos); |
michael@0 | 1052 | NS_HTML5_BREAK(markupdeclarationhyphenloop); |
michael@0 | 1053 | } |
michael@0 | 1054 | default: { |
michael@0 | 1055 | if (P::reportErrors) { |
michael@0 | 1056 | errBogusComment(); |
michael@0 | 1057 | } |
michael@0 | 1058 | reconsume = true; |
michael@0 | 1059 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 1060 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1061 | } |
michael@0 | 1062 | } |
michael@0 | 1063 | } |
michael@0 | 1064 | markupdeclarationhyphenloop_end: ; |
michael@0 | 1065 | } |
michael@0 | 1066 | case NS_HTML5TOKENIZER_COMMENT_START: { |
michael@0 | 1067 | for (; ; ) { |
michael@0 | 1068 | if (++pos == endPos) { |
michael@0 | 1069 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1070 | } |
michael@0 | 1071 | c = checkChar(buf, pos); |
michael@0 | 1072 | switch(c) { |
michael@0 | 1073 | case '-': { |
michael@0 | 1074 | appendLongStrBuf(c); |
michael@0 | 1075 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START_DASH, reconsume, pos); |
michael@0 | 1076 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1077 | } |
michael@0 | 1078 | case '>': { |
michael@0 | 1079 | if (P::reportErrors) { |
michael@0 | 1080 | errPrematureEndOfComment(); |
michael@0 | 1081 | } |
michael@0 | 1082 | emitComment(0, pos); |
michael@0 | 1083 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 1084 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1085 | } |
michael@0 | 1086 | case '\r': { |
michael@0 | 1087 | appendLongStrBufCarriageReturn(); |
michael@0 | 1088 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1089 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1090 | } |
michael@0 | 1091 | case '\n': { |
michael@0 | 1092 | appendLongStrBufLineFeed(); |
michael@0 | 1093 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1094 | NS_HTML5_BREAK(commentstartloop); |
michael@0 | 1095 | } |
michael@0 | 1096 | case '\0': { |
michael@0 | 1097 | c = 0xfffd; |
michael@0 | 1098 | } |
michael@0 | 1099 | default: { |
michael@0 | 1100 | appendLongStrBuf(c); |
michael@0 | 1101 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1102 | NS_HTML5_BREAK(commentstartloop); |
michael@0 | 1103 | } |
michael@0 | 1104 | } |
michael@0 | 1105 | } |
michael@0 | 1106 | commentstartloop_end: ; |
michael@0 | 1107 | } |
michael@0 | 1108 | case NS_HTML5TOKENIZER_COMMENT: { |
michael@0 | 1109 | for (; ; ) { |
michael@0 | 1110 | if (++pos == endPos) { |
michael@0 | 1111 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1112 | } |
michael@0 | 1113 | c = checkChar(buf, pos); |
michael@0 | 1114 | switch(c) { |
michael@0 | 1115 | case '-': { |
michael@0 | 1116 | appendLongStrBuf(c); |
michael@0 | 1117 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos); |
michael@0 | 1118 | NS_HTML5_BREAK(commentloop); |
michael@0 | 1119 | } |
michael@0 | 1120 | case '\r': { |
michael@0 | 1121 | appendLongStrBufCarriageReturn(); |
michael@0 | 1122 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1123 | } |
michael@0 | 1124 | case '\n': { |
michael@0 | 1125 | appendLongStrBufLineFeed(); |
michael@0 | 1126 | continue; |
michael@0 | 1127 | } |
michael@0 | 1128 | case '\0': { |
michael@0 | 1129 | c = 0xfffd; |
michael@0 | 1130 | } |
michael@0 | 1131 | default: { |
michael@0 | 1132 | appendLongStrBuf(c); |
michael@0 | 1133 | continue; |
michael@0 | 1134 | } |
michael@0 | 1135 | } |
michael@0 | 1136 | } |
michael@0 | 1137 | commentloop_end: ; |
michael@0 | 1138 | } |
michael@0 | 1139 | case NS_HTML5TOKENIZER_COMMENT_END_DASH: { |
michael@0 | 1140 | for (; ; ) { |
michael@0 | 1141 | if (++pos == endPos) { |
michael@0 | 1142 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1143 | } |
michael@0 | 1144 | c = checkChar(buf, pos); |
michael@0 | 1145 | switch(c) { |
michael@0 | 1146 | case '-': { |
michael@0 | 1147 | appendLongStrBuf(c); |
michael@0 | 1148 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos); |
michael@0 | 1149 | NS_HTML5_BREAK(commentenddashloop); |
michael@0 | 1150 | } |
michael@0 | 1151 | case '\r': { |
michael@0 | 1152 | appendLongStrBufCarriageReturn(); |
michael@0 | 1153 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1154 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1155 | } |
michael@0 | 1156 | case '\n': { |
michael@0 | 1157 | appendLongStrBufLineFeed(); |
michael@0 | 1158 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1159 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1160 | } |
michael@0 | 1161 | case '\0': { |
michael@0 | 1162 | c = 0xfffd; |
michael@0 | 1163 | } |
michael@0 | 1164 | default: { |
michael@0 | 1165 | appendLongStrBuf(c); |
michael@0 | 1166 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1167 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1168 | } |
michael@0 | 1169 | } |
michael@0 | 1170 | } |
michael@0 | 1171 | commentenddashloop_end: ; |
michael@0 | 1172 | } |
michael@0 | 1173 | case NS_HTML5TOKENIZER_COMMENT_END: { |
michael@0 | 1174 | for (; ; ) { |
michael@0 | 1175 | if (++pos == endPos) { |
michael@0 | 1176 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1177 | } |
michael@0 | 1178 | c = checkChar(buf, pos); |
michael@0 | 1179 | switch(c) { |
michael@0 | 1180 | case '>': { |
michael@0 | 1181 | emitComment(2, pos); |
michael@0 | 1182 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 1183 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1184 | } |
michael@0 | 1185 | case '-': { |
michael@0 | 1186 | adjustDoubleHyphenAndAppendToLongStrBufAndErr(c); |
michael@0 | 1187 | continue; |
michael@0 | 1188 | } |
michael@0 | 1189 | case '\r': { |
michael@0 | 1190 | adjustDoubleHyphenAndAppendToLongStrBufCarriageReturn(); |
michael@0 | 1191 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1192 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1193 | } |
michael@0 | 1194 | case '\n': { |
michael@0 | 1195 | adjustDoubleHyphenAndAppendToLongStrBufLineFeed(); |
michael@0 | 1196 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1197 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1198 | } |
michael@0 | 1199 | case '!': { |
michael@0 | 1200 | if (P::reportErrors) { |
michael@0 | 1201 | errHyphenHyphenBang(); |
michael@0 | 1202 | } |
michael@0 | 1203 | appendLongStrBuf(c); |
michael@0 | 1204 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_BANG, reconsume, pos); |
michael@0 | 1205 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1206 | } |
michael@0 | 1207 | case '\0': { |
michael@0 | 1208 | c = 0xfffd; |
michael@0 | 1209 | } |
michael@0 | 1210 | default: { |
michael@0 | 1211 | adjustDoubleHyphenAndAppendToLongStrBufAndErr(c); |
michael@0 | 1212 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1213 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1214 | } |
michael@0 | 1215 | } |
michael@0 | 1216 | } |
michael@0 | 1217 | |
michael@0 | 1218 | } |
michael@0 | 1219 | case NS_HTML5TOKENIZER_COMMENT_END_BANG: { |
michael@0 | 1220 | for (; ; ) { |
michael@0 | 1221 | if (++pos == endPos) { |
michael@0 | 1222 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1223 | } |
michael@0 | 1224 | c = checkChar(buf, pos); |
michael@0 | 1225 | switch(c) { |
michael@0 | 1226 | case '>': { |
michael@0 | 1227 | emitComment(3, pos); |
michael@0 | 1228 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 1229 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1230 | } |
michael@0 | 1231 | case '-': { |
michael@0 | 1232 | appendLongStrBuf(c); |
michael@0 | 1233 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos); |
michael@0 | 1234 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1235 | } |
michael@0 | 1236 | case '\r': { |
michael@0 | 1237 | appendLongStrBufCarriageReturn(); |
michael@0 | 1238 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1239 | } |
michael@0 | 1240 | case '\n': { |
michael@0 | 1241 | appendLongStrBufLineFeed(); |
michael@0 | 1242 | continue; |
michael@0 | 1243 | } |
michael@0 | 1244 | case '\0': { |
michael@0 | 1245 | c = 0xfffd; |
michael@0 | 1246 | } |
michael@0 | 1247 | default: { |
michael@0 | 1248 | appendLongStrBuf(c); |
michael@0 | 1249 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1250 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1251 | } |
michael@0 | 1252 | } |
michael@0 | 1253 | } |
michael@0 | 1254 | } |
michael@0 | 1255 | case NS_HTML5TOKENIZER_COMMENT_START_DASH: { |
michael@0 | 1256 | if (++pos == endPos) { |
michael@0 | 1257 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1258 | } |
michael@0 | 1259 | c = checkChar(buf, pos); |
michael@0 | 1260 | switch(c) { |
michael@0 | 1261 | case '-': { |
michael@0 | 1262 | appendLongStrBuf(c); |
michael@0 | 1263 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos); |
michael@0 | 1264 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1265 | } |
michael@0 | 1266 | case '>': { |
michael@0 | 1267 | if (P::reportErrors) { |
michael@0 | 1268 | errPrematureEndOfComment(); |
michael@0 | 1269 | } |
michael@0 | 1270 | emitComment(1, pos); |
michael@0 | 1271 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 1272 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1273 | } |
michael@0 | 1274 | case '\r': { |
michael@0 | 1275 | appendLongStrBufCarriageReturn(); |
michael@0 | 1276 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1277 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1278 | } |
michael@0 | 1279 | case '\n': { |
michael@0 | 1280 | appendLongStrBufLineFeed(); |
michael@0 | 1281 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1282 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1283 | } |
michael@0 | 1284 | case '\0': { |
michael@0 | 1285 | c = 0xfffd; |
michael@0 | 1286 | } |
michael@0 | 1287 | default: { |
michael@0 | 1288 | appendLongStrBuf(c); |
michael@0 | 1289 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos); |
michael@0 | 1290 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1291 | } |
michael@0 | 1292 | } |
michael@0 | 1293 | } |
michael@0 | 1294 | case NS_HTML5TOKENIZER_CDATA_START: { |
michael@0 | 1295 | for (; ; ) { |
michael@0 | 1296 | if (++pos == endPos) { |
michael@0 | 1297 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1298 | } |
michael@0 | 1299 | c = checkChar(buf, pos); |
michael@0 | 1300 | if (index < 6) { |
michael@0 | 1301 | if (c == nsHtml5Tokenizer::CDATA_LSQB[index]) { |
michael@0 | 1302 | appendLongStrBuf(c); |
michael@0 | 1303 | } else { |
michael@0 | 1304 | if (P::reportErrors) { |
michael@0 | 1305 | errBogusComment(); |
michael@0 | 1306 | } |
michael@0 | 1307 | reconsume = true; |
michael@0 | 1308 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 1309 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1310 | } |
michael@0 | 1311 | index++; |
michael@0 | 1312 | continue; |
michael@0 | 1313 | } else { |
michael@0 | 1314 | cstart = pos; |
michael@0 | 1315 | reconsume = true; |
michael@0 | 1316 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos); |
michael@0 | 1317 | break; |
michael@0 | 1318 | } |
michael@0 | 1319 | } |
michael@0 | 1320 | } |
michael@0 | 1321 | case NS_HTML5TOKENIZER_CDATA_SECTION: { |
michael@0 | 1322 | for (; ; ) { |
michael@0 | 1323 | if (reconsume) { |
michael@0 | 1324 | reconsume = false; |
michael@0 | 1325 | } else { |
michael@0 | 1326 | if (++pos == endPos) { |
michael@0 | 1327 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1328 | } |
michael@0 | 1329 | c = checkChar(buf, pos); |
michael@0 | 1330 | } |
michael@0 | 1331 | switch(c) { |
michael@0 | 1332 | case ']': { |
michael@0 | 1333 | flushChars(buf, pos); |
michael@0 | 1334 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB, reconsume, pos); |
michael@0 | 1335 | NS_HTML5_BREAK(cdatasectionloop); |
michael@0 | 1336 | } |
michael@0 | 1337 | case '\0': { |
michael@0 | 1338 | emitReplacementCharacter(buf, pos); |
michael@0 | 1339 | continue; |
michael@0 | 1340 | } |
michael@0 | 1341 | case '\r': { |
michael@0 | 1342 | emitCarriageReturn(buf, pos); |
michael@0 | 1343 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1344 | } |
michael@0 | 1345 | case '\n': { |
michael@0 | 1346 | silentLineFeed(); |
michael@0 | 1347 | } |
michael@0 | 1348 | default: { |
michael@0 | 1349 | continue; |
michael@0 | 1350 | } |
michael@0 | 1351 | } |
michael@0 | 1352 | } |
michael@0 | 1353 | cdatasectionloop_end: ; |
michael@0 | 1354 | } |
michael@0 | 1355 | case NS_HTML5TOKENIZER_CDATA_RSQB: { |
michael@0 | 1356 | for (; ; ) { |
michael@0 | 1357 | if (++pos == endPos) { |
michael@0 | 1358 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1359 | } |
michael@0 | 1360 | c = checkChar(buf, pos); |
michael@0 | 1361 | switch(c) { |
michael@0 | 1362 | case ']': { |
michael@0 | 1363 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB_RSQB, reconsume, pos); |
michael@0 | 1364 | NS_HTML5_BREAK(cdatarsqb); |
michael@0 | 1365 | } |
michael@0 | 1366 | default: { |
michael@0 | 1367 | tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1); |
michael@0 | 1368 | cstart = pos; |
michael@0 | 1369 | reconsume = true; |
michael@0 | 1370 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos); |
michael@0 | 1371 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1372 | } |
michael@0 | 1373 | } |
michael@0 | 1374 | } |
michael@0 | 1375 | cdatarsqb_end: ; |
michael@0 | 1376 | } |
michael@0 | 1377 | case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: { |
michael@0 | 1378 | for (; ; ) { |
michael@0 | 1379 | if (++pos == endPos) { |
michael@0 | 1380 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1381 | } |
michael@0 | 1382 | c = checkChar(buf, pos); |
michael@0 | 1383 | switch(c) { |
michael@0 | 1384 | case ']': { |
michael@0 | 1385 | tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1); |
michael@0 | 1386 | continue; |
michael@0 | 1387 | } |
michael@0 | 1388 | case '>': { |
michael@0 | 1389 | cstart = pos + 1; |
michael@0 | 1390 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 1391 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1392 | } |
michael@0 | 1393 | default: { |
michael@0 | 1394 | tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2); |
michael@0 | 1395 | cstart = pos; |
michael@0 | 1396 | reconsume = true; |
michael@0 | 1397 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos); |
michael@0 | 1398 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1399 | } |
michael@0 | 1400 | } |
michael@0 | 1401 | } |
michael@0 | 1402 | |
michael@0 | 1403 | } |
michael@0 | 1404 | case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED: { |
michael@0 | 1405 | for (; ; ) { |
michael@0 | 1406 | if (reconsume) { |
michael@0 | 1407 | reconsume = false; |
michael@0 | 1408 | } else { |
michael@0 | 1409 | if (++pos == endPos) { |
michael@0 | 1410 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1411 | } |
michael@0 | 1412 | c = checkChar(buf, pos); |
michael@0 | 1413 | } |
michael@0 | 1414 | switch(c) { |
michael@0 | 1415 | case '\'': { |
michael@0 | 1416 | addAttributeWithValue(); |
michael@0 | 1417 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos); |
michael@0 | 1418 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1419 | } |
michael@0 | 1420 | case '&': { |
michael@0 | 1421 | clearStrBufAndAppend(c); |
michael@0 | 1422 | setAdditionalAndRememberAmpersandLocation('\''); |
michael@0 | 1423 | returnState = state; |
michael@0 | 1424 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); |
michael@0 | 1425 | NS_HTML5_BREAK(attributevaluesinglequotedloop); |
michael@0 | 1426 | } |
michael@0 | 1427 | case '\r': { |
michael@0 | 1428 | appendLongStrBufCarriageReturn(); |
michael@0 | 1429 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1430 | } |
michael@0 | 1431 | case '\n': { |
michael@0 | 1432 | appendLongStrBufLineFeed(); |
michael@0 | 1433 | continue; |
michael@0 | 1434 | } |
michael@0 | 1435 | case '\0': { |
michael@0 | 1436 | c = 0xfffd; |
michael@0 | 1437 | } |
michael@0 | 1438 | default: { |
michael@0 | 1439 | appendLongStrBuf(c); |
michael@0 | 1440 | continue; |
michael@0 | 1441 | } |
michael@0 | 1442 | } |
michael@0 | 1443 | } |
michael@0 | 1444 | attributevaluesinglequotedloop_end: ; |
michael@0 | 1445 | } |
michael@0 | 1446 | case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: { |
michael@0 | 1447 | if (++pos == endPos) { |
michael@0 | 1448 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1449 | } |
michael@0 | 1450 | c = checkChar(buf, pos); |
michael@0 | 1451 | if (c == '\0') { |
michael@0 | 1452 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1453 | } |
michael@0 | 1454 | switch(c) { |
michael@0 | 1455 | case ' ': |
michael@0 | 1456 | case '\t': |
michael@0 | 1457 | case '\n': |
michael@0 | 1458 | case '\r': |
michael@0 | 1459 | case '\f': |
michael@0 | 1460 | case '<': |
michael@0 | 1461 | case '&': { |
michael@0 | 1462 | emitOrAppendStrBuf(returnState); |
michael@0 | 1463 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1464 | cstart = pos; |
michael@0 | 1465 | } |
michael@0 | 1466 | reconsume = true; |
michael@0 | 1467 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1468 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1469 | } |
michael@0 | 1470 | case '#': { |
michael@0 | 1471 | appendStrBuf('#'); |
michael@0 | 1472 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_NCR, reconsume, pos); |
michael@0 | 1473 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1474 | } |
michael@0 | 1475 | default: { |
michael@0 | 1476 | if (c == additional) { |
michael@0 | 1477 | emitOrAppendStrBuf(returnState); |
michael@0 | 1478 | reconsume = true; |
michael@0 | 1479 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1480 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1481 | } |
michael@0 | 1482 | if (c >= 'a' && c <= 'z') { |
michael@0 | 1483 | firstCharKey = c - 'a' + 26; |
michael@0 | 1484 | } else if (c >= 'A' && c <= 'Z') { |
michael@0 | 1485 | firstCharKey = c - 'A'; |
michael@0 | 1486 | } else { |
michael@0 | 1487 | if (P::reportErrors) { |
michael@0 | 1488 | errNoNamedCharacterMatch(); |
michael@0 | 1489 | } |
michael@0 | 1490 | emitOrAppendStrBuf(returnState); |
michael@0 | 1491 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1492 | cstart = pos; |
michael@0 | 1493 | } |
michael@0 | 1494 | reconsume = true; |
michael@0 | 1495 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1496 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1497 | } |
michael@0 | 1498 | appendStrBuf(c); |
michael@0 | 1499 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP, reconsume, pos); |
michael@0 | 1500 | } |
michael@0 | 1501 | } |
michael@0 | 1502 | } |
michael@0 | 1503 | case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: { |
michael@0 | 1504 | { |
michael@0 | 1505 | if (++pos == endPos) { |
michael@0 | 1506 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1507 | } |
michael@0 | 1508 | c = checkChar(buf, pos); |
michael@0 | 1509 | if (c == '\0') { |
michael@0 | 1510 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1511 | } |
michael@0 | 1512 | int32_t hilo = 0; |
michael@0 | 1513 | if (c <= 'z') { |
michael@0 | 1514 | const int32_t* row = nsHtml5NamedCharactersAccel::HILO_ACCEL[c]; |
michael@0 | 1515 | if (row) { |
michael@0 | 1516 | hilo = row[firstCharKey]; |
michael@0 | 1517 | } |
michael@0 | 1518 | } |
michael@0 | 1519 | if (!hilo) { |
michael@0 | 1520 | if (P::reportErrors) { |
michael@0 | 1521 | errNoNamedCharacterMatch(); |
michael@0 | 1522 | } |
michael@0 | 1523 | emitOrAppendStrBuf(returnState); |
michael@0 | 1524 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1525 | cstart = pos; |
michael@0 | 1526 | } |
michael@0 | 1527 | reconsume = true; |
michael@0 | 1528 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1529 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1530 | } |
michael@0 | 1531 | appendStrBuf(c); |
michael@0 | 1532 | lo = hilo & 0xFFFF; |
michael@0 | 1533 | hi = hilo >> 16; |
michael@0 | 1534 | entCol = -1; |
michael@0 | 1535 | candidate = -1; |
michael@0 | 1536 | strBufMark = 0; |
michael@0 | 1537 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL, reconsume, pos); |
michael@0 | 1538 | } |
michael@0 | 1539 | } |
michael@0 | 1540 | case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: { |
michael@0 | 1541 | for (; ; ) { |
michael@0 | 1542 | if (++pos == endPos) { |
michael@0 | 1543 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1544 | } |
michael@0 | 1545 | c = checkChar(buf, pos); |
michael@0 | 1546 | if (c == '\0') { |
michael@0 | 1547 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1548 | } |
michael@0 | 1549 | entCol++; |
michael@0 | 1550 | for (; ; ) { |
michael@0 | 1551 | if (hi < lo) { |
michael@0 | 1552 | NS_HTML5_BREAK(outer); |
michael@0 | 1553 | } |
michael@0 | 1554 | if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) { |
michael@0 | 1555 | candidate = lo; |
michael@0 | 1556 | strBufMark = strBufLen; |
michael@0 | 1557 | lo++; |
michael@0 | 1558 | } else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) { |
michael@0 | 1559 | NS_HTML5_BREAK(outer); |
michael@0 | 1560 | } else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) { |
michael@0 | 1561 | lo++; |
michael@0 | 1562 | } else { |
michael@0 | 1563 | NS_HTML5_BREAK(loloop); |
michael@0 | 1564 | } |
michael@0 | 1565 | } |
michael@0 | 1566 | loloop_end: ; |
michael@0 | 1567 | for (; ; ) { |
michael@0 | 1568 | if (hi < lo) { |
michael@0 | 1569 | NS_HTML5_BREAK(outer); |
michael@0 | 1570 | } |
michael@0 | 1571 | if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) { |
michael@0 | 1572 | NS_HTML5_BREAK(hiloop); |
michael@0 | 1573 | } |
michael@0 | 1574 | if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) { |
michael@0 | 1575 | NS_HTML5_BREAK(outer); |
michael@0 | 1576 | } else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) { |
michael@0 | 1577 | hi--; |
michael@0 | 1578 | } else { |
michael@0 | 1579 | NS_HTML5_BREAK(hiloop); |
michael@0 | 1580 | } |
michael@0 | 1581 | } |
michael@0 | 1582 | hiloop_end: ; |
michael@0 | 1583 | if (c == ';') { |
michael@0 | 1584 | if (entCol + 1 == nsHtml5NamedCharacters::NAMES[lo].length()) { |
michael@0 | 1585 | candidate = lo; |
michael@0 | 1586 | strBufMark = strBufLen; |
michael@0 | 1587 | } |
michael@0 | 1588 | NS_HTML5_BREAK(outer); |
michael@0 | 1589 | } |
michael@0 | 1590 | if (hi < lo) { |
michael@0 | 1591 | NS_HTML5_BREAK(outer); |
michael@0 | 1592 | } |
michael@0 | 1593 | appendStrBuf(c); |
michael@0 | 1594 | continue; |
michael@0 | 1595 | } |
michael@0 | 1596 | outer_end: ; |
michael@0 | 1597 | if (candidate == -1) { |
michael@0 | 1598 | if (P::reportErrors) { |
michael@0 | 1599 | errNoNamedCharacterMatch(); |
michael@0 | 1600 | } |
michael@0 | 1601 | emitOrAppendStrBuf(returnState); |
michael@0 | 1602 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1603 | cstart = pos; |
michael@0 | 1604 | } |
michael@0 | 1605 | reconsume = true; |
michael@0 | 1606 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1607 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1608 | } else { |
michael@0 | 1609 | const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate]; |
michael@0 | 1610 | if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') { |
michael@0 | 1611 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1612 | char16_t ch; |
michael@0 | 1613 | if (strBufMark == strBufLen) { |
michael@0 | 1614 | ch = c; |
michael@0 | 1615 | } else { |
michael@0 | 1616 | ch = strBuf[strBufMark]; |
michael@0 | 1617 | } |
michael@0 | 1618 | if (ch == '=' || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { |
michael@0 | 1619 | if (P::reportErrors) { |
michael@0 | 1620 | errNoNamedCharacterMatch(); |
michael@0 | 1621 | } |
michael@0 | 1622 | appendStrBufToLongStrBuf(); |
michael@0 | 1623 | reconsume = true; |
michael@0 | 1624 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1625 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1626 | } |
michael@0 | 1627 | } |
michael@0 | 1628 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1629 | if (P::reportErrors) { |
michael@0 | 1630 | errUnescapedAmpersandInterpretedAsCharacterReference(); |
michael@0 | 1631 | } |
michael@0 | 1632 | } else { |
michael@0 | 1633 | if (P::reportErrors) { |
michael@0 | 1634 | errNotSemicolonTerminated(); |
michael@0 | 1635 | } |
michael@0 | 1636 | } |
michael@0 | 1637 | } |
michael@0 | 1638 | P::completedNamedCharacterReference(mViewSource); |
michael@0 | 1639 | const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate]; |
michael@0 | 1640 | if (!val[1]) { |
michael@0 | 1641 | emitOrAppendOne(val, returnState); |
michael@0 | 1642 | } else { |
michael@0 | 1643 | emitOrAppendTwo(val, returnState); |
michael@0 | 1644 | } |
michael@0 | 1645 | if (strBufMark < strBufLen) { |
michael@0 | 1646 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1647 | for (int32_t i = strBufMark; i < strBufLen; i++) { |
michael@0 | 1648 | appendLongStrBuf(strBuf[i]); |
michael@0 | 1649 | } |
michael@0 | 1650 | } else { |
michael@0 | 1651 | tokenHandler->characters(strBuf, strBufMark, strBufLen - strBufMark); |
michael@0 | 1652 | } |
michael@0 | 1653 | } |
michael@0 | 1654 | bool earlyBreak = (c == ';' && strBufMark == strBufLen); |
michael@0 | 1655 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1656 | cstart = earlyBreak ? pos + 1 : pos; |
michael@0 | 1657 | } |
michael@0 | 1658 | reconsume = !earlyBreak; |
michael@0 | 1659 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1660 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1661 | } |
michael@0 | 1662 | } |
michael@0 | 1663 | case NS_HTML5TOKENIZER_CONSUME_NCR: { |
michael@0 | 1664 | if (++pos == endPos) { |
michael@0 | 1665 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1666 | } |
michael@0 | 1667 | c = checkChar(buf, pos); |
michael@0 | 1668 | prevValue = -1; |
michael@0 | 1669 | value = 0; |
michael@0 | 1670 | seenDigits = false; |
michael@0 | 1671 | switch(c) { |
michael@0 | 1672 | case 'x': |
michael@0 | 1673 | case 'X': { |
michael@0 | 1674 | appendStrBuf(c); |
michael@0 | 1675 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_HEX_NCR_LOOP, reconsume, pos); |
michael@0 | 1676 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1677 | } |
michael@0 | 1678 | default: { |
michael@0 | 1679 | reconsume = true; |
michael@0 | 1680 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP, reconsume, pos); |
michael@0 | 1681 | } |
michael@0 | 1682 | } |
michael@0 | 1683 | } |
michael@0 | 1684 | case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP: { |
michael@0 | 1685 | for (; ; ) { |
michael@0 | 1686 | if (reconsume) { |
michael@0 | 1687 | reconsume = false; |
michael@0 | 1688 | } else { |
michael@0 | 1689 | if (++pos == endPos) { |
michael@0 | 1690 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1691 | } |
michael@0 | 1692 | c = checkChar(buf, pos); |
michael@0 | 1693 | } |
michael@0 | 1694 | if (value < prevValue) { |
michael@0 | 1695 | value = 0x110000; |
michael@0 | 1696 | } |
michael@0 | 1697 | prevValue = value; |
michael@0 | 1698 | if (c >= '0' && c <= '9') { |
michael@0 | 1699 | seenDigits = true; |
michael@0 | 1700 | value *= 10; |
michael@0 | 1701 | value += c - '0'; |
michael@0 | 1702 | continue; |
michael@0 | 1703 | } else if (c == ';') { |
michael@0 | 1704 | if (seenDigits) { |
michael@0 | 1705 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1706 | cstart = pos + 1; |
michael@0 | 1707 | } |
michael@0 | 1708 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); |
michael@0 | 1709 | NS_HTML5_BREAK(decimalloop); |
michael@0 | 1710 | } else { |
michael@0 | 1711 | if (P::reportErrors) { |
michael@0 | 1712 | errNoDigitsInNCR(); |
michael@0 | 1713 | } |
michael@0 | 1714 | appendStrBuf(';'); |
michael@0 | 1715 | emitOrAppendStrBuf(returnState); |
michael@0 | 1716 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1717 | cstart = pos + 1; |
michael@0 | 1718 | } |
michael@0 | 1719 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1720 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1721 | } |
michael@0 | 1722 | } else { |
michael@0 | 1723 | if (!seenDigits) { |
michael@0 | 1724 | if (P::reportErrors) { |
michael@0 | 1725 | errNoDigitsInNCR(); |
michael@0 | 1726 | } |
michael@0 | 1727 | emitOrAppendStrBuf(returnState); |
michael@0 | 1728 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1729 | cstart = pos; |
michael@0 | 1730 | } |
michael@0 | 1731 | reconsume = true; |
michael@0 | 1732 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1733 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1734 | } else { |
michael@0 | 1735 | if (P::reportErrors) { |
michael@0 | 1736 | errCharRefLacksSemicolon(); |
michael@0 | 1737 | } |
michael@0 | 1738 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1739 | cstart = pos; |
michael@0 | 1740 | } |
michael@0 | 1741 | reconsume = true; |
michael@0 | 1742 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); |
michael@0 | 1743 | NS_HTML5_BREAK(decimalloop); |
michael@0 | 1744 | } |
michael@0 | 1745 | } |
michael@0 | 1746 | } |
michael@0 | 1747 | decimalloop_end: ; |
michael@0 | 1748 | } |
michael@0 | 1749 | case NS_HTML5TOKENIZER_HANDLE_NCR_VALUE: { |
michael@0 | 1750 | handleNcrValue(returnState); |
michael@0 | 1751 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1752 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1753 | } |
michael@0 | 1754 | case NS_HTML5TOKENIZER_HEX_NCR_LOOP: { |
michael@0 | 1755 | for (; ; ) { |
michael@0 | 1756 | if (++pos == endPos) { |
michael@0 | 1757 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1758 | } |
michael@0 | 1759 | c = checkChar(buf, pos); |
michael@0 | 1760 | if (value < prevValue) { |
michael@0 | 1761 | value = 0x110000; |
michael@0 | 1762 | } |
michael@0 | 1763 | prevValue = value; |
michael@0 | 1764 | if (c >= '0' && c <= '9') { |
michael@0 | 1765 | seenDigits = true; |
michael@0 | 1766 | value *= 16; |
michael@0 | 1767 | value += c - '0'; |
michael@0 | 1768 | continue; |
michael@0 | 1769 | } else if (c >= 'A' && c <= 'F') { |
michael@0 | 1770 | seenDigits = true; |
michael@0 | 1771 | value *= 16; |
michael@0 | 1772 | value += c - 'A' + 10; |
michael@0 | 1773 | continue; |
michael@0 | 1774 | } else if (c >= 'a' && c <= 'f') { |
michael@0 | 1775 | seenDigits = true; |
michael@0 | 1776 | value *= 16; |
michael@0 | 1777 | value += c - 'a' + 10; |
michael@0 | 1778 | continue; |
michael@0 | 1779 | } else if (c == ';') { |
michael@0 | 1780 | if (seenDigits) { |
michael@0 | 1781 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1782 | cstart = pos + 1; |
michael@0 | 1783 | } |
michael@0 | 1784 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); |
michael@0 | 1785 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1786 | } else { |
michael@0 | 1787 | if (P::reportErrors) { |
michael@0 | 1788 | errNoDigitsInNCR(); |
michael@0 | 1789 | } |
michael@0 | 1790 | appendStrBuf(';'); |
michael@0 | 1791 | emitOrAppendStrBuf(returnState); |
michael@0 | 1792 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1793 | cstart = pos + 1; |
michael@0 | 1794 | } |
michael@0 | 1795 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1796 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1797 | } |
michael@0 | 1798 | } else { |
michael@0 | 1799 | if (!seenDigits) { |
michael@0 | 1800 | if (P::reportErrors) { |
michael@0 | 1801 | errNoDigitsInNCR(); |
michael@0 | 1802 | } |
michael@0 | 1803 | emitOrAppendStrBuf(returnState); |
michael@0 | 1804 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1805 | cstart = pos; |
michael@0 | 1806 | } |
michael@0 | 1807 | reconsume = true; |
michael@0 | 1808 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 1809 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1810 | } else { |
michael@0 | 1811 | if (P::reportErrors) { |
michael@0 | 1812 | errCharRefLacksSemicolon(); |
michael@0 | 1813 | } |
michael@0 | 1814 | if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 1815 | cstart = pos; |
michael@0 | 1816 | } |
michael@0 | 1817 | reconsume = true; |
michael@0 | 1818 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos); |
michael@0 | 1819 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1820 | } |
michael@0 | 1821 | } |
michael@0 | 1822 | } |
michael@0 | 1823 | } |
michael@0 | 1824 | case NS_HTML5TOKENIZER_PLAINTEXT: { |
michael@0 | 1825 | for (; ; ) { |
michael@0 | 1826 | if (reconsume) { |
michael@0 | 1827 | reconsume = false; |
michael@0 | 1828 | } else { |
michael@0 | 1829 | if (++pos == endPos) { |
michael@0 | 1830 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1831 | } |
michael@0 | 1832 | c = checkChar(buf, pos); |
michael@0 | 1833 | } |
michael@0 | 1834 | switch(c) { |
michael@0 | 1835 | case '\0': { |
michael@0 | 1836 | emitPlaintextReplacementCharacter(buf, pos); |
michael@0 | 1837 | continue; |
michael@0 | 1838 | } |
michael@0 | 1839 | case '\r': { |
michael@0 | 1840 | emitCarriageReturn(buf, pos); |
michael@0 | 1841 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1842 | } |
michael@0 | 1843 | case '\n': { |
michael@0 | 1844 | silentLineFeed(); |
michael@0 | 1845 | } |
michael@0 | 1846 | default: { |
michael@0 | 1847 | continue; |
michael@0 | 1848 | } |
michael@0 | 1849 | } |
michael@0 | 1850 | } |
michael@0 | 1851 | |
michael@0 | 1852 | } |
michael@0 | 1853 | case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: { |
michael@0 | 1854 | if (++pos == endPos) { |
michael@0 | 1855 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1856 | } |
michael@0 | 1857 | c = checkChar(buf, pos); |
michael@0 | 1858 | switch(c) { |
michael@0 | 1859 | case '>': { |
michael@0 | 1860 | if (P::reportErrors) { |
michael@0 | 1861 | errLtSlashGt(); |
michael@0 | 1862 | } |
michael@0 | 1863 | cstart = pos + 1; |
michael@0 | 1864 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 1865 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1866 | } |
michael@0 | 1867 | case '\r': { |
michael@0 | 1868 | silentCarriageReturn(); |
michael@0 | 1869 | if (P::reportErrors) { |
michael@0 | 1870 | errGarbageAfterLtSlash(); |
michael@0 | 1871 | } |
michael@0 | 1872 | clearLongStrBufAndAppend('\n'); |
michael@0 | 1873 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 1874 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1875 | } |
michael@0 | 1876 | case '\n': { |
michael@0 | 1877 | silentLineFeed(); |
michael@0 | 1878 | if (P::reportErrors) { |
michael@0 | 1879 | errGarbageAfterLtSlash(); |
michael@0 | 1880 | } |
michael@0 | 1881 | clearLongStrBufAndAppend('\n'); |
michael@0 | 1882 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 1883 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1884 | } |
michael@0 | 1885 | case '\0': { |
michael@0 | 1886 | c = 0xfffd; |
michael@0 | 1887 | } |
michael@0 | 1888 | default: { |
michael@0 | 1889 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 1890 | c += 0x20; |
michael@0 | 1891 | } |
michael@0 | 1892 | if (c >= 'a' && c <= 'z') { |
michael@0 | 1893 | endTag = true; |
michael@0 | 1894 | clearStrBufAndAppend(c); |
michael@0 | 1895 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos); |
michael@0 | 1896 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1897 | } else { |
michael@0 | 1898 | if (P::reportErrors) { |
michael@0 | 1899 | errGarbageAfterLtSlash(); |
michael@0 | 1900 | } |
michael@0 | 1901 | clearLongStrBufAndAppend(c); |
michael@0 | 1902 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 1903 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1904 | } |
michael@0 | 1905 | } |
michael@0 | 1906 | } |
michael@0 | 1907 | } |
michael@0 | 1908 | case NS_HTML5TOKENIZER_RCDATA: { |
michael@0 | 1909 | for (; ; ) { |
michael@0 | 1910 | if (reconsume) { |
michael@0 | 1911 | reconsume = false; |
michael@0 | 1912 | } else { |
michael@0 | 1913 | if (++pos == endPos) { |
michael@0 | 1914 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1915 | } |
michael@0 | 1916 | c = checkChar(buf, pos); |
michael@0 | 1917 | } |
michael@0 | 1918 | switch(c) { |
michael@0 | 1919 | case '&': { |
michael@0 | 1920 | flushChars(buf, pos); |
michael@0 | 1921 | clearStrBufAndAppend(c); |
michael@0 | 1922 | additional = '\0'; |
michael@0 | 1923 | returnState = state; |
michael@0 | 1924 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos); |
michael@0 | 1925 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1926 | } |
michael@0 | 1927 | case '<': { |
michael@0 | 1928 | flushChars(buf, pos); |
michael@0 | 1929 | returnState = state; |
michael@0 | 1930 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 1931 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 1932 | } |
michael@0 | 1933 | case '\0': { |
michael@0 | 1934 | emitReplacementCharacter(buf, pos); |
michael@0 | 1935 | continue; |
michael@0 | 1936 | } |
michael@0 | 1937 | case '\r': { |
michael@0 | 1938 | emitCarriageReturn(buf, pos); |
michael@0 | 1939 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1940 | } |
michael@0 | 1941 | case '\n': { |
michael@0 | 1942 | silentLineFeed(); |
michael@0 | 1943 | } |
michael@0 | 1944 | default: { |
michael@0 | 1945 | continue; |
michael@0 | 1946 | } |
michael@0 | 1947 | } |
michael@0 | 1948 | } |
michael@0 | 1949 | |
michael@0 | 1950 | } |
michael@0 | 1951 | case NS_HTML5TOKENIZER_RAWTEXT: { |
michael@0 | 1952 | for (; ; ) { |
michael@0 | 1953 | if (reconsume) { |
michael@0 | 1954 | reconsume = false; |
michael@0 | 1955 | } else { |
michael@0 | 1956 | if (++pos == endPos) { |
michael@0 | 1957 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1958 | } |
michael@0 | 1959 | c = checkChar(buf, pos); |
michael@0 | 1960 | } |
michael@0 | 1961 | switch(c) { |
michael@0 | 1962 | case '<': { |
michael@0 | 1963 | flushChars(buf, pos); |
michael@0 | 1964 | returnState = state; |
michael@0 | 1965 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 1966 | NS_HTML5_BREAK(rawtextloop); |
michael@0 | 1967 | } |
michael@0 | 1968 | case '\0': { |
michael@0 | 1969 | emitReplacementCharacter(buf, pos); |
michael@0 | 1970 | continue; |
michael@0 | 1971 | } |
michael@0 | 1972 | case '\r': { |
michael@0 | 1973 | emitCarriageReturn(buf, pos); |
michael@0 | 1974 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1975 | } |
michael@0 | 1976 | case '\n': { |
michael@0 | 1977 | silentLineFeed(); |
michael@0 | 1978 | } |
michael@0 | 1979 | default: { |
michael@0 | 1980 | continue; |
michael@0 | 1981 | } |
michael@0 | 1982 | } |
michael@0 | 1983 | } |
michael@0 | 1984 | rawtextloop_end: ; |
michael@0 | 1985 | } |
michael@0 | 1986 | case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: { |
michael@0 | 1987 | for (; ; ) { |
michael@0 | 1988 | if (++pos == endPos) { |
michael@0 | 1989 | NS_HTML5_BREAK(stateloop); |
michael@0 | 1990 | } |
michael@0 | 1991 | c = checkChar(buf, pos); |
michael@0 | 1992 | switch(c) { |
michael@0 | 1993 | case '/': { |
michael@0 | 1994 | index = 0; |
michael@0 | 1995 | clearStrBuf(); |
michael@0 | 1996 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos); |
michael@0 | 1997 | NS_HTML5_BREAK(rawtextrcdatalessthansignloop); |
michael@0 | 1998 | } |
michael@0 | 1999 | default: { |
michael@0 | 2000 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 2001 | cstart = pos; |
michael@0 | 2002 | reconsume = true; |
michael@0 | 2003 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 2004 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2005 | } |
michael@0 | 2006 | } |
michael@0 | 2007 | } |
michael@0 | 2008 | rawtextrcdatalessthansignloop_end: ; |
michael@0 | 2009 | } |
michael@0 | 2010 | case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: { |
michael@0 | 2011 | for (; ; ) { |
michael@0 | 2012 | if (++pos == endPos) { |
michael@0 | 2013 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2014 | } |
michael@0 | 2015 | c = checkChar(buf, pos); |
michael@0 | 2016 | if (index < endTagExpectationAsArray.length) { |
michael@0 | 2017 | char16_t e = endTagExpectationAsArray[index]; |
michael@0 | 2018 | char16_t folded = c; |
michael@0 | 2019 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2020 | folded += 0x20; |
michael@0 | 2021 | } |
michael@0 | 2022 | if (folded != e) { |
michael@0 | 2023 | tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); |
michael@0 | 2024 | emitStrBuf(); |
michael@0 | 2025 | cstart = pos; |
michael@0 | 2026 | reconsume = true; |
michael@0 | 2027 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 2028 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2029 | } |
michael@0 | 2030 | appendStrBuf(c); |
michael@0 | 2031 | index++; |
michael@0 | 2032 | continue; |
michael@0 | 2033 | } else { |
michael@0 | 2034 | endTag = true; |
michael@0 | 2035 | tagName = endTagExpectation; |
michael@0 | 2036 | switch(c) { |
michael@0 | 2037 | case '\r': { |
michael@0 | 2038 | silentCarriageReturn(); |
michael@0 | 2039 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 2040 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2041 | } |
michael@0 | 2042 | case '\n': { |
michael@0 | 2043 | silentLineFeed(); |
michael@0 | 2044 | } |
michael@0 | 2045 | case ' ': |
michael@0 | 2046 | case '\t': |
michael@0 | 2047 | case '\f': { |
michael@0 | 2048 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos); |
michael@0 | 2049 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2050 | } |
michael@0 | 2051 | case '/': { |
michael@0 | 2052 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos); |
michael@0 | 2053 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2054 | } |
michael@0 | 2055 | case '>': { |
michael@0 | 2056 | state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos); |
michael@0 | 2057 | if (shouldSuspend) { |
michael@0 | 2058 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2059 | } |
michael@0 | 2060 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2061 | } |
michael@0 | 2062 | default: { |
michael@0 | 2063 | tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); |
michael@0 | 2064 | emitStrBuf(); |
michael@0 | 2065 | if (c == '\0') { |
michael@0 | 2066 | emitReplacementCharacter(buf, pos); |
michael@0 | 2067 | } else { |
michael@0 | 2068 | cstart = pos; |
michael@0 | 2069 | } |
michael@0 | 2070 | state = P::transition(mViewSource, returnState, reconsume, pos); |
michael@0 | 2071 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2072 | } |
michael@0 | 2073 | } |
michael@0 | 2074 | } |
michael@0 | 2075 | } |
michael@0 | 2076 | } |
michael@0 | 2077 | case NS_HTML5TOKENIZER_BOGUS_COMMENT: { |
michael@0 | 2078 | for (; ; ) { |
michael@0 | 2079 | if (reconsume) { |
michael@0 | 2080 | reconsume = false; |
michael@0 | 2081 | } else { |
michael@0 | 2082 | if (++pos == endPos) { |
michael@0 | 2083 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2084 | } |
michael@0 | 2085 | c = checkChar(buf, pos); |
michael@0 | 2086 | } |
michael@0 | 2087 | switch(c) { |
michael@0 | 2088 | case '>': { |
michael@0 | 2089 | emitComment(0, pos); |
michael@0 | 2090 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2091 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2092 | } |
michael@0 | 2093 | case '-': { |
michael@0 | 2094 | appendLongStrBuf(c); |
michael@0 | 2095 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN, reconsume, pos); |
michael@0 | 2096 | NS_HTML5_BREAK(boguscommentloop); |
michael@0 | 2097 | } |
michael@0 | 2098 | case '\r': { |
michael@0 | 2099 | appendLongStrBufCarriageReturn(); |
michael@0 | 2100 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2101 | } |
michael@0 | 2102 | case '\n': { |
michael@0 | 2103 | appendLongStrBufLineFeed(); |
michael@0 | 2104 | continue; |
michael@0 | 2105 | } |
michael@0 | 2106 | case '\0': { |
michael@0 | 2107 | c = 0xfffd; |
michael@0 | 2108 | } |
michael@0 | 2109 | default: { |
michael@0 | 2110 | appendLongStrBuf(c); |
michael@0 | 2111 | continue; |
michael@0 | 2112 | } |
michael@0 | 2113 | } |
michael@0 | 2114 | } |
michael@0 | 2115 | boguscommentloop_end: ; |
michael@0 | 2116 | } |
michael@0 | 2117 | case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: { |
michael@0 | 2118 | boguscommenthyphenloop: for (; ; ) { |
michael@0 | 2119 | if (++pos == endPos) { |
michael@0 | 2120 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2121 | } |
michael@0 | 2122 | c = checkChar(buf, pos); |
michael@0 | 2123 | switch(c) { |
michael@0 | 2124 | case '>': { |
michael@0 | 2125 | emitComment(0, pos); |
michael@0 | 2126 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2127 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2128 | } |
michael@0 | 2129 | case '-': { |
michael@0 | 2130 | appendSecondHyphenToBogusComment(); |
michael@0 | 2131 | NS_HTML5_CONTINUE(boguscommenthyphenloop); |
michael@0 | 2132 | } |
michael@0 | 2133 | case '\r': { |
michael@0 | 2134 | appendLongStrBufCarriageReturn(); |
michael@0 | 2135 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 2136 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2137 | } |
michael@0 | 2138 | case '\n': { |
michael@0 | 2139 | appendLongStrBufLineFeed(); |
michael@0 | 2140 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 2141 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2142 | } |
michael@0 | 2143 | case '\0': { |
michael@0 | 2144 | c = 0xfffd; |
michael@0 | 2145 | } |
michael@0 | 2146 | default: { |
michael@0 | 2147 | appendLongStrBuf(c); |
michael@0 | 2148 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 2149 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2150 | } |
michael@0 | 2151 | } |
michael@0 | 2152 | } |
michael@0 | 2153 | |
michael@0 | 2154 | } |
michael@0 | 2155 | case NS_HTML5TOKENIZER_SCRIPT_DATA: { |
michael@0 | 2156 | for (; ; ) { |
michael@0 | 2157 | if (reconsume) { |
michael@0 | 2158 | reconsume = false; |
michael@0 | 2159 | } else { |
michael@0 | 2160 | if (++pos == endPos) { |
michael@0 | 2161 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2162 | } |
michael@0 | 2163 | c = checkChar(buf, pos); |
michael@0 | 2164 | } |
michael@0 | 2165 | switch(c) { |
michael@0 | 2166 | case '<': { |
michael@0 | 2167 | flushChars(buf, pos); |
michael@0 | 2168 | returnState = state; |
michael@0 | 2169 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2170 | NS_HTML5_BREAK(scriptdataloop); |
michael@0 | 2171 | } |
michael@0 | 2172 | case '\0': { |
michael@0 | 2173 | emitReplacementCharacter(buf, pos); |
michael@0 | 2174 | continue; |
michael@0 | 2175 | } |
michael@0 | 2176 | case '\r': { |
michael@0 | 2177 | emitCarriageReturn(buf, pos); |
michael@0 | 2178 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2179 | } |
michael@0 | 2180 | case '\n': { |
michael@0 | 2181 | silentLineFeed(); |
michael@0 | 2182 | } |
michael@0 | 2183 | default: { |
michael@0 | 2184 | continue; |
michael@0 | 2185 | } |
michael@0 | 2186 | } |
michael@0 | 2187 | } |
michael@0 | 2188 | scriptdataloop_end: ; |
michael@0 | 2189 | } |
michael@0 | 2190 | case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN: { |
michael@0 | 2191 | for (; ; ) { |
michael@0 | 2192 | if (++pos == endPos) { |
michael@0 | 2193 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2194 | } |
michael@0 | 2195 | c = checkChar(buf, pos); |
michael@0 | 2196 | switch(c) { |
michael@0 | 2197 | case '/': { |
michael@0 | 2198 | index = 0; |
michael@0 | 2199 | clearStrBuf(); |
michael@0 | 2200 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos); |
michael@0 | 2201 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2202 | } |
michael@0 | 2203 | case '!': { |
michael@0 | 2204 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 2205 | cstart = pos; |
michael@0 | 2206 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START, reconsume, pos); |
michael@0 | 2207 | NS_HTML5_BREAK(scriptdatalessthansignloop); |
michael@0 | 2208 | } |
michael@0 | 2209 | default: { |
michael@0 | 2210 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 2211 | cstart = pos; |
michael@0 | 2212 | reconsume = true; |
michael@0 | 2213 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); |
michael@0 | 2214 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2215 | } |
michael@0 | 2216 | } |
michael@0 | 2217 | } |
michael@0 | 2218 | scriptdatalessthansignloop_end: ; |
michael@0 | 2219 | } |
michael@0 | 2220 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START: { |
michael@0 | 2221 | for (; ; ) { |
michael@0 | 2222 | if (++pos == endPos) { |
michael@0 | 2223 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2224 | } |
michael@0 | 2225 | c = checkChar(buf, pos); |
michael@0 | 2226 | switch(c) { |
michael@0 | 2227 | case '-': { |
michael@0 | 2228 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH, reconsume, pos); |
michael@0 | 2229 | NS_HTML5_BREAK(scriptdataescapestartloop); |
michael@0 | 2230 | } |
michael@0 | 2231 | default: { |
michael@0 | 2232 | reconsume = true; |
michael@0 | 2233 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); |
michael@0 | 2234 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2235 | } |
michael@0 | 2236 | } |
michael@0 | 2237 | } |
michael@0 | 2238 | scriptdataescapestartloop_end: ; |
michael@0 | 2239 | } |
michael@0 | 2240 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH: { |
michael@0 | 2241 | for (; ; ) { |
michael@0 | 2242 | if (++pos == endPos) { |
michael@0 | 2243 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2244 | } |
michael@0 | 2245 | c = checkChar(buf, pos); |
michael@0 | 2246 | switch(c) { |
michael@0 | 2247 | case '-': { |
michael@0 | 2248 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos); |
michael@0 | 2249 | NS_HTML5_BREAK(scriptdataescapestartdashloop); |
michael@0 | 2250 | } |
michael@0 | 2251 | default: { |
michael@0 | 2252 | reconsume = true; |
michael@0 | 2253 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); |
michael@0 | 2254 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2255 | } |
michael@0 | 2256 | } |
michael@0 | 2257 | } |
michael@0 | 2258 | scriptdataescapestartdashloop_end: ; |
michael@0 | 2259 | } |
michael@0 | 2260 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH: { |
michael@0 | 2261 | for (; ; ) { |
michael@0 | 2262 | if (++pos == endPos) { |
michael@0 | 2263 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2264 | } |
michael@0 | 2265 | c = checkChar(buf, pos); |
michael@0 | 2266 | switch(c) { |
michael@0 | 2267 | case '-': { |
michael@0 | 2268 | continue; |
michael@0 | 2269 | } |
michael@0 | 2270 | case '<': { |
michael@0 | 2271 | flushChars(buf, pos); |
michael@0 | 2272 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2273 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2274 | } |
michael@0 | 2275 | case '>': { |
michael@0 | 2276 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); |
michael@0 | 2277 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2278 | } |
michael@0 | 2279 | case '\0': { |
michael@0 | 2280 | emitReplacementCharacter(buf, pos); |
michael@0 | 2281 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2282 | NS_HTML5_BREAK(scriptdataescapeddashdashloop); |
michael@0 | 2283 | } |
michael@0 | 2284 | case '\r': { |
michael@0 | 2285 | emitCarriageReturn(buf, pos); |
michael@0 | 2286 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2287 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2288 | } |
michael@0 | 2289 | case '\n': { |
michael@0 | 2290 | silentLineFeed(); |
michael@0 | 2291 | } |
michael@0 | 2292 | default: { |
michael@0 | 2293 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2294 | NS_HTML5_BREAK(scriptdataescapeddashdashloop); |
michael@0 | 2295 | } |
michael@0 | 2296 | } |
michael@0 | 2297 | } |
michael@0 | 2298 | scriptdataescapeddashdashloop_end: ; |
michael@0 | 2299 | } |
michael@0 | 2300 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED: { |
michael@0 | 2301 | for (; ; ) { |
michael@0 | 2302 | if (reconsume) { |
michael@0 | 2303 | reconsume = false; |
michael@0 | 2304 | } else { |
michael@0 | 2305 | if (++pos == endPos) { |
michael@0 | 2306 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2307 | } |
michael@0 | 2308 | c = checkChar(buf, pos); |
michael@0 | 2309 | } |
michael@0 | 2310 | switch(c) { |
michael@0 | 2311 | case '-': { |
michael@0 | 2312 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH, reconsume, pos); |
michael@0 | 2313 | NS_HTML5_BREAK(scriptdataescapedloop); |
michael@0 | 2314 | } |
michael@0 | 2315 | case '<': { |
michael@0 | 2316 | flushChars(buf, pos); |
michael@0 | 2317 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2318 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2319 | } |
michael@0 | 2320 | case '\0': { |
michael@0 | 2321 | emitReplacementCharacter(buf, pos); |
michael@0 | 2322 | continue; |
michael@0 | 2323 | } |
michael@0 | 2324 | case '\r': { |
michael@0 | 2325 | emitCarriageReturn(buf, pos); |
michael@0 | 2326 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2327 | } |
michael@0 | 2328 | case '\n': { |
michael@0 | 2329 | silentLineFeed(); |
michael@0 | 2330 | } |
michael@0 | 2331 | default: { |
michael@0 | 2332 | continue; |
michael@0 | 2333 | } |
michael@0 | 2334 | } |
michael@0 | 2335 | } |
michael@0 | 2336 | scriptdataescapedloop_end: ; |
michael@0 | 2337 | } |
michael@0 | 2338 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH: { |
michael@0 | 2339 | for (; ; ) { |
michael@0 | 2340 | if (++pos == endPos) { |
michael@0 | 2341 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2342 | } |
michael@0 | 2343 | c = checkChar(buf, pos); |
michael@0 | 2344 | switch(c) { |
michael@0 | 2345 | case '-': { |
michael@0 | 2346 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos); |
michael@0 | 2347 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2348 | } |
michael@0 | 2349 | case '<': { |
michael@0 | 2350 | flushChars(buf, pos); |
michael@0 | 2351 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2352 | NS_HTML5_BREAK(scriptdataescapeddashloop); |
michael@0 | 2353 | } |
michael@0 | 2354 | case '\0': { |
michael@0 | 2355 | emitReplacementCharacter(buf, pos); |
michael@0 | 2356 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2357 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2358 | } |
michael@0 | 2359 | case '\r': { |
michael@0 | 2360 | emitCarriageReturn(buf, pos); |
michael@0 | 2361 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2362 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2363 | } |
michael@0 | 2364 | case '\n': { |
michael@0 | 2365 | silentLineFeed(); |
michael@0 | 2366 | } |
michael@0 | 2367 | default: { |
michael@0 | 2368 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2369 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2370 | } |
michael@0 | 2371 | } |
michael@0 | 2372 | } |
michael@0 | 2373 | scriptdataescapeddashloop_end: ; |
michael@0 | 2374 | } |
michael@0 | 2375 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: { |
michael@0 | 2376 | for (; ; ) { |
michael@0 | 2377 | if (++pos == endPos) { |
michael@0 | 2378 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2379 | } |
michael@0 | 2380 | c = checkChar(buf, pos); |
michael@0 | 2381 | switch(c) { |
michael@0 | 2382 | case '/': { |
michael@0 | 2383 | index = 0; |
michael@0 | 2384 | clearStrBuf(); |
michael@0 | 2385 | returnState = NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED; |
michael@0 | 2386 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos); |
michael@0 | 2387 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2388 | } |
michael@0 | 2389 | case 'S': |
michael@0 | 2390 | case 's': { |
michael@0 | 2391 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 2392 | cstart = pos; |
michael@0 | 2393 | index = 1; |
michael@0 | 2394 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START, reconsume, pos); |
michael@0 | 2395 | NS_HTML5_BREAK(scriptdataescapedlessthanloop); |
michael@0 | 2396 | } |
michael@0 | 2397 | default: { |
michael@0 | 2398 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 2399 | cstart = pos; |
michael@0 | 2400 | reconsume = true; |
michael@0 | 2401 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2402 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2403 | } |
michael@0 | 2404 | } |
michael@0 | 2405 | } |
michael@0 | 2406 | scriptdataescapedlessthanloop_end: ; |
michael@0 | 2407 | } |
michael@0 | 2408 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START: { |
michael@0 | 2409 | for (; ; ) { |
michael@0 | 2410 | if (++pos == endPos) { |
michael@0 | 2411 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2412 | } |
michael@0 | 2413 | c = checkChar(buf, pos); |
michael@0 | 2414 | MOZ_ASSERT(index > 0); |
michael@0 | 2415 | if (index < 6) { |
michael@0 | 2416 | char16_t folded = c; |
michael@0 | 2417 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2418 | folded += 0x20; |
michael@0 | 2419 | } |
michael@0 | 2420 | if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) { |
michael@0 | 2421 | reconsume = true; |
michael@0 | 2422 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2423 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2424 | } |
michael@0 | 2425 | index++; |
michael@0 | 2426 | continue; |
michael@0 | 2427 | } |
michael@0 | 2428 | switch(c) { |
michael@0 | 2429 | case '\r': { |
michael@0 | 2430 | emitCarriageReturn(buf, pos); |
michael@0 | 2431 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2432 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2433 | } |
michael@0 | 2434 | case '\n': { |
michael@0 | 2435 | silentLineFeed(); |
michael@0 | 2436 | } |
michael@0 | 2437 | case ' ': |
michael@0 | 2438 | case '\t': |
michael@0 | 2439 | case '\f': |
michael@0 | 2440 | case '/': |
michael@0 | 2441 | case '>': { |
michael@0 | 2442 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2443 | NS_HTML5_BREAK(scriptdatadoubleescapestartloop); |
michael@0 | 2444 | } |
michael@0 | 2445 | default: { |
michael@0 | 2446 | reconsume = true; |
michael@0 | 2447 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2448 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2449 | } |
michael@0 | 2450 | } |
michael@0 | 2451 | } |
michael@0 | 2452 | scriptdatadoubleescapestartloop_end: ; |
michael@0 | 2453 | } |
michael@0 | 2454 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED: { |
michael@0 | 2455 | for (; ; ) { |
michael@0 | 2456 | if (reconsume) { |
michael@0 | 2457 | reconsume = false; |
michael@0 | 2458 | } else { |
michael@0 | 2459 | if (++pos == endPos) { |
michael@0 | 2460 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2461 | } |
michael@0 | 2462 | c = checkChar(buf, pos); |
michael@0 | 2463 | } |
michael@0 | 2464 | switch(c) { |
michael@0 | 2465 | case '-': { |
michael@0 | 2466 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH, reconsume, pos); |
michael@0 | 2467 | NS_HTML5_BREAK(scriptdatadoubleescapedloop); |
michael@0 | 2468 | } |
michael@0 | 2469 | case '<': { |
michael@0 | 2470 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2471 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2472 | } |
michael@0 | 2473 | case '\0': { |
michael@0 | 2474 | emitReplacementCharacter(buf, pos); |
michael@0 | 2475 | continue; |
michael@0 | 2476 | } |
michael@0 | 2477 | case '\r': { |
michael@0 | 2478 | emitCarriageReturn(buf, pos); |
michael@0 | 2479 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2480 | } |
michael@0 | 2481 | case '\n': { |
michael@0 | 2482 | silentLineFeed(); |
michael@0 | 2483 | } |
michael@0 | 2484 | default: { |
michael@0 | 2485 | continue; |
michael@0 | 2486 | } |
michael@0 | 2487 | } |
michael@0 | 2488 | } |
michael@0 | 2489 | scriptdatadoubleescapedloop_end: ; |
michael@0 | 2490 | } |
michael@0 | 2491 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH: { |
michael@0 | 2492 | for (; ; ) { |
michael@0 | 2493 | if (++pos == endPos) { |
michael@0 | 2494 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2495 | } |
michael@0 | 2496 | c = checkChar(buf, pos); |
michael@0 | 2497 | switch(c) { |
michael@0 | 2498 | case '-': { |
michael@0 | 2499 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH, reconsume, pos); |
michael@0 | 2500 | NS_HTML5_BREAK(scriptdatadoubleescapeddashloop); |
michael@0 | 2501 | } |
michael@0 | 2502 | case '<': { |
michael@0 | 2503 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2504 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2505 | } |
michael@0 | 2506 | case '\0': { |
michael@0 | 2507 | emitReplacementCharacter(buf, pos); |
michael@0 | 2508 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2509 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2510 | } |
michael@0 | 2511 | case '\r': { |
michael@0 | 2512 | emitCarriageReturn(buf, pos); |
michael@0 | 2513 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2514 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2515 | } |
michael@0 | 2516 | case '\n': { |
michael@0 | 2517 | silentLineFeed(); |
michael@0 | 2518 | } |
michael@0 | 2519 | default: { |
michael@0 | 2520 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2521 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2522 | } |
michael@0 | 2523 | } |
michael@0 | 2524 | } |
michael@0 | 2525 | scriptdatadoubleescapeddashloop_end: ; |
michael@0 | 2526 | } |
michael@0 | 2527 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: { |
michael@0 | 2528 | for (; ; ) { |
michael@0 | 2529 | if (++pos == endPos) { |
michael@0 | 2530 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2531 | } |
michael@0 | 2532 | c = checkChar(buf, pos); |
michael@0 | 2533 | switch(c) { |
michael@0 | 2534 | case '-': { |
michael@0 | 2535 | continue; |
michael@0 | 2536 | } |
michael@0 | 2537 | case '<': { |
michael@0 | 2538 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos); |
michael@0 | 2539 | NS_HTML5_BREAK(scriptdatadoubleescapeddashdashloop); |
michael@0 | 2540 | } |
michael@0 | 2541 | case '>': { |
michael@0 | 2542 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos); |
michael@0 | 2543 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2544 | } |
michael@0 | 2545 | case '\0': { |
michael@0 | 2546 | emitReplacementCharacter(buf, pos); |
michael@0 | 2547 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2548 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2549 | } |
michael@0 | 2550 | case '\r': { |
michael@0 | 2551 | emitCarriageReturn(buf, pos); |
michael@0 | 2552 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2553 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2554 | } |
michael@0 | 2555 | case '\n': { |
michael@0 | 2556 | silentLineFeed(); |
michael@0 | 2557 | } |
michael@0 | 2558 | default: { |
michael@0 | 2559 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2560 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2561 | } |
michael@0 | 2562 | } |
michael@0 | 2563 | } |
michael@0 | 2564 | scriptdatadoubleescapeddashdashloop_end: ; |
michael@0 | 2565 | } |
michael@0 | 2566 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: { |
michael@0 | 2567 | for (; ; ) { |
michael@0 | 2568 | if (++pos == endPos) { |
michael@0 | 2569 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2570 | } |
michael@0 | 2571 | c = checkChar(buf, pos); |
michael@0 | 2572 | switch(c) { |
michael@0 | 2573 | case '/': { |
michael@0 | 2574 | index = 0; |
michael@0 | 2575 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END, reconsume, pos); |
michael@0 | 2576 | NS_HTML5_BREAK(scriptdatadoubleescapedlessthanloop); |
michael@0 | 2577 | } |
michael@0 | 2578 | default: { |
michael@0 | 2579 | reconsume = true; |
michael@0 | 2580 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2581 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2582 | } |
michael@0 | 2583 | } |
michael@0 | 2584 | } |
michael@0 | 2585 | scriptdatadoubleescapedlessthanloop_end: ; |
michael@0 | 2586 | } |
michael@0 | 2587 | case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: { |
michael@0 | 2588 | for (; ; ) { |
michael@0 | 2589 | if (++pos == endPos) { |
michael@0 | 2590 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2591 | } |
michael@0 | 2592 | c = checkChar(buf, pos); |
michael@0 | 2593 | if (index < 6) { |
michael@0 | 2594 | char16_t folded = c; |
michael@0 | 2595 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2596 | folded += 0x20; |
michael@0 | 2597 | } |
michael@0 | 2598 | if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) { |
michael@0 | 2599 | reconsume = true; |
michael@0 | 2600 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2601 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2602 | } |
michael@0 | 2603 | index++; |
michael@0 | 2604 | continue; |
michael@0 | 2605 | } |
michael@0 | 2606 | switch(c) { |
michael@0 | 2607 | case '\r': { |
michael@0 | 2608 | emitCarriageReturn(buf, pos); |
michael@0 | 2609 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2610 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2611 | } |
michael@0 | 2612 | case '\n': { |
michael@0 | 2613 | silentLineFeed(); |
michael@0 | 2614 | } |
michael@0 | 2615 | case ' ': |
michael@0 | 2616 | case '\t': |
michael@0 | 2617 | case '\f': |
michael@0 | 2618 | case '/': |
michael@0 | 2619 | case '>': { |
michael@0 | 2620 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos); |
michael@0 | 2621 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2622 | } |
michael@0 | 2623 | default: { |
michael@0 | 2624 | reconsume = true; |
michael@0 | 2625 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos); |
michael@0 | 2626 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2627 | } |
michael@0 | 2628 | } |
michael@0 | 2629 | } |
michael@0 | 2630 | |
michael@0 | 2631 | } |
michael@0 | 2632 | case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: { |
michael@0 | 2633 | for (; ; ) { |
michael@0 | 2634 | if (++pos == endPos) { |
michael@0 | 2635 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2636 | } |
michael@0 | 2637 | c = checkChar(buf, pos); |
michael@0 | 2638 | if (index < 6) { |
michael@0 | 2639 | char16_t folded = c; |
michael@0 | 2640 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2641 | folded += 0x20; |
michael@0 | 2642 | } |
michael@0 | 2643 | if (folded == nsHtml5Tokenizer::OCTYPE[index]) { |
michael@0 | 2644 | appendLongStrBuf(c); |
michael@0 | 2645 | } else { |
michael@0 | 2646 | if (P::reportErrors) { |
michael@0 | 2647 | errBogusComment(); |
michael@0 | 2648 | } |
michael@0 | 2649 | reconsume = true; |
michael@0 | 2650 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos); |
michael@0 | 2651 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2652 | } |
michael@0 | 2653 | index++; |
michael@0 | 2654 | continue; |
michael@0 | 2655 | } else { |
michael@0 | 2656 | reconsume = true; |
michael@0 | 2657 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE, reconsume, pos); |
michael@0 | 2658 | NS_HTML5_BREAK(markupdeclarationdoctypeloop); |
michael@0 | 2659 | } |
michael@0 | 2660 | } |
michael@0 | 2661 | markupdeclarationdoctypeloop_end: ; |
michael@0 | 2662 | } |
michael@0 | 2663 | case NS_HTML5TOKENIZER_DOCTYPE: { |
michael@0 | 2664 | for (; ; ) { |
michael@0 | 2665 | if (reconsume) { |
michael@0 | 2666 | reconsume = false; |
michael@0 | 2667 | } else { |
michael@0 | 2668 | if (++pos == endPos) { |
michael@0 | 2669 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2670 | } |
michael@0 | 2671 | c = checkChar(buf, pos); |
michael@0 | 2672 | } |
michael@0 | 2673 | initDoctypeFields(); |
michael@0 | 2674 | switch(c) { |
michael@0 | 2675 | case '\r': { |
michael@0 | 2676 | silentCarriageReturn(); |
michael@0 | 2677 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos); |
michael@0 | 2678 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2679 | } |
michael@0 | 2680 | case '\n': { |
michael@0 | 2681 | silentLineFeed(); |
michael@0 | 2682 | } |
michael@0 | 2683 | case ' ': |
michael@0 | 2684 | case '\t': |
michael@0 | 2685 | case '\f': { |
michael@0 | 2686 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos); |
michael@0 | 2687 | NS_HTML5_BREAK(doctypeloop); |
michael@0 | 2688 | } |
michael@0 | 2689 | default: { |
michael@0 | 2690 | if (P::reportErrors) { |
michael@0 | 2691 | errMissingSpaceBeforeDoctypeName(); |
michael@0 | 2692 | } |
michael@0 | 2693 | reconsume = true; |
michael@0 | 2694 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos); |
michael@0 | 2695 | NS_HTML5_BREAK(doctypeloop); |
michael@0 | 2696 | } |
michael@0 | 2697 | } |
michael@0 | 2698 | } |
michael@0 | 2699 | doctypeloop_end: ; |
michael@0 | 2700 | } |
michael@0 | 2701 | case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: { |
michael@0 | 2702 | for (; ; ) { |
michael@0 | 2703 | if (reconsume) { |
michael@0 | 2704 | reconsume = false; |
michael@0 | 2705 | } else { |
michael@0 | 2706 | if (++pos == endPos) { |
michael@0 | 2707 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2708 | } |
michael@0 | 2709 | c = checkChar(buf, pos); |
michael@0 | 2710 | } |
michael@0 | 2711 | switch(c) { |
michael@0 | 2712 | case '\r': { |
michael@0 | 2713 | silentCarriageReturn(); |
michael@0 | 2714 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2715 | } |
michael@0 | 2716 | case '\n': { |
michael@0 | 2717 | silentLineFeed(); |
michael@0 | 2718 | } |
michael@0 | 2719 | case ' ': |
michael@0 | 2720 | case '\t': |
michael@0 | 2721 | case '\f': { |
michael@0 | 2722 | continue; |
michael@0 | 2723 | } |
michael@0 | 2724 | case '>': { |
michael@0 | 2725 | if (P::reportErrors) { |
michael@0 | 2726 | errNamelessDoctype(); |
michael@0 | 2727 | } |
michael@0 | 2728 | forceQuirks = true; |
michael@0 | 2729 | emitDoctypeToken(pos); |
michael@0 | 2730 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2731 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2732 | } |
michael@0 | 2733 | case '\0': { |
michael@0 | 2734 | c = 0xfffd; |
michael@0 | 2735 | } |
michael@0 | 2736 | default: { |
michael@0 | 2737 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2738 | c += 0x20; |
michael@0 | 2739 | } |
michael@0 | 2740 | clearStrBufAndAppend(c); |
michael@0 | 2741 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_NAME, reconsume, pos); |
michael@0 | 2742 | NS_HTML5_BREAK(beforedoctypenameloop); |
michael@0 | 2743 | } |
michael@0 | 2744 | } |
michael@0 | 2745 | } |
michael@0 | 2746 | beforedoctypenameloop_end: ; |
michael@0 | 2747 | } |
michael@0 | 2748 | case NS_HTML5TOKENIZER_DOCTYPE_NAME: { |
michael@0 | 2749 | for (; ; ) { |
michael@0 | 2750 | if (++pos == endPos) { |
michael@0 | 2751 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2752 | } |
michael@0 | 2753 | c = checkChar(buf, pos); |
michael@0 | 2754 | switch(c) { |
michael@0 | 2755 | case '\r': { |
michael@0 | 2756 | silentCarriageReturn(); |
michael@0 | 2757 | strBufToDoctypeName(); |
michael@0 | 2758 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos); |
michael@0 | 2759 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2760 | } |
michael@0 | 2761 | case '\n': { |
michael@0 | 2762 | silentLineFeed(); |
michael@0 | 2763 | } |
michael@0 | 2764 | case ' ': |
michael@0 | 2765 | case '\t': |
michael@0 | 2766 | case '\f': { |
michael@0 | 2767 | strBufToDoctypeName(); |
michael@0 | 2768 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos); |
michael@0 | 2769 | NS_HTML5_BREAK(doctypenameloop); |
michael@0 | 2770 | } |
michael@0 | 2771 | case '>': { |
michael@0 | 2772 | strBufToDoctypeName(); |
michael@0 | 2773 | emitDoctypeToken(pos); |
michael@0 | 2774 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2775 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2776 | } |
michael@0 | 2777 | case '\0': { |
michael@0 | 2778 | c = 0xfffd; |
michael@0 | 2779 | } |
michael@0 | 2780 | default: { |
michael@0 | 2781 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2782 | c += 0x0020; |
michael@0 | 2783 | } |
michael@0 | 2784 | appendStrBuf(c); |
michael@0 | 2785 | continue; |
michael@0 | 2786 | } |
michael@0 | 2787 | } |
michael@0 | 2788 | } |
michael@0 | 2789 | doctypenameloop_end: ; |
michael@0 | 2790 | } |
michael@0 | 2791 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME: { |
michael@0 | 2792 | for (; ; ) { |
michael@0 | 2793 | if (++pos == endPos) { |
michael@0 | 2794 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2795 | } |
michael@0 | 2796 | c = checkChar(buf, pos); |
michael@0 | 2797 | switch(c) { |
michael@0 | 2798 | case '\r': { |
michael@0 | 2799 | silentCarriageReturn(); |
michael@0 | 2800 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2801 | } |
michael@0 | 2802 | case '\n': { |
michael@0 | 2803 | silentLineFeed(); |
michael@0 | 2804 | } |
michael@0 | 2805 | case ' ': |
michael@0 | 2806 | case '\t': |
michael@0 | 2807 | case '\f': { |
michael@0 | 2808 | continue; |
michael@0 | 2809 | } |
michael@0 | 2810 | case '>': { |
michael@0 | 2811 | emitDoctypeToken(pos); |
michael@0 | 2812 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2813 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2814 | } |
michael@0 | 2815 | case 'p': |
michael@0 | 2816 | case 'P': { |
michael@0 | 2817 | index = 0; |
michael@0 | 2818 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_UBLIC, reconsume, pos); |
michael@0 | 2819 | NS_HTML5_BREAK(afterdoctypenameloop); |
michael@0 | 2820 | } |
michael@0 | 2821 | case 's': |
michael@0 | 2822 | case 'S': { |
michael@0 | 2823 | index = 0; |
michael@0 | 2824 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_YSTEM, reconsume, pos); |
michael@0 | 2825 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2826 | } |
michael@0 | 2827 | default: { |
michael@0 | 2828 | bogusDoctype(); |
michael@0 | 2829 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 2830 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2831 | } |
michael@0 | 2832 | } |
michael@0 | 2833 | } |
michael@0 | 2834 | afterdoctypenameloop_end: ; |
michael@0 | 2835 | } |
michael@0 | 2836 | case NS_HTML5TOKENIZER_DOCTYPE_UBLIC: { |
michael@0 | 2837 | for (; ; ) { |
michael@0 | 2838 | if (++pos == endPos) { |
michael@0 | 2839 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2840 | } |
michael@0 | 2841 | c = checkChar(buf, pos); |
michael@0 | 2842 | if (index < 5) { |
michael@0 | 2843 | char16_t folded = c; |
michael@0 | 2844 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 2845 | folded += 0x20; |
michael@0 | 2846 | } |
michael@0 | 2847 | if (folded != nsHtml5Tokenizer::UBLIC[index]) { |
michael@0 | 2848 | bogusDoctype(); |
michael@0 | 2849 | reconsume = true; |
michael@0 | 2850 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 2851 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2852 | } |
michael@0 | 2853 | index++; |
michael@0 | 2854 | continue; |
michael@0 | 2855 | } else { |
michael@0 | 2856 | reconsume = true; |
michael@0 | 2857 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD, reconsume, pos); |
michael@0 | 2858 | NS_HTML5_BREAK(doctypeublicloop); |
michael@0 | 2859 | } |
michael@0 | 2860 | } |
michael@0 | 2861 | doctypeublicloop_end: ; |
michael@0 | 2862 | } |
michael@0 | 2863 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD: { |
michael@0 | 2864 | for (; ; ) { |
michael@0 | 2865 | if (reconsume) { |
michael@0 | 2866 | reconsume = false; |
michael@0 | 2867 | } else { |
michael@0 | 2868 | if (++pos == endPos) { |
michael@0 | 2869 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2870 | } |
michael@0 | 2871 | c = checkChar(buf, pos); |
michael@0 | 2872 | } |
michael@0 | 2873 | switch(c) { |
michael@0 | 2874 | case '\r': { |
michael@0 | 2875 | silentCarriageReturn(); |
michael@0 | 2876 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); |
michael@0 | 2877 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2878 | } |
michael@0 | 2879 | case '\n': { |
michael@0 | 2880 | silentLineFeed(); |
michael@0 | 2881 | } |
michael@0 | 2882 | case ' ': |
michael@0 | 2883 | case '\t': |
michael@0 | 2884 | case '\f': { |
michael@0 | 2885 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); |
michael@0 | 2886 | NS_HTML5_BREAK(afterdoctypepublickeywordloop); |
michael@0 | 2887 | } |
michael@0 | 2888 | case '\"': { |
michael@0 | 2889 | if (P::reportErrors) { |
michael@0 | 2890 | errNoSpaceBetweenDoctypePublicKeywordAndQuote(); |
michael@0 | 2891 | } |
michael@0 | 2892 | clearLongStrBuf(); |
michael@0 | 2893 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 2894 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2895 | } |
michael@0 | 2896 | case '\'': { |
michael@0 | 2897 | if (P::reportErrors) { |
michael@0 | 2898 | errNoSpaceBetweenDoctypePublicKeywordAndQuote(); |
michael@0 | 2899 | } |
michael@0 | 2900 | clearLongStrBuf(); |
michael@0 | 2901 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 2902 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2903 | } |
michael@0 | 2904 | case '>': { |
michael@0 | 2905 | if (P::reportErrors) { |
michael@0 | 2906 | errExpectedPublicId(); |
michael@0 | 2907 | } |
michael@0 | 2908 | forceQuirks = true; |
michael@0 | 2909 | emitDoctypeToken(pos); |
michael@0 | 2910 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2911 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2912 | } |
michael@0 | 2913 | default: { |
michael@0 | 2914 | bogusDoctype(); |
michael@0 | 2915 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 2916 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2917 | } |
michael@0 | 2918 | } |
michael@0 | 2919 | } |
michael@0 | 2920 | afterdoctypepublickeywordloop_end: ; |
michael@0 | 2921 | } |
michael@0 | 2922 | case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: { |
michael@0 | 2923 | for (; ; ) { |
michael@0 | 2924 | if (++pos == endPos) { |
michael@0 | 2925 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2926 | } |
michael@0 | 2927 | c = checkChar(buf, pos); |
michael@0 | 2928 | switch(c) { |
michael@0 | 2929 | case '\r': { |
michael@0 | 2930 | silentCarriageReturn(); |
michael@0 | 2931 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2932 | } |
michael@0 | 2933 | case '\n': { |
michael@0 | 2934 | silentLineFeed(); |
michael@0 | 2935 | } |
michael@0 | 2936 | case ' ': |
michael@0 | 2937 | case '\t': |
michael@0 | 2938 | case '\f': { |
michael@0 | 2939 | continue; |
michael@0 | 2940 | } |
michael@0 | 2941 | case '\"': { |
michael@0 | 2942 | clearLongStrBuf(); |
michael@0 | 2943 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 2944 | NS_HTML5_BREAK(beforedoctypepublicidentifierloop); |
michael@0 | 2945 | } |
michael@0 | 2946 | case '\'': { |
michael@0 | 2947 | clearLongStrBuf(); |
michael@0 | 2948 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 2949 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2950 | } |
michael@0 | 2951 | case '>': { |
michael@0 | 2952 | if (P::reportErrors) { |
michael@0 | 2953 | errExpectedPublicId(); |
michael@0 | 2954 | } |
michael@0 | 2955 | forceQuirks = true; |
michael@0 | 2956 | emitDoctypeToken(pos); |
michael@0 | 2957 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2958 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2959 | } |
michael@0 | 2960 | default: { |
michael@0 | 2961 | bogusDoctype(); |
michael@0 | 2962 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 2963 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2964 | } |
michael@0 | 2965 | } |
michael@0 | 2966 | } |
michael@0 | 2967 | beforedoctypepublicidentifierloop_end: ; |
michael@0 | 2968 | } |
michael@0 | 2969 | case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: { |
michael@0 | 2970 | for (; ; ) { |
michael@0 | 2971 | if (++pos == endPos) { |
michael@0 | 2972 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2973 | } |
michael@0 | 2974 | c = checkChar(buf, pos); |
michael@0 | 2975 | switch(c) { |
michael@0 | 2976 | case '\"': { |
michael@0 | 2977 | publicIdentifier = longStrBufToString(); |
michael@0 | 2978 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); |
michael@0 | 2979 | NS_HTML5_BREAK(doctypepublicidentifierdoublequotedloop); |
michael@0 | 2980 | } |
michael@0 | 2981 | case '>': { |
michael@0 | 2982 | if (P::reportErrors) { |
michael@0 | 2983 | errGtInPublicId(); |
michael@0 | 2984 | } |
michael@0 | 2985 | forceQuirks = true; |
michael@0 | 2986 | publicIdentifier = longStrBufToString(); |
michael@0 | 2987 | emitDoctypeToken(pos); |
michael@0 | 2988 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 2989 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 2990 | } |
michael@0 | 2991 | case '\r': { |
michael@0 | 2992 | appendLongStrBufCarriageReturn(); |
michael@0 | 2993 | NS_HTML5_BREAK(stateloop); |
michael@0 | 2994 | } |
michael@0 | 2995 | case '\n': { |
michael@0 | 2996 | appendLongStrBufLineFeed(); |
michael@0 | 2997 | continue; |
michael@0 | 2998 | } |
michael@0 | 2999 | case '\0': { |
michael@0 | 3000 | c = 0xfffd; |
michael@0 | 3001 | } |
michael@0 | 3002 | default: { |
michael@0 | 3003 | appendLongStrBuf(c); |
michael@0 | 3004 | continue; |
michael@0 | 3005 | } |
michael@0 | 3006 | } |
michael@0 | 3007 | } |
michael@0 | 3008 | doctypepublicidentifierdoublequotedloop_end: ; |
michael@0 | 3009 | } |
michael@0 | 3010 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER: { |
michael@0 | 3011 | for (; ; ) { |
michael@0 | 3012 | if (++pos == endPos) { |
michael@0 | 3013 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3014 | } |
michael@0 | 3015 | c = checkChar(buf, pos); |
michael@0 | 3016 | switch(c) { |
michael@0 | 3017 | case '\r': { |
michael@0 | 3018 | silentCarriageReturn(); |
michael@0 | 3019 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos); |
michael@0 | 3020 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3021 | } |
michael@0 | 3022 | case '\n': { |
michael@0 | 3023 | silentLineFeed(); |
michael@0 | 3024 | } |
michael@0 | 3025 | case ' ': |
michael@0 | 3026 | case '\t': |
michael@0 | 3027 | case '\f': { |
michael@0 | 3028 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos); |
michael@0 | 3029 | NS_HTML5_BREAK(afterdoctypepublicidentifierloop); |
michael@0 | 3030 | } |
michael@0 | 3031 | case '>': { |
michael@0 | 3032 | emitDoctypeToken(pos); |
michael@0 | 3033 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3034 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3035 | } |
michael@0 | 3036 | case '\"': { |
michael@0 | 3037 | if (P::reportErrors) { |
michael@0 | 3038 | errNoSpaceBetweenPublicAndSystemIds(); |
michael@0 | 3039 | } |
michael@0 | 3040 | clearLongStrBuf(); |
michael@0 | 3041 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 3042 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3043 | } |
michael@0 | 3044 | case '\'': { |
michael@0 | 3045 | if (P::reportErrors) { |
michael@0 | 3046 | errNoSpaceBetweenPublicAndSystemIds(); |
michael@0 | 3047 | } |
michael@0 | 3048 | clearLongStrBuf(); |
michael@0 | 3049 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 3050 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3051 | } |
michael@0 | 3052 | default: { |
michael@0 | 3053 | bogusDoctype(); |
michael@0 | 3054 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 3055 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3056 | } |
michael@0 | 3057 | } |
michael@0 | 3058 | } |
michael@0 | 3059 | afterdoctypepublicidentifierloop_end: ; |
michael@0 | 3060 | } |
michael@0 | 3061 | case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: { |
michael@0 | 3062 | for (; ; ) { |
michael@0 | 3063 | if (++pos == endPos) { |
michael@0 | 3064 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3065 | } |
michael@0 | 3066 | c = checkChar(buf, pos); |
michael@0 | 3067 | switch(c) { |
michael@0 | 3068 | case '\r': { |
michael@0 | 3069 | silentCarriageReturn(); |
michael@0 | 3070 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3071 | } |
michael@0 | 3072 | case '\n': { |
michael@0 | 3073 | silentLineFeed(); |
michael@0 | 3074 | } |
michael@0 | 3075 | case ' ': |
michael@0 | 3076 | case '\t': |
michael@0 | 3077 | case '\f': { |
michael@0 | 3078 | continue; |
michael@0 | 3079 | } |
michael@0 | 3080 | case '>': { |
michael@0 | 3081 | emitDoctypeToken(pos); |
michael@0 | 3082 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3083 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3084 | } |
michael@0 | 3085 | case '\"': { |
michael@0 | 3086 | clearLongStrBuf(); |
michael@0 | 3087 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 3088 | NS_HTML5_BREAK(betweendoctypepublicandsystemidentifiersloop); |
michael@0 | 3089 | } |
michael@0 | 3090 | case '\'': { |
michael@0 | 3091 | clearLongStrBuf(); |
michael@0 | 3092 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 3093 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3094 | } |
michael@0 | 3095 | default: { |
michael@0 | 3096 | bogusDoctype(); |
michael@0 | 3097 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 3098 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3099 | } |
michael@0 | 3100 | } |
michael@0 | 3101 | } |
michael@0 | 3102 | betweendoctypepublicandsystemidentifiersloop_end: ; |
michael@0 | 3103 | } |
michael@0 | 3104 | case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: { |
michael@0 | 3105 | for (; ; ) { |
michael@0 | 3106 | if (++pos == endPos) { |
michael@0 | 3107 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3108 | } |
michael@0 | 3109 | c = checkChar(buf, pos); |
michael@0 | 3110 | switch(c) { |
michael@0 | 3111 | case '\"': { |
michael@0 | 3112 | systemIdentifier = longStrBufToString(); |
michael@0 | 3113 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); |
michael@0 | 3114 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3115 | } |
michael@0 | 3116 | case '>': { |
michael@0 | 3117 | if (P::reportErrors) { |
michael@0 | 3118 | errGtInSystemId(); |
michael@0 | 3119 | } |
michael@0 | 3120 | forceQuirks = true; |
michael@0 | 3121 | systemIdentifier = longStrBufToString(); |
michael@0 | 3122 | emitDoctypeToken(pos); |
michael@0 | 3123 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3124 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3125 | } |
michael@0 | 3126 | case '\r': { |
michael@0 | 3127 | appendLongStrBufCarriageReturn(); |
michael@0 | 3128 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3129 | } |
michael@0 | 3130 | case '\n': { |
michael@0 | 3131 | appendLongStrBufLineFeed(); |
michael@0 | 3132 | continue; |
michael@0 | 3133 | } |
michael@0 | 3134 | case '\0': { |
michael@0 | 3135 | c = 0xfffd; |
michael@0 | 3136 | } |
michael@0 | 3137 | default: { |
michael@0 | 3138 | appendLongStrBuf(c); |
michael@0 | 3139 | continue; |
michael@0 | 3140 | } |
michael@0 | 3141 | } |
michael@0 | 3142 | } |
michael@0 | 3143 | |
michael@0 | 3144 | } |
michael@0 | 3145 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: { |
michael@0 | 3146 | for (; ; ) { |
michael@0 | 3147 | if (++pos == endPos) { |
michael@0 | 3148 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3149 | } |
michael@0 | 3150 | c = checkChar(buf, pos); |
michael@0 | 3151 | switch(c) { |
michael@0 | 3152 | case '\r': { |
michael@0 | 3153 | silentCarriageReturn(); |
michael@0 | 3154 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3155 | } |
michael@0 | 3156 | case '\n': { |
michael@0 | 3157 | silentLineFeed(); |
michael@0 | 3158 | } |
michael@0 | 3159 | case ' ': |
michael@0 | 3160 | case '\t': |
michael@0 | 3161 | case '\f': { |
michael@0 | 3162 | continue; |
michael@0 | 3163 | } |
michael@0 | 3164 | case '>': { |
michael@0 | 3165 | emitDoctypeToken(pos); |
michael@0 | 3166 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3167 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3168 | } |
michael@0 | 3169 | default: { |
michael@0 | 3170 | bogusDoctypeWithoutQuirks(); |
michael@0 | 3171 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 3172 | NS_HTML5_BREAK(afterdoctypesystemidentifierloop); |
michael@0 | 3173 | } |
michael@0 | 3174 | } |
michael@0 | 3175 | } |
michael@0 | 3176 | afterdoctypesystemidentifierloop_end: ; |
michael@0 | 3177 | } |
michael@0 | 3178 | case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: { |
michael@0 | 3179 | for (; ; ) { |
michael@0 | 3180 | if (reconsume) { |
michael@0 | 3181 | reconsume = false; |
michael@0 | 3182 | } else { |
michael@0 | 3183 | if (++pos == endPos) { |
michael@0 | 3184 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3185 | } |
michael@0 | 3186 | c = checkChar(buf, pos); |
michael@0 | 3187 | } |
michael@0 | 3188 | switch(c) { |
michael@0 | 3189 | case '>': { |
michael@0 | 3190 | emitDoctypeToken(pos); |
michael@0 | 3191 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3192 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3193 | } |
michael@0 | 3194 | case '\r': { |
michael@0 | 3195 | silentCarriageReturn(); |
michael@0 | 3196 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3197 | } |
michael@0 | 3198 | case '\n': { |
michael@0 | 3199 | silentLineFeed(); |
michael@0 | 3200 | } |
michael@0 | 3201 | default: { |
michael@0 | 3202 | continue; |
michael@0 | 3203 | } |
michael@0 | 3204 | } |
michael@0 | 3205 | } |
michael@0 | 3206 | } |
michael@0 | 3207 | case NS_HTML5TOKENIZER_DOCTYPE_YSTEM: { |
michael@0 | 3208 | for (; ; ) { |
michael@0 | 3209 | if (++pos == endPos) { |
michael@0 | 3210 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3211 | } |
michael@0 | 3212 | c = checkChar(buf, pos); |
michael@0 | 3213 | if (index < 5) { |
michael@0 | 3214 | char16_t folded = c; |
michael@0 | 3215 | if (c >= 'A' && c <= 'Z') { |
michael@0 | 3216 | folded += 0x20; |
michael@0 | 3217 | } |
michael@0 | 3218 | if (folded != nsHtml5Tokenizer::YSTEM[index]) { |
michael@0 | 3219 | bogusDoctype(); |
michael@0 | 3220 | reconsume = true; |
michael@0 | 3221 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 3222 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3223 | } |
michael@0 | 3224 | index++; |
michael@0 | 3225 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3226 | } else { |
michael@0 | 3227 | reconsume = true; |
michael@0 | 3228 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD, reconsume, pos); |
michael@0 | 3229 | NS_HTML5_BREAK(doctypeystemloop); |
michael@0 | 3230 | } |
michael@0 | 3231 | } |
michael@0 | 3232 | doctypeystemloop_end: ; |
michael@0 | 3233 | } |
michael@0 | 3234 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD: { |
michael@0 | 3235 | for (; ; ) { |
michael@0 | 3236 | if (reconsume) { |
michael@0 | 3237 | reconsume = false; |
michael@0 | 3238 | } else { |
michael@0 | 3239 | if (++pos == endPos) { |
michael@0 | 3240 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3241 | } |
michael@0 | 3242 | c = checkChar(buf, pos); |
michael@0 | 3243 | } |
michael@0 | 3244 | switch(c) { |
michael@0 | 3245 | case '\r': { |
michael@0 | 3246 | silentCarriageReturn(); |
michael@0 | 3247 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); |
michael@0 | 3248 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3249 | } |
michael@0 | 3250 | case '\n': { |
michael@0 | 3251 | silentLineFeed(); |
michael@0 | 3252 | } |
michael@0 | 3253 | case ' ': |
michael@0 | 3254 | case '\t': |
michael@0 | 3255 | case '\f': { |
michael@0 | 3256 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); |
michael@0 | 3257 | NS_HTML5_BREAK(afterdoctypesystemkeywordloop); |
michael@0 | 3258 | } |
michael@0 | 3259 | case '\"': { |
michael@0 | 3260 | if (P::reportErrors) { |
michael@0 | 3261 | errNoSpaceBetweenDoctypeSystemKeywordAndQuote(); |
michael@0 | 3262 | } |
michael@0 | 3263 | clearLongStrBuf(); |
michael@0 | 3264 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 3265 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3266 | } |
michael@0 | 3267 | case '\'': { |
michael@0 | 3268 | if (P::reportErrors) { |
michael@0 | 3269 | errNoSpaceBetweenDoctypeSystemKeywordAndQuote(); |
michael@0 | 3270 | } |
michael@0 | 3271 | clearLongStrBuf(); |
michael@0 | 3272 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 3273 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3274 | } |
michael@0 | 3275 | case '>': { |
michael@0 | 3276 | if (P::reportErrors) { |
michael@0 | 3277 | errExpectedPublicId(); |
michael@0 | 3278 | } |
michael@0 | 3279 | forceQuirks = true; |
michael@0 | 3280 | emitDoctypeToken(pos); |
michael@0 | 3281 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3282 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3283 | } |
michael@0 | 3284 | default: { |
michael@0 | 3285 | bogusDoctype(); |
michael@0 | 3286 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 3287 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3288 | } |
michael@0 | 3289 | } |
michael@0 | 3290 | } |
michael@0 | 3291 | afterdoctypesystemkeywordloop_end: ; |
michael@0 | 3292 | } |
michael@0 | 3293 | case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: { |
michael@0 | 3294 | for (; ; ) { |
michael@0 | 3295 | if (++pos == endPos) { |
michael@0 | 3296 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3297 | } |
michael@0 | 3298 | c = checkChar(buf, pos); |
michael@0 | 3299 | switch(c) { |
michael@0 | 3300 | case '\r': { |
michael@0 | 3301 | silentCarriageReturn(); |
michael@0 | 3302 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3303 | } |
michael@0 | 3304 | case '\n': { |
michael@0 | 3305 | silentLineFeed(); |
michael@0 | 3306 | } |
michael@0 | 3307 | case ' ': |
michael@0 | 3308 | case '\t': |
michael@0 | 3309 | case '\f': { |
michael@0 | 3310 | continue; |
michael@0 | 3311 | } |
michael@0 | 3312 | case '\"': { |
michael@0 | 3313 | clearLongStrBuf(); |
michael@0 | 3314 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos); |
michael@0 | 3315 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3316 | } |
michael@0 | 3317 | case '\'': { |
michael@0 | 3318 | clearLongStrBuf(); |
michael@0 | 3319 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos); |
michael@0 | 3320 | NS_HTML5_BREAK(beforedoctypesystemidentifierloop); |
michael@0 | 3321 | } |
michael@0 | 3322 | case '>': { |
michael@0 | 3323 | if (P::reportErrors) { |
michael@0 | 3324 | errExpectedSystemId(); |
michael@0 | 3325 | } |
michael@0 | 3326 | forceQuirks = true; |
michael@0 | 3327 | emitDoctypeToken(pos); |
michael@0 | 3328 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3329 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3330 | } |
michael@0 | 3331 | default: { |
michael@0 | 3332 | bogusDoctype(); |
michael@0 | 3333 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos); |
michael@0 | 3334 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3335 | } |
michael@0 | 3336 | } |
michael@0 | 3337 | } |
michael@0 | 3338 | beforedoctypesystemidentifierloop_end: ; |
michael@0 | 3339 | } |
michael@0 | 3340 | case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: { |
michael@0 | 3341 | for (; ; ) { |
michael@0 | 3342 | if (++pos == endPos) { |
michael@0 | 3343 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3344 | } |
michael@0 | 3345 | c = checkChar(buf, pos); |
michael@0 | 3346 | switch(c) { |
michael@0 | 3347 | case '\'': { |
michael@0 | 3348 | systemIdentifier = longStrBufToString(); |
michael@0 | 3349 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos); |
michael@0 | 3350 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3351 | } |
michael@0 | 3352 | case '>': { |
michael@0 | 3353 | if (P::reportErrors) { |
michael@0 | 3354 | errGtInSystemId(); |
michael@0 | 3355 | } |
michael@0 | 3356 | forceQuirks = true; |
michael@0 | 3357 | systemIdentifier = longStrBufToString(); |
michael@0 | 3358 | emitDoctypeToken(pos); |
michael@0 | 3359 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3360 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3361 | } |
michael@0 | 3362 | case '\r': { |
michael@0 | 3363 | appendLongStrBufCarriageReturn(); |
michael@0 | 3364 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3365 | } |
michael@0 | 3366 | case '\n': { |
michael@0 | 3367 | appendLongStrBufLineFeed(); |
michael@0 | 3368 | continue; |
michael@0 | 3369 | } |
michael@0 | 3370 | case '\0': { |
michael@0 | 3371 | c = 0xfffd; |
michael@0 | 3372 | } |
michael@0 | 3373 | default: { |
michael@0 | 3374 | appendLongStrBuf(c); |
michael@0 | 3375 | continue; |
michael@0 | 3376 | } |
michael@0 | 3377 | } |
michael@0 | 3378 | } |
michael@0 | 3379 | } |
michael@0 | 3380 | case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: { |
michael@0 | 3381 | for (; ; ) { |
michael@0 | 3382 | if (++pos == endPos) { |
michael@0 | 3383 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3384 | } |
michael@0 | 3385 | c = checkChar(buf, pos); |
michael@0 | 3386 | switch(c) { |
michael@0 | 3387 | case '\'': { |
michael@0 | 3388 | publicIdentifier = longStrBufToString(); |
michael@0 | 3389 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos); |
michael@0 | 3390 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3391 | } |
michael@0 | 3392 | case '>': { |
michael@0 | 3393 | if (P::reportErrors) { |
michael@0 | 3394 | errGtInPublicId(); |
michael@0 | 3395 | } |
michael@0 | 3396 | forceQuirks = true; |
michael@0 | 3397 | publicIdentifier = longStrBufToString(); |
michael@0 | 3398 | emitDoctypeToken(pos); |
michael@0 | 3399 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3400 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3401 | } |
michael@0 | 3402 | case '\r': { |
michael@0 | 3403 | appendLongStrBufCarriageReturn(); |
michael@0 | 3404 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3405 | } |
michael@0 | 3406 | case '\n': { |
michael@0 | 3407 | appendLongStrBufLineFeed(); |
michael@0 | 3408 | continue; |
michael@0 | 3409 | } |
michael@0 | 3410 | case '\0': { |
michael@0 | 3411 | c = 0xfffd; |
michael@0 | 3412 | } |
michael@0 | 3413 | default: { |
michael@0 | 3414 | appendLongStrBuf(c); |
michael@0 | 3415 | continue; |
michael@0 | 3416 | } |
michael@0 | 3417 | } |
michael@0 | 3418 | } |
michael@0 | 3419 | } |
michael@0 | 3420 | case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION: { |
michael@0 | 3421 | for (; ; ) { |
michael@0 | 3422 | if (++pos == endPos) { |
michael@0 | 3423 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3424 | } |
michael@0 | 3425 | c = checkChar(buf, pos); |
michael@0 | 3426 | switch(c) { |
michael@0 | 3427 | case '\?': { |
michael@0 | 3428 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK, reconsume, pos); |
michael@0 | 3429 | NS_HTML5_BREAK(processinginstructionloop); |
michael@0 | 3430 | } |
michael@0 | 3431 | default: { |
michael@0 | 3432 | continue; |
michael@0 | 3433 | } |
michael@0 | 3434 | } |
michael@0 | 3435 | } |
michael@0 | 3436 | processinginstructionloop_end: ; |
michael@0 | 3437 | } |
michael@0 | 3438 | case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK: { |
michael@0 | 3439 | if (++pos == endPos) { |
michael@0 | 3440 | NS_HTML5_BREAK(stateloop); |
michael@0 | 3441 | } |
michael@0 | 3442 | c = checkChar(buf, pos); |
michael@0 | 3443 | switch(c) { |
michael@0 | 3444 | case '>': { |
michael@0 | 3445 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos); |
michael@0 | 3446 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3447 | } |
michael@0 | 3448 | default: { |
michael@0 | 3449 | state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos); |
michael@0 | 3450 | NS_HTML5_CONTINUE(stateloop); |
michael@0 | 3451 | } |
michael@0 | 3452 | } |
michael@0 | 3453 | } |
michael@0 | 3454 | } |
michael@0 | 3455 | } |
michael@0 | 3456 | stateloop_end: ; |
michael@0 | 3457 | flushChars(buf, pos); |
michael@0 | 3458 | stateSave = state; |
michael@0 | 3459 | returnStateSave = returnState; |
michael@0 | 3460 | return pos; |
michael@0 | 3461 | } |
michael@0 | 3462 | |
michael@0 | 3463 | void |
michael@0 | 3464 | nsHtml5Tokenizer::initDoctypeFields() |
michael@0 | 3465 | { |
michael@0 | 3466 | doctypeName = nsHtml5Atoms::emptystring; |
michael@0 | 3467 | if (systemIdentifier) { |
michael@0 | 3468 | nsHtml5Portability::releaseString(systemIdentifier); |
michael@0 | 3469 | systemIdentifier = nullptr; |
michael@0 | 3470 | } |
michael@0 | 3471 | if (publicIdentifier) { |
michael@0 | 3472 | nsHtml5Portability::releaseString(publicIdentifier); |
michael@0 | 3473 | publicIdentifier = nullptr; |
michael@0 | 3474 | } |
michael@0 | 3475 | forceQuirks = false; |
michael@0 | 3476 | } |
michael@0 | 3477 | |
michael@0 | 3478 | void |
michael@0 | 3479 | nsHtml5Tokenizer::emitCarriageReturn(char16_t* buf, int32_t pos) |
michael@0 | 3480 | { |
michael@0 | 3481 | silentCarriageReturn(); |
michael@0 | 3482 | flushChars(buf, pos); |
michael@0 | 3483 | tokenHandler->characters(nsHtml5Tokenizer::LF, 0, 1); |
michael@0 | 3484 | cstart = INT32_MAX; |
michael@0 | 3485 | } |
michael@0 | 3486 | |
michael@0 | 3487 | void |
michael@0 | 3488 | nsHtml5Tokenizer::emitReplacementCharacter(char16_t* buf, int32_t pos) |
michael@0 | 3489 | { |
michael@0 | 3490 | flushChars(buf, pos); |
michael@0 | 3491 | tokenHandler->zeroOriginatingReplacementCharacter(); |
michael@0 | 3492 | cstart = pos + 1; |
michael@0 | 3493 | } |
michael@0 | 3494 | |
michael@0 | 3495 | void |
michael@0 | 3496 | nsHtml5Tokenizer::emitPlaintextReplacementCharacter(char16_t* buf, int32_t pos) |
michael@0 | 3497 | { |
michael@0 | 3498 | flushChars(buf, pos); |
michael@0 | 3499 | tokenHandler->characters(REPLACEMENT_CHARACTER, 0, 1); |
michael@0 | 3500 | cstart = pos + 1; |
michael@0 | 3501 | } |
michael@0 | 3502 | |
michael@0 | 3503 | void |
michael@0 | 3504 | nsHtml5Tokenizer::setAdditionalAndRememberAmpersandLocation(char16_t add) |
michael@0 | 3505 | { |
michael@0 | 3506 | additional = add; |
michael@0 | 3507 | } |
michael@0 | 3508 | |
michael@0 | 3509 | void |
michael@0 | 3510 | nsHtml5Tokenizer::bogusDoctype() |
michael@0 | 3511 | { |
michael@0 | 3512 | errBogusDoctype(); |
michael@0 | 3513 | forceQuirks = true; |
michael@0 | 3514 | } |
michael@0 | 3515 | |
michael@0 | 3516 | void |
michael@0 | 3517 | nsHtml5Tokenizer::bogusDoctypeWithoutQuirks() |
michael@0 | 3518 | { |
michael@0 | 3519 | errBogusDoctype(); |
michael@0 | 3520 | forceQuirks = false; |
michael@0 | 3521 | } |
michael@0 | 3522 | |
michael@0 | 3523 | void |
michael@0 | 3524 | nsHtml5Tokenizer::emitOrAppendStrBuf(int32_t returnState) |
michael@0 | 3525 | { |
michael@0 | 3526 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 3527 | appendStrBufToLongStrBuf(); |
michael@0 | 3528 | } else { |
michael@0 | 3529 | emitStrBuf(); |
michael@0 | 3530 | } |
michael@0 | 3531 | } |
michael@0 | 3532 | |
michael@0 | 3533 | void |
michael@0 | 3534 | nsHtml5Tokenizer::handleNcrValue(int32_t returnState) |
michael@0 | 3535 | { |
michael@0 | 3536 | if (value <= 0xFFFF) { |
michael@0 | 3537 | if (value >= 0x80 && value <= 0x9f) { |
michael@0 | 3538 | errNcrInC1Range(); |
michael@0 | 3539 | char16_t* val = nsHtml5NamedCharacters::WINDOWS_1252[value - 0x80]; |
michael@0 | 3540 | emitOrAppendOne(val, returnState); |
michael@0 | 3541 | } else if (value == 0x0) { |
michael@0 | 3542 | errNcrZero(); |
michael@0 | 3543 | emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState); |
michael@0 | 3544 | } else if ((value & 0xF800) == 0xD800) { |
michael@0 | 3545 | errNcrSurrogate(); |
michael@0 | 3546 | emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState); |
michael@0 | 3547 | } else { |
michael@0 | 3548 | char16_t ch = (char16_t) value; |
michael@0 | 3549 | bmpChar[0] = ch; |
michael@0 | 3550 | emitOrAppendOne(bmpChar, returnState); |
michael@0 | 3551 | } |
michael@0 | 3552 | } else if (value <= 0x10FFFF) { |
michael@0 | 3553 | astralChar[0] = (char16_t) (NS_HTML5TOKENIZER_LEAD_OFFSET + (value >> 10)); |
michael@0 | 3554 | astralChar[1] = (char16_t) (0xDC00 + (value & 0x3FF)); |
michael@0 | 3555 | emitOrAppendTwo(astralChar, returnState); |
michael@0 | 3556 | } else { |
michael@0 | 3557 | errNcrOutOfRange(); |
michael@0 | 3558 | emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState); |
michael@0 | 3559 | } |
michael@0 | 3560 | } |
michael@0 | 3561 | |
michael@0 | 3562 | void |
michael@0 | 3563 | nsHtml5Tokenizer::eof() |
michael@0 | 3564 | { |
michael@0 | 3565 | int32_t state = stateSave; |
michael@0 | 3566 | int32_t returnState = returnStateSave; |
michael@0 | 3567 | eofloop: for (; ; ) { |
michael@0 | 3568 | switch(state) { |
michael@0 | 3569 | case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN: |
michael@0 | 3570 | case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: { |
michael@0 | 3571 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 3572 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3573 | } |
michael@0 | 3574 | case NS_HTML5TOKENIZER_TAG_OPEN: { |
michael@0 | 3575 | errEofAfterLt(); |
michael@0 | 3576 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 3577 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3578 | } |
michael@0 | 3579 | case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: { |
michael@0 | 3580 | tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1); |
michael@0 | 3581 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3582 | } |
michael@0 | 3583 | case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: { |
michael@0 | 3584 | tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); |
michael@0 | 3585 | emitStrBuf(); |
michael@0 | 3586 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3587 | } |
michael@0 | 3588 | case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: { |
michael@0 | 3589 | errEofAfterLt(); |
michael@0 | 3590 | tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); |
michael@0 | 3591 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3592 | } |
michael@0 | 3593 | case NS_HTML5TOKENIZER_TAG_NAME: { |
michael@0 | 3594 | errEofInTagName(); |
michael@0 | 3595 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3596 | } |
michael@0 | 3597 | case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME: |
michael@0 | 3598 | case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED: |
michael@0 | 3599 | case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: { |
michael@0 | 3600 | errEofWithoutGt(); |
michael@0 | 3601 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3602 | } |
michael@0 | 3603 | case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: { |
michael@0 | 3604 | errEofInAttributeName(); |
michael@0 | 3605 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3606 | } |
michael@0 | 3607 | case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME: |
michael@0 | 3608 | case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: { |
michael@0 | 3609 | errEofWithoutGt(); |
michael@0 | 3610 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3611 | } |
michael@0 | 3612 | case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: |
michael@0 | 3613 | case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED: |
michael@0 | 3614 | case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: { |
michael@0 | 3615 | errEofInAttributeValue(); |
michael@0 | 3616 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3617 | } |
michael@0 | 3618 | case NS_HTML5TOKENIZER_BOGUS_COMMENT: { |
michael@0 | 3619 | emitComment(0, 0); |
michael@0 | 3620 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3621 | } |
michael@0 | 3622 | case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: { |
michael@0 | 3623 | emitComment(0, 0); |
michael@0 | 3624 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3625 | } |
michael@0 | 3626 | case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: { |
michael@0 | 3627 | errBogusComment(); |
michael@0 | 3628 | clearLongStrBuf(); |
michael@0 | 3629 | emitComment(0, 0); |
michael@0 | 3630 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3631 | } |
michael@0 | 3632 | case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: { |
michael@0 | 3633 | errBogusComment(); |
michael@0 | 3634 | emitComment(0, 0); |
michael@0 | 3635 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3636 | } |
michael@0 | 3637 | case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: { |
michael@0 | 3638 | if (index < 6) { |
michael@0 | 3639 | errBogusComment(); |
michael@0 | 3640 | emitComment(0, 0); |
michael@0 | 3641 | } else { |
michael@0 | 3642 | errEofInDoctype(); |
michael@0 | 3643 | doctypeName = nsHtml5Atoms::emptystring; |
michael@0 | 3644 | if (systemIdentifier) { |
michael@0 | 3645 | nsHtml5Portability::releaseString(systemIdentifier); |
michael@0 | 3646 | systemIdentifier = nullptr; |
michael@0 | 3647 | } |
michael@0 | 3648 | if (publicIdentifier) { |
michael@0 | 3649 | nsHtml5Portability::releaseString(publicIdentifier); |
michael@0 | 3650 | publicIdentifier = nullptr; |
michael@0 | 3651 | } |
michael@0 | 3652 | forceQuirks = true; |
michael@0 | 3653 | emitDoctypeToken(0); |
michael@0 | 3654 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3655 | } |
michael@0 | 3656 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3657 | } |
michael@0 | 3658 | case NS_HTML5TOKENIZER_COMMENT_START: |
michael@0 | 3659 | case NS_HTML5TOKENIZER_COMMENT: { |
michael@0 | 3660 | errEofInComment(); |
michael@0 | 3661 | emitComment(0, 0); |
michael@0 | 3662 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3663 | } |
michael@0 | 3664 | case NS_HTML5TOKENIZER_COMMENT_END: { |
michael@0 | 3665 | errEofInComment(); |
michael@0 | 3666 | emitComment(2, 0); |
michael@0 | 3667 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3668 | } |
michael@0 | 3669 | case NS_HTML5TOKENIZER_COMMENT_END_DASH: |
michael@0 | 3670 | case NS_HTML5TOKENIZER_COMMENT_START_DASH: { |
michael@0 | 3671 | errEofInComment(); |
michael@0 | 3672 | emitComment(1, 0); |
michael@0 | 3673 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3674 | } |
michael@0 | 3675 | case NS_HTML5TOKENIZER_COMMENT_END_BANG: { |
michael@0 | 3676 | errEofInComment(); |
michael@0 | 3677 | emitComment(3, 0); |
michael@0 | 3678 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3679 | } |
michael@0 | 3680 | case NS_HTML5TOKENIZER_DOCTYPE: |
michael@0 | 3681 | case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: { |
michael@0 | 3682 | errEofInDoctype(); |
michael@0 | 3683 | forceQuirks = true; |
michael@0 | 3684 | emitDoctypeToken(0); |
michael@0 | 3685 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3686 | } |
michael@0 | 3687 | case NS_HTML5TOKENIZER_DOCTYPE_NAME: { |
michael@0 | 3688 | errEofInDoctype(); |
michael@0 | 3689 | strBufToDoctypeName(); |
michael@0 | 3690 | forceQuirks = true; |
michael@0 | 3691 | emitDoctypeToken(0); |
michael@0 | 3692 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3693 | } |
michael@0 | 3694 | case NS_HTML5TOKENIZER_DOCTYPE_UBLIC: |
michael@0 | 3695 | case NS_HTML5TOKENIZER_DOCTYPE_YSTEM: |
michael@0 | 3696 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME: |
michael@0 | 3697 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD: |
michael@0 | 3698 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD: |
michael@0 | 3699 | case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: { |
michael@0 | 3700 | errEofInDoctype(); |
michael@0 | 3701 | forceQuirks = true; |
michael@0 | 3702 | emitDoctypeToken(0); |
michael@0 | 3703 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3704 | } |
michael@0 | 3705 | case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: |
michael@0 | 3706 | case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: { |
michael@0 | 3707 | errEofInPublicId(); |
michael@0 | 3708 | forceQuirks = true; |
michael@0 | 3709 | publicIdentifier = longStrBufToString(); |
michael@0 | 3710 | emitDoctypeToken(0); |
michael@0 | 3711 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3712 | } |
michael@0 | 3713 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER: |
michael@0 | 3714 | case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: |
michael@0 | 3715 | case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: { |
michael@0 | 3716 | errEofInDoctype(); |
michael@0 | 3717 | forceQuirks = true; |
michael@0 | 3718 | emitDoctypeToken(0); |
michael@0 | 3719 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3720 | } |
michael@0 | 3721 | case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: |
michael@0 | 3722 | case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: { |
michael@0 | 3723 | errEofInSystemId(); |
michael@0 | 3724 | forceQuirks = true; |
michael@0 | 3725 | systemIdentifier = longStrBufToString(); |
michael@0 | 3726 | emitDoctypeToken(0); |
michael@0 | 3727 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3728 | } |
michael@0 | 3729 | case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: { |
michael@0 | 3730 | errEofInDoctype(); |
michael@0 | 3731 | forceQuirks = true; |
michael@0 | 3732 | emitDoctypeToken(0); |
michael@0 | 3733 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3734 | } |
michael@0 | 3735 | case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: { |
michael@0 | 3736 | emitDoctypeToken(0); |
michael@0 | 3737 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3738 | } |
michael@0 | 3739 | case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: { |
michael@0 | 3740 | emitOrAppendStrBuf(returnState); |
michael@0 | 3741 | state = returnState; |
michael@0 | 3742 | continue; |
michael@0 | 3743 | } |
michael@0 | 3744 | case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: { |
michael@0 | 3745 | errNoNamedCharacterMatch(); |
michael@0 | 3746 | emitOrAppendStrBuf(returnState); |
michael@0 | 3747 | state = returnState; |
michael@0 | 3748 | continue; |
michael@0 | 3749 | } |
michael@0 | 3750 | case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: { |
michael@0 | 3751 | for (; ; ) { |
michael@0 | 3752 | char16_t c = '\0'; |
michael@0 | 3753 | entCol++; |
michael@0 | 3754 | for (; ; ) { |
michael@0 | 3755 | if (hi == -1) { |
michael@0 | 3756 | NS_HTML5_BREAK(hiloop); |
michael@0 | 3757 | } |
michael@0 | 3758 | if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) { |
michael@0 | 3759 | NS_HTML5_BREAK(hiloop); |
michael@0 | 3760 | } |
michael@0 | 3761 | if (entCol > nsHtml5NamedCharacters::NAMES[hi].length()) { |
michael@0 | 3762 | NS_HTML5_BREAK(outer); |
michael@0 | 3763 | } else if (c < nsHtml5NamedCharacters::NAMES[hi].charAt(entCol)) { |
michael@0 | 3764 | hi--; |
michael@0 | 3765 | } else { |
michael@0 | 3766 | NS_HTML5_BREAK(hiloop); |
michael@0 | 3767 | } |
michael@0 | 3768 | } |
michael@0 | 3769 | hiloop_end: ; |
michael@0 | 3770 | for (; ; ) { |
michael@0 | 3771 | if (hi < lo) { |
michael@0 | 3772 | NS_HTML5_BREAK(outer); |
michael@0 | 3773 | } |
michael@0 | 3774 | if (entCol == nsHtml5NamedCharacters::NAMES[lo].length()) { |
michael@0 | 3775 | candidate = lo; |
michael@0 | 3776 | strBufMark = strBufLen; |
michael@0 | 3777 | lo++; |
michael@0 | 3778 | } else if (entCol > nsHtml5NamedCharacters::NAMES[lo].length()) { |
michael@0 | 3779 | NS_HTML5_BREAK(outer); |
michael@0 | 3780 | } else if (c > nsHtml5NamedCharacters::NAMES[lo].charAt(entCol)) { |
michael@0 | 3781 | lo++; |
michael@0 | 3782 | } else { |
michael@0 | 3783 | NS_HTML5_BREAK(loloop); |
michael@0 | 3784 | } |
michael@0 | 3785 | } |
michael@0 | 3786 | loloop_end: ; |
michael@0 | 3787 | if (hi < lo) { |
michael@0 | 3788 | NS_HTML5_BREAK(outer); |
michael@0 | 3789 | } |
michael@0 | 3790 | continue; |
michael@0 | 3791 | } |
michael@0 | 3792 | outer_end: ; |
michael@0 | 3793 | if (candidate == -1) { |
michael@0 | 3794 | errNoNamedCharacterMatch(); |
michael@0 | 3795 | emitOrAppendStrBuf(returnState); |
michael@0 | 3796 | state = returnState; |
michael@0 | 3797 | NS_HTML5_CONTINUE(eofloop); |
michael@0 | 3798 | } else { |
michael@0 | 3799 | const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate]; |
michael@0 | 3800 | if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') { |
michael@0 | 3801 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 3802 | char16_t ch; |
michael@0 | 3803 | if (strBufMark == strBufLen) { |
michael@0 | 3804 | ch = '\0'; |
michael@0 | 3805 | } else { |
michael@0 | 3806 | ch = strBuf[strBufMark]; |
michael@0 | 3807 | } |
michael@0 | 3808 | if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { |
michael@0 | 3809 | errNoNamedCharacterMatch(); |
michael@0 | 3810 | appendStrBufToLongStrBuf(); |
michael@0 | 3811 | state = returnState; |
michael@0 | 3812 | NS_HTML5_CONTINUE(eofloop); |
michael@0 | 3813 | } |
michael@0 | 3814 | } |
michael@0 | 3815 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 3816 | errUnescapedAmpersandInterpretedAsCharacterReference(); |
michael@0 | 3817 | } else { |
michael@0 | 3818 | errNotSemicolonTerminated(); |
michael@0 | 3819 | } |
michael@0 | 3820 | } |
michael@0 | 3821 | const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate]; |
michael@0 | 3822 | if (!val[1]) { |
michael@0 | 3823 | emitOrAppendOne(val, returnState); |
michael@0 | 3824 | } else { |
michael@0 | 3825 | emitOrAppendTwo(val, returnState); |
michael@0 | 3826 | } |
michael@0 | 3827 | if (strBufMark < strBufLen) { |
michael@0 | 3828 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 3829 | for (int32_t i = strBufMark; i < strBufLen; i++) { |
michael@0 | 3830 | appendLongStrBuf(strBuf[i]); |
michael@0 | 3831 | } |
michael@0 | 3832 | } else { |
michael@0 | 3833 | tokenHandler->characters(strBuf, strBufMark, strBufLen - strBufMark); |
michael@0 | 3834 | } |
michael@0 | 3835 | } |
michael@0 | 3836 | state = returnState; |
michael@0 | 3837 | NS_HTML5_CONTINUE(eofloop); |
michael@0 | 3838 | } |
michael@0 | 3839 | } |
michael@0 | 3840 | case NS_HTML5TOKENIZER_CONSUME_NCR: |
michael@0 | 3841 | case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP: |
michael@0 | 3842 | case NS_HTML5TOKENIZER_HEX_NCR_LOOP: { |
michael@0 | 3843 | if (!seenDigits) { |
michael@0 | 3844 | errNoDigitsInNCR(); |
michael@0 | 3845 | emitOrAppendStrBuf(returnState); |
michael@0 | 3846 | state = returnState; |
michael@0 | 3847 | continue; |
michael@0 | 3848 | } else { |
michael@0 | 3849 | errCharRefLacksSemicolon(); |
michael@0 | 3850 | } |
michael@0 | 3851 | handleNcrValue(returnState); |
michael@0 | 3852 | state = returnState; |
michael@0 | 3853 | continue; |
michael@0 | 3854 | } |
michael@0 | 3855 | case NS_HTML5TOKENIZER_CDATA_RSQB: { |
michael@0 | 3856 | tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1); |
michael@0 | 3857 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3858 | } |
michael@0 | 3859 | case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: { |
michael@0 | 3860 | tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2); |
michael@0 | 3861 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3862 | } |
michael@0 | 3863 | case NS_HTML5TOKENIZER_DATA: |
michael@0 | 3864 | default: { |
michael@0 | 3865 | NS_HTML5_BREAK(eofloop); |
michael@0 | 3866 | } |
michael@0 | 3867 | } |
michael@0 | 3868 | } |
michael@0 | 3869 | eofloop_end: ; |
michael@0 | 3870 | tokenHandler->eof(); |
michael@0 | 3871 | return; |
michael@0 | 3872 | } |
michael@0 | 3873 | |
michael@0 | 3874 | void |
michael@0 | 3875 | nsHtml5Tokenizer::emitDoctypeToken(int32_t pos) |
michael@0 | 3876 | { |
michael@0 | 3877 | cstart = pos + 1; |
michael@0 | 3878 | tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks); |
michael@0 | 3879 | doctypeName = nullptr; |
michael@0 | 3880 | nsHtml5Portability::releaseString(publicIdentifier); |
michael@0 | 3881 | publicIdentifier = nullptr; |
michael@0 | 3882 | nsHtml5Portability::releaseString(systemIdentifier); |
michael@0 | 3883 | systemIdentifier = nullptr; |
michael@0 | 3884 | } |
michael@0 | 3885 | |
michael@0 | 3886 | bool |
michael@0 | 3887 | nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset) |
michael@0 | 3888 | { |
michael@0 | 3889 | if (encodingDeclarationHandler) { |
michael@0 | 3890 | return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset); |
michael@0 | 3891 | } |
michael@0 | 3892 | return false; |
michael@0 | 3893 | } |
michael@0 | 3894 | |
michael@0 | 3895 | void |
michael@0 | 3896 | nsHtml5Tokenizer::emitOrAppendTwo(const char16_t* val, int32_t returnState) |
michael@0 | 3897 | { |
michael@0 | 3898 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 3899 | appendLongStrBuf(val[0]); |
michael@0 | 3900 | appendLongStrBuf(val[1]); |
michael@0 | 3901 | } else { |
michael@0 | 3902 | tokenHandler->characters(val, 0, 2); |
michael@0 | 3903 | } |
michael@0 | 3904 | } |
michael@0 | 3905 | |
michael@0 | 3906 | void |
michael@0 | 3907 | nsHtml5Tokenizer::emitOrAppendOne(const char16_t* val, int32_t returnState) |
michael@0 | 3908 | { |
michael@0 | 3909 | if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) { |
michael@0 | 3910 | appendLongStrBuf(val[0]); |
michael@0 | 3911 | } else { |
michael@0 | 3912 | tokenHandler->characters(val, 0, 1); |
michael@0 | 3913 | } |
michael@0 | 3914 | } |
michael@0 | 3915 | |
michael@0 | 3916 | void |
michael@0 | 3917 | nsHtml5Tokenizer::end() |
michael@0 | 3918 | { |
michael@0 | 3919 | strBuf = nullptr; |
michael@0 | 3920 | longStrBuf = nullptr; |
michael@0 | 3921 | doctypeName = nullptr; |
michael@0 | 3922 | if (systemIdentifier) { |
michael@0 | 3923 | nsHtml5Portability::releaseString(systemIdentifier); |
michael@0 | 3924 | systemIdentifier = nullptr; |
michael@0 | 3925 | } |
michael@0 | 3926 | if (publicIdentifier) { |
michael@0 | 3927 | nsHtml5Portability::releaseString(publicIdentifier); |
michael@0 | 3928 | publicIdentifier = nullptr; |
michael@0 | 3929 | } |
michael@0 | 3930 | if (tagName) { |
michael@0 | 3931 | tagName->release(); |
michael@0 | 3932 | tagName = nullptr; |
michael@0 | 3933 | } |
michael@0 | 3934 | if (attributeName) { |
michael@0 | 3935 | attributeName->release(); |
michael@0 | 3936 | attributeName = nullptr; |
michael@0 | 3937 | } |
michael@0 | 3938 | tokenHandler->endTokenization(); |
michael@0 | 3939 | if (attributes) { |
michael@0 | 3940 | attributes->clear(0); |
michael@0 | 3941 | } |
michael@0 | 3942 | } |
michael@0 | 3943 | |
michael@0 | 3944 | void |
michael@0 | 3945 | nsHtml5Tokenizer::requestSuspension() |
michael@0 | 3946 | { |
michael@0 | 3947 | shouldSuspend = true; |
michael@0 | 3948 | } |
michael@0 | 3949 | |
michael@0 | 3950 | bool |
michael@0 | 3951 | nsHtml5Tokenizer::isInDataState() |
michael@0 | 3952 | { |
michael@0 | 3953 | return (stateSave == NS_HTML5TOKENIZER_DATA); |
michael@0 | 3954 | } |
michael@0 | 3955 | |
michael@0 | 3956 | void |
michael@0 | 3957 | nsHtml5Tokenizer::resetToDataState() |
michael@0 | 3958 | { |
michael@0 | 3959 | strBufLen = 0; |
michael@0 | 3960 | longStrBufLen = 0; |
michael@0 | 3961 | stateSave = NS_HTML5TOKENIZER_DATA; |
michael@0 | 3962 | lastCR = false; |
michael@0 | 3963 | index = 0; |
michael@0 | 3964 | forceQuirks = false; |
michael@0 | 3965 | additional = '\0'; |
michael@0 | 3966 | entCol = -1; |
michael@0 | 3967 | firstCharKey = -1; |
michael@0 | 3968 | lo = 0; |
michael@0 | 3969 | hi = 0; |
michael@0 | 3970 | candidate = -1; |
michael@0 | 3971 | strBufMark = 0; |
michael@0 | 3972 | prevValue = -1; |
michael@0 | 3973 | value = 0; |
michael@0 | 3974 | seenDigits = false; |
michael@0 | 3975 | endTag = false; |
michael@0 | 3976 | shouldSuspend = false; |
michael@0 | 3977 | initDoctypeFields(); |
michael@0 | 3978 | if (tagName) { |
michael@0 | 3979 | tagName->release(); |
michael@0 | 3980 | tagName = nullptr; |
michael@0 | 3981 | } |
michael@0 | 3982 | if (attributeName) { |
michael@0 | 3983 | attributeName->release(); |
michael@0 | 3984 | attributeName = nullptr; |
michael@0 | 3985 | } |
michael@0 | 3986 | if (newAttributesEachTime) { |
michael@0 | 3987 | if (attributes) { |
michael@0 | 3988 | delete attributes; |
michael@0 | 3989 | attributes = nullptr; |
michael@0 | 3990 | } |
michael@0 | 3991 | } |
michael@0 | 3992 | } |
michael@0 | 3993 | |
michael@0 | 3994 | void |
michael@0 | 3995 | nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other) |
michael@0 | 3996 | { |
michael@0 | 3997 | strBufLen = other->strBufLen; |
michael@0 | 3998 | if (strBufLen > strBuf.length) { |
michael@0 | 3999 | strBuf = jArray<char16_t,int32_t>::newJArray(strBufLen); |
michael@0 | 4000 | } |
michael@0 | 4001 | nsHtml5ArrayCopy::arraycopy(other->strBuf, strBuf, strBufLen); |
michael@0 | 4002 | longStrBufLen = other->longStrBufLen; |
michael@0 | 4003 | if (longStrBufLen > longStrBuf.length) { |
michael@0 | 4004 | longStrBuf = jArray<char16_t,int32_t>::newJArray(longStrBufLen); |
michael@0 | 4005 | } |
michael@0 | 4006 | nsHtml5ArrayCopy::arraycopy(other->longStrBuf, longStrBuf, longStrBufLen); |
michael@0 | 4007 | stateSave = other->stateSave; |
michael@0 | 4008 | returnStateSave = other->returnStateSave; |
michael@0 | 4009 | endTagExpectation = other->endTagExpectation; |
michael@0 | 4010 | endTagExpectationAsArray = other->endTagExpectationAsArray; |
michael@0 | 4011 | lastCR = other->lastCR; |
michael@0 | 4012 | index = other->index; |
michael@0 | 4013 | forceQuirks = other->forceQuirks; |
michael@0 | 4014 | additional = other->additional; |
michael@0 | 4015 | entCol = other->entCol; |
michael@0 | 4016 | firstCharKey = other->firstCharKey; |
michael@0 | 4017 | lo = other->lo; |
michael@0 | 4018 | hi = other->hi; |
michael@0 | 4019 | candidate = other->candidate; |
michael@0 | 4020 | strBufMark = other->strBufMark; |
michael@0 | 4021 | prevValue = other->prevValue; |
michael@0 | 4022 | value = other->value; |
michael@0 | 4023 | seenDigits = other->seenDigits; |
michael@0 | 4024 | endTag = other->endTag; |
michael@0 | 4025 | shouldSuspend = false; |
michael@0 | 4026 | if (!other->doctypeName) { |
michael@0 | 4027 | doctypeName = nullptr; |
michael@0 | 4028 | } else { |
michael@0 | 4029 | doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner); |
michael@0 | 4030 | } |
michael@0 | 4031 | nsHtml5Portability::releaseString(systemIdentifier); |
michael@0 | 4032 | if (!other->systemIdentifier) { |
michael@0 | 4033 | systemIdentifier = nullptr; |
michael@0 | 4034 | } else { |
michael@0 | 4035 | systemIdentifier = nsHtml5Portability::newStringFromString(other->systemIdentifier); |
michael@0 | 4036 | } |
michael@0 | 4037 | nsHtml5Portability::releaseString(publicIdentifier); |
michael@0 | 4038 | if (!other->publicIdentifier) { |
michael@0 | 4039 | publicIdentifier = nullptr; |
michael@0 | 4040 | } else { |
michael@0 | 4041 | publicIdentifier = nsHtml5Portability::newStringFromString(other->publicIdentifier); |
michael@0 | 4042 | } |
michael@0 | 4043 | if (tagName) { |
michael@0 | 4044 | tagName->release(); |
michael@0 | 4045 | } |
michael@0 | 4046 | if (!other->tagName) { |
michael@0 | 4047 | tagName = nullptr; |
michael@0 | 4048 | } else { |
michael@0 | 4049 | tagName = other->tagName->cloneElementName(interner); |
michael@0 | 4050 | } |
michael@0 | 4051 | if (attributeName) { |
michael@0 | 4052 | attributeName->release(); |
michael@0 | 4053 | } |
michael@0 | 4054 | if (!other->attributeName) { |
michael@0 | 4055 | attributeName = nullptr; |
michael@0 | 4056 | } else { |
michael@0 | 4057 | attributeName = other->attributeName->cloneAttributeName(interner); |
michael@0 | 4058 | } |
michael@0 | 4059 | delete attributes; |
michael@0 | 4060 | if (!other->attributes) { |
michael@0 | 4061 | attributes = nullptr; |
michael@0 | 4062 | } else { |
michael@0 | 4063 | attributes = other->attributes->cloneAttributes(interner); |
michael@0 | 4064 | } |
michael@0 | 4065 | } |
michael@0 | 4066 | |
michael@0 | 4067 | void |
michael@0 | 4068 | nsHtml5Tokenizer::initializeWithoutStarting() |
michael@0 | 4069 | { |
michael@0 | 4070 | confident = false; |
michael@0 | 4071 | strBuf = jArray<char16_t,int32_t>::newJArray(64); |
michael@0 | 4072 | longStrBuf = jArray<char16_t,int32_t>::newJArray(1024); |
michael@0 | 4073 | line = 1; |
michael@0 | 4074 | resetToDataState(); |
michael@0 | 4075 | } |
michael@0 | 4076 | |
michael@0 | 4077 | void |
michael@0 | 4078 | nsHtml5Tokenizer::setEncodingDeclarationHandler(nsHtml5StreamParser* encodingDeclarationHandler) |
michael@0 | 4079 | { |
michael@0 | 4080 | this->encodingDeclarationHandler = encodingDeclarationHandler; |
michael@0 | 4081 | } |
michael@0 | 4082 | |
michael@0 | 4083 | |
michael@0 | 4084 | nsHtml5Tokenizer::~nsHtml5Tokenizer() |
michael@0 | 4085 | { |
michael@0 | 4086 | MOZ_COUNT_DTOR(nsHtml5Tokenizer); |
michael@0 | 4087 | delete attributes; |
michael@0 | 4088 | attributes = nullptr; |
michael@0 | 4089 | } |
michael@0 | 4090 | |
michael@0 | 4091 | void |
michael@0 | 4092 | nsHtml5Tokenizer::initializeStatics() |
michael@0 | 4093 | { |
michael@0 | 4094 | } |
michael@0 | 4095 | |
michael@0 | 4096 | void |
michael@0 | 4097 | nsHtml5Tokenizer::releaseStatics() |
michael@0 | 4098 | { |
michael@0 | 4099 | } |
michael@0 | 4100 | |
michael@0 | 4101 | |
michael@0 | 4102 | #include "nsHtml5TokenizerCppSupplement.h" |
michael@0 | 4103 |