1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

LibWeb: Let Paintable perform the painting

This patch adds a bunch of Paintable subclasses, each corresponding to
the Layout::Node subclasses that had a paint() override. All painting
logic is moved from layout nodes into their corresponding paintables.

Paintables are now created by asking a Layout::Box to produce one:

    static NonnullOwnPtr<Paintable> Layout::Box::create_paintable()

Note that inline nodes still have their painting logic. Since they
are not boxes, and all paintables have a corresponding box, we'll need
to come up with some other solution for them.
This commit is contained in:
Andreas Kling 2022-03-10 14:02:25 +01:00
parent f6497b64ac
commit 02b316fd5c
64 changed files with 1307 additions and 602 deletions

View file

@ -22,10 +22,14 @@ public:
virtual ~Paintable();
virtual void paint(PaintContext&, PaintPhase) const;
bool is_visible() const { return m_layout_box.is_visible(); }
Layout::Box const& m_layout_box;
auto& box_model() { return m_layout_box.box_model(); }
auto const& box_model() const { return m_layout_box.box_model(); }
auto const& computed_values() const { return m_layout_box.computed_values(); }
struct OverflowData {
Gfx::FloatRect scrollable_overflow_rect;
@ -109,10 +113,22 @@ public:
void set_stacking_context(NonnullOwnPtr<Painting::StackingContext> context) { m_stacking_context = move(context); }
StackingContext* enclosing_stacking_context();
DOM::Node const* dom_node() const { return m_layout_box.dom_node(); }
DOM::Document const& document() const { return m_layout_box.document(); }
virtual void before_children_paint(PaintContext&, PaintPhase) const;
virtual void after_children_paint(PaintContext&, PaintPhase) const;
protected:
explicit Paintable(Layout::Box const&);
virtual void paint_border(PaintContext&) const;
virtual void paint_background(PaintContext&) const;
virtual void paint_box_shadow(PaintContext&) const;
private:
Painting::BorderRadiusData normalized_border_radius_data() const;
OwnPtr<Painting::StackingContext> m_stacking_context;
};
@ -138,6 +154,8 @@ public:
}
}
virtual void paint(PaintContext&, PaintPhase) const override;
private:
PaintableWithLines(Layout::BlockContainer const&);