| 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 Apple Inc. All rights reserved. | 3  * Copyright (C) 2011 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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 962         return; | 962         return; | 
| 963     } | 963     } | 
| 964     m_tree.generateImpliedEndTags(); | 964     m_tree.generateImpliedEndTags(); | 
| 965     if (!m_tree.currentStackItem()->hasLocalName(token->name())) | 965     if (!m_tree.currentStackItem()->hasLocalName(token->name())) | 
| 966         parseError(token); | 966         parseError(token); | 
| 967     m_tree.openElements()->popUntilPopped(token->name()); | 967     m_tree.openElements()->popUntilPopped(token->name()); | 
| 968     m_tree.activeFormattingElements()->clearToLastMarker(); | 968     m_tree.activeFormattingElements()->clearToLastMarker(); | 
| 969     m_templateInsertionModes.removeLast(); | 969     m_templateInsertionModes.removeLast(); | 
| 970     resetInsertionModeAppropriately(); | 970     resetInsertionModeAppropriately(); | 
| 971 } | 971 } | 
|  | 972 | 
|  | 973 bool HTMLTreeBuilder::popAllTemplatesForEndOfFile() | 
|  | 974 { | 
|  | 975     if (m_templateInsertionModes.isEmpty()) | 
|  | 976         return false; | 
|  | 977 | 
|  | 978     while (!m_templateInsertionModes.isEmpty()) { | 
|  | 979         if (m_tree.currentIsRootNode()) | 
|  | 980             return false; | 
|  | 981         if (m_tree.currentNode()->hasTagName(templateTag)) | 
|  | 982             m_templateInsertionModes.removeLast(); | 
|  | 983         m_tree.openElements()->pop(); | 
|  | 984     } | 
|  | 985 | 
|  | 986     resetInsertionModeAppropriately(); | 
|  | 987     return true; | 
|  | 988 } | 
| 972 #endif | 989 #endif | 
| 973 | 990 | 
| 974 bool HTMLTreeBuilder::processColgroupEndTagForInColumnGroup() | 991 bool HTMLTreeBuilder::processColgroupEndTagForInColumnGroup() | 
| 975 { | 992 { | 
| 976     if (m_tree.currentIsRootNode() || m_tree.currentNode()->hasTagName(templateT
      ag)) { | 993     bool ignoreFakeEndTag = m_tree.currentIsRootNode(); | 
|  | 994 #if ENABLE(TEMPLATE_ELEMENT) | 
|  | 995     ignoreFakeEndTag = ignoreFakeEndTag || m_tree.currentNode()->hasTagName(temp
      lateTag); | 
|  | 996 #endif | 
|  | 997 | 
|  | 998     if (ignoreFakeEndTag) { | 
| 977         ASSERT(isParsingFragmentOrTemplateContents()); | 999         ASSERT(isParsingFragmentOrTemplateContents()); | 
| 978         // FIXME: parse error | 1000         // FIXME: parse error | 
| 979         return false; | 1001         return false; | 
| 980     } | 1002     } | 
| 981     m_tree.openElements()->pop(); | 1003     m_tree.openElements()->pop(); | 
| 982     setInsertionMode(InTableMode); | 1004     setInsertionMode(InTableMode); | 
| 983     return true; | 1005     return true; | 
| 984 } | 1006 } | 
| 985 | 1007 | 
| 986 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
      #close-the-cell | 1008 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
      #close-the-cell | 
