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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 class PumpSession; | 67 class PumpSession; |
68 | 68 |
69 class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptR
unnerHost { | 69 class HTMLDocumentParser : public ScriptableDocumentParser, private HTMLScriptR
unnerHost { |
70 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLDocumentParser); | 70 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLDocumentParser); |
71 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); | 71 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLDocumentParser); |
72 public: | 72 public: |
73 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors, ParserSynchronizationPolicy backgroundParsingPolicy) | 73 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(HTMLDocument& docum
ent, bool reportErrors, ParserSynchronizationPolicy backgroundParsingPolicy) |
74 { | 74 { |
75 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors,
backgroundParsingPolicy)); | 75 return adoptRefWillBeNoop(new HTMLDocumentParser(document, reportErrors,
backgroundParsingPolicy)); |
76 } | 76 } |
77 virtual ~HTMLDocumentParser(); | 77 ~HTMLDocumentParser() override; |
78 DECLARE_VIRTUAL_TRACE(); | 78 DECLARE_VIRTUAL_TRACE(); |
79 | 79 |
80 // Exposed for HTMLParserScheduler | 80 // Exposed for HTMLParserScheduler |
81 void resumeParsingAfterYield(); | 81 void resumeParsingAfterYield(); |
82 | 82 |
83 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement, ParserContentPolicy = AllowScriptingContent); | 83 static void parseDocumentFragment(const String&, DocumentFragment*, Element*
contextElement, ParserContentPolicy = AllowScriptingContent); |
84 | 84 |
85 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } | 85 HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } |
86 | 86 |
87 virtual TextPosition textPosition() const override final; | 87 TextPosition textPosition() const final; |
88 virtual bool isParsingAtLineNumber() const override final; | 88 bool isParsingAtLineNumber() const final; |
89 virtual OrdinalNumber lineNumber() const override final; | 89 OrdinalNumber lineNumber() const final; |
90 | 90 |
91 virtual void suspendScheduledTasks() override final; | 91 void suspendScheduledTasks() final; |
92 virtual void resumeScheduledTasks() override final; | 92 void resumeScheduledTasks() final; |
93 | 93 |
94 struct ParsedChunk { | 94 struct ParsedChunk { |
95 OwnPtr<CompactHTMLTokenStream> tokens; | 95 OwnPtr<CompactHTMLTokenStream> tokens; |
96 PreloadRequestStream preloads; | 96 PreloadRequestStream preloads; |
97 XSSInfoStream xssInfos; | 97 XSSInfoStream xssInfos; |
98 HTMLTokenizer::State tokenizerState; | 98 HTMLTokenizer::State tokenizerState; |
99 HTMLTreeBuilderSimulator::State treeBuilderState; | 99 HTMLTreeBuilderSimulator::State treeBuilderState; |
100 HTMLInputCheckpoint inputCheckpoint; | 100 HTMLInputCheckpoint inputCheckpoint; |
101 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 101 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
102 bool startingScript; | 102 bool startingScript; |
103 }; | 103 }; |
104 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 104 void didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
105 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&)
; | 105 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&)
; |
106 | 106 |
107 virtual void appendBytes(const char* bytes, size_t length) override; | 107 void appendBytes(const char* bytes, size_t length) override; |
108 virtual void flush() override final; | 108 void flush() final; |
109 virtual void setDecoder(PassOwnPtr<TextResourceDecoder>) override final; | 109 void setDecoder(PassOwnPtr<TextResourceDecoder>) final; |
110 | 110 |
111 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi
on()); } | 111 UseCounter* useCounter() { return UseCounter::getFrom(contextForParsingSessi
on()); } |
112 | 112 |
113 protected: | 113 protected: |
114 virtual void insert(const SegmentedString&) override final; | 114 void insert(const SegmentedString&) final; |
115 virtual void append(const String&) override; | 115 void append(const String&) override; |
116 virtual void finish() override final; | 116 void finish() final; |
117 | 117 |
118 HTMLDocumentParser(HTMLDocument&, bool reportErrors, ParserSynchronizationPo
licy); | 118 HTMLDocumentParser(HTMLDocument&, bool reportErrors, ParserSynchronizationPo
licy); |
119 HTMLDocumentParser(DocumentFragment*, Element* contextElement, ParserContent
Policy); | 119 HTMLDocumentParser(DocumentFragment*, Element* contextElement, ParserContent
Policy); |
120 | 120 |
121 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } | 121 HTMLTreeBuilder* treeBuilder() const { return m_treeBuilder.get(); } |
122 | 122 |
123 void forcePlaintextForTextDocument(); | 123 void forcePlaintextForTextDocument(); |
124 | 124 |
125 private: | 125 private: |
126 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(DocumentFragment* f
ragment, Element* contextElement, ParserContentPolicy parserContentPolicy) | 126 static PassRefPtrWillBeRawPtr<HTMLDocumentParser> create(DocumentFragment* f
ragment, Element* contextElement, ParserContentPolicy parserContentPolicy) |
127 { | 127 { |
128 return adoptRefWillBeNoop(new HTMLDocumentParser(fragment, contextElemen
t, parserContentPolicy)); | 128 return adoptRefWillBeNoop(new HTMLDocumentParser(fragment, contextElemen
t, parserContentPolicy)); |
129 } | 129 } |
130 | 130 |
131 // DocumentParser | 131 // DocumentParser |
132 virtual void detach() override final; | 132 void detach() final; |
133 virtual bool hasInsertionPoint() override final; | 133 bool hasInsertionPoint() final; |
134 virtual bool processingData() const override final; | 134 bool processingData() const final; |
135 virtual void prepareToStopParsing() override final; | 135 void prepareToStopParsing() final; |
136 virtual void stopParsing() override final; | 136 void stopParsing() final; |
137 virtual bool isWaitingForScripts() const override final; | 137 bool isWaitingForScripts() const final; |
138 virtual bool isExecutingScript() const override final; | 138 bool isExecutingScript() const final; |
139 virtual void executeScriptsWaitingForResources() override final; | 139 void executeScriptsWaitingForResources() final; |
140 | 140 |
141 // HTMLScriptRunnerHost | 141 // HTMLScriptRunnerHost |
142 virtual void notifyScriptLoaded(Resource*) override final; | 142 void notifyScriptLoaded(Resource*) final; |
143 virtual HTMLInputStream& inputStream() override final { return m_input; } | 143 HTMLInputStream& inputStream() final { return m_input; } |
144 virtual bool hasPreloadScanner() const override final { return m_preloadScan
ner.get() && !shouldUseThreading(); } | 144 bool hasPreloadScanner() const final { return m_preloadScanner.get() && !sho
uldUseThreading(); } |
145 virtual void appendCurrentInputStreamToPreloadScannerAndScan() override fina
l; | 145 void appendCurrentInputStreamToPreloadScannerAndScan() final; |
146 | 146 |
147 void startBackgroundParser(); | 147 void startBackgroundParser(); |
148 void stopBackgroundParser(); | 148 void stopBackgroundParser(); |
149 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); | 149 void validateSpeculations(PassOwnPtr<ParsedChunk> lastChunk); |
150 void discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunk, Pas
sOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>); | 150 void discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunk, Pas
sOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>); |
151 size_t processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); | 151 size_t processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>); |
152 void pumpPendingSpeculations(); | 152 void pumpPendingSpeculations(); |
153 | 153 |
154 Document* contextForParsingSession(); | 154 Document* contextForParsingSession(); |
155 | 155 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 bool m_haveBackgroundParser; | 205 bool m_haveBackgroundParser; |
206 bool m_tasksWereSuspended; | 206 bool m_tasksWereSuspended; |
207 unsigned m_pumpSessionNestingLevel; | 207 unsigned m_pumpSessionNestingLevel; |
208 unsigned m_pumpSpeculationsSessionNestingLevel; | 208 unsigned m_pumpSpeculationsSessionNestingLevel; |
209 bool m_isParsingAtLineNumber; | 209 bool m_isParsingAtLineNumber; |
210 }; | 210 }; |
211 | 211 |
212 } | 212 } |
213 | 213 |
214 #endif | 214 #endif |
OLD | NEW |