Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1329)

Unified Diff: Source/core/layout/LayoutFlexibleBox.cpp

Issue 1304853002: Add a use counter to determine compat impact of changing flexbox's intrinsic size calculation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: new function Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutFlexibleBox.cpp
diff --git a/Source/core/layout/LayoutFlexibleBox.cpp b/Source/core/layout/LayoutFlexibleBox.cpp
index e1f9fede5c8486e6d1330b4978243dbf0ff78813..0aef4d7a635139b21d387f428a3f2689479fdfad 100644
--- a/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/Source/core/layout/LayoutFlexibleBox.cpp
@@ -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
// the flex shorthand stops setting it to 0.
// 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()) {
if (child->isOutOfFlowPositioned())
continue;
@@ -125,6 +126,8 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth);
maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth);
}
+
+ previousMaxContentFlexFraction = countIntrinsicSizeForAlgorithmChange(maxPreferredLogicalWidth, child, previousMaxContentFlexFraction);
}
maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
@@ -134,6 +137,27 @@ void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt
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)
{
if (direction == HorizontalLine) {
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698