diff options
43 files changed, 241 insertions, 241 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 3a47c87aa6..dd61bd7d6b 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -31,7 +31,7 @@ #include <LibWeb/Layout/InitialContainingBlockBox.h> #include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/OutOfProcessWebView.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Browser { diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index 13d28f3591..4d85f0a6b6 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -26,7 +26,7 @@ #include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Window.h> #include <LibWeb/Origin.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/WebAssembly/WebAssemblyObject.h> #include <LibWeb/Bindings/WindowObjectHelper.h> @@ -344,10 +344,10 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::top_getter) auto* impl = impl_from(vm, global_object); if (!impl) return {}; - auto* this_frame = impl->document().frame(); - VERIFY(this_frame); - VERIFY(this_frame->main_frame().document()); - auto& top_window = this_frame->main_frame().document()->window(); + auto* this_browsing_context = impl->document().browsing_context(); + VERIFY(this_browsing_context); + VERIFY(this_browsing_context->top_level_browsing_context().document()); + auto& top_window = this_browsing_context->top_level_browsing_context().document()->window(); return top_window.wrapper(); } @@ -356,14 +356,14 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::parent_getter) auto* impl = impl_from(vm, global_object); if (!impl) return {}; - auto* this_frame = impl->document().frame(); - VERIFY(this_frame); - if (this_frame->parent()) { - VERIFY(this_frame->parent()->document()); - auto& parent_window = this_frame->parent()->document()->window(); + auto* this_browsing_context = impl->document().browsing_context(); + VERIFY(this_browsing_context); + if (this_browsing_context->parent()) { + VERIFY(this_browsing_context->parent()->document()); + auto& parent_window = this_browsing_context->parent()->document()->window(); return parent_window.wrapper(); } - VERIFY(this_frame == &this_frame->main_frame()); + VERIFY(this_browsing_context == &this_browsing_context->top_level_browsing_context()); return impl->wrapper(); } diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index bc9123ed83..4649f46f0c 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -205,9 +205,9 @@ set(SOURCES Namespace.cpp NavigationTiming/PerformanceTiming.cpp OutOfProcessWebView.cpp + Page/BrowsingContext.cpp Page/EditEventHandler.cpp Page/EventHandler.cpp - Page/Frame.cpp Page/Page.cpp Painting/BorderPainting.cpp Painting/StackingContext.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index 18558e126d..6d19c06aee 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -7,7 +7,7 @@ #include <LibWeb/CSS/Length.h> #include <LibWeb/DOM/Document.h> #include <LibWeb/HTML/HTMLHtmlElement.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::CSS { @@ -21,16 +21,16 @@ float Length::relative_length_to_px(const Layout::Node& layout_node) const case Type::Rem: return m_value * layout_node.document().document_element()->layout_node()->font_size(); case Type::Vw: - return layout_node.document().frame()->viewport_rect().width() * (m_value / 100); + return layout_node.document().browsing_context()->viewport_rect().width() * (m_value / 100); case Type::Vh: - return layout_node.document().frame()->viewport_rect().height() * (m_value / 100); + return layout_node.document().browsing_context()->viewport_rect().height() * (m_value / 100); case Type::Vmin: { - auto viewport = layout_node.document().frame()->viewport_rect(); + auto viewport = layout_node.document().browsing_context()->viewport_rect(); return min(viewport.width(), viewport.height()) * (m_value / 100); } case Type::Vmax: { - auto viewport = layout_node.document().frame()->viewport_rect(); + auto viewport = layout_node.document().browsing_context()->viewport_rect(); return max(viewport.width(), viewport.height()) * (m_value / 100); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 96ee5c5304..7d85f56227 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -11,7 +11,7 @@ #include <LibWeb/InProcessWebView.h> #include <LibWeb/Loader/LoadRequest.h> #include <LibWeb/Loader/ResourceLoader.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::CSS { @@ -165,8 +165,8 @@ void ImageStyleValue::resource_did_load() return; m_bitmap = resource()->bitmap(); // FIXME: Do less than a full repaint if possible? - if (m_document->frame()) - m_document->frame()->set_needs_display({}); + if (m_document->browsing_context()) + m_document->browsing_context()->set_needs_display({}); } } diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 5307657753..b9887a8553 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -50,7 +50,7 @@ #include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Namespace.h> #include <LibWeb/Origin.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/SVG/TagNames.h> #include <LibWeb/UIEvents/MouseEvent.h> #include <ctype.h> @@ -281,22 +281,22 @@ void Document::set_title(const String& title) title_element->append_child(adopt_ref(*new Text(*this, title))); if (auto* page = this->page()) { - if (frame() == &page->main_frame()) + if (browsing_context() == &page->top_level_browsing_context()) page->client().page_did_change_title(title); } } -void Document::attach_to_frame(Badge<Frame>, Frame& frame) +void Document::attach_to_browsing_context(Badge<BrowsingContext>, BrowsingContext& browsing_context) { - m_frame = frame; + m_browsing_context = browsing_context; update_layout(); } -void Document::detach_from_frame(Badge<Frame>, Frame& frame) +void Document::detach_from_browsing_context(Badge<BrowsingContext>, BrowsingContext& browsing_context) { - VERIFY(&frame == m_frame); + VERIFY(&browsing_context == m_browsing_context); tear_down_layout_tree(); - m_frame = nullptr; + m_browsing_context = nullptr; } void Document::tear_down_layout_tree() @@ -399,7 +399,7 @@ void Document::force_layout() void Document::update_layout() { - if (!frame()) + if (!browsing_context()) return; if (!m_layout_root) { @@ -412,7 +412,7 @@ void Document::update_layout() m_layout_root->set_needs_display(); - if (frame()->is_main_frame()) { + if (browsing_context()->is_top_level()) { if (auto* page = this->page()) page->client().page_did_layout(); } @@ -881,12 +881,12 @@ void Document::set_ready_state(const String& ready_state) Page* Document::page() { - return m_frame ? m_frame->page() : nullptr; + return m_browsing_context ? m_browsing_context->page() : nullptr; } const Page* Document::page() const { - return m_frame ? m_frame->page() : nullptr; + return m_browsing_context ? m_browsing_context->page() : nullptr; } EventTarget* Document::get_parent(const Event& event) diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 98b73fe919..d9934f3421 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -115,11 +115,11 @@ public: String title() const; void set_title(const String&); - void attach_to_frame(Badge<Frame>, Frame&); - void detach_from_frame(Badge<Frame>, Frame&); + void attach_to_browsing_context(Badge<BrowsingContext>, BrowsingContext&); + void detach_from_browsing_context(Badge<BrowsingContext>, BrowsingContext&); - Frame* frame() { return m_frame.ptr(); } - const Frame* frame() const { return m_frame.ptr(); } + BrowsingContext* browsing_context() { return m_browsing_context.ptr(); } + const BrowsingContext* browsing_context() const { return m_browsing_context.ptr(); } Page* page(); const Page* page() const; @@ -297,7 +297,7 @@ private: RefPtr<CSS::StyleSheetList> m_style_sheets; RefPtr<Node> m_hovered_node; RefPtr<Node> m_inspected_node; - WeakPtr<Frame> m_frame; + WeakPtr<BrowsingContext> m_browsing_context; URL m_url; RefPtr<Window> m_window; diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index a5fc6fe89b..24ff88fc88 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -14,7 +14,7 @@ #include <LibWeb/HighResolutionTime/Performance.h> #include <LibWeb/InProcessWebView.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::DOM { @@ -139,7 +139,7 @@ void Window::cancel_animation_frame(i32 id) void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& new_href) { - auto* frame = document().frame(); + auto* frame = document().browsing_context(); if (!frame) return; frame->loader().load(new_href, FrameLoader::Type::Navigation); @@ -147,7 +147,7 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& n void Window::did_call_location_reload(Badge<Bindings::LocationObject>) { - auto* frame = document().frame(); + auto* frame = document().browsing_context(); if (!frame) return; frame->loader().load(document().url(), FrameLoader::Type::Reload); diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 3098f02da7..186e0d2b17 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -179,7 +179,7 @@ class TextNode; namespace Web { class EventHandler; class EditEventHandler; -class Frame; +class BrowsingContext; class FrameLoader; class InProcessWebView; class LoadRequest; diff --git a/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp b/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp index 30b338a8d3..66a4467205 100644 --- a/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp @@ -8,7 +8,7 @@ #include <LibWeb/DOM/Event.h> #include <LibWeb/HTML/FrameHostElement.h> #include <LibWeb/Origin.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::HTML { @@ -26,18 +26,18 @@ void FrameHostElement::inserted() HTMLElement::inserted(); if (!is_connected()) return; - if (auto* frame = document().frame()) { - m_content_frame = Frame::create_subframe(*this, frame->main_frame()); - m_content_frame->set_frame_nesting_levels(frame->frame_nesting_levels()); - m_content_frame->register_frame_nesting(document().url()); + if (auto* frame = document().browsing_context()) { + m_nested_browsing_context = BrowsingContext::create_nested(*this, frame->top_level_browsing_context()); + m_nested_browsing_context->set_frame_nesting_levels(frame->frame_nesting_levels()); + m_nested_browsing_context->register_frame_nesting(document().url()); } } Origin FrameHostElement::content_origin() const { - if (!m_content_frame || !m_content_frame->document()) + if (!m_nested_browsing_context || !m_nested_browsing_context->document()) return {}; - return m_content_frame->document()->origin(); + return m_nested_browsing_context->document()->origin(); } bool FrameHostElement::may_access_from_origin(const Origin& origin) const @@ -47,10 +47,10 @@ bool FrameHostElement::may_access_from_origin(const Origin& origin) const const DOM::Document* FrameHostElement::content_document() const { - return m_content_frame ? m_content_frame->document() : nullptr; + return m_nested_browsing_context ? m_nested_browsing_context->document() : nullptr; } -void FrameHostElement::content_frame_did_load(Badge<FrameLoader>) +void FrameHostElement::nested_browsing_context_did_load(Badge<FrameLoader>) { dispatch_event(DOM::Event::create(EventNames::load)); } diff --git a/Userland/Libraries/LibWeb/HTML/FrameHostElement.h b/Userland/Libraries/LibWeb/HTML/FrameHostElement.h index 54891becd4..6bb7afaefe 100644 --- a/Userland/Libraries/LibWeb/HTML/FrameHostElement.h +++ b/Userland/Libraries/LibWeb/HTML/FrameHostElement.h @@ -15,20 +15,20 @@ public: FrameHostElement(DOM::Document&, QualifiedName); virtual ~FrameHostElement() override; - Frame* content_frame() { return m_content_frame; } - const Frame* content_frame() const { return m_content_frame; } + BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; } + const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; } const DOM::Document* content_document() const; Origin content_origin() const; bool may_access_from_origin(const Origin&) const; - void content_frame_did_load(Badge<FrameLoader>); + void nested_browsing_context_did_load(Badge<FrameLoader>); virtual void inserted() override; protected: - RefPtr<Frame> m_content_frame; + RefPtr<BrowsingContext> m_nested_browsing_context; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index cfba5f8d4f..53c5c45137 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -10,7 +10,7 @@ #include <LibWeb/HTML/HTMLInputElement.h> #include <LibWeb/HTML/SubmitEvent.h> #include <LibWeb/InProcessWebView.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/URLEncoder.h> namespace Web::HTML { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 736a446457..ba01d28f43 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -8,7 +8,7 @@ #include <LibWeb/HTML/HTMLIFrameElement.h> #include <LibWeb/Layout/FrameBox.h> #include <LibWeb/Origin.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::HTML { @@ -43,7 +43,7 @@ void HTMLIFrameElement::inserted() void HTMLIFrameElement::load_src(const String& value) { - if (!m_content_frame) + if (!m_nested_browsing_context) return; if (value.is_null()) @@ -60,7 +60,7 @@ void HTMLIFrameElement::load_src(const String& value) } dbgln("Loading iframe document from {}", value); - m_content_frame->loader().load(url, FrameLoader::Type::IFrame); + m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 27fcc3e7bd..480f90f3a0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -17,7 +17,7 @@ #include <LibWeb/Layout/ButtonBox.h> #include <LibWeb/Layout/CheckBox.h> #include <LibWeb/Layout/RadioButton.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::HTML { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp index c2efc192db..b87e715b27 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp @@ -23,7 +23,7 @@ void HTMLTitleElement::children_changed() { HTMLElement::children_changed(); if (auto* page = document().page()) { - if (document().frame() == &page->main_frame()) + if (document().browsing_context() == &page->top_level_browsing_context()) page->client().page_did_change_title(document().title()); } } diff --git a/Userland/Libraries/LibWeb/InProcessWebView.cpp b/Userland/Libraries/LibWeb/InProcessWebView.cpp index 5417658e6c..f7447e483f 100644 --- a/Userland/Libraries/LibWeb/InProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/InProcessWebView.cpp @@ -23,8 +23,8 @@ #include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/TextNode.h> #include <LibWeb/Loader/ResourceLoader.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Page/EventHandler.h> -#include <LibWeb/Page/Frame.h> #include <LibWeb/Painting/PaintContext.h> #include <LibWeb/UIEvents/MouseEvent.h> @@ -89,7 +89,7 @@ void InProcessWebView::select_all() String InProcessWebView::selected_text() const { - return page().focused_frame().selected_text(); + return page().focused_context().selected_text(); } void InProcessWebView::page_did_layout() @@ -104,7 +104,7 @@ void InProcessWebView::page_did_change_title(const String& title) on_title_change(title); } -void InProcessWebView::page_did_set_document_in_main_frame(DOM::Document* document) +void InProcessWebView::page_did_set_document_in_top_level_browsing_context(DOM::Document* document) { if (on_set_document) on_set_document(document); @@ -210,17 +210,17 @@ void InProcessWebView::layout_and_sync_size() bool had_vertical_scrollbar = vertical_scrollbar().is_visible(); bool had_horizontal_scrollbar = horizontal_scrollbar().is_visible(); - page().main_frame().set_size(available_size()); + page().top_level_browsing_context().set_size(available_size()); set_content_size(layout_root()->size().to_type<int>()); // NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again // since the scrollbars now take up some of the available space. if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) { - page().main_frame().set_size(available_size()); + page().top_level_browsing_context().set_size(available_size()); set_content_size(layout_root()->size().to_type<int>()); } - page().main_frame().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() }); + page().top_level_browsing_context().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() }); } void InProcessWebView::resize_event(GUI::ResizeEvent& event) @@ -319,9 +319,9 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event) URL InProcessWebView::url() const { - if (!page().main_frame().document()) + if (!page().top_level_browsing_context().document()) return {}; - return page().main_frame().document()->url(); + return page().top_level_browsing_context().document()->url(); } void InProcessWebView::reload() @@ -331,13 +331,13 @@ void InProcessWebView::reload() void InProcessWebView::load_html(const StringView& html, const URL& url) { - page().main_frame().loader().load_html(html, url); + page().top_level_browsing_context().loader().load_html(html, url); } bool InProcessWebView::load(const URL& url) { set_override_cursor(Gfx::StandardCursor::None); - return page().main_frame().loader().load(url, FrameLoader::Type::Navigation); + return page().top_level_browsing_context().loader().load(url, FrameLoader::Type::Navigation); } const Layout::InitialContainingBlockBox* InProcessWebView::layout_root() const @@ -360,27 +360,27 @@ void InProcessWebView::page_did_request_scroll_into_view(const Gfx::IntRect& rec void InProcessWebView::load_empty_document() { - page().main_frame().set_document(nullptr); + page().top_level_browsing_context().set_document(nullptr); } DOM::Document* InProcessWebView::document() { - return page().main_frame().document(); + return page().top_level_browsing_context().document(); } const DOM::Document* InProcessWebView::document() const { - return page().main_frame().document(); + return page().top_level_browsing_context().document(); } void InProcessWebView::set_document(DOM::Document* document) { - page().main_frame().set_document(document); + page().top_level_browsing_context().set_document(document); } void InProcessWebView::did_scroll() { - page().main_frame().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() }); + page().top_level_browsing_context().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() }); } void InProcessWebView::drop_event(GUI::DropEvent& event) diff --git a/Userland/Libraries/LibWeb/InProcessWebView.h b/Userland/Libraries/LibWeb/InProcessWebView.h index 12c5e58864..beb779c19a 100644 --- a/Userland/Libraries/LibWeb/InProcessWebView.h +++ b/Userland/Libraries/LibWeb/InProcessWebView.h @@ -70,7 +70,7 @@ private: virtual Gfx::Palette palette() const override { return GUI::AbstractScrollableWidget::palette(); } virtual Gfx::IntRect screen_rect() const override { return GUI::Desktop::the().rect(); } virtual void page_did_change_title(const String&) override; - virtual void page_did_set_document_in_main_frame(DOM::Document*) override; + virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) override; virtual void page_did_start_loading(const URL&) override; virtual void page_did_finish_loading(const URL&) override; virtual void page_did_change_selection() override; diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index b0650284ef..f7a21b01b4 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -13,7 +13,7 @@ #include <LibWeb/Layout/InlineFormattingContext.h> #include <LibWeb/Layout/ListItemBox.h> #include <LibWeb/Layout/ReplacedBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -516,7 +516,7 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_mode) { - auto viewport_rect = context_box().frame().viewport_rect(); + auto viewport_rect = context_box().browsing_context().viewport_rect(); auto& icb = downcast<Layout::InitialContainingBlockBox>(context_box()); icb.build_stacking_context_tree(); diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp index de85dde8c5..398ffb4909 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.cpp +++ b/Userland/Libraries/LibWeb/Layout/Box.cpp @@ -10,7 +10,7 @@ #include <LibWeb/HTML/HTMLHtmlElement.h> #include <LibWeb/Layout/BlockBox.h> #include <LibWeb/Layout/Box.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Painting/BorderPainting.h> namespace Web::Layout { @@ -293,7 +293,7 @@ HitTestResult Box::hit_test(const Gfx::IntPoint& position, HitTestType type) con void Box::set_needs_display() { if (!is_inline()) { - frame().set_needs_display(enclosing_int_rect(absolute_rect())); + browsing_context().set_needs_display(enclosing_int_rect(absolute_rect())); return; } diff --git a/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp b/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp index 614f4bcada..0679257e55 100644 --- a/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp @@ -11,7 +11,7 @@ #include <LibWeb/DOM/Document.h> #include <LibWeb/Layout/ButtonBox.h> #include <LibWeb/Layout/Label.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -63,7 +63,7 @@ void ButtonBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsi set_needs_display(); m_tracking_mouse = true; - frame().event_handler().set_mouse_event_tracking_layout_node(this); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(this); } void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) @@ -73,7 +73,7 @@ void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& positio // NOTE: Handling the click may run arbitrary JS, which could disappear this node. NonnullRefPtr protected_this = *this; - NonnullRefPtr protected_frame = frame(); + NonnullRefPtr protected_frame = browsing_context(); bool is_inside_node_or_label = enclosing_int_rect(absolute_rect()).contains(position); if (!is_inside_node_or_label) @@ -114,7 +114,7 @@ void ButtonBox::handle_associated_label_mouseup(Badge<Label>) { // NOTE: Handling the click may run arbitrary JS, which could disappear this node. NonnullRefPtr protected_this = *this; - NonnullRefPtr protected_frame = frame(); + NonnullRefPtr protected_frame = browsing_context(); dom_node().did_click_button({}); m_being_pressed = false; diff --git a/Userland/Libraries/LibWeb/Layout/CheckBox.cpp b/Userland/Libraries/LibWeb/Layout/CheckBox.cpp index a9f323b4b5..fc92179cdb 100644 --- a/Userland/Libraries/LibWeb/Layout/CheckBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/CheckBox.cpp @@ -10,7 +10,7 @@ #include <LibGfx/StylePainter.h> #include <LibWeb/Layout/CheckBox.h> #include <LibWeb/Layout/Label.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -48,7 +48,7 @@ void CheckBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsig set_needs_display(); m_tracking_mouse = true; - frame().event_handler().set_mouse_event_tracking_layout_node(this); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(this); } void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) @@ -68,7 +68,7 @@ void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position m_being_pressed = false; m_tracking_mouse = false; - frame().event_handler().set_mouse_event_tracking_layout_node(nullptr); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr); } void CheckBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned) diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp index 092aa61d37..1ed914c87e 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp @@ -10,7 +10,7 @@ #include <LibWeb/InProcessWebView.h> #include <LibWeb/Layout/FrameBox.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -25,7 +25,7 @@ FrameBox::~FrameBox() void FrameBox::prepare_for_replaced_layout() { - VERIFY(dom_node().content_frame()); + VERIFY(dom_node().nested_browsing_context()); set_has_intrinsic_width(true); set_has_intrinsic_height(true); @@ -52,14 +52,14 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase) context.painter().add_clip_rect(enclosing_int_rect(absolute_rect())); context.painter().translate(absolute_x(), absolute_y()); - context.set_viewport_rect({ {}, dom_node().content_frame()->size() }); + context.set_viewport_rect({ {}, dom_node().nested_browsing_context()->size() }); const_cast<Layout::InitialContainingBlockBox*>(hosted_layout_tree)->paint_all_phases(context); context.set_viewport_rect(old_viewport_rect); context.painter().restore(); if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) { - if (dom_node().content_frame()->is_focused_frame()) { + if (dom_node().nested_browsing_context()->is_focused_context()) { context.painter().draw_rect(absolute_rect().to_type<int>(), Color::Cyan); } } @@ -70,8 +70,8 @@ void FrameBox::did_set_rect() { ReplacedBox::did_set_rect(); - VERIFY(dom_node().content_frame()); - dom_node().content_frame()->set_size(size().to_type<int>()); + VERIFY(dom_node().nested_browsing_context()); + dom_node().nested_browsing_context()->set_size(size().to_type<int>()); } } diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp index c358c08d66..c1b0065002 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp @@ -8,7 +8,7 @@ #include <LibGfx/Painter.h> #include <LibGfx/StylePainter.h> #include <LibWeb/Layout/ImageBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -16,12 +16,12 @@ ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr : ReplacedBox(document, element, move(style)) , m_image_loader(image_loader) { - frame().register_viewport_client(*this); + browsing_context().register_viewport_client(*this); } ImageBox::~ImageBox() { - frame().unregister_viewport_client(*this); + browsing_context().unregister_viewport_client(*this); } int ImageBox::preferred_width() const diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.h b/Userland/Libraries/LibWeb/Layout/ImageBox.h index de4527c814..c58853d373 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.h +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.h @@ -8,13 +8,13 @@ #include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/Layout/ReplacedBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { class ImageBox : public ReplacedBox - , public Frame::ViewportClient { + , public BrowsingContext::ViewportClient { public: ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&); virtual ~ImageBox() override; diff --git a/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp b/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp index 3cd7f29a33..3863546763 100644 --- a/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/InitialContainingBlockBox.cpp @@ -7,7 +7,7 @@ #include <LibGfx/Painter.h> #include <LibWeb/Dump.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Painting/StackingContext.h> namespace Web::Layout { diff --git a/Userland/Libraries/LibWeb/Layout/Label.cpp b/Userland/Libraries/LibWeb/Layout/Label.cpp index 053ff54fd4..0edff98432 100644 --- a/Userland/Libraries/LibWeb/Layout/Label.cpp +++ b/Userland/Libraries/LibWeb/Layout/Label.cpp @@ -13,7 +13,7 @@ #include <LibWeb/Layout/Label.h> #include <LibWeb/Layout/LabelableNode.h> #include <LibWeb/Layout/TextNode.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 533c747ffd..81be66ef25 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -15,7 +15,7 @@ #include <LibWeb/Layout/InitialContainingBlockBox.h> #include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/TextNode.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -104,16 +104,16 @@ HitTestResult Node::hit_test(const Gfx::IntPoint& position, HitTestType type) co return result; } -const Frame& Node::frame() const +const BrowsingContext& Node::browsing_context() const { - VERIFY(document().frame()); - return *document().frame(); + VERIFY(document().browsing_context()); + return *document().browsing_context(); } -Frame& Node::frame() +BrowsingContext& Node::browsing_context() { - VERIFY(document().frame()); - return *document().frame(); + VERIFY(document().browsing_context()); + return *document().browsing_context(); } const InitialContainingBlockBox& Node::root() const @@ -140,7 +140,7 @@ void Node::set_needs_display() if (auto* block = containing_block()) { block->for_each_fragment([&](auto& fragment) { if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) { - frame().set_needs_display(enclosing_int_rect(fragment.absolute_rect())); + browsing_context().set_needs_display(enclosing_int_rect(fragment.absolute_rect())); } return IterationDecision::Continue; }); diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index 770339732c..837ea203db 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -65,8 +65,8 @@ public: DOM::Document& document() { return m_document; } const DOM::Document& document() const { return m_document; } - const Frame& frame() const; - Frame& frame(); + const BrowsingContext& browsing_context() const; + BrowsingContext& browsing_context(); const InitialContainingBlockBox& root() const; InitialContainingBlockBox& root(); diff --git a/Userland/Libraries/LibWeb/Layout/RadioButton.cpp b/Userland/Libraries/LibWeb/Layout/RadioButton.cpp index 02399b7a7b..8712c2f9b0 100644 --- a/Userland/Libraries/LibWeb/Layout/RadioButton.cpp +++ b/Userland/Libraries/LibWeb/Layout/RadioButton.cpp @@ -10,7 +10,7 @@ #include <LibWeb/DOM/Document.h> #include <LibWeb/Layout/Label.h> #include <LibWeb/Layout/RadioButton.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { @@ -48,7 +48,7 @@ void RadioButton::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, un set_needs_display(); m_tracking_mouse = true; - frame().event_handler().set_mouse_event_tracking_layout_node(this); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(this); } void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) @@ -68,7 +68,7 @@ void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& posit m_being_pressed = false; m_tracking_mouse = false; - frame().event_handler().set_mouse_event_tracking_layout_node(nullptr); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr); } void RadioButton::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned) diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 24bcf24326..677a24f1b7 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -12,7 +12,7 @@ #include <LibWeb/Layout/TableFormattingContext.h> #include <LibWeb/Layout/TableRowBox.h> #include <LibWeb/Layout/TableRowGroupBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> namespace Web::Layout { diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.cpp b/Userland/Libraries/LibWeb/Layout/TextNode.cpp index e2f6783e31..c5aaeb47d8 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.cpp +++ b/Userland/Libraries/LibWeb/Layout/TextNode.cpp @@ -12,7 +12,7 @@ #include <LibWeb/Layout/InlineFormattingContext.h> #include <LibWeb/Layout/Label.h> #include <LibWeb/Layout/TextNode.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <ctype.h> namespace Web::Layout { @@ -77,17 +77,17 @@ void TextNode::paint_fragment(PaintContext& context, const LineBoxFragment& frag void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragment& fragment) const { - if (!frame().is_focused_frame()) + if (!browsing_context().is_focused_context()) return; - if (!frame().cursor_blink_state()) + if (!browsing_context().cursor_blink_state()) return; - if (frame().cursor_position().node() != &dom_node()) + if (browsing_context().cursor_position().node() != &dom_node()) return; // NOTE: This checks if the cursor is before the start or after the end of the fragment. If it is at the end, after all text, it should still be painted. - if (frame().cursor_position().offset() < (unsigned)fragment.start() || frame().cursor_position().offset() > (unsigned)(fragment.start() + fragment.length())) + if (browsing_context().cursor_position().offset() < (unsigned)fragment.start() || browsing_context().cursor_position().offset() > (unsigned)(fragment.start() + fragment.length())) return; if (!fragment.layout_node().dom_node() || !fragment.layout_node().dom_node()->is_editable()) @@ -95,7 +95,7 @@ void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragme auto fragment_rect = fragment.absolute_rect(); - float cursor_x = fragment_rect.x() + font().width(fragment.text().substring_view(0, frame().cursor_position().offset() - fragment.start())); + float cursor_x = fragment_rect.x() + font().width(fragment.text().substring_view(0, browsing_context().cursor_position().offset() - fragment.start())); float cursor_top = fragment_rect.top(); float cursor_height = fragment_rect.height(); Gfx::IntRect cursor_rect(cursor_x, cursor_top, 1, cursor_height); @@ -234,7 +234,7 @@ void TextNode::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint& positi if (!parent() || !is<Label>(*parent())) return; downcast<Label>(*parent()).handle_mousedown_on_label({}, position, button); - frame().event_handler().set_mouse_event_tracking_layout_node(this); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(this); } void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) @@ -246,7 +246,7 @@ void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position NonnullRefPtr protect = *this; downcast<Label>(*parent()).handle_mouseup_on_label({}, position, button); - frame().event_handler().set_mouse_event_tracking_layout_node(nullptr); + browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr); } void TextNode::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index f1ff25c13e..df5b565da1 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -18,13 +18,13 @@ #include <LibWeb/Loader/FrameLoader.h> #include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Namespace.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Page/Page.h> namespace Web { -FrameLoader::FrameLoader(Frame& frame) - : m_frame(frame) +FrameLoader::FrameLoader(BrowsingContext& browsing_context) + : m_browsing_context(browsing_context) { } @@ -136,7 +136,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type) return false; } - if (!m_frame.is_frame_nesting_allowed(request.url())) { + if (!m_browsing_context.is_frame_nesting_allowed(request.url())) { dbgln("No further recursion is allowed for the frame, abort load!"); return false; } @@ -144,7 +144,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type) auto& url = request.url(); if (type == Type::Navigation || type == Type::Reload) { - if (auto* page = frame().page()) + if (auto* page = browsing_context().page()) page->client().page_did_start_loading(url); } @@ -171,7 +171,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type) return; } dbgln("Decoded favicon, {}", bitmap->size()); - if (auto* page = frame().page()) + if (auto* page = browsing_context().page()) page->client().page_did_change_favicon(*bitmap); }); } @@ -188,7 +188,7 @@ bool FrameLoader::load(const URL& url, Type type) return false; } - auto request = LoadRequest::create_for_url_on_page(url, frame().page()); + auto request = LoadRequest::create_for_url_on_page(url, browsing_context().page()); return load(request, type); } @@ -197,7 +197,7 @@ void FrameLoader::load_html(const StringView& html, const URL& url) auto document = DOM::Document::create(url); HTML::HTMLDocumentParser parser(document, html, "utf-8"); parser.run(url); - frame().set_document(&parser.document()); + browsing_context().set_document(&parser.document()); } // FIXME: Use an actual templating engine (our own one when it's built, preferably @@ -217,7 +217,7 @@ void FrameLoader::load_error_page(const URL& failed_url, const String& error) generator.append(data); auto document = HTML::parse_html_document(generator.as_string_view(), failed_url, "utf-8"); VERIFY(document); - frame().set_document(document); + browsing_context().set_document(document); }, [](auto& error, auto) { dbgln("Failed to load error page: {}", error); @@ -259,7 +259,7 @@ void FrameLoader::resource_did_load() document->set_encoding(resource()->encoding()); document->set_content_type(resource()->mime_type()); - frame().set_document(document); + browsing_context().set_document(document); if (!parse_document(*document, resource()->encoded_data())) { load_error_page(url, "Failed to parse content."); @@ -272,15 +272,15 @@ void FrameLoader::resource_did_load() document->set_cookie(set_cookie.value(), Cookie::Source::Http); if (!url.fragment().is_empty()) - frame().scroll_to_anchor(url.fragment()); + browsing_context().scroll_to_anchor(url.fragment()); - if (auto* host_element = frame().host_element()) { + if (auto* host_element = browsing_context().host_element()) { // FIXME: Perhaps in the future we'll have a better common base class for <frame> and <iframe> VERIFY(is<HTML::HTMLIFrameElement>(*host_element)); - downcast<HTML::HTMLIFrameElement>(*host_element).content_frame_did_load({}); + downcast<HTML::HTMLIFrameElement>(*host_element).nested_browsing_context_did_load({}); } - if (auto* page = frame().page()) + if (auto* page = browsing_context().page()) page->client().page_did_finish_loading(url); } diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.h b/Userland/Libraries/LibWeb/Loader/FrameLoader.h index d3b1536470..2cd98a94a7 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.h +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.h @@ -23,7 +23,7 @@ public: IFrame, }; - explicit FrameLoader(Frame&); + explicit FrameLoader(BrowsingContext&); ~FrameLoader(); bool load(const URL&, Type); @@ -31,8 +31,8 @@ public: void load_html(const StringView&, const URL&); - Frame& frame() { return m_frame; } - const Frame& frame() const { return m_frame; } + BrowsingContext& browsing_context() { return m_browsing_context; } + const BrowsingContext& browsing_context() const { return m_browsing_context; } private: // ^ResourceClient @@ -42,7 +42,7 @@ private: void load_error_page(const URL& failed_url, const String& error_message); bool parse_document(DOM::Document&, const ByteBuffer& data); - Frame& m_frame; + BrowsingContext& m_browsing_context; size_t m_redirects_count { 0 }; }; diff --git a/Userland/Libraries/LibWeb/Page/Frame.cpp b/Userland/Libraries/LibWeb/Page/BrowsingContext.cpp index 0d130f2fa8..da594353f2 100644 --- a/Userland/Libraries/LibWeb/Page/Frame.cpp +++ b/Userland/Libraries/LibWeb/Page/BrowsingContext.cpp @@ -13,14 +13,14 @@ #include <LibWeb/Layout/BreakNode.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> #include <LibWeb/Layout/TextNode.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/UIEvents/EventNames.h> namespace Web { -Frame::Frame(DOM::Element& host_element, Frame& main_frame) - : m_page(*main_frame.page()) - , m_main_frame(main_frame) +BrowsingContext::BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context) + : m_page(*top_level_browsing_context.page()) + , m_top_level_browsing_context(top_level_browsing_context) , m_loader(*this) , m_event_handler({}, *this) , m_host_element(host_element) @@ -28,23 +28,23 @@ Frame::Frame(DOM::Element& host_element, Frame& main_frame) setup(); } -Frame::Frame(Page& page) +BrowsingContext::BrowsingContext(Page& page) : m_page(page) - , m_main_frame(*this) + , m_top_level_browsing_context(*this) , m_loader(*this) , m_event_handler({}, *this) { setup(); } -Frame::~Frame() +BrowsingContext::~BrowsingContext() { } -void Frame::setup() +void BrowsingContext::setup() { m_cursor_blink_timer = Core::Timer::construct(500, [this] { - if (!is_focused_frame()) + if (!is_focused_context()) return; if (m_cursor_position.node() && m_cursor_position.node()->layout_node()) { m_cursor_blink_state = !m_cursor_blink_state; @@ -53,24 +53,24 @@ void Frame::setup() }); } -void Frame::did_edit(Badge<EditEventHandler>) +void BrowsingContext::did_edit(Badge<EditEventHandler>) { reset_cursor_blink_cycle(); } -void Frame::reset_cursor_blink_cycle() +void BrowsingContext::reset_cursor_blink_cycle() { m_cursor_blink_state = true; m_cursor_blink_timer->restart(); m_cursor_position.node()->layout_node()->set_needs_display(); } -bool Frame::is_focused_frame() const +bool BrowsingContext::is_focused_context() const { - return m_page && &m_page->focused_frame() == this; + return m_page && &m_page->focused_context() == this; } -void Frame::set_document(DOM::Document* document) +void BrowsingContext::set_document(DOM::Document* document) { if (m_document == document) return; @@ -78,21 +78,21 @@ void Frame::set_document(DOM::Document* document) m_cursor_position = {}; if (m_document) - m_document->detach_from_frame({}, *this); + m_document->detach_from_browsing_context({}, *this); m_document = document; if (m_document) { - m_document->attach_to_frame({}, *this); - if (m_page && is_main_frame()) + m_document->attach_to_browsing_context({}, *this); + if (m_page && is_top_level()) m_page->client().page_did_change_title(m_document->title()); } if (m_page) - m_page->client().page_did_set_document_in_main_frame(m_document); + m_page->client().page_did_set_document_in_top_level_browsing_context(m_document); } -void Frame::set_viewport_rect(const Gfx::IntRect& rect) +void BrowsingContext::set_viewport_rect(const Gfx::IntRect& rect) { bool did_change = false; @@ -116,7 +116,7 @@ void Frame::set_viewport_rect(const Gfx::IntRect& rect) } } -void Frame::set_size(const Gfx::IntSize& size) +void BrowsingContext::set_size(const Gfx::IntSize& size) { if (m_size == size) return; @@ -130,7 +130,7 @@ void Frame::set_size(const Gfx::IntSize& size) client->frame_did_set_viewport_rect(viewport_rect()); } -void Frame::set_viewport_scroll_offset(const Gfx::IntPoint& offset) +void BrowsingContext::set_viewport_scroll_offset(const Gfx::IntPoint& offset) { if (m_viewport_scroll_offset == offset) return; @@ -140,14 +140,14 @@ void Frame::set_viewport_scroll_offset(const Gfx::IntPoint& offset) client->frame_did_set_viewport_rect(viewport_rect()); } -void Frame::set_needs_display(const Gfx::IntRect& rect) +void BrowsingContext::set_needs_display(const Gfx::IntRect& rect) { if (!viewport_rect().intersects(rect)) return; - if (is_main_frame()) { + if (is_top_level()) { if (m_page) - m_page->client().page_did_invalidate(to_main_frame_rect(rect)); + m_page->client().page_did_invalidate(to_top_level_rect(rect)); return; } @@ -155,7 +155,7 @@ void Frame::set_needs_display(const Gfx::IntRect& rect) host_element()->layout_node()->set_needs_display(); } -void Frame::scroll_to_anchor(const String& fragment) +void BrowsingContext::scroll_to_anchor(const String& fragment) { if (!document()) return; @@ -190,18 +190,18 @@ void Frame::scroll_to_anchor(const String& fragment) m_page->client().page_did_request_scroll_into_view(enclosing_int_rect(float_rect)); } -Gfx::IntRect Frame::to_main_frame_rect(const Gfx::IntRect& a_rect) +Gfx::IntRect BrowsingContext::to_top_level_rect(const Gfx::IntRect& a_rect) { auto rect = a_rect; - rect.set_location(to_main_frame_position(a_rect.location())); + rect.set_location(to_top_level_position(a_rect.location())); return rect; } -Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position) +Gfx::IntPoint BrowsingContext::to_top_level_position(const Gfx::IntPoint& a_position) { auto position = a_position; for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { - if (ancestor->is_main_frame()) + if (ancestor->is_top_level()) break; if (!ancestor->host_element()) return {}; @@ -212,7 +212,7 @@ Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position) return position; } -void Frame::set_cursor_position(DOM::Position position) +void BrowsingContext::set_cursor_position(DOM::Position position) { if (m_cursor_position == position) return; @@ -228,7 +228,7 @@ void Frame::set_cursor_position(DOM::Position position) reset_cursor_blink_cycle(); } -String Frame::selected_text() const +String BrowsingContext::selected_text() const { StringBuilder builder; if (!m_document) @@ -275,29 +275,29 @@ String Frame::selected_text() const return builder.to_string(); } -void Frame::register_viewport_client(ViewportClient& client) +void BrowsingContext::register_viewport_client(ViewportClient& client) { auto result = m_viewport_clients.set(&client); VERIFY(result == AK::HashSetResult::InsertedNewEntry); } -void Frame::unregister_viewport_client(ViewportClient& client) +void BrowsingContext::unregister_viewport_client(ViewportClient& client) { bool was_removed = m_viewport_clients.remove(&client); VERIFY(was_removed); } -void Frame::register_frame_nesting(URL const& url) +void BrowsingContext::register_frame_nesting(URL const& url) { m_frame_nesting_levels.ensure(url)++; } -bool Frame::is_frame_nesting_allowed(URL const& url) const +bool BrowsingContext::is_frame_nesting_allowed(URL const& url) const { return m_frame_nesting_levels.get(url).value_or(0) < 3; } -bool Frame::increment_cursor_position_offset() +bool BrowsingContext::increment_cursor_position_offset() { if (!m_cursor_position.increment_offset()) return false; @@ -305,7 +305,7 @@ bool Frame::increment_cursor_position_offset() return true; } -bool Frame::decrement_cursor_position_offset() +bool BrowsingContext::decrement_cursor_position_offset() { if (!m_cursor_position.decrement_offset()) return false; diff --git a/Userland/Libraries/LibWeb/Page/Frame.h b/Userland/Libraries/LibWeb/Page/BrowsingContext.h index 8a0346d0b7..fc8c1f72ed 100644 --- a/Userland/Libraries/LibWeb/Page/Frame.h +++ b/Userland/Libraries/LibWeb/Page/BrowsingContext.h @@ -21,11 +21,11 @@ namespace Web { -class Frame : public TreeNode<Frame> { +class BrowsingContext : public TreeNode<BrowsingContext> { public: - static NonnullRefPtr<Frame> create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt_ref(*new Frame(host_element, main_frame)); } - static NonnullRefPtr<Frame> create(Page& page) { return adopt_ref(*new Frame(page)); } - ~Frame(); + static NonnullRefPtr<BrowsingContext> create_nested(DOM::Element& host_element, BrowsingContext& top_level_browsing_context) { return adopt_ref(*new BrowsingContext(host_element, top_level_browsing_context)); } + static NonnullRefPtr<BrowsingContext> create(Page& page) { return adopt_ref(*new BrowsingContext(page)); } + ~BrowsingContext(); class ViewportClient { public: @@ -35,8 +35,8 @@ public: void register_viewport_client(ViewportClient&); void unregister_viewport_client(ViewportClient&); - bool is_main_frame() const { return this == &m_main_frame; } - bool is_focused_frame() const; + bool is_top_level() const { return this == &m_top_level_browsing_context; } + bool is_focused_context() const; const DOM::Document* document() const { return m_document; } DOM::Document* document() { return m_document; } @@ -63,14 +63,14 @@ public: void scroll_to_anchor(const String&); - Frame& main_frame() { return m_main_frame; } - const Frame& main_frame() const { return m_main_frame; } + BrowsingContext& top_level_browsing_context() { return m_top_level_browsing_context; } + BrowsingContext const& top_level_browsing_context() const { return m_top_level_browsing_context; } DOM::Element* host_element() { return m_host_element; } const DOM::Element* host_element() const { return m_host_element; } - Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&); - Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&); + Gfx::IntPoint to_top_level_position(const Gfx::IntPoint&); + Gfx::IntRect to_top_level_rect(const Gfx::IntRect&); const DOM::Position& cursor_position() const { return m_cursor_position; } void set_cursor_position(DOM::Position); @@ -90,15 +90,15 @@ public: HashMap<URL, size_t> const& frame_nesting_levels() const { return m_frame_nesting_levels; } private: - explicit Frame(DOM::Element& host_element, Frame& main_frame); - explicit Frame(Page&); + explicit BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context); + explicit BrowsingContext(Page&); void reset_cursor_blink_cycle(); void setup(); WeakPtr<Page> m_page; - Frame& m_main_frame; + BrowsingContext& m_top_level_browsing_context; FrameLoader m_loader; EventHandler m_event_handler; diff --git a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp index e3d6691cda..a9246df1e6 100644 --- a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp @@ -12,8 +12,8 @@ #include <LibWeb/DOM/Text.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> #include <LibWeb/Layout/LayoutPosition.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Page/EditEventHandler.h> -#include <LibWeb/Page/Frame.h> namespace Web { diff --git a/Userland/Libraries/LibWeb/Page/EditEventHandler.h b/Userland/Libraries/LibWeb/Page/EditEventHandler.h index 30fe21f30a..0ac8827ebf 100644 --- a/Userland/Libraries/LibWeb/Page/EditEventHandler.h +++ b/Userland/Libraries/LibWeb/Page/EditEventHandler.h @@ -13,7 +13,7 @@ namespace Web { class EditEventHandler { public: - explicit EditEventHandler(Frame& frame) + explicit EditEventHandler(BrowsingContext& frame) : m_frame(frame) { } @@ -25,7 +25,7 @@ public: virtual void handle_insert(DOM::Position, u32 code_point); private: - Frame& m_frame; + BrowsingContext& m_frame; }; } diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index c5c491dc43..31fd4c9cc4 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -14,8 +14,8 @@ #include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/InProcessWebView.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Page/EventHandler.h> -#include <LibWeb/Page/Frame.h> #include <LibWeb/UIEvents/EventNames.h> #include <LibWeb/UIEvents/MouseEvent.h> @@ -87,7 +87,7 @@ static Gfx::IntPoint compute_mouse_event_offset(const Gfx::IntPoint& position, c }; } -EventHandler::EventHandler(Badge<Frame>, Frame& frame) +EventHandler::EventHandler(Badge<BrowsingContext>, BrowsingContext& frame) : m_frame(frame) , m_edit_event_handler(make<EditEventHandler>(frame)) { @@ -158,7 +158,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button if (result.layout_node && result.layout_node->dom_node()) { RefPtr<DOM::Node> node = result.layout_node->dom_node(); if (is<HTML::HTMLIFrameElement>(*node)) { - if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).content_frame()) + if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).nested_browsing_context()) return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return false; } @@ -202,13 +202,13 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt return false; if (is<HTML::HTMLIFrameElement>(*node)) { - if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).content_frame()) + if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).nested_browsing_context()) return subframe->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return false; } if (auto* page = m_frame.page()) - page->set_focused_frame({}, m_frame); + page->set_focused_browsing_context({}, m_frame); auto offset = compute_mouse_event_offset(position, *result.layout_node); node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mousedown, offset.x(), offset.y(), position.x(), position.y())); @@ -222,7 +222,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt auto& image_element = downcast<HTML::HTMLImageElement>(*node); auto image_url = image_element.document().complete_url(image_element.src()); if (auto* page = m_frame.page()) - page->client().page_did_request_image_context_menu(m_frame.to_main_frame_position(position), image_url, "", modifiers, image_element.bitmap()); + page->client().page_did_request_image_context_menu(m_frame.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap()); return true; } @@ -237,7 +237,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt auto anchor = href.substring_view(1, href.length() - 1); m_frame.scroll_to_anchor(anchor); } else { - if (m_frame.is_main_frame()) { + if (m_frame.is_top_level()) { if (auto* page = m_frame.page()) page->client().page_did_click_link(url, link->target(), modifiers); } else { @@ -247,7 +247,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt } } else if (button == GUI::MouseButton::Right) { if (auto* page = m_frame.page()) - page->client().page_did_request_link_context_menu(m_frame.to_main_frame_position(position), url, link->target(), modifiers); + page->client().page_did_request_link_context_menu(m_frame.to_top_level_position(position), url, link->target(), modifiers); } else if (button == GUI::MouseButton::Middle) { if (auto* page = m_frame.page()) page->client().page_did_middle_click_link(url, link->target(), modifiers); @@ -262,7 +262,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt } } else if (button == GUI::MouseButton::Right) { if (auto* page = m_frame.page()) - page->client().page_did_request_context_menu(m_frame.to_main_frame_position(position)); + page->client().page_did_request_context_menu(m_frame.to_top_level_position(position)); } } return true; @@ -299,7 +299,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt RefPtr<DOM::Node> node = result.layout_node->dom_node(); if (node && is<HTML::HTMLIFrameElement>(*node)) { - if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).content_frame()) + if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).nested_browsing_context()) return subframe->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers); return false; } @@ -340,7 +340,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt if (hovered_node_changed) { RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr; if (hovered_html_element && !hovered_html_element->title().is_null()) { - page->client().page_did_enter_tooltip_area(m_frame.to_main_frame_position(position), hovered_html_element->title()); + page->client().page_did_enter_tooltip_area(m_frame.to_top_level_position(position), hovered_html_element->title()); } else { page->client().page_did_leave_tooltip_area(); } diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.h b/Userland/Libraries/LibWeb/Page/EventHandler.h index 9232a54942..796bac09cb 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.h +++ b/Userland/Libraries/LibWeb/Page/EventHandler.h @@ -17,11 +17,11 @@ namespace Web { -class Frame; +class BrowsingContext; class EventHandler { public: - explicit EventHandler(Badge<Frame>, Frame&); + explicit EventHandler(Badge<BrowsingContext>, BrowsingContext&); ~EventHandler(); bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers); @@ -42,7 +42,7 @@ private: Layout::InitialContainingBlockBox* layout_root(); const Layout::InitialContainingBlockBox* layout_root() const; - Frame& m_frame; + BrowsingContext& m_frame; bool m_in_mouse_selection { false }; diff --git a/Userland/Libraries/LibWeb/Page/Page.cpp b/Userland/Libraries/LibWeb/Page/Page.cpp index 5b8e583980..f44117d373 100644 --- a/Userland/Libraries/LibWeb/Page/Page.cpp +++ b/Userland/Libraries/LibWeb/Page/Page.cpp @@ -5,7 +5,7 @@ */ #include <LibWeb/InProcessWebView.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <LibWeb/Page/Page.h> namespace Web { @@ -13,38 +13,38 @@ namespace Web { Page::Page(PageClient& client) : m_client(client) { - m_main_frame = Frame::create(*this); + m_top_level_browsing_context = BrowsingContext::create(*this); } Page::~Page() { } -Frame& Page::focused_frame() +BrowsingContext& Page::focused_context() { - if (m_focused_frame) - return *m_focused_frame; - return main_frame(); + if (m_focused_context) + return *m_focused_context; + return top_level_browsing_context(); } -void Page::set_focused_frame(Badge<EventHandler>, Frame& frame) +void Page::set_focused_browsing_context(Badge<EventHandler>, BrowsingContext& browsing_context) { - m_focused_frame = frame.make_weak_ptr(); + m_focused_context = browsing_context.make_weak_ptr(); } void Page::load(const URL& url) { - main_frame().loader().load(url, FrameLoader::Type::Navigation); + top_level_browsing_context().loader().load(url, FrameLoader::Type::Navigation); } void Page::load(const LoadRequest& request) { - main_frame().loader().load(request, FrameLoader::Type::Navigation); + top_level_browsing_context().loader().load(request, FrameLoader::Type::Navigation); } void Page::load_html(const StringView& html, const URL& url) { - main_frame().loader().load_html(html, url); + top_level_browsing_context().loader().load_html(html, url); } Gfx::Palette Page::palette() const @@ -59,27 +59,27 @@ Gfx::IntRect Page::screen_rect() const bool Page::handle_mousewheel(const Gfx::IntPoint& position, unsigned button, unsigned modifiers, int wheel_delta) { - return main_frame().event_handler().handle_mousewheel(position, button, modifiers, wheel_delta); + return top_level_browsing_context().event_handler().handle_mousewheel(position, button, modifiers, wheel_delta); } bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { - return main_frame().event_handler().handle_mouseup(position, button, modifiers); + return top_level_browsing_context().event_handler().handle_mouseup(position, button, modifiers); } bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { - return main_frame().event_handler().handle_mousedown(position, button, modifiers); + return top_level_browsing_context().event_handler().handle_mousedown(position, button, modifiers); } bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers) { - return main_frame().event_handler().handle_mousemove(position, buttons, modifiers); + return top_level_browsing_context().event_handler().handle_mousemove(position, buttons, modifiers); } bool Page::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point) { - return focused_frame().event_handler().handle_keydown(key, modifiers, code_point); + return focused_context().event_handler().handle_keydown(key, modifiers, code_point); } } diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index ba676b9a5a..b48d205003 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -33,13 +33,13 @@ public: PageClient& client() { return m_client; } const PageClient& client() const { return m_client; } - Web::Frame& main_frame() { return *m_main_frame; } - const Web::Frame& main_frame() const { return *m_main_frame; } + Web::BrowsingContext& top_level_browsing_context() { return *m_top_level_browsing_context; } + const Web::BrowsingContext& top_level_browsing_context() const { return *m_top_level_browsing_context; } - Web::Frame& focused_frame(); - const Web::Frame& focused_frame() const { return const_cast<Page*>(this)->focused_frame(); } + Web::BrowsingContext& focused_context(); + const Web::BrowsingContext& focused_context() const { return const_cast<Page*>(this)->focused_context(); } - void set_focused_frame(Badge<EventHandler>, Frame&); + void set_focused_browsing_context(Badge<EventHandler>, BrowsingContext&); void load(const URL&); void load(const LoadRequest&); @@ -59,8 +59,8 @@ public: private: PageClient& m_client; - RefPtr<Frame> m_main_frame; - WeakPtr<Frame> m_focused_frame; + RefPtr<BrowsingContext> m_top_level_browsing_context; + WeakPtr<BrowsingContext> m_focused_context; }; class PageClient { @@ -68,7 +68,7 @@ public: virtual bool is_multi_process() const = 0; virtual Gfx::Palette palette() const = 0; virtual Gfx::IntRect screen_rect() const = 0; - virtual void page_did_set_document_in_main_frame(DOM::Document*) { } + virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) { } virtual void page_did_change_title(const String&) { } virtual void page_did_start_loading(const URL&) { } virtual void page_did_finish_loading(const URL&) { } diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp index 899273b622..093a5267d5 100644 --- a/Userland/Services/WebContent/ClientConnection.cpp +++ b/Userland/Services/WebContent/ClientConnection.cpp @@ -20,7 +20,7 @@ #include <LibWeb/Dump.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> #include <LibWeb/Loader/ResourceLoader.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <WebContent/ClientConnection.h> #include <WebContent/PageHost.h> #include <WebContent/WebContentClientEndpoint.h> @@ -171,19 +171,19 @@ void ClientConnection::key_down(i32 key, unsigned int modifiers, u32 code_point) void ClientConnection::debug_request(const String& request, const String& argument) { if (request == "dump-dom-tree") { - if (auto* doc = page().main_frame().document()) + if (auto* doc = page().top_level_browsing_context().document()) Web::dump_tree(*doc); } if (request == "dump-layout-tree") { - if (auto* doc = page().main_frame().document()) { + if (auto* doc = page().top_level_browsing_context().document()) { if (auto* icb = doc->layout_node()) Web::dump_tree(*icb); } } if (request == "dump-style-sheets") { - if (auto* doc = page().main_frame().document()) { + if (auto* doc = page().top_level_browsing_context().document()) { for (auto& sheet : doc->style_sheets().sheets()) { Web::dump_sheet(sheet); } @@ -197,7 +197,7 @@ void ClientConnection::debug_request(const String& request, const String& argume if (request == "set-line-box-borders") { bool state = argument == "on"; m_page_host->set_should_show_line_box_borders(state); - page().main_frame().set_needs_display(page().main_frame().viewport_rect()); + page().top_level_browsing_context().set_needs_display(page().top_level_browsing_context().viewport_rect()); } if (request == "clear-cache") { @@ -211,14 +211,14 @@ void ClientConnection::debug_request(const String& request, const String& argume void ClientConnection::get_source() { - if (auto* doc = page().main_frame().document()) { + if (auto* doc = page().top_level_browsing_context().document()) { async_did_get_source(doc->url(), doc->source()); } } void ClientConnection::js_console_initialize() { - if (auto* document = page().main_frame().document()) { + if (auto* document = page().top_level_browsing_context().document()) { auto interpreter = document->interpreter().make_weak_ptr(); if (m_interpreter.ptr() == interpreter.ptr()) return; diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 71df79afe7..26538b64f5 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -10,7 +10,7 @@ #include <LibGfx/SystemTheme.h> #include <LibWeb/Cookie/ParsedCookie.h> #include <LibWeb/Layout/InitialContainingBlockBox.h> -#include <LibWeb/Page/Frame.h> +#include <LibWeb/Page/BrowsingContext.h> #include <WebContent/WebContentClientEndpoint.h> namespace WebContent { @@ -48,7 +48,7 @@ void PageHost::set_palette_impl(const Gfx::PaletteImpl& impl) Web::Layout::InitialContainingBlockBox* PageHost::layout_root() { - auto* document = page().main_frame().document(); + auto* document = page().top_level_browsing_context().document(); if (!document) return nullptr; return document->layout_node(); @@ -73,7 +73,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target) void PageHost::set_viewport_rect(const Gfx::IntRect& rect) { - page().main_frame().set_viewport_rect(rect); + page().top_level_browsing_context().set_viewport_rect(rect); } void PageHost::page_did_invalidate(const Gfx::IntRect& content_rect) |