mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Use unsafe layout/paintable accessors where appropriate
Add unsafe_layout_node(), unsafe_paintable(), and unsafe_paintable_box() accessors that skip layout-staleness verification. These are for use in contexts where accessing layout/paintable data is legitimate despite layout not being up to date: tree construction, style recalculation, painting, animation interpolation, DOM mutation, and invalidation propagation. Also add wrapper APIs on Node to centralize common patterns: - set_needs_display() wraps if (unsafe_paintable()) ...set_needs_display - set_needs_paint_only_properties_update() wraps similar - set_needs_layout_update() wraps if (unsafe_layout_node()) ... And add Document::layout_is_up_to_date() which checks whether layout tree update flags are all clear.
This commit is contained in:
committed by
Andreas Kling
parent
b8b63ddc8f
commit
a146225331
Notes:
github-actions[bot]
2026-02-26 20:10:33 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/a146225331e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8182
@@ -307,8 +307,9 @@ void Node::recompute_containing_block(Badge<DOM::Document>)
|
||||
if (dom_ancestor.ptr() == containing_block_dom_node)
|
||||
break;
|
||||
|
||||
// NB: Called during containing block recomputation as part of layout.
|
||||
// Check if this DOM element has an InlineNode in the layout tree.
|
||||
auto layout_node = dom_ancestor->layout_node();
|
||||
auto layout_node = dom_ancestor->unsafe_layout_node();
|
||||
if (!layout_node || !is<InlineNode>(*layout_node))
|
||||
continue;
|
||||
|
||||
@@ -506,14 +507,16 @@ GC::Ptr<HTML::Navigable> Node::navigable() const
|
||||
|
||||
Viewport const& Node::root() const
|
||||
{
|
||||
VERIFY(document().layout_node());
|
||||
return *document().layout_node();
|
||||
// NB: Called during layout, which is in progress.
|
||||
VERIFY(document().unsafe_layout_node());
|
||||
return *document().unsafe_layout_node();
|
||||
}
|
||||
|
||||
Viewport& Node::root()
|
||||
{
|
||||
VERIFY(document().layout_node());
|
||||
return *document().layout_node();
|
||||
// NB: Called during layout, which is in progress.
|
||||
VERIFY(document().unsafe_layout_node());
|
||||
return *document().unsafe_layout_node();
|
||||
}
|
||||
|
||||
bool Node::is_floating() const
|
||||
|
||||
Reference in New Issue
Block a user