diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index ea65051ae3..c2a3557912 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -835,9 +835,9 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(L return IdentifierStyleValue::create(ValueID::None); // The transform matrix is held by the StackingContext, so we need to make sure we have one first. - auto const* viewport = layout_node.document().paintable_box(); + auto const* viewport = layout_node.document().paintable(); VERIFY(viewport); - const_cast(verify_cast(*viewport)).build_stacking_context_tree_if_needed(); + const_cast(*viewport).build_stacking_context_tree_if_needed(); VERIFY(layout_node.paintable()); auto const& paintable_box = verify_cast(layout_node.paintable()); diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index e7193a61cd..de9752e86a 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -3396,4 +3397,14 @@ void Document::shared_declarative_refresh_steps(StringView input, JS::GCPtr(Node::paintable()); +} + +Painting::ViewportPaintable* Document::paintable() +{ + return static_cast(Node::paintable()); +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 3addf25a26..1872f5dfc6 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -210,6 +210,9 @@ public: Layout::Viewport const* layout_node() const; Layout::Viewport* layout_node(); + Painting::ViewportPaintable const* paintable() const; + Painting::ViewportPaintable* paintable(); + void schedule_style_update(); void schedule_layout_update(); diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 66ef92be48..f5bd577185 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -1445,6 +1445,13 @@ Painting::Paintable const* Node::paintable() const return layout_node()->paintable(); } +Painting::Paintable* Node::paintable() +{ + if (!layout_node()) + return nullptr; + return layout_node()->paintable(); +} + Painting::PaintableBox const* Node::paintable_box() const { if (!layout_node()) diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 854f6778fa..2bb02f7211 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -185,6 +185,7 @@ public: Painting::PaintableBox const* paintable_box() const; Painting::PaintableBox* paintable_box(); Painting::Paintable const* paintable() const; + Painting::Paintable* paintable(); void set_layout_node(Badge, JS::NonnullGCPtr); void detach_layout_node(Badge); diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 2bab4b6c8e..791a3fa8d8 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -521,6 +521,7 @@ class PaintableWithLines; class StackingContext; class TextPaintable; class VideoPaintable; +class ViewportPaintable; enum class PaintPhase; diff --git a/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp b/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp index 8ce1d38f70..72eba5e401 100644 --- a/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp @@ -44,7 +44,7 @@ void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase pha auto* hosted_document = layout_box().dom_node().content_document_without_origin_check(); if (!hosted_document) return; - auto* hosted_paint_tree = hosted_document->paintable_box(); + auto* hosted_paint_tree = hosted_document->paintable(); if (!hosted_paint_tree) return; @@ -57,7 +57,7 @@ void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase pha context.painter().translate(absolute_device_rect.x().value(), absolute_device_rect.y().value()); context.set_device_viewport_rect({ {}, context.enclosing_device_size(layout_box().dom_node().nested_browsing_context()->size()) }); - const_cast(verify_cast(*hosted_paint_tree)).paint_all_phases(context); + const_cast(hosted_paint_tree)->paint_all_phases(context); context.set_device_viewport_rect(old_viewport_rect); context.painter().restore(); diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 53027b0352..839a00ad87 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -100,7 +100,7 @@ void SVGDecodedImageData::render(Gfx::IntSize size) const Gfx::Painter painter(*m_bitmap); PaintContext context(painter, m_page_client->palette(), m_page_client->device_pixels_per_css_pixel()); - verify_cast(*m_document->paintable_box()).paint_all_phases(context); + m_document->paintable()->paint_all_phases(context); } RefPtr SVGDecodedImageData::bitmap(size_t, Gfx::IntSize size) const diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 9dce9a7d66..816722f39b 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -31,8 +31,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index cfd7e9a831..0af50f8861 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -122,8 +122,10 @@ void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& targ Gfx::Painter painter(target); Gfx::IntRect bitmap_rect { {}, content_rect.size().to_type() }; - if (auto* document = page().top_level_browsing_context().active_document()) + auto document = page().top_level_browsing_context().active_document(); + if (document) { document->update_layout(); + } auto background_color = this->background_color(); @@ -131,16 +133,14 @@ void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& targ painter.clear_rect(bitmap_rect, palette().base()); painter.fill_rect(bitmap_rect, background_color); - auto* layout_root = this->layout_root(); - if (!layout_root) { + if (!document->paintable()) return; - } Web::PaintContext context(painter, palette(), device_pixels_per_css_pixel()); context.set_should_show_line_box_borders(m_should_show_line_box_borders); context.set_device_viewport_rect(content_rect); context.set_has_focus(m_has_focus); - verify_cast(*layout_root->paintable_box()).paint_all_phases(context); + document->paintable()->paint_all_phases(context); } void PageHost::set_viewport_rect(Web::DevicePixelRect const& rect)