diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-27 10:59:52 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-28 14:17:44 +0100 |
commit | 19954dfdf859ea6bc5523c59cf8a3ad0b7cea0f6 (patch) | |
tree | bc866c6049009e00684c1236e2d74a2ca77c111f /Userland | |
parent | 1d058238106fa1b2571bd412fc4b0fb64d6c48c4 (diff) | |
download | serenity-19954dfdf859ea6bc5523c59cf8a3ad0b7cea0f6.zip |
LibWeb: Add FormattingState::clone()
This makes a deep copy of a FormattingState.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FormattingState.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingState.h b/Userland/Libraries/LibWeb/Layout/FormattingState.h index 1ed6071cd4..1d2dfa0be2 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingState.h +++ b/Userland/Libraries/LibWeb/Layout/FormattingState.h @@ -66,6 +66,15 @@ struct FormattingState { void commit(); + FormattingState clone() const + { + FormattingState new_state; + for (auto& it : nodes) { + new_state.nodes.set(it.key, make<NodeState>(*it.value)); + } + return new_state; + } + NodeState& get_mutable(NodeWithStyleAndBoxModelMetrics const& box) { return *nodes.ensure(&box, [] { return make<NodeState>(); }); |