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:
Aliaksandr Kalenik 2025-03-26 16:48:59 +00:00 committed by Jelle Raaijmakers
commit 7cae4fadbc
Notes: github-actions[bot] 2025-03-26 17:53:01 +00:00
3 changed files with 11 additions and 6 deletions

View file

@ -40,6 +40,9 @@ public:
bool has_natural_height() const { return natural_height().has_value(); }
bool has_natural_aspect_ratio() const { return natural_aspect_ratio().has_value(); }
bool has_size_containment() const { return m_has_size_containment; }
void set_has_size_containment(bool value) { m_has_size_containment = value; }
void set_natural_width(Optional<CSSPixels> width) { m_natural_width = width; }
void set_natural_height(Optional<CSSPixels> height) { m_natural_height = height; }
void set_natural_aspect_ratio(Optional<CSSPixelFraction> ratio) { m_natural_aspect_ratio = ratio; }
@ -79,6 +82,8 @@ private:
Optional<CSSPixels> m_natural_height;
Optional<CSSPixelFraction> m_natural_aspect_ratio;
bool m_has_size_containment { false };
Vector<GC::Ref<Node>> m_contained_abspos_children;
OwnPtr<IntrinsicSizes> mutable m_cached_intrinsic_sizes;