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

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

Issue 2540653002: Revert of Script blocking resources tracking should be only done by Document::isScriptExecutionReady (Closed)
Patch Set: 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.
405 if (isWaitingForScripts()) { 401 if (isWaitingForScripts()) {
406 // We're waiting on a network script, just save the chunk, we'll get a 402 // We're waiting on a network script, just save the chunk, we'll get a
407 // second validateSpeculations call after the script completes. This call 403 // second validateSpeculations call after the script completes. This call
408 // should have been made immediately after runScriptsForPausedTreeBuilder 404 // should have been made immediately after runScriptsForPausedTreeBuilder
409 // which may have started a network load and left us waiting. 405 // which may have started a network load and left us waiting.
410 ASSERT(!m_lastChunkBeforeScript); 406 ASSERT(!m_lastChunkBeforeScript);
411 m_lastChunkBeforeScript = std::move(chunk); 407 m_lastChunkBeforeScript = std::move(chunk);
412 return; 408 return;
413 } 409 }
414 410
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 // If either object has a blocking script, the parser should be paused. 1054 // If either object has a blocking script, the parser should be paused.
1059 return treeBuilderHasBlockingScript || scriptRunnerHasBlockingScript || 1055 return treeBuilderHasBlockingScript || scriptRunnerHasBlockingScript ||
1060 m_reentryPermit->parserPauseFlag(); 1056 m_reentryPermit->parserPauseFlag();
1061 } 1057 }
1062 1058
1063 void HTMLDocumentParser::resumeParsingAfterScriptExecution() { 1059 void HTMLDocumentParser::resumeParsingAfterScriptExecution() {
1064 ASSERT(!isExecutingScript()); 1060 ASSERT(!isExecutingScript());
1065 ASSERT(!isWaitingForScripts()); 1061 ASSERT(!isWaitingForScripts());
1066 1062
1067 if (m_haveBackgroundParser) { 1063 if (m_haveBackgroundParser) {
1068 if (m_lastChunkBeforeScript) { 1064 validateSpeculations(std::move(m_lastChunkBeforeScript));
1069 validateSpeculations(std::move(m_lastChunkBeforeScript)); 1065 ASSERT(!m_lastChunkBeforeScript);
1070 DCHECK(!m_lastChunkBeforeScript); 1066 pumpPendingSpeculations();
1071 pumpPendingSpeculations();
1072 }
1073 return; 1067 return;
1074 } 1068 }
1075 1069
1076 m_insertionPreloadScanner.reset(); 1070 m_insertionPreloadScanner.reset();
1077 pumpTokenizerIfPossible(); 1071 pumpTokenizerIfPossible();
1078 endIfDelayed(); 1072 endIfDelayed();
1079 } 1073 }
1080 1074
1081 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() { 1075 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() {
1082 ASSERT(m_preloadScanner); 1076 ASSERT(m_preloadScanner);
(...skipping 14 matching lines...) Expand all
1097 attemptToRunDeferredScriptsAndEnd(); 1091 attemptToRunDeferredScriptsAndEnd();
1098 return; 1092 return;
1099 } 1093 }
1100 1094
1101 m_scriptRunner->executeScriptsWaitingForLoad(cachedResource); 1095 m_scriptRunner->executeScriptsWaitingForLoad(cachedResource);
1102 if (!isWaitingForScripts()) 1096 if (!isWaitingForScripts())
1103 resumeParsingAfterScriptExecution(); 1097 resumeParsingAfterScriptExecution();
1104 } 1098 }
1105 1099
1106 void HTMLDocumentParser::executeScriptsWaitingForResources() { 1100 void HTMLDocumentParser::executeScriptsWaitingForResources() {
1107 DCHECK(document()->isScriptExecutionReady());
1108
1109 // Document only calls this when the Document owns the DocumentParser so this 1101 // Document only calls this when the Document owns the DocumentParser so this
1110 // will not be called in the DocumentFragment case. 1102 // will not be called in the DocumentFragment case.
1111 DCHECK(m_scriptRunner); 1103 ASSERT(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())
1108 return;
1112 m_scriptRunner->executeScriptsWaitingForResources(); 1109 m_scriptRunner->executeScriptsWaitingForResources();
1113 if (!isWaitingForScripts()) 1110 if (!isWaitingForScripts())
1114 resumeParsingAfterScriptExecution(); 1111 resumeParsingAfterScriptExecution();
1115 } 1112 }
1116 1113
1117 void HTMLDocumentParser::parseDocumentFragment( 1114 void HTMLDocumentParser::parseDocumentFragment(
1118 const String& source, 1115 const String& source,
1119 DocumentFragment* fragment, 1116 DocumentFragment* fragment,
1120 Element* contextElement, 1117 Element* contextElement,
1121 ParserContentPolicy parserContentPolicy) { 1118 ParserContentPolicy parserContentPolicy) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 case Asynchronous: 1300 case Asynchronous:
1304 m_loadingTaskRunner->postTask( 1301 m_loadingTaskRunner->postTask(
1305 BLINK_FROM_HERE, 1302 BLINK_FROM_HERE,
1306 WTF::bind(function, std::forward<Ps>(parameters)...)); 1303 WTF::bind(function, std::forward<Ps>(parameters)...));
1307 return; 1304 return;
1308 } 1305 }
1309 NOTREACHED(); 1306 NOTREACHED();
1310 } 1307 }
1311 1308
1312 } // namespace blink 1309 } // 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