mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +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:
parent
d89e42902e
commit
ad7e6878fe
11 changed files with 40 additions and 33 deletions
|
@ -206,8 +206,8 @@ class NodeWithStyle : public Node {
|
|||
public:
|
||||
virtual ~NodeWithStyle() override = default;
|
||||
|
||||
const CSS::ImmutableComputedValues& computed_values() const { return static_cast<const CSS::ImmutableComputedValues&>(m_computed_values); }
|
||||
CSS::MutableComputedValues& mutable_computed_values() { return static_cast<CSS::MutableComputedValues&>(m_computed_values); }
|
||||
CSS::ImmutableComputedValues const& computed_values() const { return static_cast<CSS::ImmutableComputedValues const&>(*m_computed_values); }
|
||||
CSS::MutableComputedValues& mutable_computed_values() { return static_cast<CSS::MutableComputedValues&>(*m_computed_values); }
|
||||
|
||||
void apply_style(const CSS::StyleProperties&);
|
||||
|
||||
|
@ -223,13 +223,13 @@ public:
|
|||
|
||||
protected:
|
||||
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
|
||||
NodeWithStyle(DOM::Document&, DOM::Node*, CSS::ComputedValues);
|
||||
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullOwnPtr<CSS::ComputedValues>);
|
||||
|
||||
private:
|
||||
void reset_table_box_computed_values_used_by_wrapper_to_init_values();
|
||||
void propagate_style_to_anonymous_wrappers();
|
||||
|
||||
CSS::ComputedValues m_computed_values;
|
||||
NonnullOwnPtr<CSS::ComputedValues> m_computed_values;
|
||||
RefPtr<CSS::AbstractImageStyleValue const> m_list_style_image;
|
||||
};
|
||||
|
||||
|
@ -246,7 +246,7 @@ protected:
|
|||
{
|
||||
}
|
||||
|
||||
NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, CSS::ComputedValues computed_values)
|
||||
NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, NonnullOwnPtr<CSS::ComputedValues> computed_values)
|
||||
: NodeWithStyle(document, node, move(computed_values))
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue