Skip to content

Commit

Permalink
LibWeb: Remove the flex item size cache
Browse files Browse the repository at this point in the history
This was overly permissive as the FIXME stated and was causing layout
issues.
  • Loading branch information
sin-ack authored and awesomekling committed Sep 18, 2022
1 parent 97b5230 commit e9d5d2f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
11 changes: 1 addition & 10 deletions Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,16 +713,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
if (has_definite_main_size(child_box))
return resolved_definite_main_size(flex_item);

// NOTE: To avoid repeated layout work, we keep a cache of flex item main sizes on the
// root LayoutState object. It's available through a full layout cycle.
// FIXME: Make sure this cache isn't overly permissive..
auto& size_cache = m_state.m_root.flex_item_size_cache;
auto it = size_cache.find(&flex_item.box);
if (it != size_cache.end())
return it->value;
auto main_size = calculate_indefinite_main_size(flex_item);
size_cache.set(&flex_item.box, main_size);
return main_size;
return calculate_indefinite_main_size(flex_item);
}();

// The hypothetical main size is the item’s flex base size clamped according to its used min and max main sizes (and flooring the content box size at zero).
Expand Down
2 changes: 0 additions & 2 deletions Userland/Libraries/LibWeb/Layout/LayoutState.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ struct LayoutState {

HashMap<NodeWithStyleAndBoxModelMetrics const*, NonnullOwnPtr<IntrinsicSizes>> mutable intrinsic_sizes;

HashMap<Box const*, float> mutable flex_item_size_cache;

LayoutState const* m_parent { nullptr };
LayoutState const& m_root;
};
Expand Down

0 comments on commit e9d5d2f

Please sign in to comment.