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