| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 PreloadRequestStream preloads; | 116 PreloadRequestStream preloads; |
| 117 ViewportDescriptionWrapper viewport; | 117 ViewportDescriptionWrapper viewport; |
| 118 XSSInfoStream xssInfos; | 118 XSSInfoStream xssInfos; |
| 119 HTMLTokenizer::State tokenizerState; | 119 HTMLTokenizer::State tokenizerState; |
| 120 HTMLTreeBuilderSimulator::State treeBuilderState; | 120 HTMLTreeBuilderSimulator::State treeBuilderState; |
| 121 HTMLInputCheckpoint inputCheckpoint; | 121 HTMLInputCheckpoint inputCheckpoint; |
| 122 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 122 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
| 123 bool startingScript; | 123 bool startingScript; |
| 124 // Indices into |tokens|. | 124 // Indices into |tokens|. |
| 125 Vector<int> likelyDocumentWriteScriptIndices; | 125 Vector<int> likelyDocumentWriteScriptIndices; |
| 126 // Index into |tokens| of the last <meta> csp tag in |tokens|. Preloads | 126 // Index into |tokens| of the last <meta> csp tag in |tokens|. Preloads will |
| 127 // will be deferred until this token is parsed. Will be | 127 // be deferred until this token is parsed. Will be noPendingToken if there |
| 128 // noPendingToken if there are no csp tokens. | 128 // are no csp tokens. |
| 129 int pendingCSPMetaTokenIndex; | 129 int pendingCSPMetaTokenIndex; |
| 130 | 130 |
| 131 static constexpr int noPendingToken = -1; | 131 static constexpr int noPendingToken = -1; |
| 132 }; | 132 }; |
| 133 void notifyPendingTokenizedChunks(); | 133 void notifyPendingTokenizedChunks(); |
| 134 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&); | 134 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&); |
| 135 | 135 |
| 136 void appendBytes(const char* bytes, size_t length) override; | 136 void appendBytes(const char* bytes, size_t length) override; |
| 137 void flush() final; | 137 void flush() final; |
| 138 void setDecoder(std::unique_ptr<TextResourceDecoder>) final; | 138 void setDecoder(std::unique_ptr<TextResourceDecoder>) final; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 isExecutingScript(); | 215 isExecutingScript(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 std::unique_ptr<HTMLPreloadScanner> createPreloadScanner(); | 218 std::unique_ptr<HTMLPreloadScanner> createPreloadScanner(); |
| 219 | 219 |
| 220 void fetchQueuedPreloads(); | 220 void fetchQueuedPreloads(); |
| 221 | 221 |
| 222 void evaluateAndPreloadScriptForDocumentWrite(const String& source); | 222 void evaluateAndPreloadScriptForDocumentWrite(const String& source); |
| 223 | 223 |
| 224 // Temporary enum for the ParseHTMLOnMainThread experiment. This is used to | 224 // Temporary enum for the ParseHTMLOnMainThread experiment. This is used to |
| 225 // annotate whether a given task should post a task or not on the main | 225 // annotate whether a given task should post a task or not on the main thread |
| 226 // thread if the lookahead parser is living on the main thread. | 226 // if the lookahead parser is living on the main thread. |
| 227 enum LookaheadParserTaskSynchrony { | 227 enum LookaheadParserTaskSynchrony { |
| 228 Synchronous, | 228 Synchronous, |
| 229 Asynchronous, | 229 Asynchronous, |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 // Setting |synchronyPolicy| to Synchronous will just call the function | 232 // Setting |synchronyPolicy| to Synchronous will just call the function with |
| 233 // with the given parameters. Note, this method is completely temporary | 233 // the given parameters. Note, this method is completely temporary as we need |
| 234 // as we need to maintain both threading implementations until the | 234 // to maintain both threading implementations until the ParseHTMLOnMainThread |
| 235 // ParseHTMLOnMainThread experiment finishes. | 235 // experiment finishes. |
| 236 template <typename FunctionType, typename... Ps> | 236 template <typename FunctionType, typename... Ps> |
| 237 void postTaskToLookaheadParser(LookaheadParserTaskSynchrony synchronyPolicy, | 237 void postTaskToLookaheadParser(LookaheadParserTaskSynchrony synchronyPolicy, |
| 238 FunctionType, | 238 FunctionType, |
| 239 Ps&&... parameters); | 239 Ps&&... parameters); |
| 240 | 240 |
| 241 HTMLToken& token() { return *m_token; } | 241 HTMLToken& token() { return *m_token; } |
| 242 | 242 |
| 243 HTMLParserOptions m_options; | 243 HTMLParserOptions m_options; |
| 244 HTMLInputStream m_input; | 244 HTMLInputStream m_input; |
| 245 RefPtr<HTMLParserReentryPermit> m_reentryPermit; | 245 RefPtr<HTMLParserReentryPermit> m_reentryPermit; |
| 246 | 246 |
| 247 std::unique_ptr<HTMLToken> m_token; | 247 std::unique_ptr<HTMLToken> m_token; |
| 248 std::unique_ptr<HTMLTokenizer> m_tokenizer; | 248 std::unique_ptr<HTMLTokenizer> m_tokenizer; |
| 249 Member<HTMLScriptRunner> m_scriptRunner; | 249 Member<HTMLScriptRunner> m_scriptRunner; |
| 250 Member<HTMLTreeBuilder> m_treeBuilder; | 250 Member<HTMLTreeBuilder> m_treeBuilder; |
| 251 std::unique_ptr<HTMLPreloadScanner> m_preloadScanner; | 251 std::unique_ptr<HTMLPreloadScanner> m_preloadScanner; |
| 252 std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner; | 252 std::unique_ptr<HTMLPreloadScanner> m_insertionPreloadScanner; |
| 253 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; | 253 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; |
| 254 Member<HTMLParserScheduler> m_parserScheduler; | 254 Member<HTMLParserScheduler> m_parserScheduler; |
| 255 HTMLSourceTracker m_sourceTracker; | 255 HTMLSourceTracker m_sourceTracker; |
| 256 TextPosition m_textPosition; | 256 TextPosition m_textPosition; |
| 257 XSSAuditor m_xssAuditor; | 257 XSSAuditor m_xssAuditor; |
| 258 XSSAuditorDelegate m_xssAuditorDelegate; | 258 XSSAuditorDelegate m_xssAuditorDelegate; |
| 259 | 259 |
| 260 // FIXME: m_lastChunkBeforeScript, m_tokenizer, m_token, and m_input should be
combined into a single state object | 260 // FIXME: m_lastChunkBeforeScript, m_tokenizer, m_token, and m_input should be |
| 261 // so they can be set and cleared together and passed between threads together
. | 261 // combined into a single state object so they can be set and cleared together |
| 262 // and passed between threads together. |
| 262 std::unique_ptr<TokenizedChunk> m_lastChunkBeforeScript; | 263 std::unique_ptr<TokenizedChunk> m_lastChunkBeforeScript; |
| 263 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; | 264 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; |
| 264 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; | 265 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; |
| 265 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 266 WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
| 266 Member<HTMLResourcePreloader> m_preloader; | 267 Member<HTMLResourcePreloader> m_preloader; |
| 267 PreloadRequestStream m_queuedPreloads; | 268 PreloadRequestStream m_queuedPreloads; |
| 268 Vector<String> m_queuedDocumentWriteScripts; | 269 Vector<String> m_queuedDocumentWriteScripts; |
| 269 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; | 270 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; |
| 270 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; | 271 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; |
| 271 | 272 |
| 272 // If this is non-null, then there is a meta CSP token somewhere in the | 273 // If this is non-null, then there is a meta CSP token somewhere in the |
| 273 // speculation buffer. Preloads will be deferred until a token matching this | 274 // speculation buffer. Preloads will be deferred until a token matching this |
| 274 // pointer is parsed and the CSP policy is applied. Note that this pointer | 275 // pointer is parsed and the CSP policy is applied. Note that this pointer |
| 275 // tracks the *last* meta token in the speculation buffer, so it | 276 // tracks the *last* meta token in the speculation buffer, so it overestimates |
| 276 // overestimates how long to defer preloads. This is for simplicity, as the | 277 // how long to defer preloads. This is for simplicity, as the alternative |
| 277 // alternative would require keeping track of token positions of preload | 278 // would require keeping track of token positions of preload requests. |
| 278 // requests. | |
| 279 CompactHTMLToken* m_pendingCSPMetaToken; | 279 CompactHTMLToken* m_pendingCSPMetaToken; |
| 280 | 280 |
| 281 bool m_shouldUseThreading; | 281 bool m_shouldUseThreading; |
| 282 bool m_endWasDelayed; | 282 bool m_endWasDelayed; |
| 283 bool m_haveBackgroundParser; | 283 bool m_haveBackgroundParser; |
| 284 bool m_tasksWereSuspended; | 284 bool m_tasksWereSuspended; |
| 285 unsigned m_pumpSessionNestingLevel; | 285 unsigned m_pumpSessionNestingLevel; |
| 286 unsigned m_pumpSpeculationsSessionNestingLevel; | 286 unsigned m_pumpSpeculationsSessionNestingLevel; |
| 287 bool m_isParsingAtLineNumber; | 287 bool m_isParsingAtLineNumber; |
| 288 bool m_triedLoadingLinkHeaders; | 288 bool m_triedLoadingLinkHeaders; |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 } // namespace blink | 291 } // namespace blink |
| 292 | 292 |
| 293 #endif | 293 #endif // HTMLDocumentParser_h |
| OLD | NEW |