mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
LibWeb: Make Layout::FormattingState copies shallow
Previously, each NodeState in a FormattingState was shared with the parent FormattingState, but the HashMap of NodeState had to be copied when making FormattingState copies. This patch makes copying instant by keeping a pointer to the parent FormattingState instead. When fetching immutable state via get(), we may now return a reference to a NodeState owned by a parent FormattingState. get_mutable() will copy any NodeState found in the ancestor chain before making a brand new one.
This commit is contained in:
parent
b6097cf724
commit
515db5fc1b
4 changed files with 40 additions and 30 deletions
|
@ -824,7 +824,7 @@ FormattingState::IntrinsicSizes FormattingContext::calculate_intrinsic_sizes(Lay
|
|||
auto& cached_box_sizes = m_state.intrinsic_sizes.ensure(&box);
|
||||
auto const& containing_block = *box.containing_block();
|
||||
{
|
||||
auto throwaway_state = m_state;
|
||||
FormattingState throwaway_state(&m_state);
|
||||
throwaway_state.get_mutable(containing_block).content_width = INFINITY;
|
||||
throwaway_state.get_mutable(containing_block).content_height = INFINITY;
|
||||
auto independent_formatting_context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
|
@ -836,7 +836,7 @@ FormattingState::IntrinsicSizes FormattingContext::calculate_intrinsic_sizes(Lay
|
|||
}
|
||||
|
||||
{
|
||||
auto throwaway_state = m_state;
|
||||
FormattingState throwaway_state(&m_state);
|
||||
throwaway_state.get_mutable(containing_block).content_width = 0;
|
||||
throwaway_state.get_mutable(containing_block).content_height = 0;
|
||||
auto independent_formatting_context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue