Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
| diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
| index 07f747367118d5231744ac8252c9c26bf526b0f6..d90eef3c8038302c570595001bde62b5eaa7246b 100644 |
| --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
| +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
| @@ -89,6 +89,17 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem |
| return HTMLTokenizer::DataState; |
| } |
| +// static |
| +HTMLDocumentParser* HTMLDocumentParser::create( |
|
Charlie Harrison
2016/08/03 14:40:03
I have a slight preference for passing the sync po
droger
2016/08/03 16:45:50
Done.
|
| + HTMLDocument& document, |
| + ParserSynchronizationPolicy backgroundParsingPolicy) |
| +{ |
| + return new HTMLDocumentParser( |
| + document, |
| + threadingAllowedForDocument(document) |
| + ? backgroundParsingPolicy : ForceSynchronousParsing); |
| +} |
| + |
| HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchronizationPolicy syncPolicy) |
| : HTMLDocumentParser(document, AllowScriptingContent, syncPolicy) |
| { |
| @@ -150,6 +161,12 @@ DEFINE_TRACE(HTMLDocumentParser) |
| HTMLScriptRunnerHost::trace(visitor); |
| } |
| +// static |
| +bool HTMLDocumentParser::threadingAllowedForDocument(HTMLDocument& document) |
| +{ |
| + return !document.isPrefetchOnly(); |
| +} |
| + |
| void HTMLDocumentParser::detach() |
| { |
| if (!isParsingFragment() && m_tokenizedChunkQueue.get() && m_tokenizedChunkQueue->peakPendingChunkCount()) { |
| @@ -707,7 +724,8 @@ void HTMLDocumentParser::insert(const SegmentedString& source) |
| if (!m_insertionPreloadScanner) |
| m_insertionPreloadScanner = createPreloadScanner(); |
| m_insertionPreloadScanner->appendToEnd(source); |
| - m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()->validBaseElementURL(), nullptr); |
| + m_insertionPreloadScanner->scanAndPreload( |
|
Charlie Harrison
2016/08/03 14:40:03
nit: Unnecessary line break.
droger
2016/08/03 16:45:50
Done.
|
| + m_preloader.get(), document()->validBaseElementURL(), nullptr); |
| } |
| endIfDelayed(); |
| @@ -788,6 +806,17 @@ void HTMLDocumentParser::append(const String& inputSource) |
| TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::append", "size", inputSource.length()); |
| const SegmentedString source(inputSource); |
| + if (document()->isPrefetchOnly()) { |
| + if (!m_preloadScanner) |
| + m_preloadScanner = createPreloadScanner(); |
| + |
| + m_preloadScanner->appendToEnd(source); |
| + m_preloadScanner->scanAndPreload(m_preloader.get(), document()->validBaseElementURL(), nullptr); |
|
Charlie Harrison
2016/08/03 14:40:03
This just preloads the tokens normally. Do we want
droger
2016/08/03 16:45:50
This uses the same code as the standard preload sc
Charlie Harrison
2016/08/03 17:15:14
Nope, LOAD_PREFETCH afaik is only used for the lin
pasko
2016/08/04 12:23:08
csharrison: thank you for investigation and the in
|
| + |
| + // Return after the preload scanner, do not actually parse the document. |
| + return; |
| + } |
| + |
| if (m_preloadScanner) { |
| if (m_input.current().isEmpty() && !isWaitingForScripts()) { |
| // We have parsed until the end of the current input and so are now moving ahead of the preload scanner. |