OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * Copyright (C) 2011, 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2014 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 fragment->document(), | 243 fragment->document(), |
244 parserContentPolicy, | 244 parserContentPolicy, |
245 options) { | 245 options) { |
246 ASSERT(isMainThread()); | 246 ASSERT(isMainThread()); |
247 ASSERT(contextElement); | 247 ASSERT(contextElement); |
248 m_tree.initFragmentParsing(fragment, contextElement); | 248 m_tree.initFragmentParsing(fragment, contextElement); |
249 m_fragmentContext.init(fragment, contextElement); | 249 m_fragmentContext.init(fragment, contextElement); |
250 | 250 |
251 // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: | 251 // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: |
252 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fr
agment-case | 252 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fr
agment-case |
253 // For efficiency, we skip step 4.2 ("Let root be a new html element with no a
ttributes") | 253 // For efficiency, we skip step 4.2 ("Let root be a new html element with no |
254 // and instead use the DocumentFragment as a root node. | 254 // attributes") and instead use the DocumentFragment as a root node. |
255 m_tree.openElements()->pushRootNode(HTMLStackItem::create( | 255 m_tree.openElements()->pushRootNode(HTMLStackItem::create( |
256 fragment, HTMLStackItem::ItemForDocumentFragmentNode)); | 256 fragment, HTMLStackItem::ItemForDocumentFragmentNode)); |
257 | 257 |
258 if (isHTMLTemplateElement(*contextElement)) | 258 if (isHTMLTemplateElement(*contextElement)) |
259 m_templateInsertionModes.append(TemplateContentsMode); | 259 m_templateInsertionModes.append(TemplateContentsMode); |
260 | 260 |
261 resetInsertionModeAppropriately(); | 261 resetInsertionModeAppropriately(); |
262 } | 262 } |
263 | 263 |
264 HTMLTreeBuilder::~HTMLTreeBuilder() {} | 264 HTMLTreeBuilder::~HTMLTreeBuilder() {} |
(...skipping 14 matching lines...) Expand all Loading... |
279 | 279 |
280 DEFINE_TRACE(HTMLTreeBuilder) { | 280 DEFINE_TRACE(HTMLTreeBuilder) { |
281 visitor->trace(m_fragmentContext); | 281 visitor->trace(m_fragmentContext); |
282 visitor->trace(m_tree); | 282 visitor->trace(m_tree); |
283 visitor->trace(m_parser); | 283 visitor->trace(m_parser); |
284 visitor->trace(m_scriptToProcess); | 284 visitor->trace(m_scriptToProcess); |
285 } | 285 } |
286 | 286 |
287 void HTMLTreeBuilder::detach() { | 287 void HTMLTreeBuilder::detach() { |
288 #if ENABLE(ASSERT) | 288 #if ENABLE(ASSERT) |
289 // This call makes little sense in fragment mode, but for | 289 // This call makes little sense in fragment mode, but for consistency |
290 // consistency DocumentParser expects detach() to always be called | 290 // DocumentParser expects detach() to always be called before it's destroyed. |
291 // before it's destroyed. | |
292 m_isAttached = false; | 291 m_isAttached = false; |
293 #endif | 292 #endif |
294 // HTMLConstructionSite might be on the callstack when detach() is called | 293 // HTMLConstructionSite might be on the callstack when detach() is called |
295 // otherwise we'd just call m_tree.clear() here instead. | 294 // otherwise we'd just call m_tree.clear() here instead. |
296 m_tree.detach(); | 295 m_tree.detach(); |
297 } | 296 } |
298 | 297 |
299 Element* HTMLTreeBuilder::takeScriptToProcess( | 298 Element* HTMLTreeBuilder::takeScriptToProcess( |
300 TextPosition& scriptStartPosition) { | 299 TextPosition& scriptStartPosition) { |
301 ASSERT(m_scriptToProcess); | 300 ASSERT(m_scriptToProcess); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 m_tree.executeQueuedTasks(); | 332 m_tree.executeQueuedTasks(); |
334 // We might be detached now. | 333 // We might be detached now. |
335 } | 334 } |
336 | 335 |
337 void HTMLTreeBuilder::processToken(AtomicHTMLToken* token) { | 336 void HTMLTreeBuilder::processToken(AtomicHTMLToken* token) { |
338 if (token->type() == HTMLToken::Character) { | 337 if (token->type() == HTMLToken::Character) { |
339 processCharacter(token); | 338 processCharacter(token); |
340 return; | 339 return; |
341 } | 340 } |
342 | 341 |
343 // Any non-character token needs to cause us to flush any pending text immedia
tely. | 342 // Any non-character token needs to cause us to flush any pending text |
344 // NOTE: flush() can cause any queued tasks to execute, possibly re-entering t
he parser. | 343 // immediately. NOTE: flush() can cause any queued tasks to execute, possibly |
| 344 // re-entering the parser. |
345 m_tree.flush(FlushAlways); | 345 m_tree.flush(FlushAlways); |
346 m_shouldSkipLeadingNewline = false; | 346 m_shouldSkipLeadingNewline = false; |
347 | 347 |
348 switch (token->type()) { | 348 switch (token->type()) { |
349 case HTMLToken::Uninitialized: | 349 case HTMLToken::Uninitialized: |
350 case HTMLToken::Character: | 350 case HTMLToken::Character: |
351 ASSERT_NOT_REACHED(); | 351 ASSERT_NOT_REACHED(); |
352 break; | 352 break; |
353 case HTMLToken::DOCTYPE: | 353 case HTMLToken::DOCTYPE: |
354 processDoctypeToken(token); | 354 processDoctypeToken(token); |
(...skipping 23 matching lines...) Expand all Loading... |
378 if (m_insertionMode == InTableTextMode) { | 378 if (m_insertionMode == InTableTextMode) { |
379 defaultForInTableText(); | 379 defaultForInTableText(); |
380 processDoctypeToken(token); | 380 processDoctypeToken(token); |
381 return; | 381 return; |
382 } | 382 } |
383 parseError(token); | 383 parseError(token); |
384 } | 384 } |
385 | 385 |
386 void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, | 386 void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, |
387 const Vector<Attribute>& attributes) { | 387 const Vector<Attribute>& attributes) { |
388 // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML
tags. | 388 // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML |
| 389 // tags. |
389 AtomicHTMLToken fakeToken(HTMLToken::StartTag, tagName.localName(), | 390 AtomicHTMLToken fakeToken(HTMLToken::StartTag, tagName.localName(), |
390 attributes); | 391 attributes); |
391 processStartTag(&fakeToken); | 392 processStartTag(&fakeToken); |
392 } | 393 } |
393 | 394 |
394 void HTMLTreeBuilder::processFakeEndTag(const AtomicString& tagName) { | 395 void HTMLTreeBuilder::processFakeEndTag(const AtomicString& tagName) { |
395 AtomicHTMLToken fakeToken(HTMLToken::EndTag, tagName); | 396 AtomicHTMLToken fakeToken(HTMLToken::EndTag, tagName); |
396 processEndTag(&fakeToken); | 397 processEndTag(&fakeToken); |
397 } | 398 } |
398 | 399 |
399 void HTMLTreeBuilder::processFakeEndTag(const QualifiedName& tagName) { | 400 void HTMLTreeBuilder::processFakeEndTag(const QualifiedName& tagName) { |
400 // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML
tags. | 401 // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML |
| 402 // tags. |
401 processFakeEndTag(tagName.localName()); | 403 processFakeEndTag(tagName.localName()); |
402 } | 404 } |
403 | 405 |
404 void HTMLTreeBuilder::processFakePEndTagIfPInButtonScope() { | 406 void HTMLTreeBuilder::processFakePEndTagIfPInButtonScope() { |
405 if (!m_tree.openElements()->inButtonScope(pTag.localName())) | 407 if (!m_tree.openElements()->inButtonScope(pTag.localName())) |
406 return; | 408 return; |
407 AtomicHTMLToken endP(HTMLToken::EndTag, pTag.localName()); | 409 AtomicHTMLToken endP(HTMLToken::EndTag, pTag.localName()); |
408 processEndTag(&endP); | 410 processEndTag(&endP); |
409 } | 411 } |
410 | 412 |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 } | 1102 } |
1101 if (!processColgroupEndTagForInColumnGroup()) { | 1103 if (!processColgroupEndTagForInColumnGroup()) { |
1102 ASSERT(isParsingFragmentOrTemplateContents()); | 1104 ASSERT(isParsingFragmentOrTemplateContents()); |
1103 return; | 1105 return; |
1104 } | 1106 } |
1105 processStartTag(token); | 1107 processStartTag(token); |
1106 break; | 1108 break; |
1107 case InTableBodyMode: | 1109 case InTableBodyMode: |
1108 ASSERT(getInsertionMode() == InTableBodyMode); | 1110 ASSERT(getInsertionMode() == InTableBodyMode); |
1109 if (token->name() == trTag) { | 1111 if (token->name() == trTag) { |
1110 m_tree.openElements() | 1112 // How is there ever anything to pop? |
1111 ->popUntilTableBodyScopeMarker(); // How is there ever anything to
pop? | 1113 m_tree.openElements()->popUntilTableBodyScopeMarker(); |
1112 m_tree.insertHTMLElement(token); | 1114 m_tree.insertHTMLElement(token); |
1113 setInsertionMode(InRowMode); | 1115 setInsertionMode(InRowMode); |
1114 return; | 1116 return; |
1115 } | 1117 } |
1116 if (isTableCellContextTag(token->name())) { | 1118 if (isTableCellContextTag(token->name())) { |
1117 parseError(token); | 1119 parseError(token); |
1118 processFakeStartTag(trTag); | 1120 processFakeStartTag(trTag); |
1119 ASSERT(getInsertionMode() == InRowMode); | 1121 ASSERT(getInsertionMode() == InRowMode); |
1120 processStartTag(token); | 1122 processStartTag(token); |
1121 return; | 1123 return; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 m_tree.insertHTMLHtmlStartTagInBody(token); | 1369 m_tree.insertHTMLHtmlStartTagInBody(token); |
1368 } | 1370 } |
1369 | 1371 |
1370 bool HTMLTreeBuilder::processBodyEndTagForInBody(AtomicHTMLToken* token) { | 1372 bool HTMLTreeBuilder::processBodyEndTagForInBody(AtomicHTMLToken* token) { |
1371 ASSERT(token->type() == HTMLToken::EndTag); | 1373 ASSERT(token->type() == HTMLToken::EndTag); |
1372 ASSERT(token->name() == bodyTag); | 1374 ASSERT(token->name() == bodyTag); |
1373 if (!m_tree.openElements()->inScope(bodyTag.localName())) { | 1375 if (!m_tree.openElements()->inScope(bodyTag.localName())) { |
1374 parseError(token); | 1376 parseError(token); |
1375 return false; | 1377 return false; |
1376 } | 1378 } |
1377 DVLOG(1) | 1379 // Emit a more specific parse error based on stack contents. |
1378 << "Not implmeneted."; // Emit a more specific parse error based on stack
contents. | 1380 DVLOG(1) << "Not implmeneted."; |
1379 setInsertionMode(AfterBodyMode); | 1381 setInsertionMode(AfterBodyMode); |
1380 return true; | 1382 return true; |
1381 } | 1383 } |
1382 | 1384 |
1383 void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken* token) { | 1385 void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken* token) { |
1384 ASSERT(token->type() == HTMLToken::EndTag); | 1386 ASSERT(token->type() == HTMLToken::EndTag); |
1385 if (token->name() == menuitemTag) | 1387 if (token->name() == menuitemTag) |
1386 UseCounter::count(m_tree.currentNode()->document(), | 1388 UseCounter::count(m_tree.currentNode()->document(), |
1387 UseCounter::MenuItemCloseTag); | 1389 UseCounter::MenuItemCloseTag); |
1388 HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord(); | 1390 HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord(); |
(...skipping 29 matching lines...) Expand all Loading... |
1418 Element* formattingElement = | 1420 Element* formattingElement = |
1419 m_tree.activeFormattingElements()->closestElementInScopeWithName( | 1421 m_tree.activeFormattingElements()->closestElementInScopeWithName( |
1420 token->name()); | 1422 token->name()); |
1421 // 4.a | 1423 // 4.a |
1422 if (!formattingElement) | 1424 if (!formattingElement) |
1423 return processAnyOtherEndTagForInBody(token); | 1425 return processAnyOtherEndTagForInBody(token); |
1424 // 4.c | 1426 // 4.c |
1425 if ((m_tree.openElements()->contains(formattingElement)) && | 1427 if ((m_tree.openElements()->contains(formattingElement)) && |
1426 !m_tree.openElements()->inScope(formattingElement)) { | 1428 !m_tree.openElements()->inScope(formattingElement)) { |
1427 parseError(token); | 1429 parseError(token); |
1428 DVLOG(1) | 1430 // Check the stack of open elements for a more specific parse error. |
1429 << "Not implemented."; // Check the stack of open elements for a more
specific parse error. | 1431 DVLOG(1) << "Not implemented."; |
1430 return; | 1432 return; |
1431 } | 1433 } |
1432 // 4.b | 1434 // 4.b |
1433 HTMLElementStack::ElementRecord* formattingElementRecord = | 1435 HTMLElementStack::ElementRecord* formattingElementRecord = |
1434 m_tree.openElements()->find(formattingElement); | 1436 m_tree.openElements()->find(formattingElement); |
1435 if (!formattingElementRecord) { | 1437 if (!formattingElementRecord) { |
1436 parseError(token); | 1438 parseError(token); |
1437 m_tree.activeFormattingElements()->remove(formattingElement); | 1439 m_tree.activeFormattingElements()->remove(formattingElement); |
1438 return; | 1440 return; |
1439 } | 1441 } |
(...skipping 19 matching lines...) Expand all Loading... |
1459 m_tree.activeFormattingElements()->bookmarkFor(formattingElement); | 1461 m_tree.activeFormattingElements()->bookmarkFor(formattingElement); |
1460 // 9. | 1462 // 9. |
1461 HTMLElementStack::ElementRecord* node = furthestBlock; | 1463 HTMLElementStack::ElementRecord* node = furthestBlock; |
1462 HTMLElementStack::ElementRecord* nextNode = node->next(); | 1464 HTMLElementStack::ElementRecord* nextNode = node->next(); |
1463 HTMLElementStack::ElementRecord* lastNode = furthestBlock; | 1465 HTMLElementStack::ElementRecord* lastNode = furthestBlock; |
1464 // 9.1, 9.2, 9.3 and 9.11 are covered by the for() loop. | 1466 // 9.1, 9.2, 9.3 and 9.11 are covered by the for() loop. |
1465 for (int i = 0; i < innerIterationLimit; ++i) { | 1467 for (int i = 0; i < innerIterationLimit; ++i) { |
1466 // 9.4 | 1468 // 9.4 |
1467 node = nextNode; | 1469 node = nextNode; |
1468 ASSERT(node); | 1470 ASSERT(node); |
1469 nextNode = | 1471 // Save node->next() for the next iteration in case node is deleted in |
1470 node->next(); // Save node->next() for the next iteration in case nod
e is deleted in 9.5. | 1472 // 9.5. |
| 1473 nextNode = node->next(); |
1471 // 9.5 | 1474 // 9.5 |
1472 if (!m_tree.activeFormattingElements()->contains(node->element())) { | 1475 if (!m_tree.activeFormattingElements()->contains(node->element())) { |
1473 m_tree.openElements()->remove(node->element()); | 1476 m_tree.openElements()->remove(node->element()); |
1474 node = 0; | 1477 node = 0; |
1475 continue; | 1478 continue; |
1476 } | 1479 } |
1477 // 9.6 | 1480 // 9.6 |
1478 if (node == formattingElementRecord) | 1481 if (node == formattingElementRecord) |
1479 break; | 1482 break; |
1480 // 9.7 | 1483 // 9.7 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 if (token->name() != headTag && token->name() != bodyTag && | 1885 if (token->name() != headTag && token->name() != bodyTag && |
1883 token->name() != htmlTag && token->name() != brTag) { | 1886 token->name() != htmlTag && token->name() != brTag) { |
1884 parseError(token); | 1887 parseError(token); |
1885 return; | 1888 return; |
1886 } | 1889 } |
1887 defaultForBeforeHead(); | 1890 defaultForBeforeHead(); |
1888 // Fall through. | 1891 // Fall through. |
1889 case InHeadMode: | 1892 case InHeadMode: |
1890 ASSERT(getInsertionMode() == InHeadMode); | 1893 ASSERT(getInsertionMode() == InHeadMode); |
1891 // FIXME: This case should be broken out into processEndTagForInHead, | 1894 // FIXME: This case should be broken out into processEndTagForInHead, |
1892 // because other end tag cases now refer to it ("process the token for usi
ng the rules of the "in head" insertion mode"). | 1895 // because other end tag cases now refer to it ("process the token for |
1893 // but because the logic falls through to AfterHeadMode, that gets a littl
e messy. | 1896 // using the rules of the "in head" insertion mode"). but because the |
| 1897 // logic falls through to AfterHeadMode, that gets a little messy. |
1894 if (token->name() == templateTag) { | 1898 if (token->name() == templateTag) { |
1895 processTemplateEndTag(token); | 1899 processTemplateEndTag(token); |
1896 return; | 1900 return; |
1897 } | 1901 } |
1898 if (token->name() == headTag) { | 1902 if (token->name() == headTag) { |
1899 m_tree.openElements()->popHTMLHeadElement(); | 1903 m_tree.openElements()->popHTMLHeadElement(); |
1900 setInsertionMode(AfterHeadMode); | 1904 setInsertionMode(AfterHeadMode); |
1901 return; | 1905 return; |
1902 } | 1906 } |
1903 if (token->name() != bodyTag && token->name() != htmlTag && | 1907 if (token->name() != bodyTag && token->name() != htmlTag && |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 if (token->name() != brTag) { | 2014 if (token->name() != brTag) { |
2011 parseError(token); | 2015 parseError(token); |
2012 return; | 2016 return; |
2013 } | 2017 } |
2014 defaultForInHeadNoscript(); | 2018 defaultForInHeadNoscript(); |
2015 processToken(token); | 2019 processToken(token); |
2016 break; | 2020 break; |
2017 case TextMode: | 2021 case TextMode: |
2018 if (token->name() == scriptTag && | 2022 if (token->name() == scriptTag && |
2019 m_tree.currentStackItem()->hasTagName(scriptTag)) { | 2023 m_tree.currentStackItem()->hasTagName(scriptTag)) { |
2020 // Pause ourselves so that parsing stops until the script can be process
ed by the caller. | 2024 // Pause ourselves so that parsing stops until the script can be |
| 2025 // processed by the caller. |
2021 if (scriptingContentIsAllowed(m_tree.getParserContentPolicy())) | 2026 if (scriptingContentIsAllowed(m_tree.getParserContentPolicy())) |
2022 m_scriptToProcess = m_tree.currentElement(); | 2027 m_scriptToProcess = m_tree.currentElement(); |
2023 m_tree.openElements()->pop(); | 2028 m_tree.openElements()->pop(); |
2024 setInsertionMode(m_originalInsertionMode); | 2029 setInsertionMode(m_originalInsertionMode); |
2025 | 2030 |
2026 if (m_parser->tokenizer()) { | 2031 if (m_parser->tokenizer()) { |
2027 // We must set the tokenizer's state to | 2032 // We must set the tokenizer's state to DataState explicitly if the |
2028 // DataState explicitly if the tokenizer didn't have a chance to. | 2033 // tokenizer didn't have a chance to. |
2029 m_parser->tokenizer()->setState(HTMLTokenizer::DataState); | 2034 m_parser->tokenizer()->setState(HTMLTokenizer::DataState); |
2030 } | 2035 } |
2031 return; | 2036 return; |
2032 } | 2037 } |
2033 m_tree.openElements()->pop(); | 2038 m_tree.openElements()->pop(); |
2034 setInsertionMode(m_originalInsertionMode); | 2039 setInsertionMode(m_originalInsertionMode); |
2035 break; | 2040 break; |
2036 case InFramesetMode: | 2041 case InFramesetMode: |
2037 ASSERT(getInsertionMode() == InFramesetMode); | 2042 ASSERT(getInsertionMode() == InFramesetMode); |
2038 if (token->name() == framesetTag) { | 2043 if (token->name() == framesetTag) { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 // Fall through | 2376 // Fall through |
2372 case InBodyMode: | 2377 case InBodyMode: |
2373 case InCellMode: | 2378 case InCellMode: |
2374 case InCaptionMode: | 2379 case InCaptionMode: |
2375 case InRowMode: | 2380 case InRowMode: |
2376 ASSERT(getInsertionMode() == InBodyMode || | 2381 ASSERT(getInsertionMode() == InBodyMode || |
2377 getInsertionMode() == InCellMode || | 2382 getInsertionMode() == InCellMode || |
2378 getInsertionMode() == InCaptionMode || | 2383 getInsertionMode() == InCaptionMode || |
2379 getInsertionMode() == InRowMode || | 2384 getInsertionMode() == InRowMode || |
2380 getInsertionMode() == TemplateContentsMode); | 2385 getInsertionMode() == TemplateContentsMode); |
2381 DVLOG(1) | 2386 // Emit parse error based on what elements are still open. |
2382 << "Not implemented."; // Emit parse error based on what elements are
still open. | 2387 DVLOG(1) << "Not implemented."; |
2383 if (!m_templateInsertionModes.isEmpty() && | 2388 if (!m_templateInsertionModes.isEmpty() && |
2384 processEndOfFileForInTemplateContents(token)) | 2389 processEndOfFileForInTemplateContents(token)) |
2385 return; | 2390 return; |
2386 break; | 2391 break; |
2387 case AfterBodyMode: | 2392 case AfterBodyMode: |
2388 case AfterAfterBodyMode: | 2393 case AfterAfterBodyMode: |
2389 ASSERT(getInsertionMode() == AfterBodyMode || | 2394 ASSERT(getInsertionMode() == AfterBodyMode || |
2390 getInsertionMode() == AfterAfterBodyMode); | 2395 getInsertionMode() == AfterAfterBodyMode); |
2391 break; | 2396 break; |
2392 case InHeadNoscriptMode: | 2397 case InHeadNoscriptMode: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 if (!m_templateInsertionModes.isEmpty() && | 2429 if (!m_templateInsertionModes.isEmpty() && |
2425 processEndOfFileForInTemplateContents(token)) | 2430 processEndOfFileForInTemplateContents(token)) |
2426 return; | 2431 return; |
2427 break; | 2432 break; |
2428 case InTableTextMode: | 2433 case InTableTextMode: |
2429 defaultForInTableText(); | 2434 defaultForInTableText(); |
2430 processEndOfFile(token); | 2435 processEndOfFile(token); |
2431 return; | 2436 return; |
2432 case TextMode: | 2437 case TextMode: |
2433 parseError(token); | 2438 parseError(token); |
2434 if (m_tree.currentStackItem()->hasTagName(scriptTag)) | 2439 if (m_tree.currentStackItem()->hasTagName(scriptTag)) { |
2435 DVLOG(1) | 2440 // Mark the script element as "already started". |
2436 << "Not implemented."; // mark the script element as "already start
ed". | 2441 DVLOG(1) << "Not implemented."; |
| 2442 } |
2437 m_tree.openElements()->pop(); | 2443 m_tree.openElements()->pop(); |
2438 ASSERT(m_originalInsertionMode != TextMode); | 2444 ASSERT(m_originalInsertionMode != TextMode); |
2439 setInsertionMode(m_originalInsertionMode); | 2445 setInsertionMode(m_originalInsertionMode); |
2440 processEndOfFile(token); | 2446 processEndOfFile(token); |
2441 return; | 2447 return; |
2442 case TemplateContentsMode: | 2448 case TemplateContentsMode: |
2443 if (processEndOfFileForInTemplateContents(token)) | 2449 if (processEndOfFileForInTemplateContents(token)) |
2444 return; | 2450 return; |
2445 break; | 2451 break; |
2446 } | 2452 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 bool HTMLTreeBuilder::processStartTagForInHead(AtomicHTMLToken* token) { | 2506 bool HTMLTreeBuilder::processStartTagForInHead(AtomicHTMLToken* token) { |
2501 ASSERT(token->type() == HTMLToken::StartTag); | 2507 ASSERT(token->type() == HTMLToken::StartTag); |
2502 if (token->name() == htmlTag) { | 2508 if (token->name() == htmlTag) { |
2503 processHtmlStartTagForInBody(token); | 2509 processHtmlStartTagForInBody(token); |
2504 return true; | 2510 return true; |
2505 } | 2511 } |
2506 if (token->name() == baseTag || token->name() == basefontTag || | 2512 if (token->name() == baseTag || token->name() == basefontTag || |
2507 token->name() == bgsoundTag || token->name() == commandTag || | 2513 token->name() == bgsoundTag || token->name() == commandTag || |
2508 token->name() == linkTag || token->name() == metaTag) { | 2514 token->name() == linkTag || token->name() == metaTag) { |
2509 m_tree.insertSelfClosingHTMLElementDestroyingToken(token); | 2515 m_tree.insertSelfClosingHTMLElementDestroyingToken(token); |
2510 // Note: The custom processing for the <meta> tag is done in HTMLMetaElement
::process(). | 2516 // Note: The custom processing for the <meta> tag is done in |
| 2517 // HTMLMetaElement::process(). |
2511 return true; | 2518 return true; |
2512 } | 2519 } |
2513 if (token->name() == titleTag) { | 2520 if (token->name() == titleTag) { |
2514 processGenericRCDATAStartTag(token); | 2521 processGenericRCDATAStartTag(token); |
2515 return true; | 2522 return true; |
2516 } | 2523 } |
2517 if (token->name() == noscriptTag) { | 2524 if (token->name() == noscriptTag) { |
2518 if (m_options.scriptEnabled) { | 2525 if (m_options.scriptEnabled) { |
2519 processGenericRawTextStartTag(token); | 2526 processGenericRawTextStartTag(token); |
2520 return true; | 2527 return true; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 adjustSVGTagNameCase(token); | 2677 adjustSVGTagNameCase(token); |
2671 | 2678 |
2672 if (token->name() == SVGNames::scriptTag && | 2679 if (token->name() == SVGNames::scriptTag && |
2673 m_tree.currentStackItem()->hasTagName(SVGNames::scriptTag)) { | 2680 m_tree.currentStackItem()->hasTagName(SVGNames::scriptTag)) { |
2674 if (scriptingContentIsAllowed(m_tree.getParserContentPolicy())) | 2681 if (scriptingContentIsAllowed(m_tree.getParserContentPolicy())) |
2675 m_scriptToProcess = m_tree.currentElement(); | 2682 m_scriptToProcess = m_tree.currentElement(); |
2676 m_tree.openElements()->pop(); | 2683 m_tree.openElements()->pop(); |
2677 return; | 2684 return; |
2678 } | 2685 } |
2679 if (!m_tree.currentStackItem()->isInHTMLNamespace()) { | 2686 if (!m_tree.currentStackItem()->isInHTMLNamespace()) { |
2680 // FIXME: This code just wants an Element* iterator, instead of an Eleme
ntRecord* | 2687 // FIXME: This code just wants an Element* iterator, instead of an |
| 2688 // ElementRecord* |
2681 HTMLElementStack::ElementRecord* nodeRecord = | 2689 HTMLElementStack::ElementRecord* nodeRecord = |
2682 m_tree.openElements()->topRecord(); | 2690 m_tree.openElements()->topRecord(); |
2683 if (!nodeRecord->stackItem()->hasLocalName(token->name())) | 2691 if (!nodeRecord->stackItem()->hasLocalName(token->name())) |
2684 parseError(token); | 2692 parseError(token); |
2685 while (1) { | 2693 while (1) { |
2686 if (nodeRecord->stackItem()->hasLocalName(token->name())) { | 2694 if (nodeRecord->stackItem()->hasLocalName(token->name())) { |
2687 m_tree.openElements()->popUntilPopped(nodeRecord->element()); | 2695 m_tree.openElements()->popUntilPopped(nodeRecord->element()); |
2688 return; | 2696 return; |
2689 } | 2697 } |
2690 nodeRecord = nodeRecord->next(); | 2698 nodeRecord = nodeRecord->next(); |
2691 | 2699 |
2692 if (nodeRecord->stackItem()->isInHTMLNamespace()) | 2700 if (nodeRecord->stackItem()->isInHTMLNamespace()) |
2693 break; | 2701 break; |
2694 } | 2702 } |
2695 } | 2703 } |
2696 // Otherwise, process the token according to the rules given in the sectio
n corresponding to the current insertion mode in HTML content. | 2704 // Otherwise, process the token according to the rules given in the |
| 2705 // section corresponding to the current insertion mode in HTML content. |
2697 processEndTag(token); | 2706 processEndTag(token); |
2698 break; | 2707 break; |
2699 } | 2708 } |
2700 case HTMLToken::Comment: | 2709 case HTMLToken::Comment: |
2701 m_tree.insertComment(token); | 2710 m_tree.insertComment(token); |
2702 break; | 2711 break; |
2703 case HTMLToken::Character: | 2712 case HTMLToken::Character: |
2704 case HTMLToken::EndOfFile: | 2713 case HTMLToken::EndOfFile: |
2705 ASSERT_NOT_REACHED(); | 2714 ASSERT_NOT_REACHED(); |
2706 break; | 2715 break; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2748 DEFINE_STRINGIFY(AfterFramesetMode) | 2757 DEFINE_STRINGIFY(AfterFramesetMode) |
2749 DEFINE_STRINGIFY(AfterAfterBodyMode) | 2758 DEFINE_STRINGIFY(AfterAfterBodyMode) |
2750 DEFINE_STRINGIFY(AfterAfterFramesetMode) | 2759 DEFINE_STRINGIFY(AfterAfterFramesetMode) |
2751 #undef DEFINE_STRINGIFY | 2760 #undef DEFINE_STRINGIFY |
2752 } | 2761 } |
2753 return "<unknown>"; | 2762 return "<unknown>"; |
2754 } | 2763 } |
2755 #endif | 2764 #endif |
2756 | 2765 |
2757 } // namespace blink | 2766 } // namespace blink |
OLD | NEW |