diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-03-14 12:02:33 +0300 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-03-16 13:17:37 -0400 |
commit | c4f94b084640432b30985faea21840b84b6c69b6 (patch) | |
tree | bd8dd60f268e3e55120ff41870373c195d7bff76 /Userland/Libraries | |
parent | 9d79a9b214af9470b3cee732f2ad420379b99a3c (diff) | |
download | serenity-c4f94b084640432b30985faea21840b84b6c69b6.zip |
LibWeb: Introduce AbstractBrowsingContext
Introducing class for abstract browsing context is going to make it
possible to have separate implementations for:
1) Local browsing context (Top level BC of current page and iframes)
2) Remote browsing context (BC of a page that lives in another
WebContent process)
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.h b/Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.h new file mode 100644 index 0000000000..dfae19224d --- /dev/null +++ b/Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.h @@ -0,0 +1,56 @@ +/* + * 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/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; + + DeprecatedString const& name() const { return m_name; } + void set_name(DeprecatedString 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; } + + virtual WebIDL::ExceptionOr<void> navigate( + JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource, + BrowsingContext& source_browsing_context, + bool exceptions_enabled = false, + HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Default, + 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 = {}) + = 0; + + void set_is_popup(bool is_popup) { m_is_popup = is_popup; } + + virtual String const& window_handle() const = 0; + virtual void set_window_handle(String handle) = 0; + +protected: + DeprecatedString m_name; + + // https://html.spec.whatwg.org/multipage/browsers.html#is-popup + bool m_is_popup { false }; + + // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context + JS::GCPtr<BrowsingContext> m_opener_browsing_context; +}; + +} |