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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.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, 10 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 } 277 }
278 278
279 return true; 279 return true;
280 } 280 }
281 281
282 bool ScriptLoader::fetchScript(const String& sourceUrl, FetchRequest::DeferOptio n defer) 282 bool ScriptLoader::fetchScript(const String& sourceUrl, FetchRequest::DeferOptio n defer)
283 { 283 {
284 ASSERT(m_element); 284 ASSERT(m_element);
285 285
286 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); 286 RawPtr<Document> elementDocument(m_element->document());
287 if (!m_element->inDocument() || m_element->document() != elementDocument) 287 if (!m_element->inDocument() || m_element->document() != elementDocument)
288 return false; 288 return false;
289 289
290 ASSERT(!m_resource); 290 ASSERT(!m_resource);
291 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { 291 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) {
292 FetchRequest request(ResourceRequest(elementDocument->completeURL(source Url)), m_element->localName()); 292 FetchRequest request(ResourceRequest(elementDocument->completeURL(source Url)), m_element->localName());
293 293
294 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_elem ent->fastGetAttribute(HTMLNames::crossoriginAttr)); 294 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_elem ent->fastGetAttribute(HTMLNames::crossoriginAttr));
295 if (crossOrigin != CrossOriginAttributeNotSet) 295 if (crossOrigin != CrossOriginAttributeNotSet)
296 request.setCrossOriginAccessControl(elementDocument->securityOrigin( ), crossOrigin); 296 request.setCrossOriginAccessControl(elementDocument->securityOrigin( ), crossOrigin);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 UseCounter::count(frame, feature); 348 UseCounter::count(frame, feature);
349 } 349 }
350 350
351 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com pilationFinishTime) 351 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com pilationFinishTime)
352 { 352 {
353 ASSERT(m_alreadyStarted); 353 ASSERT(m_alreadyStarted);
354 354
355 if (sourceCode.isEmpty()) 355 if (sourceCode.isEmpty())
356 return true; 356 return true;
357 357
358 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); 358 RawPtr<Document> elementDocument(m_element->document());
359 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); 359 RawPtr<Document> contextDocument = elementDocument->contextDocument().get();
360 if (!contextDocument) 360 if (!contextDocument)
361 return true; 361 return true;
362 362
363 LocalFrame* frame = contextDocument->frame(); 363 LocalFrame* frame = contextDocument->frame();
364 364
365 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); 365 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy();
366 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo rldCSP()) 366 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo rldCSP())
367 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc eAttr)) 367 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc eAttr))
368 || csp->allowScriptWithHash(sourceCode.source().toString()) 368 || csp->allowScriptWithHash(sourceCode.source().toString())
369 || (!isParserInserted() && csp->allowDynamic()); 369 || (!isParserInserted() && csp->allowDynamic());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 return true; 431 return true;
432 } 432 }
433 433
434 void ScriptLoader::execute() 434 void ScriptLoader::execute()
435 { 435 {
436 ASSERT(!m_willBeParserExecuted); 436 ASSERT(!m_willBeParserExecuted);
437 ASSERT(m_pendingScript->resource()); 437 ASSERT(m_pendingScript->resource());
438 bool errorOccurred = false; 438 bool errorOccurred = false;
439 ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred); 439 ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred);
440 RefPtrWillBeRawPtr<Element> element = m_pendingScript->releaseElementAndClea r(); 440 RawPtr<Element> element = m_pendingScript->releaseElementAndClear();
441 ALLOW_UNUSED_LOCAL(element); 441 ALLOW_UNUSED_LOCAL(element);
442 if (errorOccurred) { 442 if (errorOccurred) {
443 dispatchErrorEvent(); 443 dispatchErrorEvent();
444 } else if (!m_resource->wasCanceled()) { 444 } else if (!m_resource->wasCanceled()) {
445 if (executeScript(source)) 445 if (executeScript(source))
446 dispatchLoadEvent(); 446 dispatchLoadEvent();
447 else 447 else
448 dispatchErrorEvent(); 448 dispatchErrorEvent();
449 } 449 }
450 m_resource = nullptr; 450 m_resource = nullptr;
451 } 451 }
452 452
453 void ScriptLoader::notifyFinished(Resource* resource) 453 void ScriptLoader::notifyFinished(Resource* resource)
454 { 454 {
455 ASSERT(!m_willBeParserExecuted); 455 ASSERT(!m_willBeParserExecuted);
456 456
457 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); 457 RawPtr<Document> elementDocument(m_element->document());
458 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); 458 RawPtr<Document> contextDocument = elementDocument->contextDocument().get();
459 if (!contextDocument) 459 if (!contextDocument)
460 return; 460 return;
461 461
462 ASSERT_UNUSED(resource, resource == m_resource); 462 ASSERT_UNUSED(resource, resource == m_resource);
463 463
464 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner:: IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION; 464 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner:: IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION;
465 if (m_resource->errorOccurred()) { 465 if (m_resource->errorOccurred()) {
466 dispatchErrorEvent(); 466 dispatchErrorEvent();
467 // The error handler can move the HTMLScriptElement to a new document. 467 // The error handler can move the HTMLScriptElement to a new document.
468 // In that case, we must notify the ScriptRunner of the new document, 468 // In that case, we must notify the ScriptRunner of the new document,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 if (isHTMLScriptLoader(element)) 518 if (isHTMLScriptLoader(element))
519 return toHTMLScriptElement(element)->loader(); 519 return toHTMLScriptElement(element)->loader();
520 520
521 if (isSVGScriptLoader(element)) 521 if (isSVGScriptLoader(element))
522 return toSVGScriptElement(element)->loader(); 522 return toSVGScriptElement(element)->loader();
523 523
524 return 0; 524 return 0;
525 } 525 }
526 526
527 } // namespace blink 527 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698