| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef HTMLDocumentParser_h | 26 #ifndef HTMLDocumentParser_h |
| 27 #define HTMLDocumentParser_h | 27 #define HTMLDocumentParser_h |
| 28 | 28 |
| 29 #include "base/memory/weak_ptr.h" | 29 #include "base/memory/weak_ptr.h" |
| 30 #include "core/dom/DecodedDataDocumentParser.h" | 30 #include "core/dom/DocumentParser.h" |
| 31 #include "core/fetch/ResourceClient.h" | 31 #include "core/fetch/ResourceClient.h" |
| 32 #include "core/frame/UseCounter.h" | 32 #include "core/frame/UseCounter.h" |
| 33 #include "core/html/parser/CompactHTMLToken.h" | 33 #include "core/html/parser/CompactHTMLToken.h" |
| 34 #include "core/html/parser/HTMLInputStream.h" | 34 #include "core/html/parser/HTMLInputStream.h" |
| 35 #include "core/html/parser/HTMLParserOptions.h" | |
| 36 #include "core/html/parser/HTMLScriptRunner.h" | 35 #include "core/html/parser/HTMLScriptRunner.h" |
| 37 #include "core/html/parser/HTMLToken.h" | 36 #include "core/html/parser/HTMLToken.h" |
| 38 #include "core/html/parser/HTMLTokenizer.h" | 37 #include "core/html/parser/HTMLTokenizer.h" |
| 39 #include "core/html/parser/TextResourceDecoder.h" | 38 #include "core/html/parser/TextResourceDecoder.h" |
| 40 #include "platform/text/SegmentedString.h" | 39 #include "platform/text/SegmentedString.h" |
| 41 #include "wtf/Deque.h" | 40 #include "wtf/Deque.h" |
| 42 #include "wtf/OwnPtr.h" | 41 #include "wtf/OwnPtr.h" |
| 43 #include "wtf/WeakPtr.h" | 42 #include "wtf/WeakPtr.h" |
| 44 #include "wtf/text/TextPosition.h" | 43 #include "wtf/text/TextPosition.h" |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 48 class BackgroundHTMLParser; | 47 class BackgroundHTMLParser; |
| 49 class CompactHTMLToken; | 48 class CompactHTMLToken; |
| 50 class Document; | 49 class Document; |
| 51 class Element; | 50 class Element; |
| 52 class HTMLDocument; | 51 class HTMLDocument; |
| 53 class HTMLParserScheduler; | 52 class HTMLParserScheduler; |
| 54 class HTMLTreeBuilder; | 53 class HTMLTreeBuilder; |
| 55 class ScriptController; | 54 class ScriptController; |
| 56 class ScriptSourceCode; | 55 class ScriptSourceCode; |
| 57 | 56 |
| 58 class PumpSession; | 57 class PumpSession; |
| 59 | 58 |
| 60 class HTMLDocumentParser : public DecodedDataDocumentParser { | 59 class HTMLDocumentParser : public DocumentParser { |
| 61 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 60 WTF_MAKE_FAST_ALLOCATED; |
| 62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); | |
| 63 public: | 61 public: |
| 64 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors) | 62 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors) |
| 65 { | 63 { |
| 66 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors)
); | 64 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors)
); |
| 67 } | 65 } |
| 68 virtual ~HTMLDocumentParser(); | 66 virtual ~HTMLDocumentParser(); |
| 69 | 67 |
| 70 void parse(mojo::ScopedDataPipeConsumerHandle) override; | 68 void parse(mojo::ScopedDataPipeConsumerHandle) override; |
| 71 | 69 |
| 72 virtual void trace(Visitor*) override; | |
| 73 | |
| 74 // Exposed for HTMLParserScheduler | 70 // Exposed for HTMLParserScheduler |
| 75 void resumeParsingAfterYield(); | 71 void resumeParsingAfterYield(); |
| 76 | 72 |
| 77 TextPosition textPosition() const; | 73 TextPosition textPosition() const; |
| 78 OrdinalNumber lineNumber() const; | 74 OrdinalNumber lineNumber() const; |
| 79 | 75 |
| 80 struct ParsedChunk { | 76 struct ParsedChunk { |
| 81 OwnPtr<CompactHTMLTokenStream> tokens; | 77 OwnPtr<CompactHTMLTokenStream> tokens; |
| 82 }; | 78 }; |
| 83 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 79 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 void constructTreeFromHTMLToken(HTMLToken&); | 110 void constructTreeFromHTMLToken(HTMLToken&); |
| 115 void constructTreeFromCompactHTMLToken(const CompactHTMLToken&); | 111 void constructTreeFromCompactHTMLToken(const CompactHTMLToken&); |
| 116 | 112 |
| 117 void runScriptsForPausedTreeBuilder(); | 113 void runScriptsForPausedTreeBuilder(); |
| 118 void resumeParsingAfterScriptExecution(); | 114 void resumeParsingAfterScriptExecution(); |
| 119 | 115 |
| 120 void attemptToEnd(); | 116 void attemptToEnd(); |
| 121 void endIfDelayed(); | 117 void endIfDelayed(); |
| 122 void end(); | 118 void end(); |
| 123 | 119 |
| 124 bool shouldUseThreading() const { return m_options.useThreading; } | |
| 125 | |
| 126 bool isParsingFragment() const; | 120 bool isParsingFragment() const; |
| 127 bool isScheduledForResume() const; | 121 bool isScheduledForResume() const; |
| 128 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } | 122 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } |
| 129 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } | 123 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } |
| 130 | 124 |
| 131 HTMLParserOptions m_options; | |
| 132 | |
| 133 OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder; | 125 OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder; |
| 134 OwnPtr<HTMLParserScheduler> m_parserScheduler; | 126 OwnPtr<HTMLParserScheduler> m_parserScheduler; |
| 135 TextPosition m_textPosition; | 127 TextPosition m_textPosition; |
| 136 | 128 |
| 137 HTMLScriptRunner m_scriptRunner; | 129 HTMLScriptRunner m_scriptRunner; |
| 138 | 130 |
| 139 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; | 131 OwnPtr<ParsedChunk> m_lastChunkBeforeScript; |
| 140 Deque<OwnPtr<ParsedChunk> > m_speculations; | 132 Deque<OwnPtr<ParsedChunk> > m_speculations; |
| 141 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; | 133 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; |
| 142 base::WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 134 base::WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
| 143 | 135 |
| 144 bool m_isFragment; | 136 bool m_isFragment; |
| 145 bool m_endWasDelayed; | 137 bool m_endWasDelayed; |
| 146 bool m_haveBackgroundParser; | 138 bool m_haveBackgroundParser; |
| 147 unsigned m_pumpSessionNestingLevel; | 139 unsigned m_pumpSessionNestingLevel; |
| 148 }; | 140 }; |
| 149 | 141 |
| 150 } | 142 } |
| 151 | 143 |
| 152 #endif | 144 #endif |
| OLD | NEW |