浏览代码

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.
Matthew Olsson 4 年之前
父节点
当前提交
0b3b6310ec
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 4 0
      Libraries/LibWeb/Layout/LayoutNode.cpp
  2. 3 0
      Libraries/LibWeb/Layout/LayoutNode.h

+ 4 - 0
Libraries/LibWeb/Layout/LayoutNode.cpp

@@ -95,11 +95,15 @@ void LayoutNode::paint(PaintContext& context, PaintPhase phase)
     if (!is_visible())
     if (!is_visible())
         return;
         return;
 
 
+    before_children_paint(context, phase);
+
     for_each_child([&](auto& child) {
     for_each_child([&](auto& child) {
         if (child.is_box() && downcast<LayoutBox>(child).stacking_context())
         if (child.is_box() && downcast<LayoutBox>(child).stacking_context())
             return;
             return;
         child.paint(context, phase);
         child.paint(context, phase);
     });
     });
+
+    after_children_paint(context, phase);
 }
 }
 
 
 HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position, HitTestType type) const
 HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position, HitTestType type) const

+ 3 - 0
Libraries/LibWeb/Layout/LayoutNode.h

@@ -122,7 +122,10 @@ public:
         FocusOutline,
         FocusOutline,
         Overlay,
         Overlay,
     };
     };
+
+    virtual void before_children_paint(PaintContext&, PaintPhase) {};
     virtual void paint(PaintContext&, PaintPhase);
     virtual void paint(PaintContext&, PaintPhase);
+    virtual void after_children_paint(PaintContext&, PaintPhase) {};
 
 
     bool is_floating() const;
     bool is_floating() const;
     bool is_absolutely_positioned() const;
     bool is_absolutely_positioned() const;