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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 #include "public/platform/WebFrameScheduler.h" | 53 #include "public/platform/WebFrameScheduler.h" |
54 #include "wtf/StdLibExtras.h" | 54 #include "wtf/StdLibExtras.h" |
55 #include "wtf/text/StringBuilder.h" | 55 #include "wtf/text/StringBuilder.h" |
56 #include "wtf/text/StringHash.h" | 56 #include "wtf/text/StringHash.h" |
57 | 57 |
58 namespace blink { | 58 namespace blink { |
59 | 59 |
60 ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt arted) | 60 ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt arted) |
61 : m_element(element) | 61 : m_element(element) |
62 , m_resource(0) | 62 , m_resource(0) |
63 , m_originWorld(nullptr) | |
63 , m_startLineNumber(WTF::OrdinalNumber::beforeFirst()) | 64 , m_startLineNumber(WTF::OrdinalNumber::beforeFirst()) |
64 , m_parserInserted(parserInserted) | 65 , m_parserInserted(parserInserted) |
65 , m_isExternalScript(false) | 66 , m_isExternalScript(false) |
66 , m_alreadyStarted(alreadyStarted) | 67 , m_alreadyStarted(alreadyStarted) |
67 , m_haveFiredLoad(false) | 68 , m_haveFiredLoad(false) |
68 , m_willBeParserExecuted(false) | 69 , m_willBeParserExecuted(false) |
69 , m_readyToBeParserExecuted(false) | 70 , m_readyToBeParserExecuted(false) |
70 , m_willExecuteWhenDocumentFinishedParsing(false) | 71 , m_willExecuteWhenDocumentFinishedParsing(false) |
71 , m_forceAsync(!parserInserted) | 72 , m_forceAsync(!parserInserted) |
72 , m_willExecuteInOrder(false) | 73 , m_willExecuteInOrder(false) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 m_characterEncoding = elementDocument.characterSet(); | 234 m_characterEncoding = elementDocument.characterSet(); |
234 | 235 |
235 if (client->hasSourceAttribute()) { | 236 if (client->hasSourceAttribute()) { |
236 FetchRequest::DeferOption defer = FetchRequest::NoDefer; | 237 FetchRequest::DeferOption defer = FetchRequest::NoDefer; |
237 if (!m_parserInserted || client->asyncAttributeValue() || client->deferA ttributeValue()) | 238 if (!m_parserInserted || client->asyncAttributeValue() || client->deferA ttributeValue()) |
238 defer = FetchRequest::LazyLoad; | 239 defer = FetchRequest::LazyLoad; |
239 if (!fetchScript(client->sourceAttributeValue(), defer)) | 240 if (!fetchScript(client->sourceAttributeValue(), defer)) |
240 return false; | 241 return false; |
241 } | 242 } |
242 | 243 |
244 // Store the origin to apply when the script is done loading, as the script could be loaded in the main world. | |
245 if (v8::Isolate::GetCurrent()->InContext()) { | |
haraken
2016/01/21 10:16:15
v8::Isolate::GetCurrent() is deprecated. Use toIso
proberge
2016/01/29 18:00:48
Where is the deprecation notice? Neither api.cc no
| |
246 m_originWorld = PassRefPtr<DOMWrapperWorld>(DOMWrapperWorld::current(v8: :Isolate::GetCurrent()).originWorld()); | |
haraken
2016/01/21 10:16:15
PassRefPtr<DOMWrapperWorld> wouldn't be needed.
haraken
2016/01/21 10:16:15
v8::Isolate::GetCurrent() is deprecated.
| |
247 } | |
248 | |
243 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse rInserted && !client->asyncAttributeValue()) { | 249 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse rInserted && !client->asyncAttributeValue()) { |
244 m_willExecuteWhenDocumentFinishedParsing = true; | 250 m_willExecuteWhenDocumentFinishedParsing = true; |
245 m_willBeParserExecuted = true; | 251 m_willBeParserExecuted = true; |
246 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn cAttributeValue()) { | 252 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn cAttributeValue()) { |
247 m_willBeParserExecuted = true; | 253 m_willBeParserExecuted = true; |
248 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu ment.isRenderingReady()) { | 254 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu ment.isRenderingReady()) { |
249 m_willBeParserExecuted = true; | 255 m_willBeParserExecuted = true; |
250 m_readyToBeParserExecuted = true; | 256 m_readyToBeParserExecuted = true; |
251 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) { | 257 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) { |
252 m_willExecuteInOrder = true; | 258 m_willExecuteInOrder = true; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 } | 414 } |
409 | 415 |
410 const bool isImportedScript = contextDocument != elementDocument; | 416 const bool isImportedScript = contextDocument != elementDocument; |
411 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3 | 417 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3 |
412 // with additional support for HTML imports. | 418 // with additional support for HTML imports. |
413 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); | 419 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); |
414 | 420 |
415 if (isHTMLScriptLoader(m_element)) | 421 if (isHTMLScriptLoader(m_element)) |
416 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element)); | 422 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element)); |
417 | 423 |
424 // Ensure the origin world gets propagated to the script and is reset afterw ards. | |
425 DOMWrapperWorld::OriginWorldPusher worldPusher(ScriptState::forMainWorld(fra me)->world(), m_originWorld); | |
426 | |
418 // Create a script from the script element node, using the script | 427 // Create a script from the script element node, using the script |
419 // block's source and the script block's type. | 428 // block's source and the script block's type. |
420 // Note: This is where the script is compiled and actually executed. | 429 // Note: This is where the script is compiled and actually executed. |
421 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime); | 430 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime); |
422 | 431 |
423 if (isHTMLScriptLoader(m_element)) { | 432 if (isHTMLScriptLoader(m_element)) { |
424 ASSERT(contextDocument->currentScript() == m_element); | 433 ASSERT(contextDocument->currentScript() == m_element); |
425 contextDocument->popCurrentScript(); | 434 contextDocument->popCurrentScript(); |
426 } | 435 } |
427 | 436 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 if (isHTMLScriptLoader(element)) | 524 if (isHTMLScriptLoader(element)) |
516 return toHTMLScriptElement(element)->loader(); | 525 return toHTMLScriptElement(element)->loader(); |
517 | 526 |
518 if (isSVGScriptLoader(element)) | 527 if (isSVGScriptLoader(element)) |
519 return toSVGScriptElement(element)->loader(); | 528 return toSVGScriptElement(element)->loader(); |
520 | 529 |
521 return 0; | 530 return 0; |
522 } | 531 } |
523 | 532 |
524 } // namespace blink | 533 } // namespace blink |
OLD | NEW |