| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 if (!isScriptForEventSupported()) | 211 if (!isScriptForEventSupported()) |
| 212 return false; | 212 return false; |
| 213 | 213 |
| 214 if (!client->charsetAttributeValue().isEmpty()) | 214 if (!client->charsetAttributeValue().isEmpty()) |
| 215 m_characterEncoding = client->charsetAttributeValue(); | 215 m_characterEncoding = client->charsetAttributeValue(); |
| 216 else | 216 else |
| 217 m_characterEncoding = elementDocument.charset(); | 217 m_characterEncoding = elementDocument.charset(); |
| 218 | 218 |
| 219 if (client->hasSourceAttribute()) { | 219 if (client->hasSourceAttribute()) { |
| 220 if (!fetchScript(client->sourceAttributeValue())) | 220 FetchRequest::DeferOption defer = FetchRequest::NoDefer; |
| 221 if (!m_parserInserted || client->asyncAttributeValue() || client->deferA
ttributeValue()) |
| 222 defer = FetchRequest::LazyLoad; |
| 223 if (!fetchScript(client->sourceAttributeValue(), defer)) |
| 221 return false; | 224 return false; |
| 222 } | 225 } |
| 223 | 226 |
| 224 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse
rInserted && !client->asyncAttributeValue()) { | 227 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse
rInserted && !client->asyncAttributeValue()) { |
| 225 m_willExecuteWhenDocumentFinishedParsing = true; | 228 m_willExecuteWhenDocumentFinishedParsing = true; |
| 226 m_willBeParserExecuted = true; | 229 m_willBeParserExecuted = true; |
| 227 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn
cAttributeValue()) { | 230 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn
cAttributeValue()) { |
| 228 m_willBeParserExecuted = true; | 231 m_willBeParserExecuted = true; |
| 229 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu
ment.isRenderingReady()) { | 232 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu
ment.isRenderingReady()) { |
| 230 m_willBeParserExecuted = true; | 233 m_willBeParserExecuted = true; |
| 231 m_readyToBeParserExecuted = true; | 234 m_readyToBeParserExecuted = true; |
| 232 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() &&
!m_forceAsync) { | 235 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() &&
!m_forceAsync) { |
| 233 m_willExecuteInOrder = true; | 236 m_willExecuteInOrder = true; |
| 234 contextDocument->scriptRunner()->queueScriptForExecution(this, m_resourc
e, ScriptRunner::IN_ORDER_EXECUTION); | 237 contextDocument->scriptRunner()->queueScriptForExecution(this, m_resourc
e, ScriptRunner::IN_ORDER_EXECUTION); |
| 235 m_resource->addClient(this); | 238 m_resource->addClient(this); |
| 236 } else if (client->hasSourceAttribute()) { | 239 } else if (client->hasSourceAttribute()) { |
| 237 contextDocument->scriptRunner()->queueScriptForExecution(this, m_resourc
e, ScriptRunner::ASYNC_EXECUTION); | 240 contextDocument->scriptRunner()->queueScriptForExecution(this, m_resourc
e, ScriptRunner::ASYNC_EXECUTION); |
| 238 m_resource->addClient(this); | 241 m_resource->addClient(this); |
| 239 } else { | 242 } else { |
| 240 // Reset line numbering for nested writes. | 243 // Reset line numbering for nested writes. |
| 241 TextPosition position = elementDocument.isInDocumentWrite() ? TextPositi
on() : scriptStartPosition; | 244 TextPosition position = elementDocument.isInDocumentWrite() ? TextPositi
on() : scriptStartPosition; |
| 242 KURL scriptURL = (!elementDocument.isInDocumentWrite() && m_parserInsert
ed) ? elementDocument.url() : KURL(); | 245 KURL scriptURL = (!elementDocument.isInDocumentWrite() && m_parserInsert
ed) ? elementDocument.url() : KURL(); |
| 243 executeScript(ScriptSourceCode(scriptContent(), scriptURL, position)); | 246 executeScript(ScriptSourceCode(scriptContent(), scriptURL, position)); |
| 244 } | 247 } |
| 245 | 248 |
| 246 return true; | 249 return true; |
| 247 } | 250 } |
| 248 | 251 |
| 249 bool ScriptLoader::fetchScript(const String& sourceUrl) | 252 bool ScriptLoader::fetchScript(const String& sourceUrl, FetchRequest::DeferOptio
n defer) |
| 250 { | 253 { |
| 251 ASSERT(m_element); | 254 ASSERT(m_element); |
| 252 | 255 |
| 253 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 256 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); |
| 254 if (!m_element->inDocument() || m_element->document() != elementDocument) | 257 if (!m_element->inDocument() || m_element->document() != elementDocument) |
| 255 return false; | 258 return false; |
| 256 | 259 |
| 257 ASSERT(!m_resource); | 260 ASSERT(!m_resource); |
| 258 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { | 261 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { |
| 259 FetchRequest request(ResourceRequest(elementDocument->completeURL(source
Url)), m_element->localName()); | 262 FetchRequest request(ResourceRequest(elementDocument->completeURL(source
Url)), m_element->localName()); |
| 260 | 263 |
| 261 AtomicString crossOriginMode = m_element->fastGetAttribute(HTMLNames::cr
ossoriginAttr); | 264 AtomicString crossOriginMode = m_element->fastGetAttribute(HTMLNames::cr
ossoriginAttr); |
| 262 if (!crossOriginMode.isNull()) | 265 if (!crossOriginMode.isNull()) |
| 263 request.setCrossOriginAccessControl(elementDocument->securityOrigin(
), crossOriginMode); | 266 request.setCrossOriginAccessControl(elementDocument->securityOrigin(
), crossOriginMode); |
| 264 request.setCharset(scriptCharset()); | 267 request.setCharset(scriptCharset()); |
| 265 | 268 |
| 266 bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowSc
riptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)); | 269 bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowSc
riptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)); |
| 267 if (scriptPassesCSP) | 270 if (scriptPassesCSP) |
| 268 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); | 271 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); |
| 272 request.setDefer(defer); |
| 269 | 273 |
| 270 m_resource = elementDocument->fetcher()->fetchScript(request); | 274 m_resource = elementDocument->fetcher()->fetchScript(request); |
| 271 m_isExternalScript = true; | 275 m_isExternalScript = true; |
| 272 } | 276 } |
| 273 | 277 |
| 274 if (m_resource) | 278 if (m_resource) |
| 275 return true; | 279 return true; |
| 276 | 280 |
| 277 dispatchErrorEvent(); | 281 dispatchErrorEvent(); |
| 278 return false; | 282 return false; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 if (isHTMLScriptLoader(element)) | 446 if (isHTMLScriptLoader(element)) |
| 443 return toHTMLScriptElement(element)->loader(); | 447 return toHTMLScriptElement(element)->loader(); |
| 444 | 448 |
| 445 if (isSVGScriptLoader(element)) | 449 if (isSVGScriptLoader(element)) |
| 446 return toSVGScriptElement(element)->loader(); | 450 return toSVGScriptElement(element)->loader(); |
| 447 | 451 |
| 448 return 0; | 452 return 0; |
| 449 } | 453 } |
| 450 | 454 |
| 451 } | 455 } |
| OLD | NEW |