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

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

Issue 1742973002: [css-flexbox] Correctly resolve percentages in children of stretched flex items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests fixed Created 4 years, 10 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 d39e0314420a1617e4b77eb87ec06d7062d7d32e..d47fa6eae19edabf50a388d35f84678a7c9eaabf 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
@@ -1026,6 +1026,54 @@ LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(const LayoutBox& child
return std::max(childSize, minExtent);
}
+LayoutUnit LayoutFlexibleBox::crossSizeForPercentageResolution(const LayoutBox& child)
+{
+ if (isMultiline() || alignmentForChild(child) != ItemPositionStretch || hasAutoMarginsInCrossAxis(child))
+ return LayoutUnit(-1);
+
+ const Length& childCrossLength = isHorizontalFlow() ? child.styleRef().height() : child.styleRef().width();
+ if (crossAxisLengthIsDefinite(child, childCrossLength))
+ return LayoutUnit(-1);
+
+ LayoutUnit childCrossSize;
+
+ LogicalExtentComputedValues computedValues;
+ if (isColumnFlow()) {
+ const Length& widthLength = styleRef().logicalWidth();
+ if (widthLength.isAuto() || (widthLength.hasPercent() && !hasDefiniteLogicalWidth()))
+ return LayoutUnit(-1);
+
+ computeLogicalWidth(computedValues);
+ if (computedValues.m_extent == LayoutUnit(-1))
+ return LayoutUnit(-1);
+ childCrossSize = computedValues.m_extent - borderAndPaddingLogicalWidth() - scrollbarLogicalWidth();
+ childCrossSize = child.constrainLogicalWidthByMinMax(childCrossSize, childCrossSize, this) - child.scrollbarLogicalWidth() - child.borderAndPaddingLogicalWidth();
+ } else {
+ const Length& heightLength = styleRef().logicalHeight();
+ if (heightLength.isAuto() || (heightLength.hasPercent() && computePercentageLogicalHeight(heightLength) == -1))
+ return LayoutUnit(-1);
+
+ computeLogicalHeight(LayoutUnit(-1), LayoutUnit(), computedValues);
+ childCrossSize = computedValues.m_extent - borderAndPaddingLogicalHeight() - scrollbarLogicalHeight();
+ childCrossSize = child.constrainLogicalHeightByMinMax(childCrossSize, LayoutUnit(-1)) - child.scrollbarLogicalHeight() - child.borderAndPaddingLogicalHeight();
+ }
+ return childCrossSize;
+}
+
+LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const LayoutBox& child)
+{
+ if (!hasOrthogonalFlow(child))
+ return crossSizeForPercentageResolution(child);
+ return LayoutUnit(-1);
+}
+
+LayoutUnit LayoutFlexibleBox::childLogicalWidthForPercentageResolution(const LayoutBox& child)
leviw_travelin_and_unemployed 2016/03/01 01:58:51 This will be used later? I'd rather it land with t
cbiesinger 2016/03/01 20:36:10 This is now used.
+{
+ if (hasOrthogonalFlow(child))
+ return crossSizeForPercentageResolution(child);
+ return LayoutUnit(-1);
cbiesinger 2016/02/29 22:03:54 Note, this part of the two new functions will be u
+}
+
LayoutUnit LayoutFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(const LayoutBox& child, LayoutUnit childSize)
{
Length crossMin = isHorizontalFlow() ? child.style()->minHeight() : child.style()->minWidth();

Powered by Google App Engine
This is Rietveld 408576698