| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
MLParser>> reference, PassOwnPtr<Configuration> config, const KURL& documentURL,
PassOwnPtr<CachedDocumentParameters> cachedDocumentParameters, const MediaValue
sCached::MediaValuesCachedData& mediaValuesCachedData, PassOwnPtr<WebTaskRunner>
loadingTaskRunner) | 95 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
MLParser>> reference, PassOwnPtr<Configuration> config, const KURL& documentURL,
PassOwnPtr<CachedDocumentParameters> cachedDocumentParameters, const MediaValue
sCached::MediaValuesCachedData& mediaValuesCachedData, PassOwnPtr<WebTaskRunner>
loadingTaskRunner) |
| 96 : m_weakFactory(reference, this) | 96 : m_weakFactory(reference, this) |
| 97 , m_token(adoptPtr(new HTMLToken)) | 97 , m_token(adoptPtr(new HTMLToken)) |
| 98 , m_tokenizer(HTMLTokenizer::create(config->options)) | 98 , m_tokenizer(HTMLTokenizer::create(config->options)) |
| 99 , m_treeBuilderSimulator(config->options) | 99 , m_treeBuilderSimulator(config->options) |
| 100 , m_options(config->options) | 100 , m_options(config->options) |
| 101 , m_outstandingTokenLimit(config->outstandingTokenLimit) | 101 , m_outstandingTokenLimit(config->outstandingTokenLimit) |
| 102 , m_parser(config->parser) | 102 , m_parser(config->parser) |
| 103 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) | 103 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) |
| 104 , m_pendingTokenLimit(config->pendingTokenLimit) | 104 , m_pendingTokenLimit(config->pendingTokenLimit) |
| 105 , m_xssAuditor(config->xssAuditor.release()) | 105 , m_xssAuditor(std::move(config->xssAuditor)) |
| 106 , m_preloadScanner(adoptPtr(new TokenPreloadScanner(documentURL, std::move(c
achedDocumentParameters), mediaValuesCachedData))) | 106 , m_preloadScanner(adoptPtr(new TokenPreloadScanner(documentURL, std::move(c
achedDocumentParameters), mediaValuesCachedData))) |
| 107 , m_decoder(config->decoder.release()) | 107 , m_decoder(std::move(config->decoder)) |
| 108 , m_loadingTaskRunner(std::move(loadingTaskRunner)) | 108 , m_loadingTaskRunner(std::move(loadingTaskRunner)) |
| 109 , m_parsedChunkQueue(config->parsedChunkQueue.release()) | 109 , m_parsedChunkQueue(config->parsedChunkQueue.release()) |
| 110 , m_startingScript(false) | 110 , m_startingScript(false) |
| 111 { | 111 { |
| 112 ASSERT(m_outstandingTokenLimit > 0); | 112 ASSERT(m_outstandingTokenLimit > 0); |
| 113 ASSERT(m_pendingTokenLimit > 0); | 113 ASSERT(m_pendingTokenLimit > 0); |
| 114 ASSERT(m_outstandingTokenLimit >= m_pendingTokenLimit); | 114 ASSERT(m_outstandingTokenLimit >= m_pendingTokenLimit); |
| 115 } | 115 } |
| 116 | 116 |
| 117 BackgroundHTMLParser::~BackgroundHTMLParser() | 117 BackgroundHTMLParser::~BackgroundHTMLParser() |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 if (decodedData.isEmpty()) | 165 if (decodedData.isEmpty()) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 appendDecodedBytes(decodedData); | 168 appendDecodedBytes(decodedData); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void BackgroundHTMLParser::resumeFrom(PassOwnPtr<Checkpoint> checkpoint) | 171 void BackgroundHTMLParser::resumeFrom(PassOwnPtr<Checkpoint> checkpoint) |
| 172 { | 172 { |
| 173 m_parser = checkpoint->parser; | 173 m_parser = checkpoint->parser; |
| 174 m_token = checkpoint->token.release(); | 174 m_token = std::move(checkpoint->token); |
| 175 m_tokenizer = checkpoint->tokenizer.release(); | 175 m_tokenizer = std::move(checkpoint->tokenizer); |
| 176 m_treeBuilderSimulator.setState(checkpoint->treeBuilderState); | 176 m_treeBuilderSimulator.setState(checkpoint->treeBuilderState); |
| 177 m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput); | 177 m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput); |
| 178 m_preloadScanner->rewindTo(checkpoint->preloadScannerCheckpoint); | 178 m_preloadScanner->rewindTo(checkpoint->preloadScannerCheckpoint); |
| 179 m_startingScript = false; | 179 m_startingScript = false; |
| 180 m_parsedChunkQueue->clear(); | 180 m_parsedChunkQueue->clear(); |
| 181 pumpTokenizer(); | 181 pumpTokenizer(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void BackgroundHTMLParser::startedChunkWithCheckpoint(HTMLInputCheckpoint inputC
heckpoint) | 184 void BackgroundHTMLParser::startedChunkWithCheckpoint(HTMLInputCheckpoint inputC
heckpoint) |
| 185 { | 185 { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 235 } |
| 236 | 236 |
| 237 if (m_xssAuditor->isEnabled()) | 237 if (m_xssAuditor->isEnabled()) |
| 238 m_sourceTracker.end(m_input.current(), m_tokenizer.get(), *m_token); | 238 m_sourceTracker.end(m_input.current(), m_tokenizer.get(), *m_token); |
| 239 | 239 |
| 240 { | 240 { |
| 241 TextPosition position = TextPosition(m_input.current().currentLine()
, m_input.current().currentColumn()); | 241 TextPosition position = TextPosition(m_input.current().currentLine()
, m_input.current().currentColumn()); |
| 242 | 242 |
| 243 if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenR
equest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA()))) { | 243 if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenR
equest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA()))) { |
| 244 xssInfo->m_textPosition = position; | 244 xssInfo->m_textPosition = position; |
| 245 m_pendingXSSInfos.append(xssInfo.release()); | 245 m_pendingXSSInfos.append(std::move(xssInfo)); |
| 246 } | 246 } |
| 247 | 247 |
| 248 CompactHTMLToken token(m_token.get(), position); | 248 CompactHTMLToken token(m_token.get(), position); |
| 249 | 249 |
| 250 bool shouldEvaluateForDocumentWrite = false; | 250 bool shouldEvaluateForDocumentWrite = false; |
| 251 m_preloadScanner->scan(token, m_input.current(), m_pendingPreloads,
&m_viewportDescription, &shouldEvaluateForDocumentWrite); | 251 m_preloadScanner->scan(token, m_input.current(), m_pendingPreloads,
&m_viewportDescription, &shouldEvaluateForDocumentWrite); |
| 252 | 252 |
| 253 simulatedToken = m_treeBuilderSimulator.simulate(token, m_tokenizer.
get()); | 253 simulatedToken = m_treeBuilderSimulator.simulate(token, m_tokenizer.
get()); |
| 254 | 254 |
| 255 // Break chunks before a script tag is inserted and flag the chunk a
s starting a script | 255 // Break chunks before a script tag is inserted and flag the chunk a
s starting a script |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar
ser::ParsedChunk); | 290 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar
ser::ParsedChunk); |
| 291 TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToM
ainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT); | 291 TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToM
ainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT); |
| 292 chunk->preloads.swap(m_pendingPreloads); | 292 chunk->preloads.swap(m_pendingPreloads); |
| 293 if (m_viewportDescription.set) | 293 if (m_viewportDescription.set) |
| 294 chunk->viewport = m_viewportDescription; | 294 chunk->viewport = m_viewportDescription; |
| 295 chunk->xssInfos.swap(m_pendingXSSInfos); | 295 chunk->xssInfos.swap(m_pendingXSSInfos); |
| 296 chunk->tokenizerState = m_tokenizer->getState(); | 296 chunk->tokenizerState = m_tokenizer->getState(); |
| 297 chunk->treeBuilderState = m_treeBuilderSimulator.state(); | 297 chunk->treeBuilderState = m_treeBuilderSimulator.state(); |
| 298 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); | 298 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); |
| 299 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); | 299 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); |
| 300 chunk->tokens = m_pendingTokens.release(); | 300 chunk->tokens = std::move(m_pendingTokens); |
| 301 chunk->startingScript = m_startingScript; | 301 chunk->startingScript = m_startingScript; |
| 302 chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndi
ces); | 302 chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndi
ces); |
| 303 m_startingScript = false; | 303 m_startingScript = false; |
| 304 | 304 |
| 305 bool isEmpty = m_parsedChunkQueue->enqueue(chunk.release()); | 305 bool isEmpty = m_parsedChunkQueue->enqueue(std::move(chunk)); |
| 306 if (isEmpty) { | 306 if (isEmpty) { |
| 307 m_loadingTaskRunner->postTask( | 307 m_loadingTaskRunner->postTask( |
| 308 BLINK_FROM_HERE, | 308 BLINK_FROM_HERE, |
| 309 threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, Allow
CrossThreadAccess(m_parser))); | 309 threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, Allow
CrossThreadAccess(m_parser))); |
| 310 } | 310 } |
| 311 | 311 |
| 312 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 312 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |