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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 , m_resource(0) | 58 , m_resource(0) |
59 , m_startLineNumber(WTF::OrdinalNumber::beforeFirst()) | 59 , m_startLineNumber(WTF::OrdinalNumber::beforeFirst()) |
60 , m_parserInserted(parserInserted) | 60 , m_parserInserted(parserInserted) |
61 , m_isExternalScript(false) | 61 , m_isExternalScript(false) |
62 , m_alreadyStarted(alreadyStarted) | 62 , m_alreadyStarted(alreadyStarted) |
63 , m_haveFiredLoad(false) | 63 , m_haveFiredLoad(false) |
64 , m_willBeParserExecuted(false) | 64 , m_willBeParserExecuted(false) |
65 , m_readyToBeParserExecuted(false) | 65 , m_readyToBeParserExecuted(false) |
66 , m_willExecuteWhenDocumentFinishedParsing(false) | 66 , m_willExecuteWhenDocumentFinishedParsing(false) |
67 , m_forceAsync(!parserInserted) | 67 , m_forceAsync(!parserInserted) |
| 68 , m_hasAsyncAttribute(false) |
| 69 , m_hasDeferAttribute(false) |
68 , m_willExecuteInOrder(false) | 70 , m_willExecuteInOrder(false) |
69 { | 71 { |
70 ASSERT(m_element); | 72 ASSERT(m_element); |
71 if (parserInserted && element->document().scriptableDocumentParser() && !ele
ment->document().isInDocumentWrite()) | 73 if (parserInserted && element->document().scriptableDocumentParser() && !ele
ment->document().isInDocumentWrite()) |
72 m_startLineNumber = element->document().scriptableDocumentParser()->line
Number(); | 74 m_startLineNumber = element->document().scriptableDocumentParser()->line
Number(); |
73 } | 75 } |
74 | 76 |
75 ScriptLoader::~ScriptLoader() | 77 ScriptLoader::~ScriptLoader() |
76 { | 78 { |
77 stopLoadRequest(); | 79 stopLoadRequest(); |
(...skipping 15 matching lines...) Expand all Loading... |
93 { | 95 { |
94 if (ignoresLoadRequest() || sourceUrl.isEmpty()) | 96 if (ignoresLoadRequest() || sourceUrl.isEmpty()) |
95 return; | 97 return; |
96 | 98 |
97 prepareScript(); // FIXME: Provide a real starting line number here. | 99 prepareScript(); // FIXME: Provide a real starting line number here. |
98 } | 100 } |
99 | 101 |
100 void ScriptLoader::handleAsyncAttribute() | 102 void ScriptLoader::handleAsyncAttribute() |
101 { | 103 { |
102 m_forceAsync = false; | 104 m_forceAsync = false; |
| 105 m_hasAsyncAttribute = true; |
103 } | 106 } |
104 | 107 |
105 // Helper function | 108 // Helper function |
106 static bool isLegacySupportedJavaScriptLanguage(const String& language) | 109 static bool isLegacySupportedJavaScriptLanguage(const String& language) |
107 { | 110 { |
108 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts on
ly javascript1.1 - javascript1.3. | 111 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts on
ly javascript1.1 - javascript1.3. |
109 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. | 112 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. |
110 // WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. | 113 // WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. |
111 // Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. | 114 // Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. |
112 // We want to accept all the values that either of these browsers accept, bu
t not other values. | 115 // We want to accept all the values that either of these browsers accept, bu
t not other values. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (m_parserInserted) { | 180 if (m_parserInserted) { |
178 wasParserInserted = true; | 181 wasParserInserted = true; |
179 m_parserInserted = false; | 182 m_parserInserted = false; |
180 } else { | 183 } else { |
181 wasParserInserted = false; | 184 wasParserInserted = false; |
182 } | 185 } |
183 | 186 |
184 if (wasParserInserted && !client->asyncAttributeValue()) | 187 if (wasParserInserted && !client->asyncAttributeValue()) |
185 m_forceAsync = true; | 188 m_forceAsync = true; |
186 | 189 |
| 190 if (client->deferAttributeValue()) |
| 191 m_hasDeferAttribute = true; |
| 192 |
187 // FIXME: HTML5 spec says we should check that all children are either comme
nts or empty text nodes. | 193 // FIXME: HTML5 spec says we should check that all children are either comme
nts or empty text nodes. |
188 if (!client->hasSourceAttribute() && !m_element->hasChildren()) | 194 if (!client->hasSourceAttribute() && !m_element->hasChildren()) |
189 return false; | 195 return false; |
190 | 196 |
191 if (!m_element->inDocument()) | 197 if (!m_element->inDocument()) |
192 return false; | 198 return false; |
193 | 199 |
194 if (!isScriptTypeSupported(supportLegacyTypes)) | 200 if (!isScriptTypeSupported(supportLegacyTypes)) |
195 return false; | 201 return false; |
196 | 202 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 266 |
261 AtomicString crossOriginMode = m_element->fastGetAttribute(HTMLNames::cr
ossoriginAttr); | 267 AtomicString crossOriginMode = m_element->fastGetAttribute(HTMLNames::cr
ossoriginAttr); |
262 if (!crossOriginMode.isNull()) | 268 if (!crossOriginMode.isNull()) |
263 request.setCrossOriginAccessControl(elementDocument->securityOrigin(
), crossOriginMode); | 269 request.setCrossOriginAccessControl(elementDocument->securityOrigin(
), crossOriginMode); |
264 request.setCharset(scriptCharset()); | 270 request.setCharset(scriptCharset()); |
265 | 271 |
266 bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowSc
riptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)); | 272 bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowSc
riptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)); |
267 if (scriptPassesCSP) | 273 if (scriptPassesCSP) |
268 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); | 274 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); |
269 | 275 |
| 276 if (!m_parserInserted || m_hasAsyncAttribute || m_hasDeferAttribute) |
| 277 request.setExecAsync(true); |
| 278 |
270 m_resource = elementDocument->fetcher()->fetchScript(request); | 279 m_resource = elementDocument->fetcher()->fetchScript(request); |
271 m_isExternalScript = true; | 280 m_isExternalScript = true; |
272 } | 281 } |
273 | 282 |
274 if (m_resource) | 283 if (m_resource) |
275 return true; | 284 return true; |
276 | 285 |
277 dispatchErrorEvent(); | 286 dispatchErrorEvent(); |
278 return false; | 287 return false; |
279 } | 288 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (isHTMLScriptLoader(element)) | 451 if (isHTMLScriptLoader(element)) |
443 return toHTMLScriptElement(element)->loader(); | 452 return toHTMLScriptElement(element)->loader(); |
444 | 453 |
445 if (isSVGScriptLoader(element)) | 454 if (isSVGScriptLoader(element)) |
446 return toSVGScriptElement(element)->loader(); | 455 return toSVGScriptElement(element)->loader(); |
447 | 456 |
448 return 0; | 457 return 0; |
449 } | 458 } |
450 | 459 |
451 } | 460 } |
OLD | NEW |