| (...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2494     m_tree.reconstructTheActiveFormattingElements(); | 2516     m_tree.reconstructTheActiveFormattingElements(); | 
| 2495     String characters = buffer.takeRemaining(); | 2517     String characters = buffer.takeRemaining(); | 
| 2496     m_tree.insertTextNode(characters); | 2518     m_tree.insertTextNode(characters); | 
| 2497     if (m_framesetOk && !isAllWhitespaceOrReplacementCharacters(characters)) | 2519     if (m_framesetOk && !isAllWhitespaceOrReplacementCharacters(characters)) | 
| 2498         m_framesetOk = false; | 2520         m_framesetOk = false; | 
| 2499 } | 2521 } | 
| 2500 | 2522 | 
| 2501 void HTMLTreeBuilder::processEndOfFile(AtomicHTMLToken* token) | 2523 void HTMLTreeBuilder::processEndOfFile(AtomicHTMLToken* token) | 
| 2502 { | 2524 { | 
| 2503     ASSERT(token->type() == HTMLTokenTypes::EndOfFile); | 2525     ASSERT(token->type() == HTMLTokenTypes::EndOfFile); | 
| 2504 #if ENABLE(TEMPLATE_ELEMENT) |  | 
| 2505     m_templateInsertionModes.clear(); |  | 
| 2506 #endif |  | 
| 2507     switch (insertionMode()) { | 2526     switch (insertionMode()) { | 
| 2508     case InitialMode: | 2527     case InitialMode: | 
| 2509         ASSERT(insertionMode() == InitialMode); | 2528         ASSERT(insertionMode() == InitialMode); | 
| 2510         defaultForInitial(); | 2529         defaultForInitial(); | 
| 2511         // Fall through. | 2530         // Fall through. | 
| 2512     case BeforeHTMLMode: | 2531     case BeforeHTMLMode: | 
| 2513         ASSERT(insertionMode() == BeforeHTMLMode); | 2532         ASSERT(insertionMode() == BeforeHTMLMode); | 
| 2514         defaultForBeforeHTML(); | 2533         defaultForBeforeHTML(); | 
| 2515         // Fall through. | 2534         // Fall through. | 
| 2516     case BeforeHeadMode: | 2535     case BeforeHeadMode: | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 2529     case InCellMode: | 2548     case InCellMode: | 
| 2530     case InCaptionMode: | 2549     case InCaptionMode: | 
| 2531     case InRowMode: | 2550     case InRowMode: | 
| 2532 #if ENABLE(TEMPLATE_ELEMENT) | 2551 #if ENABLE(TEMPLATE_ELEMENT) | 
| 2533         ASSERT(insertionMode() == InBodyMode || insertionMode() == InCellMode ||
       insertionMode() == InCaptionMode || insertionMode() == InRowMode || insertionMo
      de() == TemplateContentsMode); | 2552         ASSERT(insertionMode() == InBodyMode || insertionMode() == InCellMode ||
       insertionMode() == InCaptionMode || insertionMode() == InRowMode || insertionMo
      de() == TemplateContentsMode); | 
| 2534 #else | 2553 #else | 
| 2535         ASSERT(insertionMode() != TemplateContentsMode); | 2554         ASSERT(insertionMode() != TemplateContentsMode); | 
| 2536         ASSERT(insertionMode() == InBodyMode || insertionMode() == InCellMode ||
       insertionMode() == InCaptionMode || insertionMode() == InRowMode); | 2555         ASSERT(insertionMode() == InBodyMode || insertionMode() == InCellMode ||
       insertionMode() == InCaptionMode || insertionMode() == InRowMode); | 
| 2537 #endif | 2556 #endif | 
| 2538         notImplemented(); // Emit parse error based on what elements are still o
      pen. | 2557         notImplemented(); // Emit parse error based on what elements are still o
      pen. | 
|  | 2558 #if ENABLE(TEMPLATE_ELEMENT) | 
|  | 2559         if (popAllTemplatesForEndOfFile()) { | 
|  | 2560             processEndOfFile(token); | 
|  | 2561             return; | 
|  | 2562         } | 
|  | 2563 #endif | 
| 2539         break; | 2564         break; | 
| 2540     case AfterBodyMode: | 2565     case AfterBodyMode: | 
| 2541     case AfterAfterBodyMode: | 2566     case AfterAfterBodyMode: | 
| 2542         ASSERT(insertionMode() == AfterBodyMode || insertionMode() == AfterAfter
      BodyMode); | 2567         ASSERT(insertionMode() == AfterBodyMode || insertionMode() == AfterAfter
      BodyMode); | 
| 2543         break; | 2568         break; | 
| 2544     case InHeadNoscriptMode: | 2569     case InHeadNoscriptMode: | 
| 2545         ASSERT(insertionMode() == InHeadNoscriptMode); | 2570         ASSERT(insertionMode() == InHeadNoscriptMode); | 
| 2546         defaultForInHeadNoscript(); | 2571         defaultForInHeadNoscript(); | 
| 2547         processEndOfFile(token); | 2572         processEndOfFile(token); | 
| 2548         return; | 2573         return; | 
| 2549     case AfterFramesetMode: | 2574     case AfterFramesetMode: | 
| 2550     case AfterAfterFramesetMode: | 2575     case AfterAfterFramesetMode: | 
| 2551         ASSERT(insertionMode() == AfterFramesetMode || insertionMode() == AfterA
      fterFramesetMode); | 2576         ASSERT(insertionMode() == AfterFramesetMode || insertionMode() == AfterA
      fterFramesetMode); | 
| 2552         break; | 2577         break; | 
| 2553     case InFramesetMode: |  | 
| 2554     case InTableMode: |  | 
| 2555     case InTableBodyMode: |  | 
| 2556     case InSelectInTableMode: |  | 
| 2557     case InSelectMode: |  | 
| 2558         ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInT
      ableMode || insertionMode() == InTableMode || insertionMode() == InFramesetMode 
      || insertionMode() == InTableBodyMode); |  | 
| 2559         if (m_tree.currentNode() != m_tree.openElements()->rootNode()) |  | 
| 2560             parseError(token); |  | 
| 2561         break; |  | 
| 2562     case InColumnGroupMode: | 2578     case InColumnGroupMode: | 
| 2563         if (m_tree.currentIsRootNode()) { | 2579         if (m_tree.currentIsRootNode()) { | 
| 2564             ASSERT(isParsingFragment()); | 2580             ASSERT(isParsingFragment()); | 
| 2565             return; // FIXME: Should we break here instead of returning? | 2581             return; // FIXME: Should we break here instead of returning? | 
| 2566         } | 2582         } | 
| 2567         if (!processColgroupEndTagForInColumnGroup()) { | 2583 #if ENABLE(TEMPLATE_ELEMENT) | 
| 2568             ASSERT(isParsingFragmentOrTemplateContents()); | 2584         ASSERT(m_tree.currentNode()->hasTagName(colgroupTag) || m_tree.currentNo
      de()->hasTagName(templateTag)); | 
| 2569             return; // FIXME: Should we break here instead of returning? | 2585 #else | 
|  | 2586         ASSERT(m_tree.currentNode()->hasTagName(colgroupTag)); | 
|  | 2587 #endif | 
|  | 2588         processColgroupEndTagForInColumnGroup(); | 
|  | 2589         // Fall through | 
|  | 2590     case InFramesetMode: | 
|  | 2591     case InTableMode: | 
|  | 2592     case InTableBodyMode: | 
|  | 2593     case InSelectInTableMode: | 
|  | 2594     case InSelectMode: | 
|  | 2595         ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInT
      ableMode || insertionMode() == InTableMode || insertionMode() == InFramesetMode 
      || insertionMode() == InTableBodyMode || insertionMode() == InColumnGroupMode); | 
|  | 2596         if (m_tree.currentNode() != m_tree.openElements()->rootNode()) | 
|  | 2597             parseError(token); | 
|  | 2598 | 
|  | 2599 #if ENABLE(TEMPLATE_ELEMENT) | 
|  | 2600         if (popAllTemplatesForEndOfFile()) { | 
|  | 2601             processEndOfFile(token); | 
|  | 2602             return; | 
| 2570         } | 2603         } | 
| 2571         processEndOfFile(token); | 2604 #endif | 
| 2572         return; | 2605         break; | 
| 2573     case InTableTextMode: | 2606     case InTableTextMode: | 
| 2574         defaultForInTableText(); | 2607         defaultForInTableText(); | 
| 2575         processEndOfFile(token); | 2608         processEndOfFile(token); | 
| 2576         return; | 2609         return; | 
| 2577     case TextMode: | 2610     case TextMode: | 
| 2578         parseError(token); | 2611         parseError(token); | 
| 2579         if (m_tree.currentStackItem()->hasTagName(scriptTag)) | 2612         if (m_tree.currentStackItem()->hasTagName(scriptTag)) | 
| 2580             notImplemented(); // mark the script element as "already started". | 2613             notImplemented(); // mark the script element as "already started". | 
| 2581         m_tree.openElements()->pop(); | 2614         m_tree.openElements()->pop(); | 
| 2582         ASSERT(m_originalInsertionMode != TextMode); | 2615         ASSERT(m_originalInsertionMode != TextMode); | 
| 2583         setInsertionMode(m_originalInsertionMode); | 2616         setInsertionMode(m_originalInsertionMode); | 
| 2584         processEndOfFile(token); | 2617         processEndOfFile(token); | 
| 2585         return; | 2618         return; | 
| 2586     case TemplateContentsMode: | 2619     case TemplateContentsMode: | 
| 2587         if (m_tree.currentIsRootNode()) { | 2620 #if ENABLE(TEMPLATE_ELEMENT) | 
| 2588             ASSERT(isParsingFragment()); | 2621         parseError(token); | 
| 2589             break; | 2622         if (popAllTemplatesForEndOfFile()) { | 
|  | 2623             processEndOfFile(token); | 
|  | 2624             return; | 
| 2590         } | 2625         } | 
| 2591         parseError(token); | 2626         break; | 
| 2592         m_tree.openElements()->pop(); | 2627 #else | 
| 2593         resetInsertionModeAppropriately(); | 2628         ASSERT_NOT_REACHED(); | 
| 2594         processEndOfFile(token); | 2629 #endif | 
| 2595         return; |  | 
| 2596     } | 2630     } | 
| 2597     ASSERT(m_tree.currentNode()); | 2631     ASSERT(m_tree.currentNode()); | 
| 2598     m_tree.openElements()->popAll(); | 2632     m_tree.openElements()->popAll(); | 
| 2599 } | 2633 } | 
| 2600 | 2634 | 
| 2601 void HTMLTreeBuilder::defaultForInitial() | 2635 void HTMLTreeBuilder::defaultForInitial() | 
| 2602 { | 2636 { | 
| 2603     notImplemented(); | 2637     notImplemented(); | 
| 2604     m_tree.setDefaultCompatibilityMode(); | 2638     m_tree.setDefaultCompatibilityMode(); | 
| 2605     // FIXME: parse error | 2639     // FIXME: parse error | 
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2897     ASSERT(m_isAttached); | 2931     ASSERT(m_isAttached); | 
| 2898     // Warning, this may detach the parser. Do not do anything else after this. | 2932     // Warning, this may detach the parser. Do not do anything else after this. | 
| 2899     m_tree.finishedParsing(); | 2933     m_tree.finishedParsing(); | 
| 2900 } | 2934 } | 
| 2901 | 2935 | 
| 2902 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) | 2936 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) | 
| 2903 { | 2937 { | 
| 2904 } | 2938 } | 
| 2905 | 2939 | 
| 2906 } | 2940 } | 
| OLD | NEW | 
|---|