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

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

Issue 1098593002: [css-flexbox] Performance optimization: Only apply min-width: auto when flex-shrinking an item (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comment Created 5 years, 8 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 c7212bed4904545c273a0aafc5ccc0924b489b38..e80b2aadb9b41f2eb09adc81dac20eb2699e6954 100644
--- a/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/Source/core/layout/LayoutFlexibleBox.cpp
@@ -834,7 +834,7 @@ void LayoutFlexibleBox::prepareOrderIteratorAndMargins()
}
}
-LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(LayoutBox& child, LayoutUnit childSize)
+LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(LayoutBox& child, LayoutUnit childSize, bool childShrunk)
{
Length max = isHorizontalFlow() ? child.style()->maxWidth() : child.style()->maxHeight();
LayoutUnit maxExtent = -1;
@@ -851,7 +851,7 @@ LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(LayoutBox& child, Layo
// 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 (min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) {
+ } else if (childShrunk && min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) {
// css-flexbox section 4.5
LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, Length(MinContent));
ASSERT(contentSize >= 0);
@@ -954,14 +954,17 @@ bool LayoutFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedF
LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(*child);
LayoutUnit childSize = preferredChildSize;
double extraSpace = 0;
- if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == PositiveFlexibility && std::isfinite(totalFlexGrow))
+ bool childShrunk = false;
+ if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == PositiveFlexibility && std::isfinite(totalFlexGrow)) {
extraSpace = availableFreeSpace * child->style()->flexGrow() / totalFlexGrow;
- else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 && flexSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink))
+ } else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 && flexSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink) && child->style()->flexShrink()) {
extraSpace = availableFreeSpace * child->style()->flexShrink() * preferredChildSize / totalWeightedFlexShrink;
+ childShrunk = true;
+ }
if (std::isfinite(extraSpace))
childSize += LayoutUnit::fromFloatRound(extraSpace);
- LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(*child, childSize);
+ LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(*child, childSize, childShrunk);
ASSERT(adjustedChildSize >= 0);
childSizes.append(adjustedChildSize);
usedFreeSpace += adjustedChildSize - preferredChildSize;
« 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