Commit 03d66d9c authored by robhogan's avatar robhogan Committed by Commit bot

Ensure cell's replaced content doesn't get the wrong width

We need to make the cell's height unusable for calculating perecent/calc height
against before computing its preferred width, otherwise replaced children may use it
to scale up their intrinsic width.

BUG=666730

Review-Url: https://codereview.chromium.org/2851513004
Cr-Commit-Position: refs/heads/master@{#472228}
parent 25ae5928
......@@ -9,13 +9,18 @@ img {
</style>
<table class="test" data-expected-height=100 data-expected-width=82>
<tr>
<td class="test" data-expected-height=96 data-expected-width=78><img src="../../images/resources/border-image-srgb-color-profile.png"></td>
<td class="test" data-expected-height=96 data-expected-width=78><img class="test" data-expected-height=94 data-expected-width=94 id="img"></td>
</tr>
</table>
<script src="../../resources/check-layout.js"></script>
<p> crbug.com/637811: Percent height replaced content in a cell should flex the height of the cell. </p>
<p> crbug.com/637811: Percent height replaced content in a cell should not flex the height or width of the cell. </p>
<div id="output"></div>
<script>
document.body.offsetTop;
checkLayout('.test', output);
img.addEventListener("load", onImageLoaded, false);
img.src = "../../images/resources/border-image-srgb-color-profile.png";
function onImageLoaded()
{
checkLayout('.test', output);
}
</script>
......@@ -209,7 +209,19 @@ void LayoutTableCell::ComputePreferredLogicalWidths() {
// grids before the child cells try to use them.
Table()->RecalcSectionsIfNeeded();
// We don't want the preferred width from children to be affected by any
// notional height on the cell, such as can happen when a percent sized image
// scales up its width to match the available height. Setting a zero override
// height prevents this from happening.
LayoutUnit content_height = HasOverrideLogicalContentHeight()
? OverrideLogicalContentHeight()
: LayoutUnit(-1);
if (content_height > -1)
SetOverrideLogicalContentHeight(LayoutUnit());
LayoutBlockFlow::ComputePreferredLogicalWidths();
if (content_height > -1)
SetOverrideLogicalContentHeight(content_height);
if (GetNode() && Style()->AutoWrap()) {
// See if nowrap was set.
Length w = StyleOrColLogicalWidth();
......
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