瀏覽代碼

LibWeb: Remove RemoteBrowsingContext and AbstractBrowsingContext

With the transition to Navigables, and a working implementation of
window.open(), we no longer need this abstraction layer.
Andrew Kaster 1 年之前
父節點
當前提交
9645daaf6c

+ 0 - 2
Meta/gn/secondary/Userland/Libraries/LibWeb/HTML/BUILD.gn

@@ -11,7 +11,6 @@ source_set("HTML") {
     "//Userland/Libraries/LibWeb:all_generated",
   ]
   sources = [
-    "AbstractBrowsingContext.cpp",
     "AnimatedBitmapDecodedImageData.cpp",
     "AttributeNames.cpp",
     "AudioTrack.cpp",
@@ -140,7 +139,6 @@ source_set("HTML") {
     "PluginArray.cpp",
     "PotentialCORSRequest.cpp",
     "PromiseRejectionEvent.cpp",
-    "RemoteBrowsingContext.cpp",
     "SelectItem.cpp",
     "SessionHistoryEntry.cpp",
     "SharedImageRequest.cpp",

+ 0 - 2
Userland/Libraries/LibWeb/CMakeLists.txt

@@ -226,7 +226,6 @@ set(SOURCES
     Geometry/DOMRect.cpp
     Geometry/DOMRectList.cpp
     Geometry/DOMRectReadOnly.cpp
-    HTML/AbstractBrowsingContext.cpp
     HTML/AnimatedBitmapDecodedImageData.cpp
     HTML/AttributeNames.cpp
     HTML/AudioTrack.cpp
@@ -374,7 +373,6 @@ set(SOURCES
     HTML/PluginArray.cpp
     HTML/PotentialCORSRequest.cpp
     HTML/PromiseRejectionEvent.cpp
-    HTML/RemoteBrowsingContext.cpp
     HTML/Scripting/ClassicScript.cpp
     HTML/Scripting/Environments.cpp
     HTML/Scripting/ExceptionReporter.cpp

+ 0 - 18
Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.cpp

@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/HTML/AbstractBrowsingContext.h>
-#include <LibWeb/HTML/BrowsingContext.h>
-
-namespace Web::HTML {
-
-void AbstractBrowsingContext::visit_edges(JS::Cell::Visitor& visitor)
-{
-    Base::visit_edges(visitor);
-    visitor.visit(m_opener_browsing_context);
-}
-
-}

+ 0 - 48
Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.h

@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibJS/Forward.h>
-#include <LibJS/Heap/Cell.h>
-#include <LibWeb/HTML/HistoryHandlingBehavior.h>
-#include <LibWeb/HTML/PolicyContainers.h>
-#include <LibWeb/HTML/TokenizedFeatures.h>
-#include <LibWeb/HTML/WindowProxy.h>
-
-namespace Web::HTML {
-
-class AbstractBrowsingContext : public JS::Cell {
-    JS_CELL(AbstractBrowsingContext, Cell);
-
-public:
-    virtual HTML::WindowProxy* window_proxy() = 0;
-    virtual HTML::WindowProxy const* window_proxy() const = 0;
-
-    String const& name() const { return m_name; }
-    void set_name(String const& name) { m_name = name; }
-
-    JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
-    void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
-
-    void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }
-
-    virtual String const& window_handle() const = 0;
-    virtual void set_window_handle(String handle) = 0;
-
-protected:
-    virtual void visit_edges(JS::Cell::Visitor&) override;
-
-    String m_name;
-
-    // https://html.spec.whatwg.org/multipage/browsers.html#is-popup
-    TokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No };
-
-    // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
-    JS::GCPtr<BrowsingContext> m_opener_browsing_context;
-};
-
-}

+ 2 - 6
Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp

@@ -10,17 +10,14 @@
 #include <LibWeb/DOM/Event.h>
 #include <LibWeb/DOM/HTMLCollection.h>
 #include <LibWeb/DOM/Range.h>
-#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
 #include <LibWeb/HTML/BrowsingContext.h>
 #include <LibWeb/HTML/BrowsingContextGroup.h>
 #include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
 #include <LibWeb/HTML/DocumentState.h>
-#include <LibWeb/HTML/EventLoop/EventLoop.h>
 #include <LibWeb/HTML/HTMLAnchorElement.h>
 #include <LibWeb/HTML/HTMLDocument.h>
 #include <LibWeb/HTML/HTMLInputElement.h>
 #include <LibWeb/HTML/NavigableContainer.h>
-#include <LibWeb/HTML/RemoteBrowsingContext.h>
 #include <LibWeb/HTML/SandboxingFlagSet.h>
 #include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
 #include <LibWeb/HTML/TraversableNavigable.h>
@@ -29,7 +26,6 @@
 #include <LibWeb/HighResolutionTime/TimeOrigin.h>
 #include <LibWeb/Infra/Strings.h>
 #include <LibWeb/Layout/BreakNode.h>
-#include <LibWeb/Layout/TextNode.h>
 #include <LibWeb/Layout/Viewport.h>
 #include <LibWeb/Namespace.h>
 #include <LibWeb/Page/Page.h>
@@ -515,7 +511,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
 {
     // The rules for choosing a browsing context, given a browsing context name name, a browsing context current, and
     // a boolean noopener are as follows:
-    JS::GCPtr<AbstractBrowsingContext> matching_name_in_tree = nullptr;
+    JS::GCPtr<BrowsingContext> matching_name_in_tree = nullptr;
     top_level_browsing_context()->for_each_in_subtree([&](auto& context) {
         if (context.name() == name) {
             matching_name_in_tree = &context;
@@ -526,7 +522,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
     });
 
     // 1. Let chosen be null.
-    JS::GCPtr<AbstractBrowsingContext> chosen = nullptr;
+    JS::GCPtr<BrowsingContext> chosen = nullptr;
 
     // 2. Let windowType be "existing or none".
     auto window_type = WindowType::ExistingOrNone;

+ 19 - 10
Userland/Libraries/LibWeb/HTML/BrowsingContext.h

@@ -16,7 +16,6 @@
 #include <LibJS/Forward.h>
 #include <LibJS/Heap/Cell.h>
 #include <LibWeb/DOM/Position.h>
-#include <LibWeb/HTML/AbstractBrowsingContext.h>
 #include <LibWeb/HTML/ActivateTab.h>
 #include <LibWeb/HTML/HistoryHandlingBehavior.h>
 #include <LibWeb/HTML/NavigableContainer.h>
@@ -31,10 +30,9 @@
 
 namespace Web::HTML {
 
-class BrowsingContext final
-    : public AbstractBrowsingContext
+class BrowsingContext final : public JS::Cell
     , public Weakable<BrowsingContext> {
-    JS_CELL(BrowsingContext, AbstractBrowsingContext);
+    JS_CELL(BrowsingContext, JS::Cell);
     JS_DECLARE_ALLOCATOR(BrowsingContext);
 
 public:
@@ -107,8 +105,8 @@ public:
     DOM::Document const* active_document() const;
     DOM::Document* active_document();
 
-    virtual HTML::WindowProxy* window_proxy() override;
-    virtual HTML::WindowProxy const* window_proxy() const override;
+    HTML::WindowProxy* window_proxy();
+    HTML::WindowProxy const* window_proxy() const;
 
     void set_window_proxy(JS::GCPtr<WindowProxy>);
 
@@ -130,7 +128,7 @@ public:
     };
 
     struct ChosenBrowsingContext {
-        JS::GCPtr<AbstractBrowsingContext> browsing_context;
+        JS::GCPtr<BrowsingContext> browsing_context;
         WindowType window_type;
     };
 
@@ -175,10 +173,13 @@ public:
 
     bool has_been_discarded() const { return m_has_been_discarded; }
 
-    Optional<AK::URL> const& creator_url() const { return m_creator_url; }
+    JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
+    void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
 
-    virtual String const& window_handle() const override { return m_window_handle; }
-    virtual void set_window_handle(String handle) override { m_window_handle = move(handle); }
+    void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }
+
+    String const& name() const { return m_name; }
+    void set_name(String name) { m_name = move(name); }
 
 private:
     explicit BrowsingContext(JS::NonnullGCPtr<Page>, HTML::NavigableContainer*);
@@ -216,6 +217,14 @@ private:
     // https://html.spec.whatwg.org/multipage/browsers.html#browsing-context
     JS::GCPtr<HTML::WindowProxy> m_window_proxy;
 
+    // https://html.spec.whatwg.org/multipage/browsers.html#is-popup
+    TokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No };
+
+    // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
+    JS::GCPtr<BrowsingContext> m_opener_browsing_context;
+
+    String m_name;
+
     JS::GCPtr<DOM::Position> m_cursor_position;
     RefPtr<Core::Timer> m_cursor_blink_timer;
     bool m_cursor_blink_state { false };

+ 0 - 1
Userland/Libraries/LibWeb/HTML/HTMLFormElement.h

@@ -10,7 +10,6 @@
 
 #include <AK/Time.h>
 #include <LibWeb/ARIA/Roles.h>
-#include <LibWeb/HTML/AbstractBrowsingContext.h>
 #include <LibWeb/HTML/HTMLElement.h>
 #include <LibWeb/HTML/HTMLInputElement.h>
 #include <LibWeb/HTML/Navigable.h>

+ 1 - 0
Userland/Libraries/LibWeb/HTML/Navigable.cpp

@@ -28,6 +28,7 @@
 #include <LibWeb/HTML/StructuredSerialize.h>
 #include <LibWeb/HTML/TraversableNavigable.h>
 #include <LibWeb/HTML/Window.h>
+#include <LibWeb/HTML/WindowProxy.h>
 #include <LibWeb/Infra/Strings.h>
 #include <LibWeb/Layout/Node.h>
 #include <LibWeb/Loader/GeneratedPagesLoader.h>

+ 0 - 32
Userland/Libraries/LibWeb/HTML/RemoteBrowsingContext.cpp

@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/HTML/RemoteBrowsingContext.h>
-
-namespace Web::HTML {
-
-JS_DEFINE_ALLOCATOR(RemoteBrowsingContext);
-
-JS::NonnullGCPtr<RemoteBrowsingContext> RemoteBrowsingContext::create_a_new_remote_browsing_context(String handle)
-{
-    auto browsing_context = Bindings::main_thread_vm().heap().allocate_without_realm<RemoteBrowsingContext>(handle);
-    return browsing_context;
-}
-
-HTML::WindowProxy* RemoteBrowsingContext::window_proxy()
-{
-    return nullptr;
-}
-
-HTML::WindowProxy const* RemoteBrowsingContext::window_proxy() const
-{
-    return nullptr;
-}
-
-RemoteBrowsingContext::RemoteBrowsingContext(String handle)
-    : m_window_handle(handle) {};
-
-}

+ 0 - 35
Userland/Libraries/LibWeb/HTML/RemoteBrowsingContext.h

@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibWeb/Bindings/MainThreadVM.h>
-#include <LibWeb/HTML/AbstractBrowsingContext.h>
-
-namespace Web::HTML {
-
-class RemoteBrowsingContext final
-    : public AbstractBrowsingContext
-    , public Weakable<RemoteBrowsingContext> {
-    JS_CELL(RemoteBrowsingContext, AbstractBrowsingContext);
-    JS_DECLARE_ALLOCATOR(RemoteBrowsingContext);
-
-public:
-    static JS::NonnullGCPtr<RemoteBrowsingContext> create_a_new_remote_browsing_context(String handle);
-
-    virtual HTML::WindowProxy* window_proxy() override;
-    virtual HTML::WindowProxy const* window_proxy() const override;
-
-    virtual String const& window_handle() const override { return m_window_handle; }
-    virtual void set_window_handle(String handle) override { m_window_handle = handle; }
-
-private:
-    explicit RemoteBrowsingContext(String);
-
-    String m_window_handle;
-};
-
-}

+ 1 - 0
Userland/Libraries/LibWeb/WebDriver/ExecuteScript.cpp

@@ -27,6 +27,7 @@
 #include <LibWeb/HTML/Scripting/Environments.h>
 #include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
 #include <LibWeb/HTML/Window.h>
+#include <LibWeb/HTML/WindowProxy.h>
 #include <LibWeb/Page/Page.h>
 #include <LibWeb/WebDriver/Contexts.h>
 #include <LibWeb/WebDriver/ExecuteScript.h>