| OLD | NEW |
| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 return true; | 281 return true; |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool ScriptLoader::fetchScript(const String& sourceUrl, FetchRequest::DeferOptio
n defer) | 284 bool ScriptLoader::fetchScript(const String& sourceUrl, FetchRequest::DeferOptio
n defer) |
| 285 { | 285 { |
| 286 ASSERT(m_element); | 286 ASSERT(m_element); |
| 287 | 287 |
| 288 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 288 RawPtr<Document> elementDocument(m_element->document()); |
| 289 if (!m_element->inDocument() || m_element->document() != elementDocument) | 289 if (!m_element->inDocument() || m_element->document() != elementDocument) |
| 290 return false; | 290 return false; |
| 291 | 291 |
| 292 ASSERT(!m_resource); | 292 ASSERT(!m_resource); |
| 293 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { | 293 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { |
| 294 FetchRequest request(ResourceRequest(elementDocument->completeURL(source
Url)), m_element->localName()); | 294 FetchRequest request(ResourceRequest(elementDocument->completeURL(source
Url)), m_element->localName()); |
| 295 | 295 |
| 296 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_elem
ent->fastGetAttribute(HTMLNames::crossoriginAttr)); | 296 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_elem
ent->fastGetAttribute(HTMLNames::crossoriginAttr)); |
| 297 if (crossOrigin != CrossOriginAttributeNotSet) | 297 if (crossOrigin != CrossOriginAttributeNotSet) |
| 298 request.setCrossOriginAccessControl(elementDocument->getSecurityOrig
in(), crossOrigin); | 298 request.setCrossOriginAccessControl(elementDocument->getSecurityOrig
in(), crossOrigin); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 UseCounter::count(frame, feature); | 357 UseCounter::count(frame, feature); |
| 358 } | 358 } |
| 359 | 359 |
| 360 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com
pilationFinishTime) | 360 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com
pilationFinishTime) |
| 361 { | 361 { |
| 362 ASSERT(m_alreadyStarted); | 362 ASSERT(m_alreadyStarted); |
| 363 | 363 |
| 364 if (sourceCode.isEmpty()) | 364 if (sourceCode.isEmpty()) |
| 365 return true; | 365 return true; |
| 366 | 366 |
| 367 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 367 RawPtr<Document> elementDocument(m_element->document()); |
| 368 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum
ent().get(); | 368 RawPtr<Document> contextDocument = elementDocument->contextDocument().get(); |
| 369 if (!contextDocument) | 369 if (!contextDocument) |
| 370 return true; | 370 return true; |
| 371 | 371 |
| 372 LocalFrame* frame = contextDocument->frame(); | 372 LocalFrame* frame = contextDocument->frame(); |
| 373 | 373 |
| 374 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); | 374 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); |
| 375 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo
rldCSP()) | 375 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo
rldCSP()) |
| 376 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc
eAttr)) | 376 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc
eAttr)) |
| 377 || csp->allowScriptWithHash(sourceCode.source().toString()) | 377 || csp->allowScriptWithHash(sourceCode.source().toString()) |
| 378 || (!isParserInserted() && csp->allowDynamic()); | 378 || (!isParserInserted() && csp->allowDynamic()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 return true; | 440 return true; |
| 441 } | 441 } |
| 442 | 442 |
| 443 void ScriptLoader::execute() | 443 void ScriptLoader::execute() |
| 444 { | 444 { |
| 445 ASSERT(!m_willBeParserExecuted); | 445 ASSERT(!m_willBeParserExecuted); |
| 446 ASSERT(m_pendingScript->resource()); | 446 ASSERT(m_pendingScript->resource()); |
| 447 bool errorOccurred = false; | 447 bool errorOccurred = false; |
| 448 ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred); | 448 ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred); |
| 449 RefPtrWillBeRawPtr<Element> element = m_pendingScript->releaseElementAndClea
r(); | 449 RawPtr<Element> element = m_pendingScript->releaseElementAndClear(); |
| 450 ALLOW_UNUSED_LOCAL(element); | 450 ALLOW_UNUSED_LOCAL(element); |
| 451 if (errorOccurred) { | 451 if (errorOccurred) { |
| 452 dispatchErrorEvent(); | 452 dispatchErrorEvent(); |
| 453 } else if (!m_resource->wasCanceled()) { | 453 } else if (!m_resource->wasCanceled()) { |
| 454 if (executeScript(source)) | 454 if (executeScript(source)) |
| 455 dispatchLoadEvent(); | 455 dispatchLoadEvent(); |
| 456 else | 456 else |
| 457 dispatchErrorEvent(); | 457 dispatchErrorEvent(); |
| 458 } | 458 } |
| 459 m_resource = nullptr; | 459 m_resource = nullptr; |
| 460 } | 460 } |
| 461 | 461 |
| 462 void ScriptLoader::notifyFinished(Resource* resource) | 462 void ScriptLoader::notifyFinished(Resource* resource) |
| 463 { | 463 { |
| 464 ASSERT(!m_willBeParserExecuted); | 464 ASSERT(!m_willBeParserExecuted); |
| 465 | 465 |
| 466 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 466 RawPtr<Document> elementDocument(m_element->document()); |
| 467 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum
ent().get(); | 467 RawPtr<Document> contextDocument = elementDocument->contextDocument().get(); |
| 468 if (!contextDocument) | 468 if (!contextDocument) |
| 469 return; | 469 return; |
| 470 | 470 |
| 471 ASSERT_UNUSED(resource, resource == m_resource); | 471 ASSERT_UNUSED(resource, resource == m_resource); |
| 472 | 472 |
| 473 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner::
IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION; | 473 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner::
IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION; |
| 474 if (m_resource->errorOccurred()) { | 474 if (m_resource->errorOccurred()) { |
| 475 contextDocument->scriptRunner()->notifyScriptLoadError(this, runOrder); | 475 contextDocument->scriptRunner()->notifyScriptLoadError(this, runOrder); |
| 476 dispatchErrorEvent(); | 476 dispatchErrorEvent(); |
| 477 detach(); | 477 detach(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 if (isHTMLScriptLoader(element)) | 522 if (isHTMLScriptLoader(element)) |
| 523 return toHTMLScriptElement(element)->loader(); | 523 return toHTMLScriptElement(element)->loader(); |
| 524 | 524 |
| 525 if (isSVGScriptLoader(element)) | 525 if (isSVGScriptLoader(element)) |
| 526 return toSVGScriptElement(element)->loader(); | 526 return toSVGScriptElement(element)->loader(); |
| 527 | 527 |
| 528 return 0; | 528 return 0; |
| 529 } | 529 } |
| 530 | 530 |
| 531 } // namespace blink | 531 } // namespace blink |
| OLD | NEW |