| 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 | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // document. | 240 // document. |
| 241 Document& elementDocument = m_element->document(); | 241 Document& elementDocument = m_element->document(); |
| 242 Document* contextDocument = elementDocument.contextDocument(); | 242 Document* contextDocument = elementDocument.contextDocument(); |
| 243 | 243 |
| 244 if (!contextDocument || !contextDocument->allowExecutingScripts(m_element)) | 244 if (!contextDocument || !contextDocument->allowExecutingScripts(m_element)) |
| 245 return false; | 245 return false; |
| 246 | 246 |
| 247 if (!isScriptForEventSupported()) | 247 if (!isScriptForEventSupported()) |
| 248 return false; | 248 return false; |
| 249 | 249 |
| 250 String encoding; |
| 250 if (!client->charsetAttributeValue().isEmpty()) | 251 if (!client->charsetAttributeValue().isEmpty()) |
| 251 m_characterEncoding = client->charsetAttributeValue(); | 252 encoding = client->charsetAttributeValue(); |
| 252 else | 253 else |
| 253 m_characterEncoding = elementDocument.characterSet(); | 254 encoding = elementDocument.characterSet(); |
| 254 | 255 |
| 255 if (client->hasSourceAttribute()) { | 256 if (client->hasSourceAttribute()) { |
| 256 FetchRequest::DeferOption defer = FetchRequest::NoDefer; | 257 FetchRequest::DeferOption defer = FetchRequest::NoDefer; |
| 257 if (!m_parserInserted || client->asyncAttributeValue() || | 258 if (!m_parserInserted || client->asyncAttributeValue() || |
| 258 client->deferAttributeValue()) | 259 client->deferAttributeValue()) |
| 259 defer = FetchRequest::LazyLoad; | 260 defer = FetchRequest::LazyLoad; |
| 260 if (m_documentWriteIntervention == | 261 if (m_documentWriteIntervention == |
| 261 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) | 262 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) |
| 262 defer = FetchRequest::IdleLoad; | 263 defer = FetchRequest::IdleLoad; |
| 263 if (!fetchScript(client->sourceAttributeValue(), defer)) | 264 if (!fetchScript(client->sourceAttributeValue(), encoding, defer)) |
| 264 return false; | 265 return false; |
| 265 } | 266 } |
| 266 | 267 |
| 267 // Since the asynchronous, low priority fetch for doc.written blocked | 268 // Since the asynchronous, low priority fetch for doc.written blocked |
| 268 // script is not for execution, return early from here. Watch for its | 269 // script is not for execution, return early from here. Watch for its |
| 269 // completion to be able to remove it from the memory cache. | 270 // completion to be able to remove it from the memory cache. |
| 270 if (m_documentWriteIntervention == | 271 if (m_documentWriteIntervention == |
| 271 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) { | 272 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) { |
| 272 m_pendingScript = PendingScript::create(m_element, m_resource.get()); | 273 m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
| 273 m_pendingScript->watchForLoad(this); | 274 m_pendingScript->watchForLoad(this); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 ScriptSourceCode(scriptContent(), scriptURL, position))) { | 321 ScriptSourceCode(scriptContent(), scriptURL, position))) { |
| 321 dispatchErrorEvent(); | 322 dispatchErrorEvent(); |
| 322 return false; | 323 return false; |
| 323 } | 324 } |
| 324 } | 325 } |
| 325 | 326 |
| 326 return true; | 327 return true; |
| 327 } | 328 } |
| 328 | 329 |
| 329 bool ScriptLoader::fetchScript(const String& sourceUrl, | 330 bool ScriptLoader::fetchScript(const String& sourceUrl, |
| 331 const String& encoding, |
| 330 FetchRequest::DeferOption defer) { | 332 FetchRequest::DeferOption defer) { |
| 331 DCHECK(m_element); | 333 DCHECK(m_element); |
| 332 | 334 |
| 333 Document* elementDocument = &(m_element->document()); | 335 Document* elementDocument = &(m_element->document()); |
| 334 if (!m_element->isConnected() || m_element->document() != elementDocument) | 336 if (!m_element->isConnected() || m_element->document() != elementDocument) |
| 335 return false; | 337 return false; |
| 336 | 338 |
| 337 DCHECK(!m_resource); | 339 DCHECK(!m_resource); |
| 338 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { | 340 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { |
| 339 FetchRequest request( | 341 FetchRequest request( |
| 340 ResourceRequest(elementDocument->completeURL(sourceUrl)), | 342 ResourceRequest(elementDocument->completeURL(sourceUrl)), |
| 341 m_element->localName()); | 343 m_element->localName()); |
| 342 | 344 |
| 343 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue( | 345 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue( |
| 344 m_element->fastGetAttribute(HTMLNames::crossoriginAttr)); | 346 m_element->fastGetAttribute(HTMLNames::crossoriginAttr)); |
| 345 if (crossOrigin != CrossOriginAttributeNotSet) | 347 if (crossOrigin != CrossOriginAttributeNotSet) |
| 346 request.setCrossOriginAccessControl(elementDocument->getSecurityOrigin(), | 348 request.setCrossOriginAccessControl(elementDocument->getSecurityOrigin(), |
| 347 crossOrigin); | 349 crossOrigin); |
| 348 request.setCharset(scriptCharset()); | 350 request.setCharset(encoding); |
| 349 | 351 |
| 350 if (ContentSecurityPolicy::isNonceableElement(m_element.get())) | 352 if (ContentSecurityPolicy::isNonceableElement(m_element.get())) |
| 351 request.setContentSecurityPolicyNonce(client()->nonce()); | 353 request.setContentSecurityPolicyNonce(client()->nonce()); |
| 352 | 354 |
| 353 request.setParserDisposition(isParserInserted() ? ParserInserted | 355 request.setParserDisposition(isParserInserted() ? ParserInserted |
| 354 : NotParserInserted); | 356 : NotParserInserted); |
| 355 | 357 |
| 356 request.setDefer(defer); | 358 request.setDefer(defer); |
| 357 | 359 |
| 358 String integrityAttr = | 360 String integrityAttr = |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 if (isHTMLScriptLoader(element)) | 644 if (isHTMLScriptLoader(element)) |
| 643 return toHTMLScriptElement(element)->loader(); | 645 return toHTMLScriptElement(element)->loader(); |
| 644 | 646 |
| 645 if (isSVGScriptLoader(element)) | 647 if (isSVGScriptLoader(element)) |
| 646 return toSVGScriptElement(element)->loader(); | 648 return toSVGScriptElement(element)->loader(); |
| 647 | 649 |
| 648 return 0; | 650 return 0; |
| 649 } | 651 } |
| 650 | 652 |
| 651 } // namespace blink | 653 } // namespace blink |
| OLD | NEW |