diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 24cd83871c..d86f1e4c28 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -202,7 +202,6 @@ set(SOURCES Geometry/DOMRectReadOnly.cpp HTML/AttributeNames.cpp HTML/BrowsingContext.cpp - HTML/BrowsingContextContainer.cpp HTML/BrowsingContextGroup.cpp HTML/Canvas/CanvasDrawImage.cpp HTML/Canvas/CanvasPath.cpp @@ -314,6 +313,7 @@ set(SOURCES HTML/MessagePort.cpp HTML/MimeType.cpp HTML/MimeTypeArray.cpp + HTML/NavigableContainer.cpp HTML/Navigator.cpp HTML/NavigatorID.cpp HTML/PageTransitionEvent.cpp diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index e9e8666407..b339c545ef 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1706,8 +1706,8 @@ bool Document::is_fully_active() const return false; if (browsing_context->is_top_level()) return true; - if (auto* browsing_context_container_document = browsing_context->container_document()) { - if (browsing_context_container_document->is_fully_active()) + if (auto* navigable_container_document = browsing_context->container_document()) { + if (navigable_container_document->is_fully_active()) return true; } return false; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 0c43633a0d..337790d04a 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -29,10 +29,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -1070,8 +1070,8 @@ void Node::serialize_tree_as_json(JsonObjectSerializer& object) c MUST(attributes.finish()); } - if (element->is_browsing_context_container()) { - auto const* container = static_cast(element); + if (element->is_navigable_container()) { + auto const* container = static_cast(element); if (auto const* content_document = container->content_document()) { auto children = MUST(object.add_array("children"sv)); JsonObjectSerializer content_document_object = MUST(children.add_object()); diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 6832d4c372..15a3f603e8 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -90,7 +90,7 @@ public: virtual bool is_html_input_element() const { return false; } virtual bool is_html_progress_element() const { return false; } virtual bool is_html_template_element() const { return false; } - virtual bool is_browsing_context_container() const { return false; } + virtual bool is_navigable_container() const { return false; } WebIDL::ExceptionOr> pre_insert(JS::NonnullGCPtr, JS::GCPtr); WebIDL::ExceptionOr> pre_remove(JS::NonnullGCPtr); diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index ffefe66d8a..64aa6c2b16 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -274,7 +274,6 @@ class DOMRectReadOnly; namespace Web::HTML { class BrowsingContext; -class BrowsingContextContainer; class BrowsingContextGroup; class CanvasRenderingContext2D; class ClassicScript; @@ -370,7 +369,9 @@ class MessageEvent; class MessagePort; class MimeType; class MimeTypeArray; +class NavigableContainer; class Navigator; +struct NavigationParams; class Origin; class PageTransitionEvent; class Path2D; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 25ccea8cbc..3193ccacc1 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -12,12 +12,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -87,7 +87,7 @@ JS::NonnullGCPtr BrowsingContext::create_a_new_top_level_browsi JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context(Page& page, JS::GCPtr creator, JS::GCPtr embedder, BrowsingContextGroup&) { // 1. Let browsingContext be a new browsing context. - BrowsingContextContainer* container = (embedder && is(*embedder)) ? static_cast(embedder.ptr()) : nullptr; + NavigableContainer* container = (embedder && is(*embedder)) ? static_cast(embedder.ptr()) : nullptr; auto browsing_context = Bindings::main_thread_vm().heap().allocate_without_realm(page, container); // 2. Let unsafeContextCreationTime be the unsafe shared current time. @@ -226,7 +226,7 @@ JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context return *browsing_context; } -BrowsingContext::BrowsingContext(Page& page, HTML::BrowsingContextContainer* container) +BrowsingContext::BrowsingContext(Page& page, HTML::NavigableContainer* container) : m_page(page) , m_loader(*this) , m_event_handler({}, *this) @@ -604,9 +604,9 @@ JS::GCPtr BrowsingContext::currently_focused_area() // 3. While candidate's focused area is a browsing context container with a non-null nested browsing context: // set candidate to the active document of that browsing context container's nested browsing context. while (candidate->focused_element() - && is(candidate->focused_element()) - && static_cast(*candidate->focused_element()).nested_browsing_context()) { - candidate = static_cast(*candidate->focused_element()).nested_browsing_context()->active_document(); + && is(candidate->focused_element()) + && static_cast(*candidate->focused_element()).nested_browsing_context()) { + candidate = static_cast(*candidate->focused_element()).nested_browsing_context()->active_document(); } // 4. If candidate's focused area is non-null, set candidate to candidate's focused area. diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index 1df8cd0021..d8dd8d200f 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -179,8 +179,8 @@ public: bool is_child_of(BrowsingContext const&) const; - HTML::BrowsingContextContainer* container() { return m_container; } - HTML::BrowsingContextContainer const* container() const { return m_container; } + HTML::NavigableContainer* container() { return m_container; } + HTML::NavigableContainer const* container() const { return m_container; } CSSPixelPoint to_top_level_position(CSSPixelPoint); CSSPixelRect to_top_level_rect(CSSPixelRect const&); @@ -266,7 +266,7 @@ public: virtual void set_window_handle(String handle) override { m_window_handle = move(handle); } private: - explicit BrowsingContext(Page&, HTML::BrowsingContextContainer*); + explicit BrowsingContext(Page&, HTML::NavigableContainer*); virtual void visit_edges(Cell::Visitor&) override; @@ -296,7 +296,7 @@ private: // https://html.spec.whatwg.org/multipage/browsers.html#creator-origin Optional m_creator_origin; - JS::GCPtr m_container; + JS::GCPtr m_container; CSSPixelSize m_size; CSSPixelPoint m_viewport_scroll_offset; diff --git a/Userland/Libraries/LibWeb/HTML/Focus.cpp b/Userland/Libraries/LibWeb/HTML/Focus.cpp index 337b898f8c..7fef91a120 100644 --- a/Userland/Libraries/LibWeb/HTML/Focus.cpp +++ b/Userland/Libraries/LibWeb/HTML/Focus.cpp @@ -174,11 +174,11 @@ void run_focusing_steps(DOM::Node* new_focus_target, DOM::Node* fallback_target, new_focus_target = fallback_target; } - // 3. If new focus target is a browsing context container with non-null nested browsing context, + // 3. If new focus target is a navigable container with non-null nested browsing context, // then set new focus target to the nested browsing context's active document. - if (is(*new_focus_target)) { - auto& browsing_context_container = static_cast(*new_focus_target); - if (auto* nested_browsing_context = browsing_context_container.nested_browsing_context()) + if (is(*new_focus_target)) { + auto& navigable_container = static_cast(*new_focus_target); + if (auto* nested_browsing_context = navigable_container.nested_browsing_context()) new_focus_target = nested_browsing_context->active_document(); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 3e9d81324a..63f9d62515 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index fc76d90b42..6d35666449 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -15,7 +15,7 @@ namespace Web::HTML { HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, DOM::QualifiedName qualified_name) - : BrowsingContextContainer(document, move(qualified_name)) + : NavigableContainer(document, move(qualified_name)) { } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index cc194cc369..2834da5c4f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -6,12 +6,12 @@ #pragma once -#include +#include namespace Web::HTML { -class HTMLIFrameElement final : public BrowsingContextContainer { - WEB_PLATFORM_OBJECT(HTMLIFrameElement, BrowsingContextContainer); +class HTMLIFrameElement final : public NavigableContainer { + WEB_PLATFORM_OBJECT(HTMLIFrameElement, NavigableContainer); public: virtual ~HTMLIFrameElement() override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 94da7a2b92..2ca5c72a83 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -17,7 +17,7 @@ namespace Web::HTML { HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name) - : BrowsingContextContainer(document, move(qualified_name)) + : NavigableContainer(document, move(qualified_name)) { // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element // Whenever one of the following conditions occur: @@ -40,7 +40,7 @@ JS::ThrowCompletionOr HTMLObjectElement::initialize(JS::Realm& realm) void HTMLObjectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) { - BrowsingContextContainer::parse_attribute(name, value); + NavigableContainer::parse_attribute(name, value); // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element // Whenever one of the following conditions occur: @@ -70,7 +70,7 @@ JS::GCPtr HTMLObjectElement::create_layout_node(NonnullRefPtr #include -#include #include #include +#include #include namespace Web::HTML { class HTMLObjectElement final - : public BrowsingContextContainer + : public NavigableContainer , public FormAssociatedElement , public ResourceClient { - WEB_PLATFORM_OBJECT(HTMLObjectElement, BrowsingContextContainer) - FORM_ASSOCIATED_ELEMENT(BrowsingContextContainer, HTMLObjectElement) + WEB_PLATFORM_OBJECT(HTMLObjectElement, NavigableContainer) + FORM_ASSOCIATED_ELEMENT(NavigableContainer, HTMLObjectElement) enum class Representation { Unknown, diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp similarity index 89% rename from Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp rename to Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp index 8caf538fe7..cc02db4365 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -9,36 +9,36 @@ #include #include #include -#include #include #include +#include #include #include #include namespace Web::HTML { -HashTable& BrowsingContextContainer::all_instances() +HashTable& NavigableContainer::all_instances() { - static HashTable set; + static HashTable set; return set; } -BrowsingContextContainer::BrowsingContextContainer(DOM::Document& document, DOM::QualifiedName qualified_name) +NavigableContainer::NavigableContainer(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { } -BrowsingContextContainer::~BrowsingContextContainer() = default; +NavigableContainer::~NavigableContainer() = default; -void BrowsingContextContainer::visit_edges(Cell::Visitor& visitor) +void NavigableContainer::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_nested_browsing_context); } // https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-nested-browsing-context -void BrowsingContextContainer::create_new_nested_browsing_context() +void NavigableContainer::create_new_nested_browsing_context() { // 1. Let group be element's node document's browsing context's top-level browsing context's group. VERIFY(document().browsing_context()); @@ -62,7 +62,7 @@ void BrowsingContextContainer::create_new_nested_browsing_context() } // https://html.spec.whatwg.org/multipage/browsers.html#concept-bcc-content-document -const DOM::Document* BrowsingContextContainer::content_document() const +const DOM::Document* NavigableContainer::content_document() const { // 1. If container's nested browsing context is null, then return null. if (m_nested_browsing_context == nullptr) @@ -89,7 +89,7 @@ const DOM::Document* BrowsingContextContainer::content_document() const return document; } -DOM::Document const* BrowsingContextContainer::content_document_without_origin_check() const +DOM::Document const* NavigableContainer::content_document_without_origin_check() const { if (!m_nested_browsing_context) return nullptr; @@ -97,7 +97,7 @@ DOM::Document const* BrowsingContextContainer::content_document_without_origin_c } // https://html.spec.whatwg.org/multipage/embedded-content-other.html#dom-media-getsvgdocument -const DOM::Document* BrowsingContextContainer::get_svg_document() const +const DOM::Document* NavigableContainer::get_svg_document() const { // 1. Let document be this element's content document. auto const* document = content_document(); @@ -109,7 +109,7 @@ const DOM::Document* BrowsingContextContainer::get_svg_document() const return nullptr; } -HTML::WindowProxy* BrowsingContextContainer::content_window() +HTML::WindowProxy* NavigableContainer::content_window() { if (!m_nested_browsing_context) return nullptr; @@ -128,7 +128,7 @@ static bool url_matches_about_blank(AK::URL const& url) } // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements -void BrowsingContextContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion) +void NavigableContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion) { // 1. Let url be the URL record about:blank. auto url = AK::URL("about:blank"); @@ -196,7 +196,7 @@ void BrowsingContextContainer::shared_attribute_processing_steps_for_iframe_and_ } // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#navigate-an-iframe-or-frame -void BrowsingContextContainer::navigate_an_iframe_or_frame(JS::NonnullGCPtr resource) +void NavigableContainer::navigate_an_iframe_or_frame(JS::NonnullGCPtr resource) { // 1. Let historyHandling be "default". auto history_handling = HistoryHandlingBehavior::Default; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/NavigableContainer.h similarity index 71% rename from Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h rename to Userland/Libraries/LibWeb/HTML/NavigableContainer.h index f2f9b14a62..3292636b6a 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.h @@ -10,13 +10,13 @@ namespace Web::HTML { -class BrowsingContextContainer : public HTMLElement { - WEB_PLATFORM_OBJECT(BrowsingContextContainer, HTMLElement); +class NavigableContainer : public HTMLElement { + WEB_PLATFORM_OBJECT(NavigableContainer, HTMLElement); public: - virtual ~BrowsingContextContainer() override; + virtual ~NavigableContainer() override; - static HashTable& all_instances(); + static HashTable& all_instances(); BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; } BrowsingContext const* nested_browsing_context() const { return m_nested_browsing_context; } @@ -29,7 +29,7 @@ public: DOM::Document const* get_svg_document() const; protected: - BrowsingContextContainer(DOM::Document&, DOM::QualifiedName); + NavigableContainer(DOM::Document&, DOM::QualifiedName); virtual void visit_edges(Cell::Visitor&) override; @@ -44,12 +44,12 @@ protected: JS::GCPtr m_nested_browsing_context; private: - virtual bool is_browsing_context_container() const override { return true; } + virtual bool is_navigable_container() const override { return true; } }; } namespace Web::DOM { template<> -inline bool Node::fast_is() const { return is_browsing_context_container(); } +inline bool Node::fast_is() const { return is_navigable_container(); } } diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index c551e2528c..63b3779dcf 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -687,10 +687,10 @@ bool EventHandler::fire_keyboard_event(FlyString const& event_name, HTML::Browsi return false; if (JS::GCPtr focused_element = document->focused_element()) { - if (is(*focused_element)) { - auto& browsing_context_container = verify_cast(*focused_element); - if (browsing_context_container.nested_browsing_context()) - return fire_keyboard_event(event_name, *browsing_context_container.nested_browsing_context(), key, modifiers, code_point); + if (is(*focused_element)) { + auto& navigable_container = verify_cast(*focused_element); + if (navigable_container.nested_browsing_context()) + return fire_keyboard_event(event_name, *navigable_container.nested_browsing_context(), key, modifiers, code_point); } auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point).release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp b/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp index d92eb57134..b3e5056960 100644 --- a/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include