From b340a85523c8f8872d184a46d292c0771d4bbffd Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 10 Sep 2023 13:41:00 +0100 Subject: [PATCH] LibWeb: Make StackingContext functions `static` where possible These don't need to be member functions, and this will make it easier to use these to paint elements (into an off-screen mask bitmap). --- Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 10 +++++----- Userland/Libraries/LibWeb/Painting/StackingContext.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 1b668d665b..bc8a004a2e 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -74,7 +74,7 @@ static PaintPhase to_paint_phase(StackingContext::StackingContextPaintPhase phas } } -void StackingContext::paint_node_as_stacking_context(Paintable const& paintable, PaintContext& context) const +void StackingContext::paint_node_as_stacking_context(Paintable const& paintable, PaintContext& context) { paint_node(paintable, context, PaintPhase::Background); paint_node(paintable, context, PaintPhase::Border); @@ -88,12 +88,12 @@ void StackingContext::paint_node_as_stacking_context(Paintable const& paintable, paint_descendants(context, paintable, StackingContextPaintPhase::FocusAndOverlay); } -void StackingContext::paint_descendants(PaintContext& context, Paintable const& paintable, StackingContextPaintPhase phase) const +void StackingContext::paint_descendants(PaintContext& context, Paintable const& paintable, StackingContextPaintPhase phase) { paintable.before_children_paint(context, to_paint_phase(phase)); paintable.apply_clip_overflow_rect(context, to_paint_phase(phase)); - paintable.for_each_child([this, &context, phase](auto& child) { + paintable.for_each_child([&context, phase](auto& child) { auto* stacking_context = child.stacking_context_rooted_here(); if (child.is_positioned()) { @@ -176,7 +176,7 @@ void StackingContext::paint_descendants(PaintContext& context, Paintable const& paintable.after_children_paint(context, to_paint_phase(phase)); } -void StackingContext::paint_child(PaintContext& context, StackingContext const& child) const +void StackingContext::paint_child(PaintContext& context, StackingContext const& child) { auto parent_paintable = child.paintable_box().parent(); if (parent_paintable) @@ -221,7 +221,7 @@ void StackingContext::paint_internal(PaintContext& context) const // Draw positioned descendants with z-index `0` or `auto` in tree order. (step 8) // FIXME: There's more to this step that we have yet to understand and implement. - paintable_box().for_each_in_subtree([this, &context](Paintable const& paintable) { + paintable_box().for_each_in_subtree([&context](Paintable const& paintable) { auto const& z_index = paintable.computed_values().z_index(); if (!paintable.is_positioned() || (z_index.has_value() && z_index.value() != 0)) { diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.h b/Userland/Libraries/LibWeb/Painting/StackingContext.h index 62739124b2..d8c81c8b0e 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.h +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.h @@ -29,8 +29,8 @@ public: FocusAndOverlay, }; - void paint_node_as_stacking_context(Paintable const&, PaintContext&) const; - void paint_descendants(PaintContext&, Paintable const&, StackingContextPaintPhase) const; + static void paint_node_as_stacking_context(Paintable const&, PaintContext&); + static void paint_descendants(PaintContext&, Paintable const&, StackingContextPaintPhase); void paint(PaintContext&) const; Optional hit_test(CSSPixelPoint, HitTestType) const; @@ -49,7 +49,7 @@ private: Vector m_children; size_t m_index_in_tree_order { 0 }; - void paint_child(PaintContext&, StackingContext const&) const; + static void paint_child(PaintContext&, StackingContext const&); void paint_internal(PaintContext&) const; Gfx::FloatMatrix4x4 get_transformation_matrix(CSS::Transformation const& transformation) const; Gfx::FloatMatrix4x4 combine_transformations(Vector const& transformations) const;