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

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

Issue 1421423005: [css-flexbox] Fix min-size: auto for a non-auto flex basis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
Index: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
index a330ed5cbd70e880e5bf283f4b7a25018e93d9ca..880c68c870a95a4ca2246217408593a57beadb42 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
@@ -446,7 +446,14 @@ LayoutUnit LayoutFlexibleBox::computeMainAxisExtentForChild(const LayoutBox& chi
// forced layout on the child.
return child.computeContentLogicalHeight(sizeType, size, child.contentLogicalHeight()) + child.scrollbarLogicalHeight();
}
- return child.computeLogicalWidthUsing(sizeType, size, contentLogicalWidth(), this) - child.borderAndPaddingLogicalWidth();
+ // computeLogicalWidth always re-computes the intrinsic widths. However, when our logical width is auto,
+ // we can just use our cached value. So let's do that here. (Compare code in LayoutBlock::computePreferredLogicalWidths)
+ LayoutUnit borderAndPadding = child.borderAndPaddingLogicalWidth();
+ if (size.type() == MinContent && styleRef().logicalWidth().isAuto())
leviw_travelin_and_unemployed 2015/10/28 01:24:56 if (styleRef().logicalWidth().isAuto) { if (size
cbiesinger 2015/10/28 01:55:24 Done, except for the "else if" part -- the style g
+ return child.minPreferredLogicalWidth() - borderAndPadding;
+ if (size.type() == MaxContent && styleRef().logicalWidth().isAuto())
+ return child.maxPreferredLogicalWidth() - borderAndPadding;
+ return child.computeLogicalWidthUsing(sizeType, size, contentLogicalWidth(), this) - borderAndPadding;
}
WritingMode LayoutFlexibleBox::transformedWritingMode() const
@@ -870,7 +877,7 @@ void LayoutFlexibleBox::prepareOrderIteratorAndMargins()
}
}
-LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(const LayoutBox& child, LayoutUnit childSize, bool childShrunk)
+LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(const LayoutBox& child, LayoutUnit childSize)
{
Length max = isHorizontalFlow() ? child.style()->maxWidth() : child.style()->maxHeight();
LayoutUnit maxExtent = -1;
@@ -888,7 +895,7 @@ LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(const LayoutBox& child
// computeMainAxisExtentForChild can return -1 when the child has a percentage
// min size, but we have an indefinite size in that axis.
minExtent = std::max(LayoutUnit(), minExtent);
- } else if (childShrunk && min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) {
+ } else if (min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) {
// css-flexbox section 4.5
LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, Length(MinContent));
ASSERT(contentSize >= 0);
@@ -994,7 +1001,6 @@ bool LayoutFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedF
LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(*child);
LayoutUnit childSize = childInnerFlexBaseSize;
double extraSpace = 0;
- bool childShrunk = false;
if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == PositiveFlexibility && std::isfinite(totalFlexGrow)) {
if (totalFlexGrow < 1)
extraSpace = availableFreeSpace * child->style()->flexGrow();
@@ -1002,12 +1008,11 @@ bool LayoutFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedF
extraSpace = availableFreeSpace * child->style()->flexGrow() / totalFlexGrow;
} else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 && flexSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink) && child->style()->flexShrink()) {
extraSpace = availableFreeSpace * child->style()->flexShrink() * childInnerFlexBaseSize / totalWeightedFlexShrink;
- childShrunk = true;
}
if (std::isfinite(extraSpace))
childSize += LayoutUnit::fromFloatRound(extraSpace);
- LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(*child, childSize, childShrunk);
+ LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(*child, childSize);
ASSERT(adjustedChildSize >= 0);
childSizes.append(adjustedChildSize);
usedFreeSpace += adjustedChildSize - childInnerFlexBaseSize;

Powered by Google App Engine
This is Rietveld 408576698