Changeset 278865 in webkit
- Timestamp:
- Jun 15, 2021 2:19:23 AM (13 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
rendering/FlexibleBoxAlgorithm.cpp (modified) (2 diffs)
-
rendering/FlexibleBoxAlgorithm.h (modified) (2 diffs)
-
rendering/RenderFlexibleBox.cpp (modified) (5 diffs)
-
rendering/RenderFlexibleBox.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278864 r278865 1 2021-05-31 Sergio Villar Senin <svillar@igalia.com> 2 3 [css-flexbox] Do not compute the min-max sizes of flex items twice 4 https://bugs.webkit.org/show_bug.cgi?id=226463 5 6 Reviewed by Simon Fraser. 7 8 When determining the flex base size, the item’s min and max main sizes are ignored (no clamping occurs). 9 Those limits are used to compute the item's hypothetical main size and also later when the flexible 10 lengths are resolved. The thing is that we were running the code that clamps the flex item size twice instead 11 of computing those limits once and apply them twice. 12 13 From now one, we just compute them once and store the limits in a std::pair in the FlexItem class. This means 14 that the FlexItem is able to compute the hypothetical main size on its own and does not need it to be passed 15 as an argument. 16 17 No new tests as this is already being tested by dozens of tests. 18 19 * rendering/FlexibleBoxAlgorithm.cpp: 20 (WebCore::FlexItem::FlexItem): 21 (WebCore::FlexItem::constrainSizeByMinMax const): Clamp the passed in size by the stored min & max sizes. 22 * rendering/FlexibleBoxAlgorithm.h: 23 * rendering/RenderFlexibleBox.cpp: 24 (WebCore::RenderFlexibleBox::computeFlexItemMinMaxSizes): Renamed from adjustChildSizeForMinAndMax and 25 without the childSize argument which is no longer needed. 26 (WebCore::RenderFlexibleBox::constructFlexItem): Use constrainSizeByMinMax. 27 (WebCore::RenderFlexibleBox::resolveFlexibleLengths): Ditto. 28 (WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax): Deleted. 29 * rendering/RenderFlexibleBox.h: 30 1 31 2021-06-11 Sergio Villar Senin <svillar@igalia.com> 2 32 -
trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.cpp
r278659 r278865 36 36 namespace WebCore { 37 37 38 FlexItem::FlexItem(RenderBox& box, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, bool everHadLayout)38 FlexItem::FlexItem(RenderBox& box, LayoutUnit flexBaseContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, std::pair<LayoutUnit, LayoutUnit> minMaxSizes, bool everHadLayout) 39 39 : box(box) 40 40 , flexBaseContentSize(flexBaseContentSize) 41 , hypotheticalMainContentSize(hypotheticalMainContentSize)42 41 , mainAxisBorderAndPadding(mainAxisBorderAndPadding) 43 42 , mainAxisMargin(mainAxisMargin) 43 , minMaxSizes(minMaxSizes) 44 , hypotheticalMainContentSize(constrainSizeByMinMax(flexBaseContentSize)) 45 , frozen(false) 44 46 , everHadLayout(everHadLayout) 45 47 { … … 87 89 } 88 90 91 LayoutUnit FlexItem::constrainSizeByMinMax(const LayoutUnit size) const 92 { 93 return std::max(minMaxSizes.first, std::min(size, minMaxSizes.second)); 94 } 95 89 96 } // namespace WebCore -
trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.h
r278659 r278865 42 42 class FlexItem { 43 43 public: 44 FlexItem(RenderBox&, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, bool everHadLayout);44 FlexItem(RenderBox&, LayoutUnit flexBaseContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, std::pair<LayoutUnit, LayoutUnit> minMaxSizes, bool everHadLayout); 45 45 46 46 LayoutUnit hypotheticalMainAxisMarginBoxSize() const … … 59 59 } 60 60 61 LayoutUnit constrainSizeByMinMax(const LayoutUnit) const; 62 61 63 RenderBox& box; 62 64 const LayoutUnit flexBaseContentSize; 63 const LayoutUnit hypotheticalMainContentSize;64 65 const LayoutUnit mainAxisBorderAndPadding; 65 66 const LayoutUnit mainAxisMargin; 67 const std::pair<LayoutUnit, LayoutUnit> minMaxSizes; 68 const LayoutUnit hypotheticalMainContentSize; 66 69 LayoutUnit flexedContentSize; 67 70 bool frozen { false }; -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r278659 r278865 1202 1202 } 1203 1203 1204 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize)1204 std::pair<LayoutUnit, LayoutUnit> RenderFlexibleBox::computeFlexItemMinMaxSizes(RenderBox& child) 1205 1205 { 1206 1206 Length max = mainSizeLengthForChild(MaxSize, child); 1207 1207 std::optional<LayoutUnit> maxExtent = std::nullopt; 1208 if (max.isSpecifiedOrIntrinsic()) {1208 if (max.isSpecifiedOrIntrinsic()) 1209 1209 maxExtent = computeMainAxisExtentForChild(child, MaxSize, max); 1210 childSize = std::min(childSize, maxExtent.value_or(childSize));1211 }1212 1210 1213 1211 Length min = mainSizeLengthForChild(MinSize, child); 1214 1212 // Intrinsic sizes in child's block axis are handled by the min-size:auto code path. 1215 1213 if (min.isSpecified() || (min.isIntrinsic() && mainAxisIsChildInlineAxis(child))) 1216 return std::max(childSize, std::max(0_lu, computeMainAxisExtentForChild(child, MinSize, min).value_or(childSize)));1214 return { computeMainAxisExtentForChild(child, MinSize, min).value_or(0_lu), maxExtent.value_or(LayoutUnit::max()) }; 1217 1215 1218 1216 if (shouldApplyMinSizeAutoForChild(child)) { … … 1235 1233 ASSERT(resolvedMainSize >= 0); 1236 1234 LayoutUnit specifiedSize = std::min(resolvedMainSize, maxExtent.value_or(resolvedMainSize)); 1237 return std::max(childSize, std::min(specifiedSize, contentSize));1235 return { std::min(specifiedSize, contentSize), maxExtent.value_or(LayoutUnit::max()) }; 1238 1236 } 1239 1237 … … 1241 1239 LayoutUnit transferredSize = computeMainSizeFromAspectRatioUsing(child, childCrossSizeLength); 1242 1240 transferredSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(child, transferredSize); 1243 return std::max(childSize, std::min(transferredSize, contentSize));1244 } 1245 1246 return std::max(childSize, contentSize);1247 } 1248 1249 return std::max(0_lu, childSize);1241 return { std::min(transferredSize, contentSize), maxExtent.value_or(LayoutUnit::max()) }; 1242 } 1243 1244 return { contentSize, maxExtent.value_or(LayoutUnit::max()) }; 1245 } 1246 1247 return { 0_lu, maxExtent.value_or(LayoutUnit::max()) }; 1250 1248 } 1251 1249 … … 1335 1333 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.horizontalBorderAndPaddingExtent() : child.verticalBorderAndPaddingExtent(); 1336 1334 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding); 1337 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(child, childInnerFlexBaseSize);1338 1335 LayoutUnit margin = isHorizontalFlow() ? child.horizontalMarginExtent() : child.verticalMarginExtent(); 1339 return FlexItem(child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin, childHadLayout);1336 return FlexItem(child, childInnerFlexBaseSize, borderAndPadding, margin, computeFlexItemMinMaxSizes(child), childHadLayout); 1340 1337 } 1341 1338 … … 1411 1408 if (std::isfinite(extraSpace)) 1412 1409 childSize += LayoutUnit::fromFloatRound(extraSpace); 1413 1414 LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(child,childSize);1410 1411 LayoutUnit adjustedChildSize = flexItem.constrainSizeByMinMax(childSize); 1415 1412 ASSERT(adjustedChildSize >= 0); 1416 1413 flexItem.flexedContentSize = adjustedChildSize; -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r278450 r278865 175 175 LayoutUnit computeChildMarginValue(Length margin); 176 176 void prepareOrderIteratorAndMargins(); 177 LayoutUnit adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize);177 std::pair<LayoutUnit, LayoutUnit> computeFlexItemMinMaxSizes(RenderBox& child); 178 178 LayoutUnit adjustChildSizeForAspectRatioCrossAxisMinAndMax(const RenderBox& child, LayoutUnit childSize); 179 179 FlexItem constructFlexItem(RenderBox&, bool relayoutChildren);
Note: See TracChangeset
for help on using the changeset viewer.