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

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: add comment 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..56bdeae30aca7ed570c8972932f51913a8334509 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
@@ -1026,6 +1026,61 @@ LayoutUnit LayoutFlexibleBox::adjustChildSizeForMinAndMax(const LayoutBox& child
return std::max(childSize, minExtent);
}
+LayoutUnit LayoutFlexibleBox::crossSizeForPercentageResolution(const LayoutBox& child)
+{
+ // This function implements section 9.8. Definite and Indefinite Sizes, case
+ // 1) of the flexbox spec.
+ // We need to check for multiline and a definite cross size of the flexbox
+ // per https://drafts.csswg.org/css-flexbox/#definite-sizes, and for
+ // stretch, auto margins, and an indefinite cross size of the flex item per
+ // https://drafts.csswg.org/css-flexbox/#stretched (linked from that
+ // section)
+ 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)
+{
+ if (hasOrthogonalFlow(child))
+ return crossSizeForPercentageResolution(child);
+ return LayoutUnit(-1);
+}
+
LayoutUnit LayoutFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(const LayoutBox& child, LayoutUnit childSize)
{
Length crossMin = isHorizontalFlow() ? child.style()->minHeight() : child.style()->minWidth();
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698