Commit 64eba27b authored by leviw@chromium.org's avatar leviw@chromium.org

Avoid blowing away the intrinsicContentLogicalHeight when stretching height in FlexBox

Cache and reset the intrinsic content logical height of children when stretching them
in FlexBox. This is to avoid them reseting it to the stretched height, which leads
us to improperly avoiding layout later when stretching is no longer necessary.

This solution is too fragile, but I couldn't come up with one that was more robust
but doesn't break the optimization.

BUG=409779

Review URL: https://codereview.chromium.org/715083002

git-svn-id: svn://svn.chromium.org/blink/trunk@185173 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3a606d08
<!DOCTYPE html>
<style>
body * {
display: flex;
flex: 1;
}
#column1{
flex-direction: column;
}
</style>
<script src="../../resources/check-layout.js"></script>
<script>
onload = function() {
var container = document.getElementById("column2");
container.innerText = "I like to eat eat eat apples and bananas.";
container.offsetTop;
container.innerText = '';
checkLayout("#column1");
}
</script>
<body>
<div style="width: 100px;">
<div id="column1" data-expected-height=0>
<div></div>
</div>
<div id="column2">
</div>
</div>
......@@ -643,6 +643,7 @@ public:
bool backgroundHasOpaqueTopLayer() const;
void updateIntrinsicContentLogicalHeight(LayoutUnit intrinsicContentLogicalHeight) const { m_intrinsicContentLogicalHeight = intrinsicContentLogicalHeight; }
protected:
virtual void willBeDestroyed() override;
......@@ -672,8 +673,6 @@ protected:
virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentCompositedLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const override;
virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const override;
void updateIntrinsicContentLogicalHeight(LayoutUnit intrinsicContentLogicalHeight) const { m_intrinsicContentLogicalHeight = intrinsicContentLogicalHeight; }
virtual PaintInvalidationReason paintInvalidationReason(const RenderLayerModelObject& paintInvalidationContainer,
const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalidationContainer,
const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalidationContainer) const override;
......
......@@ -1350,7 +1350,12 @@ void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox& child, LayoutUni
child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight());
if (childNeedsRelayout) {
child.setLogicalHeight(0);
// We cache the child's intrinsic content logical height to avoid it being reset to the stretched height.
// FIXME: This is fragile. RenderBoxes should be smart enough to determine their intrinsic content logical
// height correctly even when there's an overrideHeight.
LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogicalHeight();
child.forceChildLayout();
child.updateIntrinsicContentLogicalHeight(childIntrinsicContentLogicalHeight);
}
}
} else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment