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

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

Issue 988523003: Reimplement min-width: auto (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 9 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: Source/core/layout/LayoutFlexibleBox.cpp
diff --git a/Source/core/layout/LayoutFlexibleBox.cpp b/Source/core/layout/LayoutFlexibleBox.cpp
index a30f5d91022e034adc4ec194e96b3591ff85a4cb..ea656b856e701a455f1bca733baf5463c6d75f65 100644
--- a/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/Source/core/layout/LayoutFlexibleBox.cpp
@@ -419,7 +419,7 @@ LayoutUnit LayoutFlexibleBox::computeMainAxisExtentForChild(LayoutBox& child, Si
// We don't have to check for "auto" here - computeContentLogicalHeight will just return -1 for that case anyway.
if (size.isIntrinsic())
child.layoutIfNeeded();
- return child.computeContentLogicalHeight(size, child.logicalHeight() - child.borderAndPaddingLogicalHeight()) + child.scrollbarLogicalHeight();
+ return child.computeContentLogicalHeight(sizeType, size, child.logicalHeight() - child.borderAndPaddingLogicalHeight()) + child.scrollbarLogicalHeight();
}
return child.computeLogicalWidthUsing(sizeType, size, contentLogicalWidth(), this) - child.borderAndPaddingLogicalWidth();
}
@@ -837,16 +837,48 @@ void LayoutFlexibleBox::prepareOrderIteratorAndMargins()
LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(LayoutBox& child, LayoutUnit childSize)
{
Length max = isHorizontalFlow() ? child.style()->maxWidth() : child.style()->maxHeight();
+ LayoutUnit maxExtent = -1;
if (max.isSpecifiedOrIntrinsic()) {
- LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max);
+ maxExtent = computeMainAxisExtentForChild(child, MaxSize, max);
if (maxExtent != -1 && childSize > maxExtent)
childSize = maxExtent;
}
Length min = isHorizontalFlow() ? child.style()->minWidth() : child.style()->minHeight();
LayoutUnit minExtent = 0;
- if (min.isSpecifiedOrIntrinsic())
+ if (min.isSpecifiedOrIntrinsic()) {
minExtent = computeMainAxisExtentForChild(child, MinSize, min);
+ // 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(0), minExtent);
+ } else if (min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) {
+ // css-flexbox section 4.5
+ LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, Length(MinContent));
+ ASSERT(contentSize >= 0);
+ if (maxExtent != -1 && contentSize > maxExtent)
+ contentSize = maxExtent;
+
+ bool hasClampedSize = !childPreferredMainAxisContentExtentRequiresLayout(child);
+ if (hasClampedSize) {
+ Length flexBasis = flexBasisForChild(child);
Julien - ping for review 2015/04/06 17:06:47 const Length&?
cbiesinger 2015/04/06 21:34:16 Done.
+ bool flexBasisIsDefinite = flexBasis.isFixed() || (flexBasis.isPercent() && mainAxisExtentIsDefinite());
+ if (flexBasisIsDefinite) {
+ LayoutUnit resolvedFlexBasis = computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis);
+ ASSERT(resolvedFlexBasis >= 0);
+ LayoutUnit clampedSize = resolvedFlexBasis;
Julien - ping for review 2015/04/06 17:06:47 We don't seem to need |resolvedFlexBasis| as we di
cbiesinger 2015/04/06 21:34:16 clampedSize is basically std::min(resolvedFlexBasi
Julien - ping for review 2015/04/13 21:25:59 I think this would be clearer: LayoutUnit clamped
cbiesinger 2015/04/13 23:23:12 Done.
+ if (maxExtent != -1 && clampedSize > maxExtent)
+ clampedSize = maxExtent;
+
+ minExtent = std::min(clampedSize, contentSize);
+ } else {
+ minExtent = contentSize;
+ }
+ } else {
+ minExtent = contentSize;
+ }
+ // TODO(cbiesinger): Implement aspect ratio handling (here, transferred size) - crbug.com/249112
+ }
+ ASSERT(minExtent >= 0);
return std::max(childSize, minExtent);
}
@@ -1058,6 +1090,13 @@ bool LayoutFlexibleBox::needToStretchChildLogicalHeight(LayoutBox& child) const
return isHorizontalFlow() && child.style()->height().isAuto();
}
+EOverflow LayoutFlexibleBox::mainAxisOverflowForChild(LayoutBox& child) const
+{
+ if (isHorizontalFlow())
+ return child.styleRef().overflowX();
+ return child.styleRef().overflowY();
+}
+
void LayoutFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList& children, const Vector<LayoutUnit, 16>& childSizes, LayoutUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContexts)
{
ASSERT(childSizes.size() == children.size());

Powered by Google App Engine
This is Rietveld 408576698