Add a use counter to determine compat impact of changing flexbox's intrinsic size calculation

This is to gather data for this intent: https://groups.google.com/a/chromium.org/d/topic/blink-dev/qBqeSQeyVXc/discussion

R=leviw@chromium.org
BUG=240765

Review URL: https://codereview.chromium.org/1304853002

git-svn-id: svn://svn.chromium.org/blink/trunk@200953 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e3209471
...@@ -831,6 +831,7 @@ public: ...@@ -831,6 +831,7 @@ public:
PresentationSessionMessageEventListener = 936, PresentationSessionMessageEventListener = 936,
CSSAnimationsStackedNeutralKeyframe = 937, CSSAnimationsStackedNeutralKeyframe = 937,
ReadingCheckedInClickHandler = 938, ReadingCheckedInClickHandler = 938,
FlexboxIntrinsicSizeAlgorithmIsDifferent = 939,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -94,6 +94,7 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt ...@@ -94,6 +94,7 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
// FIXME: We're ignoring flex-basis here and we shouldn't. We can't start honoring it though until // FIXME: We're ignoring flex-basis here and we shouldn't. We can't start honoring it though until
// the flex shorthand stops setting it to 0. // the flex shorthand stops setting it to 0.
// See https://bugs.webkit.org/show_bug.cgi?id=116117 and http://crbug.com/240765. // See https://bugs.webkit.org/show_bug.cgi?id=116117 and http://crbug.com/240765.
float previousMaxContentFlexFraction = -1;
for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
if (child->isOutOfFlowPositioned()) if (child->isOutOfFlowPositioned())
continue; continue;
...@@ -125,6 +126,8 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt ...@@ -125,6 +126,8 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth); minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth);
maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth); maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth);
} }
previousMaxContentFlexFraction = countIntrinsicSizeForAlgorithmChange(maxPreferredLogicalWidth, child, previousMaxContentFlexFraction);
} }
maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
...@@ -134,6 +137,27 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt ...@@ -134,6 +137,27 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
minLogicalWidth += scrollbarWidth; minLogicalWidth += scrollbarWidth;
} }
float LayoutFlexibleBox::countIntrinsicSizeForAlgorithmChange(LayoutUnit maxPreferredLogicalWidth, LayoutBox* child, float previousMaxContentFlexFraction) const
{
// Determine whether the new version of the intrinsic size algorithm of the flexbox
// spec would produce a different result than our above algorithm.
// The algorithm produces a different result iff the max-content flex fraction
// (as defined in the new algorithm) is not identical for each flex item.
if (isColumnFlow())
return previousMaxContentFlexFraction;
Length flexBasis = child->styleRef().flexBasis();
float flexGrow = child->styleRef().flexGrow();
// A flex-basis of auto will lead to a max-content flex fraction of zero, so just like
// an inflexible item it would compute to a size of max-content, so we ignore it here.
if (flexBasis.isAuto() || flexGrow == 0)
return previousMaxContentFlexFraction;
flexGrow = std::max(1.0f, flexGrow);
float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flexGrow;
if (previousMaxContentFlexFraction != -1 && maxContentFlexFraction != previousMaxContentFlexFraction)
UseCounter::count(document(), UseCounter::FlexboxIntrinsicSizeAlgorithmIsDifferent);
return maxContentFlexFraction;
}
static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirectionMode direction) static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirectionMode direction)
{ {
if (direction == HorizontalLine) { if (direction == HorizontalLine) {
......
...@@ -167,6 +167,8 @@ private: ...@@ -167,6 +167,8 @@ private:
void flipForRightToLeftColumn(); void flipForRightToLeftColumn();
void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStartEdge); void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStartEdge);
float countIntrinsicSizeForAlgorithmChange(LayoutUnit maxPreferredWidth, LayoutBox* child, float previousMaxContentFlexFraction) const;
// This is used to cache the preferred size for orthogonal flow children so we don't have to relayout to get it // This is used to cache the preferred size for orthogonal flow children so we don't have to relayout to get it
HashMap<const LayoutObject*, LayoutUnit> m_intrinsicSizeAlongMainAxis; HashMap<const LayoutObject*, LayoutUnit> m_intrinsicSizeAlongMainAxis;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment