| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 ParserSynchronizationPolicy); | 165 ParserSynchronizationPolicy); |
| 166 | 166 |
| 167 // DocumentParser | 167 // DocumentParser |
| 168 void detach() final; | 168 void detach() final; |
| 169 bool hasInsertionPoint() final; | 169 bool hasInsertionPoint() final; |
| 170 void prepareToStopParsing() final; | 170 void prepareToStopParsing() final; |
| 171 void stopParsing() final; | 171 void stopParsing() final; |
| 172 bool isWaitingForScripts() const final; | 172 bool isWaitingForScripts() const final; |
| 173 bool isExecutingScript() const final; | 173 bool isExecutingScript() const final; |
| 174 void executeScriptsWaitingForResources() final; | 174 void executeScriptsWaitingForResources() final; |
| 175 void didAddPendingStylesheetInBody() final; |
| 176 void didLoadAllStylesheets() final; |
| 175 void documentElementAvailable() override; | 177 void documentElementAvailable() override; |
| 176 | 178 |
| 177 // HTMLParserScriptRunnerHost | 179 // HTMLParserScriptRunnerHost |
| 178 void notifyScriptLoaded(PendingScript*) final; | 180 void notifyScriptLoaded(PendingScript*) final; |
| 179 HTMLInputStream& inputStream() final { return m_input; } | 181 HTMLInputStream& inputStream() final { return m_input; } |
| 180 bool hasPreloadScanner() const final { | 182 bool hasPreloadScanner() const final { |
| 181 return m_preloadScanner.get() && !shouldUseThreading(); | 183 return m_preloadScanner.get() && !shouldUseThreading(); |
| 182 } | 184 } |
| 183 void appendCurrentInputStreamToPreloadScannerAndScan() final; | 185 void appendCurrentInputStreamToPreloadScannerAndScan() final; |
| 184 | 186 |
| 185 void startBackgroundParser(); | 187 void startBackgroundParser(); |
| 186 void stopBackgroundParser(); | 188 void stopBackgroundParser(); |
| 187 void validateSpeculations(std::unique_ptr<TokenizedChunk> lastChunk); | 189 void validateSpeculations(std::unique_ptr<TokenizedChunk> lastChunk); |
| 188 void discardSpeculationsAndResumeFrom( | 190 void discardSpeculationsAndResumeFrom( |
| 189 std::unique_ptr<TokenizedChunk> lastChunk, | 191 std::unique_ptr<TokenizedChunk> lastChunk, |
| 190 std::unique_ptr<HTMLToken>, | 192 std::unique_ptr<HTMLToken>, |
| 191 std::unique_ptr<HTMLTokenizer>); | 193 std::unique_ptr<HTMLTokenizer>); |
| 192 size_t processTokenizedChunkFromBackgroundParser( | 194 size_t processTokenizedChunkFromBackgroundParser( |
| 193 std::unique_ptr<TokenizedChunk>); | 195 std::unique_ptr<TokenizedChunk>); |
| 194 void pumpPendingSpeculations(); | 196 void pumpPendingSpeculations(); |
| 195 | 197 |
| 196 bool canTakeNextToken(); | 198 bool canTakeNextToken(); |
| 197 void pumpTokenizer(); | 199 void pumpTokenizer(); |
| 198 void pumpTokenizerIfPossible(); | 200 void pumpTokenizerIfPossible(); |
| 199 void constructTreeFromHTMLToken(); | 201 void constructTreeFromHTMLToken(); |
| 200 void constructTreeFromCompactHTMLToken(const CompactHTMLToken&); | 202 void constructTreeFromCompactHTMLToken(const CompactHTMLToken&); |
| 201 | 203 |
| 202 void runScriptsForPausedTreeBuilder(); | 204 void runScriptsForPausedTreeBuilder(); |
| 203 void resumeParsingAfterScriptExecution(); | 205 void resumeParsingAfterPause(); |
| 204 | 206 |
| 205 void attemptToEnd(); | 207 void attemptToEnd(); |
| 206 void endIfDelayed(); | 208 void endIfDelayed(); |
| 207 void attemptToRunDeferredScriptsAndEnd(); | 209 void attemptToRunDeferredScriptsAndEnd(); |
| 208 void end(); | 210 void end(); |
| 209 | 211 |
| 210 bool shouldUseThreading() const { return m_shouldUseThreading; } | 212 bool shouldUseThreading() const { return m_shouldUseThreading; } |
| 211 | 213 |
| 212 bool isParsingFragment() const; | 214 bool isParsingFragment() const; |
| 213 bool isScheduledForResume() const; | 215 bool isScheduledForResume() const; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // A scanner used only for input provided to the insert() method. | 260 // A scanner used only for input provided to the insert() method. |
| 259 std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner; | 261 std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner; |
| 260 | 262 |
| 261 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; | 263 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; |
| 262 Member<HTMLParserScheduler> m_parserScheduler; | 264 Member<HTMLParserScheduler> m_parserScheduler; |
| 263 HTMLSourceTracker m_sourceTracker; | 265 HTMLSourceTracker m_sourceTracker; |
| 264 TextPosition m_textPosition; | 266 TextPosition m_textPosition; |
| 265 XSSAuditor m_xssAuditor; | 267 XSSAuditor m_xssAuditor; |
| 266 XSSAuditorDelegate m_xssAuditorDelegate; | 268 XSSAuditorDelegate m_xssAuditorDelegate; |
| 267 | 269 |
| 268 // FIXME: m_lastChunkBeforeScript, m_tokenizer, m_token, and m_input should be | 270 // FIXME: m_lastChunkBeforePause, m_tokenizer, m_token, and m_input should be |
| 269 // combined into a single state object so they can be set and cleared together | 271 // combined into a single state object so they can be set and cleared together |
| 270 // and passed between threads together. | 272 // and passed between threads together. |
| 271 std::unique_ptr<TokenizedChunk> m_lastChunkBeforeScript; | 273 std::unique_ptr<TokenizedChunk> m_lastChunkBeforePause; |
| 272 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; | 274 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; |
| 273 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; | 275 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; |
| 274 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 276 WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
| 275 Member<HTMLResourcePreloader> m_preloader; | 277 Member<HTMLResourcePreloader> m_preloader; |
| 276 PreloadRequestStream m_queuedPreloads; | 278 PreloadRequestStream m_queuedPreloads; |
| 277 Vector<String> m_queuedDocumentWriteScripts; | 279 Vector<String> m_queuedDocumentWriteScripts; |
| 278 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; | 280 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; |
| 279 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; | 281 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; |
| 280 | 282 |
| 281 // If this is non-null, then there is a meta CSP token somewhere in the | 283 // If this is non-null, then there is a meta CSP token somewhere in the |
| 282 // speculation buffer. Preloads will be deferred until a token matching this | 284 // speculation buffer. Preloads will be deferred until a token matching this |
| 283 // pointer is parsed and the CSP policy is applied. Note that this pointer | 285 // pointer is parsed and the CSP policy is applied. Note that this pointer |
| 284 // tracks the *last* meta token in the speculation buffer, so it overestimates | 286 // tracks the *last* meta token in the speculation buffer, so it overestimates |
| 285 // how long to defer preloads. This is for simplicity, as the alternative | 287 // how long to defer preloads. This is for simplicity, as the alternative |
| 286 // would require keeping track of token positions of preload requests. | 288 // would require keeping track of token positions of preload requests. |
| 287 CompactHTMLToken* m_pendingCSPMetaToken; | 289 CompactHTMLToken* m_pendingCSPMetaToken; |
| 288 | 290 |
| 291 TaskHandle m_resumeParsingTaskHandle; |
| 292 |
| 289 bool m_shouldUseThreading; | 293 bool m_shouldUseThreading; |
| 290 bool m_endWasDelayed; | 294 bool m_endWasDelayed; |
| 291 bool m_haveBackgroundParser; | 295 bool m_haveBackgroundParser; |
| 292 bool m_tasksWereSuspended; | 296 bool m_tasksWereSuspended; |
| 293 unsigned m_pumpSessionNestingLevel; | 297 unsigned m_pumpSessionNestingLevel; |
| 294 unsigned m_pumpSpeculationsSessionNestingLevel; | 298 unsigned m_pumpSpeculationsSessionNestingLevel; |
| 295 bool m_isParsingAtLineNumber; | 299 bool m_isParsingAtLineNumber; |
| 296 bool m_triedLoadingLinkHeaders; | 300 bool m_triedLoadingLinkHeaders; |
| 301 bool m_addedPendingStylesheetInBody; |
| 302 bool m_isWaitingForStylesheets; |
| 297 }; | 303 }; |
| 298 | 304 |
| 299 } // namespace blink | 305 } // namespace blink |
| 300 | 306 |
| 301 #endif // HTMLDocumentParser_h | 307 #endif // HTMLDocumentParser_h |
| OLD | NEW |