diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index cf3d807f2fe..054491ba38d 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -538,7 +538,6 @@ set(SOURCES Layout/FieldSetBox.cpp Layout/FlexFormattingContext.cpp Layout/FormattingContext.cpp - Layout/FrameBox.cpp Layout/GridFormattingContext.cpp Layout/ImageBox.cpp Layout/ImageProvider.cpp @@ -555,6 +554,7 @@ set(SOURCES Layout/LineBuilder.cpp Layout/ListItemBox.cpp Layout/ListItemMarkerBox.cpp + Layout/NavigableContainerViewport.cpp Layout/Node.cpp Layout/RadioButton.cpp Layout/ReplacedBox.cpp diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index a8e67104934..bf637515d4b 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -35,8 +35,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -323,8 +323,8 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho builder.appendff(" children: {}", box.children_are_inline() ? "inline" : "not-inline"); - if (is(box)) { - auto const& frame_box = static_cast(box); + if (is(box)) { + auto const& frame_box = static_cast(box); if (auto const* document = frame_box.dom_node().content_document_without_origin_check()) { builder.appendff(" (url: {})", document->url()); } diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index d352d2d92db..022936135c5 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include namespace Web::HTML { @@ -36,7 +36,7 @@ void HTMLIFrameElement::initialize(JS::Realm& realm) GC::Ptr HTMLIFrameElement::create_layout_node(CSS::StyleProperties style) { - return heap().allocate(document(), *this, move(style)); + return heap().allocate(document(), *this, move(style)); } void HTMLIFrameElement::adjust_computed_style(CSS::StyleProperties& style) diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index bb81c5a03bf..8229eaf20e6 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -143,7 +143,7 @@ GC::Ptr HTMLObjectElement::create_layout_node(CSS::StyleProperties case Representation::Children: return NavigableContainer::create_layout_node(move(style)); case Representation::NestedBrowsingContext: - // FIXME: Actually paint the nested browsing context's document, similar to how iframes are painted with FrameBox and NestedBrowsingContextPaintable. + // FIXME: Actually paint the nested browsing context's document, similar to how iframes are painted with NavigableContainerViewport and NestedBrowsingContextPaintable. return nullptr; case Representation::Image: if (image_data()) diff --git a/Libraries/LibWeb/Layout/FrameBox.cpp b/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp similarity index 58% rename from Libraries/LibWeb/Layout/FrameBox.cpp rename to Libraries/LibWeb/Layout/NavigableContainerViewport.cpp index 373e7143d23..872904822b6 100644 --- a/Libraries/LibWeb/Layout/FrameBox.cpp +++ b/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp @@ -1,33 +1,33 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2024, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include -#include +#include #include #include namespace Web::Layout { -GC_DEFINE_ALLOCATOR(FrameBox); +GC_DEFINE_ALLOCATOR(NavigableContainerViewport); -FrameBox::FrameBox(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) +NavigableContainerViewport::NavigableContainerViewport(DOM::Document& document, DOM::Element& element, CSS::StyleProperties style) : ReplacedBox(document, element, move(style)) { } -FrameBox::~FrameBox() = default; +NavigableContainerViewport::~NavigableContainerViewport() = default; -void FrameBox::prepare_for_replaced_layout() +void NavigableContainerViewport::prepare_for_replaced_layout() { // FIXME: Do proper error checking, etc. set_natural_width(dom_node().get_attribute_value(HTML::AttributeNames::width).to_number().value_or(300)); set_natural_height(dom_node().get_attribute_value(HTML::AttributeNames::height).to_number().value_or(150)); } -void FrameBox::did_set_content_size() +void NavigableContainerViewport::did_set_content_size() { ReplacedBox::did_set_content_size(); @@ -35,7 +35,7 @@ void FrameBox::did_set_content_size() dom_node().content_navigable()->set_viewport_size(paintable_box()->content_size()); } -GC::Ptr FrameBox::create_paintable() const +GC::Ptr NavigableContainerViewport::create_paintable() const { return Painting::NestedBrowsingContextPaintable::create(*this); } diff --git a/Libraries/LibWeb/Layout/FrameBox.h b/Libraries/LibWeb/Layout/NavigableContainerViewport.h similarity index 62% rename from Libraries/LibWeb/Layout/FrameBox.h rename to Libraries/LibWeb/Layout/NavigableContainerViewport.h index 5d6c3f7c21a..d3f2039f014 100644 --- a/Libraries/LibWeb/Layout/FrameBox.h +++ b/Libraries/LibWeb/Layout/NavigableContainerViewport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2024, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,13 +11,13 @@ namespace Web::Layout { -class FrameBox final : public ReplacedBox { - GC_CELL(FrameBox, ReplacedBox); - GC_DECLARE_ALLOCATOR(FrameBox); +class NavigableContainerViewport final : public ReplacedBox { + GC_CELL(NavigableContainerViewport, ReplacedBox); + GC_DECLARE_ALLOCATOR(NavigableContainerViewport); public: - FrameBox(DOM::Document&, DOM::Element&, CSS::StyleProperties); - virtual ~FrameBox() override; + NavigableContainerViewport(DOM::Document&, DOM::Element&, CSS::StyleProperties); + virtual ~NavigableContainerViewport() override; virtual void prepare_for_replaced_layout() override; diff --git a/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp b/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp index 3dd520c8d27..cfc42b60ae6 100644 --- a/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp +++ b/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -16,19 +16,19 @@ namespace Web::Painting { GC_DEFINE_ALLOCATOR(NestedBrowsingContextPaintable); -GC::Ref NestedBrowsingContextPaintable::create(Layout::FrameBox const& layout_box) +GC::Ref NestedBrowsingContextPaintable::create(Layout::NavigableContainerViewport const& layout_box) { return layout_box.heap().allocate(layout_box); } -NestedBrowsingContextPaintable::NestedBrowsingContextPaintable(Layout::FrameBox const& layout_box) +NestedBrowsingContextPaintable::NestedBrowsingContextPaintable(Layout::NavigableContainerViewport const& layout_box) : PaintableBox(layout_box) { } -Layout::FrameBox const& NestedBrowsingContextPaintable::layout_box() const +Layout::NavigableContainerViewport const& NestedBrowsingContextPaintable::layout_box() const { - return static_cast(layout_node()); + return static_cast(layout_node()); } void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase phase) const diff --git a/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.h b/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.h index d966c205acd..af5eb981c83 100644 --- a/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.h +++ b/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace Web::Painting { @@ -16,14 +16,14 @@ class NestedBrowsingContextPaintable final : public PaintableBox { GC_DECLARE_ALLOCATOR(NestedBrowsingContextPaintable); public: - static GC::Ref create(Layout::FrameBox const&); + static GC::Ref create(Layout::NavigableContainerViewport const&); virtual void paint(PaintContext&, PaintPhase) const override; - Layout::FrameBox const& layout_box() const; + Layout::NavigableContainerViewport const& layout_box() const; private: - NestedBrowsingContextPaintable(Layout::FrameBox const&); + NestedBrowsingContextPaintable(Layout::NavigableContainerViewport const&); }; } diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn index 5175c74d37e..3a3bf804b87 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn @@ -16,7 +16,7 @@ source_set("Layout") { "CheckBox.cpp", "FlexFormattingContext.cpp", "FormattingContext.cpp", - "FrameBox.cpp", + "NavigableContainerViewport.cpp", "GridFormattingContext.cpp", "ImageBox.cpp", "ImageProvider.cpp", diff --git a/Tests/LibWeb/Layout/expected/misc/create-iframes-using-innerhtml.txt b/Tests/LibWeb/Layout/expected/misc/create-iframes-using-innerhtml.txt index 98763956540..5a81f552805 100644 --- a/Tests/LibWeb/Layout/expected/misc/create-iframes-using-innerhtml.txt +++ b/Tests/LibWeb/Layout/expected/misc/create-iframes-using-innerhtml.txt @@ -3,39 +3,39 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (8,8) content-size 784x0 children: not-inline BlockContainer at (8,8) content-size 784x0 children: not-inline BlockContainer
at (8,8) content-size 1x1 positioned [BFC] children: inline - frag 0 from FrameBox start: 0, length: 0, rect: [18,18 10x10] baseline: 30 - frag 1 from FrameBox start: 0, length: 0, rect: [18,48 10x10] baseline: 30 - frag 2 from FrameBox start: 0, length: 0, rect: [18,78 10x10] baseline: 30 - frag 3 from FrameBox start: 0, length: 0, rect: [18,108 10x10] baseline: 30 - frag 4 from FrameBox start: 0, length: 0, rect: [18,138 10x10] baseline: 30 - frag 5 from FrameBox start: 0, length: 0, rect: [18,168 10x10] baseline: 30 - frag 6 from FrameBox start: 0, length: 0, rect: [18,198 10x10] baseline: 30 - frag 7 from FrameBox start: 0, length: 0, rect: [18,228 10x10] baseline: 30 - frag 8 from FrameBox start: 0, length: 0, rect: [18,258 10x10] baseline: 30 - frag 9 from FrameBox start: 0, length: 0, rect: [18,288 10x10] baseline: 30 - FrameBox