diff --git a/third_party/WebKit/Source/core/dom/BUILD.gn b/third_party/WebKit/Source/core/dom/BUILD.gn index c23c3a3d3ebfe..13a8eb86ff3c8 100644 --- a/third_party/WebKit/Source/core/dom/BUILD.gn +++ b/third_party/WebKit/Source/core/dom/BUILD.gn @@ -197,8 +197,6 @@ blink_core_sources("dom") { "Modulator.h", "ModuleMap.cpp", "ModuleMap.h", - "ModulePendingScript.cpp", - "ModulePendingScript.h", "ModuleScript.cpp", "ModuleScript.h", "MutationCallback.h", diff --git a/third_party/WebKit/Source/core/dom/Modulator.h b/third_party/WebKit/Source/core/dom/Modulator.h index ad1d58268c849..ef95e0b48bf21 100644 --- a/third_party/WebKit/Source/core/dom/Modulator.h +++ b/third_party/WebKit/Source/core/dom/Modulator.h @@ -34,13 +34,6 @@ class SingleModuleClient : public GarbageCollectedMixin { virtual void NotifyModuleLoadFinished(ModuleScript*) = 0; }; -// A ModuleTreeClient is notified when a module script and its whole descendent -// tree load is complete. -class ModuleTreeClient : public GarbageCollectedMixin { - public: - virtual void NotifyModuleTreeLoadFinished(ModuleScript*) = 0; -}; - // spec: "top-level module fetch flag" // https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-top-level enum class ModuleGraphLevel { kTopLevelModuleFetch, kDependentModuleFetch }; diff --git a/third_party/WebKit/Source/core/dom/ModulePendingScript.cpp b/third_party/WebKit/Source/core/dom/ModulePendingScript.cpp deleted file mode 100644 index f0184b10301e3..0000000000000 --- a/third_party/WebKit/Source/core/dom/ModulePendingScript.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "core/dom/ModulePendingScript.h" - -#include "core/dom/ScriptLoader.h" -#include "core/frame/LocalFrame.h" - -namespace blink { - -ModulePendingScriptTreeClient::ModulePendingScriptTreeClient() - : module_script_(nullptr), pending_script_(nullptr) {} - -void ModulePendingScriptTreeClient::SetPendingScript( - ModulePendingScript* pending_script) { - DCHECK(!pending_script_); - pending_script_ = pending_script; - - if (finished_) { - pending_script_->NotifyModuleTreeLoadFinished(); - } -} - -void ModulePendingScriptTreeClient::NotifyModuleTreeLoadFinished( - ModuleScript* module_script) { - DCHECK(!(module_script && module_script->InstantiationState() == - ModuleInstantiationState::kUninstantiated)); - DCHECK(!finished_); - finished_ = true; - module_script_ = module_script; - - if (pending_script_) - pending_script_->NotifyModuleTreeLoadFinished(); -} - -DEFINE_TRACE(ModulePendingScriptTreeClient) { - visitor->Trace(module_script_); - visitor->Trace(pending_script_); - ModuleTreeClient::Trace(visitor); -} - -ModulePendingScript::ModulePendingScript(ScriptElementBase* element, - ModulePendingScriptTreeClient* client) - : PendingScript(element, TextPosition()), module_tree_client_(client) { - CHECK(this->GetElement()); - DCHECK(module_tree_client_); - client->SetPendingScript(this); -} - -ModulePendingScript::~ModulePendingScript() {} - -void ModulePendingScript::DisposeInternal() { - module_tree_client_ = nullptr; -} - -DEFINE_TRACE(ModulePendingScript) { - visitor->Trace(module_tree_client_); - PendingScript::Trace(visitor); -} - -void ModulePendingScript::NotifyModuleTreeLoadFinished() { - CHECK(!IsReady()); - ready_ = true; - - if (Client()) - Client()->PendingScriptFinished(this); -} - -Script* ModulePendingScript::GetSource(const KURL& document_url, - bool& error_occurred) const { - CHECK(IsReady()); - error_occurred = ErrorOccurred(); - return GetModuleScript(); -} - -bool ModulePendingScript::ErrorOccurred() const { - CHECK(IsReady()); - return !GetModuleScript(); -} - -} // namespace blink diff --git a/third_party/WebKit/Source/core/dom/ModulePendingScript.h b/third_party/WebKit/Source/core/dom/ModulePendingScript.h deleted file mode 100644 index 62ecccbbcfbac..0000000000000 --- a/third_party/WebKit/Source/core/dom/ModulePendingScript.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ModulePendingScript_h -#define ModulePendingScript_h - -#include "core/dom/Modulator.h" -#include "core/dom/ModuleScript.h" -#include "core/dom/PendingScript.h" - -namespace blink { - -class ModulePendingScript; - -// ModulePendingScriptTreeClient is used to connect from Modulator::FetchTree() -// to ModulePendingScript. Because ModulePendingScript is created after -// Modulator::FetchTree() is called, ModulePendingScriptTreeClient is -// registered as ModuleTreeClient to FetchTree() first, and later -// ModulePendingScript is supplied to ModulePendingScriptTreeClient via -// SetPendingScript() and is notified of module tree load finish. -class ModulePendingScriptTreeClient final - : public GarbageCollectedFinalized, - public ModuleTreeClient { - USING_GARBAGE_COLLECTED_MIXIN(ModulePendingScriptTreeClient); - - public: - static ModulePendingScriptTreeClient* Create() { - return new ModulePendingScriptTreeClient(); - } - virtual ~ModulePendingScriptTreeClient() = default; - - void SetPendingScript(ModulePendingScript* client); - - ModuleScript* GetModuleScript() const { return module_script_; } - - DECLARE_TRACE(); - - private: - ModulePendingScriptTreeClient(); - - // Implements ModuleTreeClient - void NotifyModuleTreeLoadFinished(ModuleScript*) override; - - bool finished_ = false; - Member module_script_; - Member pending_script_; -}; - -// PendingScript for a module script -// https://html.spec.whatwg.org/#module-script. -class CORE_EXPORT ModulePendingScript : public PendingScript { - public: - static ModulePendingScript* Create(ScriptElementBase* element, - ModulePendingScriptTreeClient* client) { - return new ModulePendingScript(element, client); - } - - ~ModulePendingScript() override; - - void NotifyModuleTreeLoadFinished(); - - ModuleScript* GetModuleScript() const { - return module_tree_client_->GetModuleScript(); - } - - DECLARE_TRACE(); - - private: - ModulePendingScript(ScriptElementBase*, ModulePendingScriptTreeClient*); - - // PendingScript - ScriptType GetScriptType() const override { return ScriptType::kModule; } - Script* GetSource(const KURL& document_url, - bool& error_occurred) const override; - bool IsReady() const override { return ready_; } - bool IsExternal() const override { return true; } - bool ErrorOccurred() const override; - bool WasCanceled() const override { return false; } - - void StartStreamingIfPossible(Document*, ScriptStreamer::Type) override {} - KURL UrlForClassicScript() const override { - NOTREACHED(); - return KURL(); - } - void RemoveFromMemoryCache() override { NOTREACHED(); } - - void DisposeInternal() override; - - void CheckState() const override {} - - Member module_tree_client_; - bool ready_ = false; -}; - -} // namespace blink - -#endif // ModulePendingScript_h