Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (211312 => 211313)
--- trunk/Source/WebCore/CMakeLists.txt 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-01-28 00:47:30 UTC (rev 211313)
@@ -1067,7 +1067,6 @@
animation/KeyframeEffect.cpp
animation/WebAnimation.cpp
- bindings/js/CachedModuleScript.cpp
bindings/js/CachedModuleScriptLoader.cpp
bindings/js/CachedScriptFetcher.cpp
bindings/js/CallbackFunction.cpp
Modified: trunk/Source/WebCore/ChangeLog (211312 => 211313)
--- trunk/Source/WebCore/ChangeLog 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/ChangeLog 2017-01-28 00:47:30 UTC (rev 211313)
@@ -1,3 +1,48 @@
+2017-01-27 Yusuke Suzuki <utatane....@gmail.com>
+
+ Merge CachedModuleScript and LoadableModuleScript
+ https://bugs.webkit.org/show_bug.cgi?id=167500
+
+ Reviewed by Darin Adler.
+
+ CachedModuleScript becomes duplicate with LoadableModuleScript.
+ And CachedModuleScript does not offer any meaningful functionality
+ to LoadableModuleScript.
+ This patch merges CachedModuleScript to LoadableModuleScript.
+
+ No behavior change.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/CachedModuleScript.cpp: Removed.
+ * bindings/js/CachedModuleScript.h: Removed.
+ * bindings/js/CachedModuleScriptClient.h: Removed.
+ * bindings/js/JSBindingsAllInOne.cpp:
+ * bindings/js/ScriptController.cpp:
+ (WebCore::ScriptController::loadModuleScriptInWorld):
+ (WebCore::ScriptController::loadModuleScript):
+ (WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld):
+ (WebCore::ScriptController::linkAndEvaluateModuleScript):
+ (WebCore::ScriptController::setupModuleScriptHandlers):
+ * bindings/js/ScriptController.h:
+ * dom/LoadableModuleScript.cpp:
+ (WebCore::LoadableModuleScript::create):
+ (WebCore::LoadableModuleScript::LoadableModuleScript):
+ (WebCore::LoadableModuleScript::~LoadableModuleScript):
+ (WebCore::LoadableModuleScript::isLoaded):
+ (WebCore::LoadableModuleScript::error):
+ (WebCore::LoadableModuleScript::wasCanceled):
+ (WebCore::LoadableModuleScript::notifyLoadCompleted):
+ (WebCore::LoadableModuleScript::notifyLoadFailed):
+ (WebCore::LoadableModuleScript::notifyLoadWasCanceled):
+ (WebCore::LoadableModuleScript::execute):
+ (WebCore::LoadableModuleScript::load):
+ (WebCore::LoadableModuleScript::notifyFinished): Deleted.
+ * dom/LoadableModuleScript.h:
+ * dom/ScriptElement.cpp:
+ (WebCore::ScriptElement::executeModuleScript):
+ * dom/ScriptElement.h:
+
2017-01-27 Michael Saboff <msab...@apple.com>
JSCustomElementInterface::invokeCallback can be called with a null callback because Weak<>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211312 => 211313)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-28 00:47:30 UTC (rev 211313)
@@ -6303,9 +6303,6 @@
E30592641E27A3AD00D57C98 /* InlineClassicScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E30592621E27A38C00D57C98 /* InlineClassicScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
E30592671E27A3D100D57C98 /* CachedScriptFetcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E30592651E27A3C600D57C98 /* CachedScriptFetcher.cpp */; };
E30592681E27A3D100D57C98 /* CachedScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
- E307DECC1D81E4B300141CAF /* CachedModuleScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E307DEC91D81E46E00141CAF /* CachedModuleScript.cpp */; };
- E307DECD1D81E4B600141CAF /* CachedModuleScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DECA1D81E46E00141CAF /* CachedModuleScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
- E307DECE1D81E4BA00141CAF /* CachedModuleScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DECB1D81E49500141CAF /* CachedModuleScriptClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
E307DECF1D81E4C300141CAF /* CachedModuleScriptLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */; };
E307DED01D81E4C700141CAF /* CachedModuleScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
E307DED11D81E4CB00141CAF /* CachedModuleScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DEC81D81E44800141CAF /* CachedModuleScriptLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -14360,9 +14357,6 @@
E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedModuleScriptLoader.cpp; sourceTree = "<group>"; };
E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScriptLoader.h; sourceTree = "<group>"; };
E307DEC81D81E44800141CAF /* CachedModuleScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScriptLoaderClient.h; sourceTree = "<group>"; };
- E307DEC91D81E46E00141CAF /* CachedModuleScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedModuleScript.cpp; sourceTree = "<group>"; };
- E307DECA1D81E46E00141CAF /* CachedModuleScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScript.h; sourceTree = "<group>"; };
- E307DECB1D81E49500141CAF /* CachedModuleScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScriptClient.h; sourceTree = "<group>"; };
E307DED21D81E4ED00141CAF /* LoadableModuleScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableModuleScript.cpp; sourceTree = "<group>"; };
E307DED31D81E4ED00141CAF /* LoadableModuleScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableModuleScript.h; sourceTree = "<group>"; };
E3150EA51DA7218D00194012 /* DOMJITHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITHelpers.h; sourceTree = "<group>"; };
@@ -22134,9 +22128,6 @@
BC4EDEF70C08F414007EDD49 /* Custom */,
14DFB33F0A7DF7630018F769 /* Derived Sources */,
2DFA488E1DB541C200362B99 /* BufferSource.h */,
- E307DEC91D81E46E00141CAF /* CachedModuleScript.cpp */,
- E307DECA1D81E46E00141CAF /* CachedModuleScript.h */,
- E307DECB1D81E49500141CAF /* CachedModuleScriptClient.h */,
E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */,
E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */,
E307DEC81D81E44800141CAF /* CachedModuleScriptLoaderClient.h */,
@@ -25169,8 +25160,6 @@
830030F81B7D3B7800ED3AAC /* CachedHTMLCollection.h in Headers */,
BCB16C1C0979C3BD00467741 /* CachedImage.h in Headers */,
319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */,
- E307DECD1D81E4B600141CAF /* CachedModuleScript.h in Headers */,
- E307DECE1D81E4BA00141CAF /* CachedModuleScriptClient.h in Headers */,
E307DED01D81E4C700141CAF /* CachedModuleScriptLoader.h in Headers */,
E307DED11D81E4CB00141CAF /* CachedModuleScriptLoaderClient.h in Headers */,
510184690B08602A004A825F /* CachedPage.h in Headers */,
@@ -29079,7 +29068,6 @@
BC64B4CB0CB4295D005F2B62 /* CachedFont.cpp in Sources */,
51C0AA410F2AA15E001648C2 /* CachedFrame.cpp in Sources */,
BCB16C1B0979C3BD00467741 /* CachedImage.cpp in Sources */,
- E307DECC1D81E4B300141CAF /* CachedModuleScript.cpp in Sources */,
E307DECF1D81E4C300141CAF /* CachedModuleScriptLoader.cpp in Sources */,
5101846A0B08602A004A825F /* CachedPage.cpp in Sources */,
D0EDA774143E303C0028E383 /* CachedRawResource.cpp in Sources */,
Deleted: trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp (211312 => 211313)
--- trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScript.cpp 2017-01-28 00:47:30 UTC (rev 211313)
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CachedModuleScript.h"
-
-#include "CachedModuleScriptClient.h"
-#include "DOMWrapperWorld.h"
-#include "Document.h"
-#include "ExceptionCode.h"
-#include "Frame.h"
-#include "ScriptController.h"
-#include "ScriptModuleLoader.h"
-#include "ScriptRunner.h"
-#include "ScriptSourceCode.h"
-
-namespace WebCore {
-
-Ref<CachedModuleScript> CachedModuleScript::create()
-{
- return adoptRef(*new CachedModuleScript());
-}
-
-void CachedModuleScript::load(Document& document, const URL& rootURL, CachedScriptFetcher& scriptFetcher)
-{
- if (auto* frame = document.frame())
- frame->script().loadModuleScript(*this, rootURL.string(), scriptFetcher);
-}
-
-void CachedModuleScript::load(Document& document, const ScriptSourceCode& sourceCode, CachedScriptFetcher& scriptFetcher)
-{
- if (auto* frame = document.frame())
- frame->script().loadModuleScript(*this, sourceCode, scriptFetcher);
-}
-
-void CachedModuleScript::notifyLoadCompleted(UniquedStringImpl& moduleKey)
-{
- m_moduleKey = &moduleKey;
- notifyClientFinished();
-}
-
-void CachedModuleScript::notifyLoadFailed(LoadableScript::Error&& error)
-{
- m_error = WTFMove(error);
- notifyClientFinished();
-}
-
-void CachedModuleScript::notifyLoadWasCanceled()
-{
- m_wasCanceled = true;
- notifyClientFinished();
-}
-
-void CachedModuleScript::notifyClientFinished()
-{
- m_isLoaded = true;
-
- Ref<CachedModuleScript> protectedThis(*this);
-
- Vector<CachedModuleScriptClient*> clients;
- copyToVector(m_clients, clients);
- for (auto& client : clients)
- client->notifyFinished(*this);
-}
-
-void CachedModuleScript::addClient(CachedModuleScriptClient& client)
-{
- m_clients.add(&client);
- if (!isLoaded())
- return;
- Ref<CachedModuleScript> protectedThis(*this);
- client.notifyFinished(*this);
-}
-
-void CachedModuleScript::removeClient(CachedModuleScriptClient& client)
-{
- m_clients.remove(&client);
-}
-
-}
Deleted: trunk/Source/WebCore/bindings/js/CachedModuleScript.h (211312 => 211313)
--- trunk/Source/WebCore/bindings/js/CachedModuleScript.h 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScript.h 2017-01-28 00:47:30 UTC (rev 211313)
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "CachedModuleScriptLoader.h"
-#include "LoadableScript.h"
-#include <runtime/JSInternalPromise.h>
-
-namespace WebCore {
-
-class CachedModuleScriptClient;
-class Document;
-class ScriptSourceCode;
-
-class CachedModuleScript : public RefCounted<CachedModuleScript> {
-public:
- UniquedStringImpl* moduleKey() { return m_moduleKey.get(); }
-
- void notifyLoadCompleted(UniquedStringImpl& moduleKey);
- void notifyLoadFailed(LoadableScript::Error&&);
- void notifyLoadWasCanceled();
-
- const std::optional<LoadableScript::Error>& error() const { return m_error; }
- bool wasCanceled() const { return m_wasCanceled; }
- bool isLoaded() const { return m_isLoaded; }
-
- void addClient(CachedModuleScriptClient&);
- void removeClient(CachedModuleScriptClient&);
-
- static Ref<CachedModuleScript> create();
-
- void load(Document&, const URL& rootURL, CachedScriptFetcher&);
- void load(Document&, const ScriptSourceCode&, CachedScriptFetcher&);
-
-private:
- void notifyClientFinished();
-
- RefPtr<UniquedStringImpl> m_moduleKey;
- HashCountedSet<CachedModuleScriptClient*> m_clients;
- std::optional<LoadableScript::Error> m_error;
- bool m_wasCanceled { false };
- bool m_isLoaded { false };
-};
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/bindings/js/CachedModuleScriptClient.h (211312 => 211313)
--- trunk/Source/WebCore/bindings/js/CachedModuleScriptClient.h 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/bindings/js/CachedModuleScriptClient.h 2017-01-28 00:47:30 UTC (rev 211313)
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-namespace WebCore {
-
-class CachedModuleScript;
-
-class CachedModuleScriptClient {
-public:
- virtual ~CachedModuleScriptClient() { }
-
- virtual void notifyFinished(CachedModuleScript&) = 0;
-};
-
-}
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (211312 => 211313)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2017-01-28 00:47:30 UTC (rev 211313)
@@ -25,7 +25,6 @@
// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
-#include "CachedModuleScript.cpp"
#include "CachedModuleScriptLoader.cpp"
#include "CallbackFunction.cpp"
#include "DOMWrapperWorld.cpp"
Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (211312 => 211313)
--- trunk/Source/WebCore/bindings/js/ScriptController.cpp 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp 2017-01-28 00:47:30 UTC (rev 211313)
@@ -22,7 +22,6 @@
#include "ScriptController.h"
#include "BridgeJSC.h"
-#include "CachedModuleScript.h"
#include "CachedScriptFetcher.h"
#include "CommonVM.h"
#include "ContentSecurityPolicy.h"
@@ -36,6 +35,7 @@
#include "JSDOMWindow.h"
#include "JSDocument.h"
#include "JSMainThreadExecState.h"
+#include "LoadableModuleScript.h"
#include "MainFrame.h"
#include "MemoryPressureHandler.h"
#include "NP_jsobject.h"
@@ -186,7 +186,7 @@
return evaluateInWorld(sourceCode, mainThreadNormalWorld(), exceptionDetails);
}
-void ScriptController::loadModuleScriptInWorld(CachedModuleScript& moduleScript, const String& moduleName, CachedScriptFetcher& scriptFetcher, DOMWrapperWorld& world)
+void ScriptController::loadModuleScriptInWorld(LoadableModuleScript& moduleScript, const String& moduleName, DOMWrapperWorld& world)
{
JSLockHolder lock(world.vm());
@@ -193,16 +193,16 @@
auto& shell = *windowShell(world);
auto& state = *shell.window()->globalExec();
- auto& promise = JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetcher::create(state.vm(), { &scriptFetcher }));
+ auto& promise = JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetcher::create(state.vm(), { &moduleScript }));
setupModuleScriptHandlers(moduleScript, promise, world);
}
-void ScriptController::loadModuleScript(CachedModuleScript& moduleScript, const String& moduleName, CachedScriptFetcher& scriptFetcher)
+void ScriptController::loadModuleScript(LoadableModuleScript& moduleScript, const String& moduleName)
{
- loadModuleScriptInWorld(moduleScript, moduleName, scriptFetcher, mainThreadNormalWorld());
+ loadModuleScriptInWorld(moduleScript, moduleName, mainThreadNormalWorld());
}
-void ScriptController::loadModuleScriptInWorld(CachedModuleScript& moduleScript, const ScriptSourceCode& sourceCode, CachedScriptFetcher& scriptFetcher, DOMWrapperWorld& world)
+void ScriptController::loadModuleScriptInWorld(LoadableModuleScript& moduleScript, const ScriptSourceCode& sourceCode, DOMWrapperWorld& world)
{
JSLockHolder lock(world.vm());
@@ -209,16 +209,16 @@
auto& shell = *windowShell(world);
auto& state = *shell.window()->globalExec();
- auto& promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &scriptFetcher }));
+ auto& promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &moduleScript }));
setupModuleScriptHandlers(moduleScript, promise, world);
}
-void ScriptController::loadModuleScript(CachedModuleScript& moduleScript, const ScriptSourceCode& sourceCode, CachedScriptFetcher& scriptFetcher)
+void ScriptController::loadModuleScript(LoadableModuleScript& moduleScript, const ScriptSourceCode& sourceCode)
{
- loadModuleScriptInWorld(moduleScript, sourceCode, scriptFetcher, mainThreadNormalWorld());
+ loadModuleScriptInWorld(moduleScript, sourceCode, mainThreadNormalWorld());
}
-JSC::JSValue ScriptController::linkAndEvaluateModuleScriptInWorld(CachedModuleScript& moduleScript, DOMWrapperWorld& world)
+JSC::JSValue ScriptController::linkAndEvaluateModuleScriptInWorld(LoadableModuleScript& moduleScript, DOMWrapperWorld& world)
{
JSLockHolder lock(world.vm());
@@ -240,7 +240,7 @@
return returnValue;
}
-JSC::JSValue ScriptController::linkAndEvaluateModuleScript(CachedModuleScript& moduleScript)
+JSC::JSValue ScriptController::linkAndEvaluateModuleScript(LoadableModuleScript& moduleScript)
{
return linkAndEvaluateModuleScriptInWorld(moduleScript, mainThreadNormalWorld());
}
@@ -368,7 +368,7 @@
return asString(value)->toIdentifier(exec);
}
-void ScriptController::setupModuleScriptHandlers(CachedModuleScript& moduleScriptRef, JSInternalPromise& promise, DOMWrapperWorld& world)
+void ScriptController::setupModuleScriptHandlers(LoadableModuleScript& moduleScriptRef, JSInternalPromise& promise, DOMWrapperWorld& world)
{
auto& shell = *windowShell(world);
auto& state = *shell.window()->globalExec();
@@ -380,7 +380,7 @@
JSC::PrivateName moduleLoaderAlreadyReportedErrorSymbol = m_moduleLoaderAlreadyReportedErrorSymbol;
JSC::PrivateName moduleLoaderFetchingIsCanceledSymbol = m_moduleLoaderFetchingIsCanceledSymbol;
- RefPtr<CachedModuleScript> moduleScript(&moduleScriptRef);
+ RefPtr<LoadableModuleScript> moduleScript(&moduleScriptRef);
auto& fulfillHandler = *JSNativeStdFunction::create(state.vm(), shell.window(), 1, String(), [moduleScript](ExecState* exec) {
Identifier moduleKey = jsValueToModuleKey(exec, exec->argument(0));
Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (211312 => 211313)
--- trunk/Source/WebCore/bindings/js/ScriptController.h 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h 2017-01-28 00:47:30 UTC (rev 211313)
@@ -51,11 +51,11 @@
namespace WebCore {
-class CachedModuleScript;
class CachedScriptFetcher;
class Frame;
class HTMLDocument;
class HTMLPlugInElement;
+class LoadableModuleScript;
class SecurityOrigin;
class ScriptSourceCode;
class Widget;
@@ -114,13 +114,13 @@
JSC::JSValue evaluate(const ScriptSourceCode&, ExceptionDetails* = nullptr);
JSC::JSValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld&, ExceptionDetails* = nullptr);
- void loadModuleScriptInWorld(CachedModuleScript&, const String& moduleName, CachedScriptFetcher&, DOMWrapperWorld&);
- void loadModuleScript(CachedModuleScript&, const String& moduleName, CachedScriptFetcher&);
- void loadModuleScriptInWorld(CachedModuleScript&, const ScriptSourceCode&, CachedScriptFetcher&, DOMWrapperWorld&);
- void loadModuleScript(CachedModuleScript&, const ScriptSourceCode&, CachedScriptFetcher&);
+ void loadModuleScriptInWorld(LoadableModuleScript&, const String& moduleName, DOMWrapperWorld&);
+ void loadModuleScript(LoadableModuleScript&, const String& moduleName);
+ void loadModuleScriptInWorld(LoadableModuleScript&, const ScriptSourceCode&, DOMWrapperWorld&);
+ void loadModuleScript(LoadableModuleScript&, const ScriptSourceCode&);
- JSC::JSValue linkAndEvaluateModuleScriptInWorld(CachedModuleScript& , DOMWrapperWorld&);
- JSC::JSValue linkAndEvaluateModuleScript(CachedModuleScript&);
+ JSC::JSValue linkAndEvaluateModuleScriptInWorld(LoadableModuleScript& , DOMWrapperWorld&);
+ JSC::JSValue linkAndEvaluateModuleScript(LoadableModuleScript&);
JSC::JSValue evaluateModule(const URL&, JSC::JSModuleRecord&, DOMWrapperWorld&);
JSC::JSValue evaluateModule(const URL&, JSC::JSModuleRecord&);
@@ -181,7 +181,7 @@
private:
WEBCORE_EXPORT JSDOMWindowShell* initScript(DOMWrapperWorld&);
- void setupModuleScriptHandlers(CachedModuleScript&, JSC::JSInternalPromise&, DOMWrapperWorld&);
+ void setupModuleScriptHandlers(LoadableModuleScript&, JSC::JSInternalPromise&, DOMWrapperWorld&);
void disconnectPlatformScriptObjects();
Modified: trunk/Source/WebCore/dom/LoadableModuleScript.cpp (211312 => 211313)
--- trunk/Source/WebCore/dom/LoadableModuleScript.cpp 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/dom/LoadableModuleScript.cpp 2017-01-28 00:47:30 UTC (rev 211313)
@@ -26,6 +26,9 @@
#include "config.h"
#include "LoadableModuleScript.h"
+#include "Document.h"
+#include "Frame.h"
+#include "ScriptController.h"
#include "ScriptElement.h"
namespace WebCore {
@@ -32,54 +35,69 @@
Ref<LoadableModuleScript> LoadableModuleScript::create(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
{
- return adoptRef(*new LoadableModuleScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree, CachedModuleScript::create()));
+ return adoptRef(*new LoadableModuleScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree));
}
-LoadableModuleScript::LoadableModuleScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree, Ref<CachedModuleScript>&& moduleScript)
+LoadableModuleScript::LoadableModuleScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
: LoadableScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
- , m_moduleScript(WTFMove(moduleScript))
{
- m_moduleScript->addClient(*this);
}
LoadableModuleScript::~LoadableModuleScript()
{
- m_moduleScript->removeClient(*this);
}
bool LoadableModuleScript::isLoaded() const
{
- return m_moduleScript->isLoaded();
+ return m_isLoaded;
}
std::optional<LoadableScript::Error> LoadableModuleScript::error() const
{
- return m_moduleScript->error();
+ return m_error;
}
bool LoadableModuleScript::wasCanceled() const
{
- return m_moduleScript->wasCanceled();
+ return m_wasCanceled;
}
-void LoadableModuleScript::notifyFinished(CachedModuleScript&)
+void LoadableModuleScript::notifyLoadCompleted(UniquedStringImpl& moduleKey)
{
+ m_moduleKey = &moduleKey;
+ m_isLoaded = true;
notifyClientFinished();
}
+void LoadableModuleScript::notifyLoadFailed(LoadableScript::Error&& error)
+{
+ m_error = WTFMove(error);
+ m_isLoaded = true;
+ notifyClientFinished();
+}
+
+void LoadableModuleScript::notifyLoadWasCanceled()
+{
+ m_wasCanceled = true;
+ m_isLoaded = true;
+ notifyClientFinished();
+}
+
void LoadableModuleScript::execute(ScriptElement& scriptElement)
{
- scriptElement.executeModuleScript(m_moduleScript.get());
+ scriptElement.executeModuleScript(*this);
}
void LoadableModuleScript::load(Document& document, const URL& rootURL)
{
- m_moduleScript->load(document, rootURL, *this);
+ if (auto* frame = document.frame())
+ frame->script().loadModuleScript(*this, rootURL.string());
}
void LoadableModuleScript::load(Document& document, const ScriptSourceCode& sourceCode)
{
- m_moduleScript->load(document, sourceCode, *this);
+ if (auto* frame = document.frame())
+ frame->script().loadModuleScript(*this, sourceCode);
}
}
Modified: trunk/Source/WebCore/dom/LoadableModuleScript.h (211312 => 211313)
--- trunk/Source/WebCore/dom/LoadableModuleScript.h 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/dom/LoadableModuleScript.h 2017-01-28 00:47:30 UTC (rev 211313)
@@ -25,14 +25,14 @@
#pragma once
-#include "CachedModuleScript.h"
-#include "CachedModuleScriptClient.h"
#include "LoadableScript.h"
#include <wtf/TypeCasts.h>
namespace WebCore {
-class LoadableModuleScript final : public LoadableScript, private CachedModuleScriptClient {
+class ScriptSourceCode;
+
+class LoadableModuleScript final : public LoadableScript {
public:
virtual ~LoadableModuleScript();
@@ -42,8 +42,6 @@
std::optional<Error> error() const final;
bool wasCanceled() const final;
- CachedModuleScript& moduleScript() { return m_moduleScript.get(); }
-
bool isClassicScript() const final { return false; }
bool isModuleScript() const final { return true; }
@@ -54,12 +52,19 @@
void load(Document&, const URL& rootURL);
void load(Document&, const ScriptSourceCode&);
+ void notifyLoadCompleted(UniquedStringImpl&);
+ void notifyLoadFailed(LoadableScript::Error&&);
+ void notifyLoadWasCanceled();
+
+ UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); }
+
private:
- LoadableModuleScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree, Ref<CachedModuleScript>&&);
+ LoadableModuleScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree);
- void notifyFinished(CachedModuleScript&) final;
-
- Ref<CachedModuleScript> m_moduleScript;
+ RefPtr<UniquedStringImpl> m_moduleKey;
+ std::optional<LoadableScript::Error> m_error;
+ bool m_wasCanceled { false };
+ bool m_isLoaded { false };
};
}
Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (211312 => 211313)
--- trunk/Source/WebCore/dom/ScriptElement.cpp 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp 2017-01-28 00:47:30 UTC (rev 211313)
@@ -24,7 +24,6 @@
#include "config.h"
#include "ScriptElement.h"
-#include "CachedModuleScript.h"
#include "CachedResourceLoader.h"
#include "CachedResourceRequest.h"
#include "CachedScript.h"
@@ -390,11 +389,11 @@
frame->script().evaluate(sourceCode);
}
-void ScriptElement::executeModuleScript(CachedModuleScript& moduleScript)
+void ScriptElement::executeModuleScript(LoadableModuleScript& loadableModuleScript)
{
// https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block
- ASSERT(!moduleScript.error());
+ ASSERT(!loadableModuleScript.error());
auto& document = m_element.document();
auto* frame = document.frame();
@@ -404,7 +403,7 @@
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(&document);
CurrentScriptIncrementer currentScriptIncrementer(document, m_element);
- frame->script().linkAndEvaluateModuleScript(moduleScript);
+ frame->script().linkAndEvaluateModuleScript(loadableModuleScript);
}
void ScriptElement::executeScriptAndDispatchEvent(LoadableScript& loadableScript)
Modified: trunk/Source/WebCore/dom/ScriptElement.h (211312 => 211313)
--- trunk/Source/WebCore/dom/ScriptElement.h 2017-01-28 00:33:17 UTC (rev 211312)
+++ trunk/Source/WebCore/dom/ScriptElement.h 2017-01-28 00:47:30 UTC (rev 211313)
@@ -30,10 +30,10 @@
namespace WebCore {
-class CachedModuleScript;
class CachedScript;
class ContainerNode;
class Element;
+class LoadableModuleScript;
class PendingScript;
class ScriptSourceCode;
class URL;
@@ -51,7 +51,7 @@
String scriptCharset() const { return m_characterEncoding; }
WEBCORE_EXPORT String scriptContent() const;
void executeClassicScript(const ScriptSourceCode&);
- void executeModuleScript(CachedModuleScript&);
+ void executeModuleScript(LoadableModuleScript&);
void executePendingScript(PendingScript&);