| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 PreloadRequestStream preloads; | 106 PreloadRequestStream preloads; |
| 107 ViewportDescriptionWrapper viewport; | 107 ViewportDescriptionWrapper viewport; |
| 108 XSSInfoStream xssInfos; | 108 XSSInfoStream xssInfos; |
| 109 HTMLTokenizer::State tokenizerState; | 109 HTMLTokenizer::State tokenizerState; |
| 110 HTMLTreeBuilderSimulator::State treeBuilderState; | 110 HTMLTreeBuilderSimulator::State treeBuilderState; |
| 111 HTMLInputCheckpoint inputCheckpoint; | 111 HTMLInputCheckpoint inputCheckpoint; |
| 112 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 112 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
| 113 bool startingScript; | 113 bool startingScript; |
| 114 // Indices into |tokens|. | 114 // Indices into |tokens|. |
| 115 Vector<int> likelyDocumentWriteScriptIndices; | 115 Vector<int> likelyDocumentWriteScriptIndices; |
| 116 // Index into |tokens| of the last <meta> csp tag in |tokens|. Preloads |
| 117 // will be deferred until this token is parsed. Will be |
| 118 // noPendingToken if there are no csp tokens. |
| 119 int pendingCSPMetaTokenIndex; |
| 120 |
| 121 static constexpr int noPendingToken = -1; |
| 116 }; | 122 }; |
| 117 void notifyPendingTokenizedChunks(); | 123 void notifyPendingTokenizedChunks(); |
| 118 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&)
; | 124 void didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData&)
; |
| 119 | 125 |
| 120 void appendBytes(const char* bytes, size_t length) override; | 126 void appendBytes(const char* bytes, size_t length) override; |
| 121 void flush() final; | 127 void flush() final; |
| 122 void setDecoder(std::unique_ptr<TextResourceDecoder>) final; | 128 void setDecoder(std::unique_ptr<TextResourceDecoder>) final; |
| 123 | 129 |
| 124 protected: | 130 protected: |
| 125 void insert(const SegmentedString&) final; | 131 void insert(const SegmentedString&) final; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 185 |
| 180 bool shouldUseThreading() const { return m_shouldUseThreading; } | 186 bool shouldUseThreading() const { return m_shouldUseThreading; } |
| 181 | 187 |
| 182 bool isParsingFragment() const; | 188 bool isParsingFragment() const; |
| 183 bool isScheduledForResume() const; | 189 bool isScheduledForResume() const; |
| 184 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } | 190 bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; } |
| 185 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } | 191 bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts(
) || isScheduledForResume() || isExecutingScript(); } |
| 186 | 192 |
| 187 std::unique_ptr<HTMLPreloadScanner> createPreloadScanner(); | 193 std::unique_ptr<HTMLPreloadScanner> createPreloadScanner(); |
| 188 | 194 |
| 189 int preloadInsertion(const SegmentedString& source); | 195 void fetchQueuedPreloads(); |
| 196 |
| 190 void evaluateAndPreloadScriptForDocumentWrite(const String& source); | 197 void evaluateAndPreloadScriptForDocumentWrite(const String& source); |
| 191 | 198 |
| 192 // Temporary enum for the ParseHTMLOnMainThread experiment. This is used to | 199 // Temporary enum for the ParseHTMLOnMainThread experiment. This is used to |
| 193 // annotate whether a given task should post a task or not on the main | 200 // annotate whether a given task should post a task or not on the main |
| 194 // thread if the lookahead parser is living on the main thread. | 201 // thread if the lookahead parser is living on the main thread. |
| 195 enum LookaheadParserTaskSynchrony { | 202 enum LookaheadParserTaskSynchrony { |
| 196 Synchronous, | 203 Synchronous, |
| 197 Asynchronous, | 204 Asynchronous, |
| 198 }; | 205 }; |
| 199 | 206 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 228 std::unique_ptr<TokenizedChunk> m_lastChunkBeforeScript; | 235 std::unique_ptr<TokenizedChunk> m_lastChunkBeforeScript; |
| 229 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; | 236 Deque<std::unique_ptr<TokenizedChunk>> m_speculations; |
| 230 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; | 237 WeakPtrFactory<HTMLDocumentParser> m_weakFactory; |
| 231 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 238 WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
| 232 Member<HTMLResourcePreloader> m_preloader; | 239 Member<HTMLResourcePreloader> m_preloader; |
| 233 PreloadRequestStream m_queuedPreloads; | 240 PreloadRequestStream m_queuedPreloads; |
| 234 Vector<String> m_queuedDocumentWriteScripts; | 241 Vector<String> m_queuedDocumentWriteScripts; |
| 235 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; | 242 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; |
| 236 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; | 243 std::unique_ptr<DocumentWriteEvaluator> m_evaluator; |
| 237 | 244 |
| 245 // If this is non-null, then there is a meta CSP token somewhere in the |
| 246 // speculation buffer. Preloads will be deferred until a token matching this |
| 247 // pointer is parsed and the CSP policy is applied. Note that this pointer |
| 248 // tracks the *last* meta token in the speculation buffer, so it |
| 249 // overestimates how long to defer preloads. This is for simplicity, as the |
| 250 // alternative would require keeping track of token positions of preload |
| 251 // requests. |
| 252 CompactHTMLToken* m_pendingCSPMetaToken; |
| 253 |
| 238 bool m_shouldUseThreading; | 254 bool m_shouldUseThreading; |
| 239 bool m_endWasDelayed; | 255 bool m_endWasDelayed; |
| 240 bool m_haveBackgroundParser; | 256 bool m_haveBackgroundParser; |
| 241 bool m_tasksWereSuspended; | 257 bool m_tasksWereSuspended; |
| 242 unsigned m_pumpSessionNestingLevel; | 258 unsigned m_pumpSessionNestingLevel; |
| 243 unsigned m_pumpSpeculationsSessionNestingLevel; | 259 unsigned m_pumpSpeculationsSessionNestingLevel; |
| 244 bool m_isParsingAtLineNumber; | 260 bool m_isParsingAtLineNumber; |
| 245 bool m_triedLoadingLinkHeaders; | 261 bool m_triedLoadingLinkHeaders; |
| 246 }; | 262 }; |
| 247 | 263 |
| 248 } // namespace blink | 264 } // namespace blink |
| 249 | 265 |
| 250 #endif | 266 #endif |
| OLD | NEW |