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

LibWeb: Reduce paintable tree traversals during hit-testing

By storing a list of positioned and floating descendants within the
stacking context tree node, we can eliminate the need for costly
paintable tree traversals during hit-testing.

This optimization results in hit-testing being 2 to 2.5 times faster
on https://ziglang.org/documentation/master/
This commit is contained in:
Aliaksandr Kalenik 2024-03-01 11:54:44 +01:00 committed by Andreas Kling
parent 9c6c3fe0d8
commit 2764966ccc
5 changed files with 95 additions and 77 deletions

View file

@ -14,6 +14,8 @@
namespace Web::Painting {
class StackingContext {
friend class ViewportPaintable;
public:
StackingContext(Paintable&, StackingContext* parent, size_t index_in_tree_order);
@ -50,6 +52,9 @@ private:
Vector<StackingContext*> m_children;
size_t m_index_in_tree_order { 0 };
Vector<Paintable const&> m_positioned_descendants_with_stack_level_0_and_stacking_contexts;
Vector<Paintable const&> m_non_positioned_floating_descendants;
static void paint_child(PaintContext&, StackingContext const&);
void paint_internal(PaintContext&) const;
};