1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

LibWeb: Rename FormattingState::ensure() -> get_mutable()

This makes it much more obvious what the difference between get() and
get_mutable() is.
This commit is contained in:
Andreas Kling 2022-02-21 17:42:09 +01:00
parent 0f15d1f947
commit db5bf6e64c
10 changed files with 49 additions and 51 deletions

View file

@ -66,16 +66,14 @@ struct FormattingState {
void commit();
NodeState& ensure(NodeWithStyleAndBoxModelMetrics const& box)
NodeState& get_mutable(NodeWithStyleAndBoxModelMetrics const& box)
{
return *nodes.ensure(&box, [] { return make<NodeState>(); });
}
NodeState const& get(NodeWithStyleAndBoxModelMetrics const& box) const
{
if (!nodes.contains(&box))
return const_cast<FormattingState&>(*this).ensure(box);
return *nodes.get(&box).value();
return const_cast<FormattingState&>(*this).get_mutable(box);
}
HashMap<NodeWithStyleAndBoxModelMetrics const*, NonnullOwnPtr<NodeState>> nodes;