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

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

Issue 1561663003: CL for perf tryjob on win (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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_originWorldId(0)
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
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()) {
246 DOMWrapperWorld& creatingWorld = DOMWrapperWorld::current(v8::Isolate::G etCurrent());
247 m_originWorldId = creatingWorld.originWorldId();
248 }
249
243 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse rInserted && !client->asyncAttributeValue()) { 250 if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parse rInserted && !client->asyncAttributeValue()) {
244 m_willExecuteWhenDocumentFinishedParsing = true; 251 m_willExecuteWhenDocumentFinishedParsing = true;
245 m_willBeParserExecuted = true; 252 m_willBeParserExecuted = true;
246 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn cAttributeValue()) { 253 } else if (client->hasSourceAttribute() && m_parserInserted && !client->asyn cAttributeValue()) {
247 m_willBeParserExecuted = true; 254 m_willBeParserExecuted = true;
248 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu ment.isRenderingReady()) { 255 } else if (!client->hasSourceAttribute() && m_parserInserted && !elementDocu ment.isRenderingReady()) {
249 m_willBeParserExecuted = true; 256 m_willBeParserExecuted = true;
250 m_readyToBeParserExecuted = true; 257 m_readyToBeParserExecuted = true;
251 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) { 258 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) {
252 m_willExecuteInOrder = true; 259 m_willExecuteInOrder = true;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 415 }
409 416
410 const bool isImportedScript = contextDocument != elementDocument; 417 const bool isImportedScript = contextDocument != elementDocument;
411 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3 418 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3
412 // with additional support for HTML imports. 419 // with additional support for HTML imports.
413 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); 420 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0);
414 421
415 if (isHTMLScriptLoader(m_element)) 422 if (isHTMLScriptLoader(m_element))
416 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element)); 423 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element));
417 424
425 // Ensure the parent world id gets propagated to the script and is reset aft erwards.
426 DOMWrapperWorld::ParentWorldIdPusher worldIdPusher(ScriptState::forMainWorld (frame)->world(), m_originWorldId);
427
418 // Create a script from the script element node, using the script 428 // Create a script from the script element node, using the script
419 // block's source and the script block's type. 429 // block's source and the script block's type.
420 // Note: This is where the script is compiled and actually executed. 430 // Note: This is where the script is compiled and actually executed.
421 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime); 431 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime);
422 432
423 if (isHTMLScriptLoader(m_element)) { 433 if (isHTMLScriptLoader(m_element)) {
424 ASSERT(contextDocument->currentScript() == m_element); 434 ASSERT(contextDocument->currentScript() == m_element);
425 contextDocument->popCurrentScript(); 435 contextDocument->popCurrentScript();
426 } 436 }
427 437
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (isHTMLScriptLoader(element)) 525 if (isHTMLScriptLoader(element))
516 return toHTMLScriptElement(element)->loader(); 526 return toHTMLScriptElement(element)->loader();
517 527
518 if (isSVGScriptLoader(element)) 528 if (isSVGScriptLoader(element))
519 return toSVGScriptElement(element)->loader(); 529 return toSVGScriptElement(element)->loader();
520 530
521 return 0; 531 return 0;
522 } 532 }
523 533
524 } // namespace blink 534 } // 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