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

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: 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/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 3bc1709ebb82d41630deda811a4c8265d7b1c927..3bf7f7951f552ceacaea3ff16054446c49f49cdc 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 (cb->isFlexItem() && styleToUse.logicalWidth().hasPercent() && !isOutOfFlowPositioned()) {
+ LayoutUnit stretchedWidth = toLayoutFlexibleBox(cb->parent())->childLogicalWidthForPercentageResolution(*cb);
+ 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()) {
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698