mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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
|
@ -33,9 +33,8 @@ Optional<CSSPixels> Box::natural_width() const
|
|||
// https://drafts.csswg.org/css-contain-2/#containment-size
|
||||
// Replaced elements must be treated as having a natural width and height of 0 and no natural aspect
|
||||
// ratio.
|
||||
if (dom_node() && dom_node()->is_element() && as<DOM::Element>(dom_node())->has_size_containment())
|
||||
if (m_has_size_containment)
|
||||
return 0;
|
||||
|
||||
return m_natural_width;
|
||||
}
|
||||
Optional<CSSPixels> Box::natural_height() const
|
||||
|
@ -43,9 +42,8 @@ Optional<CSSPixels> Box::natural_height() const
|
|||
// https://drafts.csswg.org/css-contain-2/#containment-size
|
||||
// Replaced elements must be treated as having a natural width and height of 0 and no natural aspect
|
||||
// ratio.
|
||||
if (dom_node() && dom_node()->is_element() && as<DOM::Element>(dom_node())->has_size_containment())
|
||||
if (m_has_size_containment)
|
||||
return 0;
|
||||
|
||||
return m_natural_height;
|
||||
}
|
||||
Optional<CSSPixelFraction> Box::natural_aspect_ratio() const
|
||||
|
@ -53,9 +51,8 @@ Optional<CSSPixelFraction> Box::natural_aspect_ratio() const
|
|||
// https://drafts.csswg.org/css-contain-2/#containment-size
|
||||
// Replaced elements must be treated as having a natural width and height of 0 and no natural aspect
|
||||
// ratio.
|
||||
if (dom_node() && dom_node()->is_element() && as<DOM::Element>(dom_node())->has_size_containment())
|
||||
if (m_has_size_containment)
|
||||
return {};
|
||||
|
||||
return m_natural_aspect_ratio;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue