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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.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/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 3bc1709ebb82d41630deda811a4c8265d7b1c927..66abd7c373716585217e30a28af175389d6e555a 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -2099,8 +2099,13 @@ void LayoutBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues)
computedValues.m_extent = constrainLogicalWidthByMinMax(minPreferredLogicalWidth(), containerLogicalWidth, cb);
} else {
LayoutUnit containerWidthInInlineDirection = containerLogicalWidth;
- if (hasPerpendicularContainingBlock)
+ if (hasPerpendicularContainingBlock) {
containerWidthInInlineDirection = perpendicularContainingBlockLogicalHeight();
+ } else if (styleToUse.logicalWidth().hasPercent() && !isOutOfFlowPositioned() && cb->isFlexItem()) {
leviw_travelin_and_unemployed 2016/03/01 01:58:51 Nit, I may have put the isFlexItem() part first.
cbiesinger 2016/03/01 20:36:10 Done.
+ LayoutUnit stretchedWidth = toLayoutFlexibleBox(cb->parent())->childLogicalHeightForPercentageResolution(*cb);
leviw_travelin_and_unemployed 2016/03/01 01:58:51 Link to spec about why width = height?
cbiesinger 2016/03/01 20:36:10 That was a typo :( I added a test that hits this
+ if (stretchedWidth != LayoutUnit(-1))
+ containerWidthInInlineDirection = stretchedWidth;
+ }
LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize, styleToUse.logicalWidth(), containerWidthInInlineDirection, cb);
computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth, containerWidthInInlineDirection, cb);
}
@@ -2600,8 +2605,14 @@ LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const
bool includeBorderPadding = isTable();
+ LayoutUnit stretchedFlexHeight(-1);
+ if (cb->isFlexItem())
+ stretchedFlexHeight = toLayoutFlexibleBox(cb->parent())->childLogicalHeightForPercentageResolution(*cb);
+
if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) {
availableHeight = containingBlockChild->containingBlockLogicalWidthForContent();
+ } else if (stretchedFlexHeight != LayoutUnit(-1)) {
+ availableHeight = stretchedFlexHeight;
} else if (hasOverrideContainingBlockLogicalHeight()) {
availableHeight = overrideContainingBlockContentLogicalHeight();
} else if (cb->isTableCell()) {

Powered by Google App Engine
This is Rietveld 408576698