summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-27 10:59:52 +0100
committerAndreas Kling <kling@serenityos.org>2022-02-28 14:17:44 +0100
commit19954dfdf859ea6bc5523c59cf8a3ad0b7cea0f6 (patch)
treebc866c6049009e00684c1236e2d74a2ca77c111f /Userland
parent1d058238106fa1b2571bd412fc4b0fb64d6c48c4 (diff)
downloadserenity-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.h9
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>(); });