LibWeb: Implement partial layout tree updates

DOM nodes now have two additional flags:

- Needs layout tree update
- Child needs layout tree update

These work similarly to the needs-style-update flags, but instead signal
the need to rebuild the corresponding part of the layout tree.

When a specific DOM node needs a layout tree update, we try to create
a new subtree starting at that node, and then replace the subtree in the
old layout tree with the newly created subtree.

This required some refactoring in TreeBuilder so that we can skip over
entire subtrees during a tree update.

Note that no partial updates happen yet (as of this commit) since we
always invalidate the full layout tree still. That will change in the
next commit.
This commit is contained in:
Andreas Kling 2025-01-13 12:23:40 +01:00 committed by Andreas Kling
commit c01d810e5a
Notes: github-actions[bot] 2025-01-18 20:02:07 +00:00
6 changed files with 152 additions and 59 deletions

View file

@ -29,7 +29,13 @@ private:
i32 calculate_list_item_index(DOM::Node&);
void create_layout_tree(DOM::Node&, Context&);
void update_layout_tree_before_children(DOM::Node&, GC::Ref<Layout::Node>, Context&, bool element_has_content_visibility_hidden);
void update_layout_tree_after_children(DOM::Node&, GC::Ref<Layout::Node>, Context&, bool element_has_content_visibility_hidden);
enum class MustCreateSubtree {
No,
Yes,
};
void update_layout_tree(DOM::Node&, Context&, MustCreateSubtree);
void push_parent(Layout::NodeWithStyle& node) { m_ancestor_stack.append(node); }
void pop_parent() { m_ancestor_stack.take_last(); }