From 19954dfdf859ea6bc5523c59cf8a3ad0b7cea0f6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Feb 2022 10:59:52 +0100 Subject: [PATCH] LibWeb: Add FormattingState::clone() This makes a deep copy of a FormattingState. --- Userland/Libraries/LibWeb/Layout/FormattingState.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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(*it.value)); + } + return new_state; + } + NodeState& get_mutable(NodeWithStyleAndBoxModelMetrics const& box) { return *nodes.ensure(&box, [] { return make(); });