Index: Source/core/rendering/RenderFlexibleBox.cpp |
diff --git a/Source/core/rendering/RenderFlexibleBox.cpp b/Source/core/rendering/RenderFlexibleBox.cpp |
index 101947da171ad711430ed55206bb94312d9ccae2..245b632674a26379e8a791691bc3f247c7656938 100644 |
--- a/Source/core/rendering/RenderFlexibleBox.cpp |
+++ b/Source/core/rendering/RenderFlexibleBox.cpp |
@@ -609,7 +609,7 @@ bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render |
LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength, bool relayoutChildren) |
{ |
- child.clearOverrideSize(); |
+ clearLogicalOverrideSize(child); |
if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() || child.isCanvas()) |
UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |
@@ -991,6 +991,14 @@ void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil |
child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAndPaddingLogicalWidth()); |
} |
+void RenderFlexibleBox::clearLogicalOverrideSize(RenderBox& child) |
+{ |
+ if (hasOrthogonalFlow(child)) |
+ child.clearOverrideLogicalContentHeight(); |
+ else |
+ child.clearOverrideLogicalContentWidth(); |
+} |
+ |
void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode) |
{ |
ASSERT(child.isOutOfFlowPositioned()); |
@@ -1351,10 +1359,11 @@ void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox& child, LayoutUni |
LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availableAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); |
ASSERT(!child.needsLayout()); |
LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogicalHeight()); |
+ LayoutUnit desiredLogicalContentHeight = desiredLogicalHeight - child.borderAndPaddingLogicalHeight(); |
// FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905. |
- if (desiredLogicalHeight != child.logicalHeight()) { |
- child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight()); |
+ if (desiredLogicalHeight != child.logicalHeight() || (!child.hasOverrideHeight() && toRenderBlock(child).hasPercentHeightDescendants())) { |
+ child.setOverrideLogicalContentHeight(desiredLogicalContentHeight); |
child.setLogicalHeight(0); |
child.forceChildLayout(); |
} |