1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

LibWeb: Allocate CSS::ComputedValues objects on the heap

This makes them cheap to move around, since we can store them in a
NonnullOwnPtr instead of memcopying 2584(!) bytes.

Drastically reduces the chance of stack overflow while building the
layout tree for deeply nested DOMs (since tree building was putting
these things on the stack).

This change also exposed a completely unnecessary ComputedValues deep
copy in block layout.
This commit is contained in:
Andreas Kling 2024-01-27 08:38:27 +01:00
parent d89e42902e
commit ad7e6878fe
11 changed files with 40 additions and 33 deletions

View file

@ -285,7 +285,13 @@ inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_val
}
class ComputedValues {
AK_MAKE_NONCOPYABLE(ComputedValues);
AK_MAKE_NONMOVABLE(ComputedValues);
public:
ComputedValues() = default;
~ComputedValues() = default;
AspectRatio aspect_ratio() const { return m_noninherited.aspect_ratio; }
CSS::Float float_() const { return m_noninherited.float_; }
CSS::Length border_spacing_horizontal() const { return m_inherited.border_spacing_horizontal; }
@ -411,10 +417,10 @@ public:
CSS::MathStyle math_style() const { return m_inherited.math_style; }
int math_depth() const { return m_inherited.math_depth; }
ComputedValues clone_inherited_values() const
NonnullOwnPtr<ComputedValues> clone_inherited_values() const
{
ComputedValues clone;
clone.m_inherited = m_inherited;
auto clone = make<ComputedValues>();
clone->m_inherited = m_inherited;
return clone;
}