| 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 "bindings/core/v8/DocumentWriteEvaluator.h" | 29 #include "bindings/core/v8/DocumentWriteEvaluator.h" |
| 30 #include "core/CoreExport.h" |
| 30 #include "core/dom/ParserContentPolicy.h" | 31 #include "core/dom/ParserContentPolicy.h" |
| 31 #include "core/dom/ScriptableDocumentParser.h" | 32 #include "core/dom/ScriptableDocumentParser.h" |
| 32 #include "core/fetch/ResourceClient.h" | 33 #include "core/fetch/ResourceClient.h" |
| 33 #include "core/frame/UseCounter.h" | 34 #include "core/frame/UseCounter.h" |
| 34 #include "core/html/parser/BackgroundHTMLInputStream.h" | 35 #include "core/html/parser/BackgroundHTMLInputStream.h" |
| 35 #include "core/html/parser/CompactHTMLToken.h" | 36 #include "core/html/parser/CompactHTMLToken.h" |
| 36 #include "core/html/parser/HTMLInputStream.h" | 37 #include "core/html/parser/HTMLInputStream.h" |
| 37 #include "core/html/parser/HTMLParserOptions.h" | 38 #include "core/html/parser/HTMLParserOptions.h" |
| 38 #include "core/html/parser/HTMLPreloadScanner.h" | 39 #include "core/html/parser/HTMLPreloadScanner.h" |
| 39 #include "core/html/parser/HTMLScriptRunnerHost.h" | 40 #include "core/html/parser/HTMLScriptRunnerHost.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 class DocumentFragment; | 61 class DocumentFragment; |
| 61 class Element; | 62 class Element; |
| 62 class HTMLDocument; | 63 class HTMLDocument; |
| 63 class HTMLParserScheduler; | 64 class HTMLParserScheduler; |
| 64 class HTMLResourcePreloader; | 65 class HTMLResourcePreloader; |
| 65 class HTMLScriptRunner; | 66 class HTMLScriptRunner; |
| 66 class HTMLTreeBuilder; | 67 class HTMLTreeBuilder; |
| 67 class PumpSession; | 68 class PumpSession; |
| 68 class TokenizedChunkQueue; | 69 class TokenizedChunkQueue; |
| 69 | 70 |
| 70 class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptR
unnerHost { | 71 class CORE_EXPORT HTMLDocumentParser : public ScriptableDocumentParser, private
HTMLScriptRunnerHost { |
| 71 USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); | 72 USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); |
| 72 USING_PRE_FINALIZER(HTMLDocumentParser, dispose); | 73 USING_PRE_FINALIZER(HTMLDocumentParser, dispose); |
| 73 public: | 74 public: |
| 74 static HTMLDocumentParser* create(HTMLDocument& document, ParserSynchronizat
ionPolicy backgroundParsingPolicy) | 75 static HTMLDocumentParser* create(HTMLDocument& document, ParserSynchronizat
ionPolicy backgroundParsingPolicy) |
| 75 { | 76 { |
| 76 return new HTMLDocumentParser(document, backgroundParsingPolicy); | 77 return new HTMLDocumentParser(document, backgroundParsingPolicy); |
| 77 } | 78 } |
| 78 ~HTMLDocumentParser() override; | 79 ~HTMLDocumentParser() override; |
| 79 DECLARE_VIRTUAL_TRACE(); | 80 DECLARE_VIRTUAL_TRACE(); |
| 80 | 81 |
| 81 // TODO(alexclarke): Remove when background parser goes away. | 82 // TODO(alexclarke): Remove when background parser goes away. |
| 82 void dispose(); | 83 void dispose(); |
| 83 | 84 |
| 84 // Exposed for HTMLParserScheduler | 85 // Exposed for HTMLParserScheduler |
| 85 void resumeParsingAfterYield(); | 86 void resumeParsingAfterYield(); |
| 86 | 87 |
| 87 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement, ParserContentPolicy = AllowScriptingContent); | 88 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement, ParserContentPolicy = AllowScriptingContent); |
| 88 | 89 |
| 90 // Exposed for testing. |
| 91 HTMLScriptRunnerHost* asHTMLScriptRunnerHostForTesting() { return this; } |
| 92 |
| 89 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } | 93 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } |
| 90 | 94 |
| 91 TextPosition textPosition() const final; | 95 TextPosition textPosition() const final; |
| 92 bool isParsingAtLineNumber() const final; | 96 bool isParsingAtLineNumber() const final; |
| 93 OrdinalNumber lineNumber() const final; | 97 OrdinalNumber lineNumber() const final; |
| 94 | 98 |
| 95 void suspendScheduledTasks() final; | 99 void suspendScheduledTasks() final; |
| 96 void resumeScheduledTasks() final; | 100 void resumeScheduledTasks() final; |
| 97 | 101 |
| 98 struct TokenizedChunk { | 102 struct TokenizedChunk { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 bool m_tasksWereSuspended; | 240 bool m_tasksWereSuspended; |
| 237 unsigned m_pumpSessionNestingLevel; | 241 unsigned m_pumpSessionNestingLevel; |
| 238 unsigned m_pumpSpeculationsSessionNestingLevel; | 242 unsigned m_pumpSpeculationsSessionNestingLevel; |
| 239 bool m_isParsingAtLineNumber; | 243 bool m_isParsingAtLineNumber; |
| 240 bool m_triedLoadingLinkHeaders; | 244 bool m_triedLoadingLinkHeaders; |
| 241 }; | 245 }; |
| 242 | 246 |
| 243 } // namespace blink | 247 } // namespace blink |
| 244 | 248 |
| 245 #endif | 249 #endif |
| OLD | NEW |