mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
LibWeb: Cache "has size containment" flag in Layout::Box
Allows us to avoid DOM node lookup whenever we need to query natural size of a box during layout. Makes 3-4% of `Box::preferred_aspect_ratio()` go away from profiles on www.nyan.cat
This commit is contained in:
parent
693fe76d1c
commit
7cae4fadbc
Notes:
github-actions[bot]
2025-03-26 17:53:01 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 7cae4fadbc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4104
Reviewed-by: https://github.com/gmta ✅
3 changed files with 11 additions and 6 deletions
|
@ -1321,6 +1321,9 @@ void Document::update_layout(UpdateLayoutReason reason)
|
|||
}
|
||||
|
||||
m_layout_root->for_each_in_inclusive_subtree_of_type<Layout::Box>([&](auto& child) {
|
||||
if (auto dom_node = child.dom_node(); dom_node && dom_node->is_element()) {
|
||||
child.set_has_size_containment(as<Element>(*dom_node).has_size_containment());
|
||||
}
|
||||
bool needs_layout_update = child.dom_node() && child.dom_node()->needs_layout_update();
|
||||
if (needs_layout_update || child.is_anonymous()) {
|
||||
child.reset_cached_intrinsic_sizes();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue