Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.cpp

Issue 1615523002: Transitively keep track of an isolated world's children scripts and worlds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a static world stack instead of a per-world private field Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 m_characterEncoding = elementDocument.characterSet(); 242 m_characterEncoding = elementDocument.characterSet();
242 243
243 if (client->hasSourceAttribute()) { 244 if (client->hasSourceAttribute()) {
244 FetchRequest::DeferOption defer = FetchRequest::NoDefer; 245 FetchRequest::DeferOption defer = FetchRequest::NoDefer;
245 if (!m_parserInserted || client->asyncAttributeValue() || client->deferA ttributeValue()) 246 if (!m_parserInserted || client->asyncAttributeValue() || client->deferA ttributeValue())
246 defer = FetchRequest::LazyLoad; 247 defer = FetchRequest::LazyLoad;
247 if (!fetchScript(client->sourceAttributeValue(), defer)) 248 if (!fetchScript(client->sourceAttributeValue(), defer))
248 return false; 249 return false;
249 } 250 }
250 251
252 // Store the origin to apply when the script is done loading, as the script could be loaded in the main world.
253 if (v8::Isolate::GetCurrent()->InContext()) {
254 m_originWorld = PassRefPtr<DOMWrapperWorld>(DOMWrapperWorld::current(v8: :Isolate::GetCurrent()).originWorld());
255 }
256
251 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse rInserted && !client->asyncAttributeValue()) { 257 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse rInserted && !client->asyncAttributeValue()) {
252 m_willExecuteWhenDocumentFinishedParsing = true; 258 m_willExecuteWhenDocumentFinishedParsing = true;
253 m_willBeParserExecuted = true; 259 m_willBeParserExecuted = true;
254 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn cAttributeValue()) { 260 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn cAttributeValue()) {
255 m_willBeParserExecuted = true; 261 m_willBeParserExecuted = true;
256 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu ment.isRenderingReady()) { 262 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu ment.isRenderingReady()) {
257 m_willBeParserExecuted = true; 263 m_willBeParserExecuted = true;
258 m_readyToBeParserExecuted = true; 264 m_readyToBeParserExecuted = true;
259 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) { 265 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) {
260 m_willExecuteInOrder = true; 266 m_willExecuteInOrder = true;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 420 }
415 421
416 const bool isImportedScript = contextDocument != elementDocument; 422 const bool isImportedScript = contextDocument != elementDocument;
417 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3 423 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3
418 // with additional support for HTML imports. 424 // with additional support for HTML imports.
419 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); 425 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0);
420 426
421 if (isHTMLScriptLoader(m_element)) 427 if (isHTMLScriptLoader(m_element))
422 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element)); 428 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element));
423 429
430 // Ensure the origin world gets propagated to the script and is reset afterw ards.
431 DOMWrapperWorld::OriginWorldScope worldScope(m_originWorld);
432
424 // Create a script from the script element node, using the script 433 // Create a script from the script element node, using the script
425 // block's source and the script block's type. 434 // block's source and the script block's type.
426 // Note: This is where the script is compiled and actually executed. 435 // Note: This is where the script is compiled and actually executed.
427 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime); 436 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime);
428 437
429 if (isHTMLScriptLoader(m_element)) { 438 if (isHTMLScriptLoader(m_element)) {
430 ASSERT(contextDocument->currentScript() == m_element); 439 ASSERT(contextDocument->currentScript() == m_element);
431 contextDocument->popCurrentScript(); 440 contextDocument->popCurrentScript();
432 } 441 }
433 442
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 if (isHTMLScriptLoader(element)) 530 if (isHTMLScriptLoader(element))
522 return toHTMLScriptElement(element)->loader(); 531 return toHTMLScriptElement(element)->loader();
523 532
524 if (isSVGScriptLoader(element)) 533 if (isSVGScriptLoader(element))
525 return toSVGScriptElement(element)->loader(); 534 return toSVGScriptElement(element)->loader();
526 535
527 return 0; 536 return 0;
528 } 537 }
529 538
530 } // namespace blink 539 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptLoader.h ('k') | third_party/WebKit/Source/core/frame/DOMTimer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698