| 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 26 matching lines...) Expand all Loading... |
| 37 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
| 38 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
| 39 #include "core/html/HTMLDocument.h" | 39 #include "core/html/HTMLDocument.h" |
| 40 #include "core/html/HTMLFormElement.h" | 40 #include "core/html/HTMLFormElement.h" |
| 41 #include "core/html/parser/AtomicHTMLToken.h" | 41 #include "core/html/parser/AtomicHTMLToken.h" |
| 42 #include "core/html/parser/HTMLDocumentParser.h" | 42 #include "core/html/parser/HTMLDocumentParser.h" |
| 43 #include "core/html/parser/HTMLParserIdioms.h" | 43 #include "core/html/parser/HTMLParserIdioms.h" |
| 44 #include "core/html/parser/HTMLStackItem.h" | 44 #include "core/html/parser/HTMLStackItem.h" |
| 45 #include "core/html/parser/HTMLToken.h" | 45 #include "core/html/parser/HTMLToken.h" |
| 46 #include "core/html/parser/HTMLTokenizer.h" | 46 #include "core/html/parser/HTMLTokenizer.h" |
| 47 #include "platform/NotImplemented.h" | |
| 48 #include "platform/text/PlatformLocale.h" | 47 #include "platform/text/PlatformLocale.h" |
| 49 #include "wtf/text/CharacterNames.h" | 48 #include "wtf/text/CharacterNames.h" |
| 50 | 49 |
| 51 namespace blink { | 50 namespace blink { |
| 52 | 51 |
| 53 using namespace HTMLNames; | 52 using namespace HTMLNames; |
| 54 | 53 |
| 55 namespace { | 54 namespace { |
| 56 | 55 |
| 57 inline bool isHTMLSpaceOrReplacementCharacter(UChar character) | 56 inline bool isHTMLSpaceOrReplacementCharacter(UChar character) |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 } | 1456 } |
| 1458 | 1457 |
| 1459 bool HTMLTreeBuilder::processBodyEndTagForInBody(AtomicHTMLToken* token) | 1458 bool HTMLTreeBuilder::processBodyEndTagForInBody(AtomicHTMLToken* token) |
| 1460 { | 1459 { |
| 1461 ASSERT(token->type() == HTMLToken::EndTag); | 1460 ASSERT(token->type() == HTMLToken::EndTag); |
| 1462 ASSERT(token->name() == bodyTag); | 1461 ASSERT(token->name() == bodyTag); |
| 1463 if (!m_tree.openElements()->inScope(bodyTag.localName())) { | 1462 if (!m_tree.openElements()->inScope(bodyTag.localName())) { |
| 1464 parseError(token); | 1463 parseError(token); |
| 1465 return false; | 1464 return false; |
| 1466 } | 1465 } |
| 1467 notImplemented(); // Emit a more specific parse error based on stack content
s. | 1466 NOTIMPLEMENTED(); // Emit a more specific parse error based on stack content
s. |
| 1468 setInsertionMode(AfterBodyMode); | 1467 setInsertionMode(AfterBodyMode); |
| 1469 return true; | 1468 return true; |
| 1470 } | 1469 } |
| 1471 | 1470 |
| 1472 void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken* token) | 1471 void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken* token) |
| 1473 { | 1472 { |
| 1474 ASSERT(token->type() == HTMLToken::EndTag); | 1473 ASSERT(token->type() == HTMLToken::EndTag); |
| 1475 if (token->name() == menuitemTag) | 1474 if (token->name() == menuitemTag) |
| 1476 UseCounter::count(m_tree.currentNode()->document(), UseCounter::MenuItem
CloseTag); | 1475 UseCounter::count(m_tree.currentNode()->document(), UseCounter::MenuItem
CloseTag); |
| 1477 HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord()
; | 1476 HTMLElementStack::ElementRecord* record = m_tree.openElements()->topRecord()
; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1505 // 1, 2, 3 and 16 are covered by the for() loop. | 1504 // 1, 2, 3 and 16 are covered by the for() loop. |
| 1506 for (int i = 0; i < outerIterationLimit; ++i) { | 1505 for (int i = 0; i < outerIterationLimit; ++i) { |
| 1507 // 4. | 1506 // 4. |
| 1508 Element* formattingElement = m_tree.activeFormattingElements()->closestE
lementInScopeWithName(token->name()); | 1507 Element* formattingElement = m_tree.activeFormattingElements()->closestE
lementInScopeWithName(token->name()); |
| 1509 // 4.a | 1508 // 4.a |
| 1510 if (!formattingElement) | 1509 if (!formattingElement) |
| 1511 return processAnyOtherEndTagForInBody(token); | 1510 return processAnyOtherEndTagForInBody(token); |
| 1512 // 4.c | 1511 // 4.c |
| 1513 if ((m_tree.openElements()->contains(formattingElement)) && !m_tree.open
Elements()->inScope(formattingElement)) { | 1512 if ((m_tree.openElements()->contains(formattingElement)) && !m_tree.open
Elements()->inScope(formattingElement)) { |
| 1514 parseError(token); | 1513 parseError(token); |
| 1515 notImplemented(); // Check the stack of open elements for a more spe
cific parse error. | 1514 NOTIMPLEMENTED(); // Check the stack of open elements for a more spe
cific parse error. |
| 1516 return; | 1515 return; |
| 1517 } | 1516 } |
| 1518 // 4.b | 1517 // 4.b |
| 1519 HTMLElementStack::ElementRecord* formattingElementRecord = m_tree.openEl
ements()->find(formattingElement); | 1518 HTMLElementStack::ElementRecord* formattingElementRecord = m_tree.openEl
ements()->find(formattingElement); |
| 1520 if (!formattingElementRecord) { | 1519 if (!formattingElementRecord) { |
| 1521 parseError(token); | 1520 parseError(token); |
| 1522 m_tree.activeFormattingElements()->remove(formattingElement); | 1521 m_tree.activeFormattingElements()->remove(formattingElement); |
| 1523 return; | 1522 return; |
| 1524 } | 1523 } |
| 1525 // 4.d | 1524 // 4.d |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2457 // Fall through. | 2456 // Fall through. |
| 2458 case AfterHeadMode: | 2457 case AfterHeadMode: |
| 2459 ASSERT(getInsertionMode() == AfterHeadMode); | 2458 ASSERT(getInsertionMode() == AfterHeadMode); |
| 2460 defaultForAfterHead(); | 2459 defaultForAfterHead(); |
| 2461 // Fall through | 2460 // Fall through |
| 2462 case InBodyMode: | 2461 case InBodyMode: |
| 2463 case InCellMode: | 2462 case InCellMode: |
| 2464 case InCaptionMode: | 2463 case InCaptionMode: |
| 2465 case InRowMode: | 2464 case InRowMode: |
| 2466 ASSERT(getInsertionMode() == InBodyMode || getInsertionMode() == InCellM
ode || getInsertionMode() == InCaptionMode || getInsertionMode() == InRowMode ||
getInsertionMode() == TemplateContentsMode); | 2465 ASSERT(getInsertionMode() == InBodyMode || getInsertionMode() == InCellM
ode || getInsertionMode() == InCaptionMode || getInsertionMode() == InRowMode ||
getInsertionMode() == TemplateContentsMode); |
| 2467 notImplemented(); // Emit parse error based on what elements are still o
pen. | 2466 NOTIMPLEMENTED(); // Emit parse error based on what elements are still o
pen. |
| 2468 if (!m_templateInsertionModes.isEmpty() && processEndOfFileForInTemplate
Contents(token)) | 2467 if (!m_templateInsertionModes.isEmpty() && processEndOfFileForInTemplate
Contents(token)) |
| 2469 return; | 2468 return; |
| 2470 break; | 2469 break; |
| 2471 case AfterBodyMode: | 2470 case AfterBodyMode: |
| 2472 case AfterAfterBodyMode: | 2471 case AfterAfterBodyMode: |
| 2473 ASSERT(getInsertionMode() == AfterBodyMode || getInsertionMode() == Afte
rAfterBodyMode); | 2472 ASSERT(getInsertionMode() == AfterBodyMode || getInsertionMode() == Afte
rAfterBodyMode); |
| 2474 break; | 2473 break; |
| 2475 case InHeadNoscriptMode: | 2474 case InHeadNoscriptMode: |
| 2476 ASSERT(getInsertionMode() == InHeadNoscriptMode); | 2475 ASSERT(getInsertionMode() == InHeadNoscriptMode); |
| 2477 defaultForInHeadNoscript(); | 2476 defaultForInHeadNoscript(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2500 if (!m_templateInsertionModes.isEmpty() && processEndOfFileForInTemplate
Contents(token)) | 2499 if (!m_templateInsertionModes.isEmpty() && processEndOfFileForInTemplate
Contents(token)) |
| 2501 return; | 2500 return; |
| 2502 break; | 2501 break; |
| 2503 case InTableTextMode: | 2502 case InTableTextMode: |
| 2504 defaultForInTableText(); | 2503 defaultForInTableText(); |
| 2505 processEndOfFile(token); | 2504 processEndOfFile(token); |
| 2506 return; | 2505 return; |
| 2507 case TextMode: | 2506 case TextMode: |
| 2508 parseError(token); | 2507 parseError(token); |
| 2509 if (m_tree.currentStackItem()->hasTagName(scriptTag)) | 2508 if (m_tree.currentStackItem()->hasTagName(scriptTag)) |
| 2510 notImplemented(); // mark the script element as "already started". | 2509 NOTIMPLEMENTED(); // mark the script element as "already started". |
| 2511 m_tree.openElements()->pop(); | 2510 m_tree.openElements()->pop(); |
| 2512 ASSERT(m_originalInsertionMode != TextMode); | 2511 ASSERT(m_originalInsertionMode != TextMode); |
| 2513 setInsertionMode(m_originalInsertionMode); | 2512 setInsertionMode(m_originalInsertionMode); |
| 2514 processEndOfFile(token); | 2513 processEndOfFile(token); |
| 2515 return; | 2514 return; |
| 2516 case TemplateContentsMode: | 2515 case TemplateContentsMode: |
| 2517 if (processEndOfFileForInTemplateContents(token)) | 2516 if (processEndOfFileForInTemplateContents(token)) |
| 2518 return; | 2517 return; |
| 2519 break; | 2518 break; |
| 2520 } | 2519 } |
| 2521 m_tree.processEndOfFile(); | 2520 m_tree.processEndOfFile(); |
| 2522 } | 2521 } |
| 2523 | 2522 |
| 2524 void HTMLTreeBuilder::defaultForInitial() | 2523 void HTMLTreeBuilder::defaultForInitial() |
| 2525 { | 2524 { |
| 2526 notImplemented(); | 2525 NOTIMPLEMENTED(); |
| 2527 m_tree.setDefaultCompatibilityMode(); | 2526 m_tree.setDefaultCompatibilityMode(); |
| 2528 // FIXME: parse error | 2527 // FIXME: parse error |
| 2529 setInsertionMode(BeforeHTMLMode); | 2528 setInsertionMode(BeforeHTMLMode); |
| 2530 } | 2529 } |
| 2531 | 2530 |
| 2532 void HTMLTreeBuilder::defaultForBeforeHTML() | 2531 void HTMLTreeBuilder::defaultForBeforeHTML() |
| 2533 { | 2532 { |
| 2534 AtomicHTMLToken startHTML(HTMLToken::StartTag, htmlTag.localName()); | 2533 AtomicHTMLToken startHTML(HTMLToken::StartTag, htmlTag.localName()); |
| 2535 m_tree.insertHTMLHtmlStartTagBeforeHTML(&startHTML); | 2534 m_tree.insertHTMLHtmlStartTagBeforeHTML(&startHTML); |
| 2536 setInsertionMode(BeforeHeadMode); | 2535 setInsertionMode(BeforeHeadMode); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2820 ASSERT(m_isAttached); | 2819 ASSERT(m_isAttached); |
| 2821 // Warning, this may detach the parser. Do not do anything else after this. | 2820 // Warning, this may detach the parser. Do not do anything else after this. |
| 2822 m_tree.finishedParsing(); | 2821 m_tree.finishedParsing(); |
| 2823 } | 2822 } |
| 2824 | 2823 |
| 2825 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) | 2824 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) |
| 2826 { | 2825 { |
| 2827 } | 2826 } |
| 2828 | 2827 |
| 2829 } // namespace blink | 2828 } // namespace blink |
| OLD | NEW |