1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibWeb: Add FormattingState::clone()

This makes a deep copy of a FormattingState.
This commit is contained in:
Andreas Kling 2022-02-27 10:59:52 +01:00
parent 1d05823810
commit 19954dfdf8

View file

@ -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>(); });