Преглед изворни кода

LibWeb: Add FormattingState::clone()

This makes a deep copy of a FormattingState.
Andreas Kling пре 3 година
родитељ
комит
19954dfdf8
1 измењених фајлова са 9 додато и 0 уклоњено
  1. 9 0
      Userland/Libraries/LibWeb/Layout/FormattingState.h

+ 9 - 0
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>(); });