Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp

Issue 2536753003: Script blocking resources tracking should be only done by Document::isScriptExecutionReady (Closed)
Patch Set: confirm lastchunkbeforescript Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 391 }
392 392
393 void HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser( 393 void HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser(
394 const DocumentEncodingData& data) { 394 const DocumentEncodingData& data) {
395 document()->setEncodingData(data); 395 document()->setEncodingData(data);
396 } 396 }
397 397
398 void HTMLDocumentParser::validateSpeculations( 398 void HTMLDocumentParser::validateSpeculations(
399 std::unique_ptr<TokenizedChunk> chunk) { 399 std::unique_ptr<TokenizedChunk> chunk) {
400 ASSERT(chunk); 400 ASSERT(chunk);
401 // TODO(kouhei): We should simplify codepath here by disallowing
402 // validateSpeculations
403 // while isWaitingForScripts, and m_lastChunkBeforeScript can simply be
404 // pushed to m_speculations.
401 if (isWaitingForScripts()) { 405 if (isWaitingForScripts()) {
402 // We're waiting on a network script, just save the chunk, we'll get a 406 // We're waiting on a network script, just save the chunk, we'll get a
403 // second validateSpeculations call after the script completes. This call 407 // second validateSpeculations call after the script completes. This call
404 // should have been made immediately after runScriptsForPausedTreeBuilder 408 // should have been made immediately after runScriptsForPausedTreeBuilder
405 // which may have started a network load and left us waiting. 409 // which may have started a network load and left us waiting.
406 ASSERT(!m_lastChunkBeforeScript); 410 ASSERT(!m_lastChunkBeforeScript);
407 m_lastChunkBeforeScript = std::move(chunk); 411 m_lastChunkBeforeScript = std::move(chunk);
408 return; 412 return;
409 } 413 }
410 414
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 // If either object has a blocking script, the parser should be paused. 1058 // If either object has a blocking script, the parser should be paused.
1055 return treeBuilderHasBlockingScript || scriptRunnerHasBlockingScript || 1059 return treeBuilderHasBlockingScript || scriptRunnerHasBlockingScript ||
1056 m_reentryPermit->parserPauseFlag(); 1060 m_reentryPermit->parserPauseFlag();
1057 } 1061 }
1058 1062
1059 void HTMLDocumentParser::resumeParsingAfterScriptExecution() { 1063 void HTMLDocumentParser::resumeParsingAfterScriptExecution() {
1060 ASSERT(!isExecutingScript()); 1064 ASSERT(!isExecutingScript());
1061 ASSERT(!isWaitingForScripts()); 1065 ASSERT(!isWaitingForScripts());
1062 1066
1063 if (m_haveBackgroundParser) { 1067 if (m_haveBackgroundParser) {
1064 validateSpeculations(std::move(m_lastChunkBeforeScript)); 1068 if (m_lastChunkBeforeScript) {
1065 ASSERT(!m_lastChunkBeforeScript); 1069 validateSpeculations(std::move(m_lastChunkBeforeScript));
1066 pumpPendingSpeculations(); 1070 DCHECK(!m_lastChunkBeforeScript);
1071 pumpPendingSpeculations();
1072 }
1067 return; 1073 return;
1068 } 1074 }
1069 1075
1070 m_insertionPreloadScanner.reset(); 1076 m_insertionPreloadScanner.reset();
1071 pumpTokenizerIfPossible(); 1077 pumpTokenizerIfPossible();
1072 endIfDelayed(); 1078 endIfDelayed();
1073 } 1079 }
1074 1080
1075 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() { 1081 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() {
1076 ASSERT(m_preloadScanner); 1082 ASSERT(m_preloadScanner);
(...skipping 14 matching lines...) Expand all
1091 attemptToRunDeferredScriptsAndEnd(); 1097 attemptToRunDeferredScriptsAndEnd();
1092 return; 1098 return;
1093 } 1099 }
1094 1100
1095 m_scriptRunner->executeScriptsWaitingForLoad(cachedResource); 1101 m_scriptRunner->executeScriptsWaitingForLoad(cachedResource);
1096 if (!isWaitingForScripts()) 1102 if (!isWaitingForScripts())
1097 resumeParsingAfterScriptExecution(); 1103 resumeParsingAfterScriptExecution();
1098 } 1104 }
1099 1105
1100 void HTMLDocumentParser::executeScriptsWaitingForResources() { 1106 void HTMLDocumentParser::executeScriptsWaitingForResources() {
1107 DCHECK(document()->isScriptExecutionReady());
1108
1101 // Document only calls this when the Document owns the DocumentParser so this 1109 // Document only calls this when the Document owns the DocumentParser so this
1102 // will not be called in the DocumentFragment case. 1110 // will not be called in the DocumentFragment case.
1103 ASSERT(m_scriptRunner); 1111 DCHECK(m_scriptRunner);
1104 // Ignore calls unless we have a script blocking the parser waiting on a
1105 // stylesheet load. Otherwise we are currently parsing and this is a
1106 // re-entrant call from encountering a </ style> tag.
1107 if (!m_scriptRunner->hasScriptsWaitingForResources())
kouhei (in TOK) 2016/11/29 06:56:14 Actually, this is a bug as it refers to the stale
1108 return;
1109 m_scriptRunner->executeScriptsWaitingForResources(); 1112 m_scriptRunner->executeScriptsWaitingForResources();
1110 if (!isWaitingForScripts()) 1113 if (!isWaitingForScripts())
1111 resumeParsingAfterScriptExecution(); 1114 resumeParsingAfterScriptExecution();
1112 } 1115 }
1113 1116
1114 void HTMLDocumentParser::parseDocumentFragment( 1117 void HTMLDocumentParser::parseDocumentFragment(
1115 const String& source, 1118 const String& source,
1116 DocumentFragment* fragment, 1119 DocumentFragment* fragment,
1117 Element* contextElement, 1120 Element* contextElement,
1118 ParserContentPolicy parserContentPolicy) { 1121 ParserContentPolicy parserContentPolicy) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 case Asynchronous: 1303 case Asynchronous:
1301 m_loadingTaskRunner->postTask( 1304 m_loadingTaskRunner->postTask(
1302 BLINK_FROM_HERE, 1305 BLINK_FROM_HERE,
1303 WTF::bind(function, std::forward<Ps>(parameters)...)); 1306 WTF::bind(function, std::forward<Ps>(parameters)...));
1304 return; 1307 return;
1305 } 1308 }
1306 NOTREACHED(); 1309 NOTREACHED();
1307 } 1310 }
1308 1311
1309 } // namespace blink 1312 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698