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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 void HTMLScriptRunner::detach() 152 void HTMLScriptRunner::detach()
153 { 153 {
154 if (!m_document) 154 if (!m_document)
155 return; 155 return;
156 156
157 m_parserBlockingScript->stopWatchingForLoad(); 157 m_parserBlockingScript->stopWatchingForLoad();
158 m_parserBlockingScript->releaseElementAndClear(); 158 m_parserBlockingScript->releaseElementAndClear();
159 159
160 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { 160 while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
161 OwnPtrWillBeRawPtr<PendingScript> pendingScript = m_scriptsToExecuteAfte rParsing.takeFirst(); 161 RawPtr<PendingScript> pendingScript = m_scriptsToExecuteAfterParsing.tak eFirst();
162 pendingScript->stopWatchingForLoad(); 162 pendingScript->stopWatchingForLoad();
163 pendingScript->releaseElementAndClear(); 163 pendingScript->releaseElementAndClear();
164 } 164 }
165 m_document = nullptr; 165 m_document = nullptr;
166 } 166 }
167 167
168 bool HTMLScriptRunner::isPendingScriptReady(const PendingScript* script) 168 bool HTMLScriptRunner::isPendingScriptReady(const PendingScript* script)
169 { 169 {
170 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionReady(); 170 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionReady();
171 if (m_hasScriptsWaitingForResources) 171 if (m_hasScriptsWaitingForResources)
(...skipping 25 matching lines...) Expand all
197 if (pendingScriptType == ScriptStreamer::ParsingBlocking) { 197 if (pendingScriptType == ScriptStreamer::ParsingBlocking) {
198 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionRead y(); 198 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionRead y();
199 // The parser cannot be unblocked as a microtask requested another r esource 199 // The parser cannot be unblocked as a microtask requested another r esource
200 if (m_hasScriptsWaitingForResources) 200 if (m_hasScriptsWaitingForResources)
201 return; 201 return;
202 } 202 }
203 } 203 }
204 204
205 TextPosition scriptStartPosition = pendingScript->startingPosition(); 205 TextPosition scriptStartPosition = pendingScript->startingPosition();
206 // Clear the pending script before possible re-entrancy from executeScript() 206 // Clear the pending script before possible re-entrancy from executeScript()
207 RefPtrWillBeRawPtr<Element> element = pendingScript->releaseElementAndClear( ); 207 RawPtr<Element> element = pendingScript->releaseElementAndClear();
208 if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element.get())) { 208 if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element.get())) {
209 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); 209 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
210 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem enter(m_document); 210 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem enter(m_document);
211 if (errorOccurred) { 211 if (errorOccurred) {
212 TRACE_EVENT_WITH_FLOW1("blink", "HTMLScriptRunner ExecuteScriptFaile d", element.get(), TRACE_EVENT_FLAG_FLOW_IN, 212 TRACE_EVENT_WITH_FLOW1("blink", "HTMLScriptRunner ExecuteScriptFaile d", element.get(), TRACE_EVENT_FLAG_FLOW_IN,
213 "data", getTraceArgsForScriptElement(element.get(), scriptStartP osition)); 213 "data", getTraceArgsForScriptElement(element.get(), scriptStartP osition));
214 scriptLoader->dispatchErrorEvent(); 214 scriptLoader->dispatchErrorEvent();
215 } else { 215 } else {
216 ASSERT(isExecutingScript()); 216 ASSERT(isExecutingScript());
217 if (!doExecuteScript(element.get(), sourceCode, scriptStartPosition) ) { 217 if (!doExecuteScript(element.get(), sourceCode, scriptStartPosition) ) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (isExecutingScript() && cachedResource->wasCanceled()) { 252 if (isExecutingScript() && cachedResource->wasCanceled()) {
253 stopWatchingResourceForLoad(cachedResource); 253 stopWatchingResourceForLoad(cachedResource);
254 return; 254 return;
255 } 255 }
256 m_host->notifyScriptLoaded(cachedResource); 256 m_host->notifyScriptLoaded(cachedResource);
257 } 257 }
258 258
259 // Implements the steps for 'An end tag whose tag name is "script"' 259 // Implements the steps for 'An end tag whose tag name is "script"'
260 // http://whatwg.org/html#scriptEndTag 260 // http://whatwg.org/html#scriptEndTag
261 // Script handling lives outside the tree builder to keep each class simple. 261 // Script handling lives outside the tree builder to keep each class simple.
262 void HTMLScriptRunner::execute(PassRefPtrWillBeRawPtr<Element> scriptElement, co nst TextPosition& scriptStartPosition) 262 void HTMLScriptRunner::execute(RawPtr<Element> scriptElement, const TextPosition & scriptStartPosition)
263 { 263 {
264 ASSERT(scriptElement); 264 ASSERT(scriptElement);
265 TRACE_EVENT1("blink", "HTMLScriptRunner::execute", 265 TRACE_EVENT1("blink", "HTMLScriptRunner::execute",
266 "data", getTraceArgsForScriptElement(scriptElement.get(), scriptStartPos ition)); 266 "data", getTraceArgsForScriptElement(scriptElement.get(), scriptStartPos ition));
267 // FIXME: If scripting is disabled, always just return. 267 // FIXME: If scripting is disabled, always just return.
268 268
269 bool hadPreloadScanner = m_host->hasPreloadScanner(); 269 bool hadPreloadScanner = m_host->hasPreloadScanner();
270 270
271 // Try to execute the script given to us. 271 // Try to execute the script given to us.
272 runScript(scriptElement.get(), scriptStartPosition); 272 runScript(scriptElement.get(), scriptStartPosition);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 TRACE_EVENT0("blink", "HTMLScriptRunner::executeScriptsWaitingForParsing"); 322 TRACE_EVENT0("blink", "HTMLScriptRunner::executeScriptsWaitingForParsing");
323 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { 323 while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
324 ASSERT(!isExecutingScript()); 324 ASSERT(!isExecutingScript());
325 ASSERT(!hasParserBlockingScript()); 325 ASSERT(!hasParserBlockingScript());
326 ASSERT(m_scriptsToExecuteAfterParsing.first()->resource()); 326 ASSERT(m_scriptsToExecuteAfterParsing.first()->resource());
327 if (!m_scriptsToExecuteAfterParsing.first()->isReady()) { 327 if (!m_scriptsToExecuteAfterParsing.first()->isReady()) {
328 m_scriptsToExecuteAfterParsing.first()->watchForLoad(this); 328 m_scriptsToExecuteAfterParsing.first()->watchForLoad(this);
329 traceParserBlockingScript(m_scriptsToExecuteAfterParsing.first().get (), !m_document->isScriptExecutionReady()); 329 traceParserBlockingScript(m_scriptsToExecuteAfterParsing.first().get (), !m_document->isScriptExecutionReady());
330 return false; 330 return false;
331 } 331 }
332 OwnPtrWillBeRawPtr<PendingScript> first = m_scriptsToExecuteAfterParsing .takeFirst(); 332 RawPtr<PendingScript> first = m_scriptsToExecuteAfterParsing.takeFirst() ;
333 executePendingScriptAndDispatchEvent(first.get(), ScriptStreamer::Deferr ed); 333 executePendingScriptAndDispatchEvent(first.get(), ScriptStreamer::Deferr ed);
334 // FIXME: What is this m_document check for? 334 // FIXME: What is this m_document check for?
335 if (!m_document) 335 if (!m_document)
336 return false; 336 return false;
337 } 337 }
338 return true; 338 return true;
339 } 339 }
340 340
341 void HTMLScriptRunner::requestParsingBlockingScript(Element* element) 341 void HTMLScriptRunner::requestParsingBlockingScript(Element* element)
342 { 342 {
(...skipping 11 matching lines...) Expand all
354 if (scriptState) 354 if (scriptState)
355 ScriptStreamer::startStreaming(m_parserBlockingScript.get(), Scr iptStreamer::ParsingBlocking, m_document->frame()->settings(), scriptState, m_do cument->loadingTaskRunner()); 355 ScriptStreamer::startStreaming(m_parserBlockingScript.get(), Scr iptStreamer::ParsingBlocking, m_document->frame()->settings(), scriptState, m_do cument->loadingTaskRunner());
356 } 356 }
357 357
358 m_parserBlockingScript->watchForLoad(this); 358 m_parserBlockingScript->watchForLoad(this);
359 } 359 }
360 } 360 }
361 361
362 void HTMLScriptRunner::requestDeferredScript(Element* element) 362 void HTMLScriptRunner::requestDeferredScript(Element* element)
363 { 363 {
364 OwnPtrWillBeRawPtr<PendingScript> pendingScript = PendingScript::create(null ptr, nullptr); 364 RawPtr<PendingScript> pendingScript = PendingScript::create(nullptr, nullptr );
365 if (!requestPendingScript(pendingScript.get(), element)) 365 if (!requestPendingScript(pendingScript.get(), element))
366 return; 366 return;
367 367
368 if (m_document->frame() && !pendingScript->isReady()) { 368 if (m_document->frame() && !pendingScript->isReady()) {
369 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame() ); 369 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame() );
370 if (scriptState) 370 if (scriptState)
371 ScriptStreamer::startStreaming(pendingScript.get(), ScriptStreamer:: Deferred, m_document->frame()->settings(), scriptState, m_document->loadingTaskR unner()); 371 ScriptStreamer::startStreaming(pendingScript.get(), ScriptStreamer:: Deferred, m_document->frame()->settings(), scriptState, m_document->loadingTaskR unner());
372 } 372 }
373 373
374 ASSERT(pendingScript->resource()); 374 ASSERT(pendingScript->resource());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 DEFINE_TRACE(HTMLScriptRunner) 440 DEFINE_TRACE(HTMLScriptRunner)
441 { 441 {
442 visitor->trace(m_document); 442 visitor->trace(m_document);
443 visitor->trace(m_host); 443 visitor->trace(m_host);
444 visitor->trace(m_parserBlockingScript); 444 visitor->trace(m_parserBlockingScript);
445 visitor->trace(m_scriptsToExecuteAfterParsing); 445 visitor->trace(m_scriptsToExecuteAfterParsing);
446 } 446 }
447 447
448 } // namespace blink 448 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698