diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-03-14 12:40:03 +0300 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-03-16 13:17:37 -0400 |
commit | 40ec976781a56e841f0b61c629d5dc4fc2634b15 (patch) | |
tree | 1e78d14e854a1109e86f3dcc65ff446581e348f0 /Userland/Libraries | |
parent | c4f94b084640432b30985faea21840b84b6c69b6 (diff) | |
download | serenity-40ec976781a56e841f0b61c629d5dc4fc2634b15.zip |
LibWeb: Inherit BrowsingContext from AbstractBrowsingContext
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContext.h | 33 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp | 2 |
3 files changed, 14 insertions, 25 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index a89ed290d0..3ea3c63635 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -620,7 +620,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex // a boolean noopener are as follows: // 1. Let chosen be null. - JS::GCPtr<BrowsingContext> chosen = nullptr; + JS::GCPtr<AbstractBrowsingContext> chosen = nullptr; // 2. Let windowType be "existing or none". auto window_type = WindowType::ExistingOrNone; @@ -734,7 +734,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex } // 9. Return chosen and windowType. - return { chosen, window_type }; + return { chosen.ptr(), window_type }; } // https://html.spec.whatwg.org/multipage/browsers.html#document-tree-child-browsing-context diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index ffab00398a..3a8c46b768 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -16,6 +16,7 @@ #include <LibJS/Forward.h> #include <LibJS/Heap/Cell.h> #include <LibWeb/DOM/Position.h> +#include <LibWeb/HTML/AbstractBrowsingContext.h> #include <LibWeb/HTML/BrowsingContextContainer.h> #include <LibWeb/HTML/HistoryHandlingBehavior.h> #include <LibWeb/HTML/Origin.h> @@ -29,15 +30,15 @@ namespace Web::HTML { class BrowsingContext final - : public JS::Cell + : public AbstractBrowsingContext , public Weakable<BrowsingContext> { - JS_CELL(BrowsingContext, JS::Cell); + JS_CELL(BrowsingContext, AbstractBrowsingContext); public: static JS::NonnullGCPtr<BrowsingContext> create_a_new_browsing_context(Page&, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder, BrowsingContextGroup&); static JS::NonnullGCPtr<BrowsingContext> create_a_new_top_level_browsing_context(Page&); - ~BrowsingContext(); + virtual ~BrowsingContext() override; JS::GCPtr<BrowsingContext> parent() const { return m_parent; } void append_child(JS::NonnullGCPtr<BrowsingContext>); @@ -121,12 +122,8 @@ public: void set_active_document(JS::NonnullGCPtr<DOM::Document>); - HTML::WindowProxy* window_proxy(); - HTML::WindowProxy const* window_proxy() const; - - 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 HTML::WindowProxy* window_proxy() override; + virtual HTML::WindowProxy const* window_proxy() const override; HTML::Window* active_window(); HTML::Window const* active_window() const; @@ -170,7 +167,7 @@ public: }; struct ChosenBrowsingContext { - JS::GCPtr<BrowsingContext> browsing_context; + JS::GCPtr<AbstractBrowsingContext> browsing_context; WindowType window_type; }; @@ -211,9 +208,6 @@ public: JS::GCPtr<DOM::Node> currently_focused_area(); - DeprecatedString const& name() const { return m_name; } - void set_name(DeprecatedString const& name) { m_name = name; } - Vector<SessionHistoryEntry>& session_history() { return m_session_history; } Vector<SessionHistoryEntry> const& session_history() const { return m_session_history; } size_t session_history_index() const { return *m_session_history_index; } @@ -231,7 +225,7 @@ public: bool is_allowed_to_navigate(BrowsingContext const&) const; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate - WebIDL::ExceptionOr<void> navigate( + virtual WebIDL::ExceptionOr<void> navigate( JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource, BrowsingContext& source_browsing_context, bool exceptions_enabled = false, @@ -239,7 +233,7 @@ public: Optional<PolicyContainer> history_policy_container = {}, DeprecatedString navigation_type = "other", Optional<DeprecatedString> navigation_id = {}, - Function<void(JS::NonnullGCPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {}); + Function<void(JS::NonnullGCPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {}) override; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid WebIDL::ExceptionOr<void> navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, DeprecatedString navigation_id); @@ -256,8 +250,6 @@ public: VisibilityState system_visibility_state() const; void set_system_visibility_state(VisibilityState); - void set_is_popup(bool is_popup) { m_is_popup = is_popup; } - // https://html.spec.whatwg.org/multipage/window-object.html#a-browsing-context-is-discarded void discard(); bool has_been_discarded() const { return m_has_been_discarded; } @@ -267,8 +259,8 @@ public: Optional<AK::URL> const& creator_url() const { return m_creator_url; } - String const& window_handle() const { return m_window_handle; } - void set_window_handle(String handle) { m_window_handle = move(handle); } + virtual String const& window_handle() const override { return m_window_handle; } + virtual void set_window_handle(String handle) override { m_window_handle = move(handle); } private: explicit BrowsingContext(Page&, HTML::BrowsingContextContainer*); @@ -311,9 +303,6 @@ 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#opener-browsing-context - JS::GCPtr<BrowsingContext> m_opener_browsing_context; - DOM::Position m_cursor_position; RefPtr<Platform::Timer> m_cursor_blink_timer; bool m_cursor_blink_state { false }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp index 4e2d9ba63a..190e65812b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp @@ -537,7 +537,7 @@ void HTMLHyperlinkElementUtils::follow_the_hyperlink(Optional<DeprecatedString> // FIXME: "navigate" means implementing the navigation algorithm here: // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate hyperlink_element_utils_queue_an_element_task(Task::Source::DOMManipulation, [url_string, target] { - target->loader().load(url_string, FrameLoader::Type::Navigation); + verify_cast<BrowsingContext>(*target).loader().load(url_string, FrameLoader::Type::Navigation); }); } |