From 0b3b6310ec6f582a13c1e27f8c152e30a46f822d Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Mon, 5 Oct 2020 16:11:33 -0700 Subject: [PATCH] LibWeb: Add {before,after}_children_paint() methods This allows layout nodes to do some setup before their children paint, and cleanup after their children paint. This will be used for SVG components, where their attributes (like stroke width, fill color, etc) need to be correctly propogated to layout nodes down the line. --- Libraries/LibWeb/Layout/LayoutNode.cpp | 4 ++++ Libraries/LibWeb/Layout/LayoutNode.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp index c44e886d8f..3bd10abeea 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.cpp +++ b/Libraries/LibWeb/Layout/LayoutNode.cpp @@ -95,11 +95,15 @@ void LayoutNode::paint(PaintContext& context, PaintPhase phase) if (!is_visible()) return; + before_children_paint(context, phase); + for_each_child([&](auto& child) { if (child.is_box() && downcast(child).stacking_context()) return; child.paint(context, phase); }); + + after_children_paint(context, phase); } HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position, HitTestType type) const diff --git a/Libraries/LibWeb/Layout/LayoutNode.h b/Libraries/LibWeb/Layout/LayoutNode.h index 066e485f83..1b72b5645b 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.h +++ b/Libraries/LibWeb/Layout/LayoutNode.h @@ -122,7 +122,10 @@ public: FocusOutline, Overlay, }; + + virtual void before_children_paint(PaintContext&, PaintPhase) {}; virtual void paint(PaintContext&, PaintPhase); + virtual void after_children_paint(PaintContext&, PaintPhase) {}; bool is_floating() const; bool is_absolutely_positioned() const;