Commit 2d44230a authored by dgrogan's avatar dgrogan Committed by Commit bot

Don't scale columns in an inner table when the outer table has width:0px

The bug has an old repro that depends on whether the inner table
is floated. This no longer seems to have an impact on our behavior.

BUG=244182

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

Cr-Commit-Position: refs/heads/master@{#374799}
parent 91e1a50d
<!DOCTYPE html>
<style>
td { padding: 0px; }
table { border-spacing: 0px; }
.yellow { background-color: yellow; }
.red { background-color: red; }
.green { background-color: green; }
</style>
</head>
This test passes if no red is showing.
<table id="outerTable" style="width:0px;" class="yellow" data-expected-width="200">
<tr>
<td>
<table class="red">
<tr>
<td style="width:50%;">
<div style="width:200px;height:20px" class="green"></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script src="../../resources/check-layout.js"></script>
<script>
checkLayout('#outerTable');
</script>
...@@ -252,6 +252,12 @@ void LayoutTable::removeColumn(const LayoutTableCol*) ...@@ -252,6 +252,12 @@ void LayoutTable::removeColumn(const LayoutTableCol*)
setNeedsSectionRecalc(); setNeedsSectionRecalc();
} }
bool LayoutTable::isLogicalWidthAuto() const
{
Length styleLogicalWidth = style()->logicalWidth();
return (!styleLogicalWidth.isSpecified() || !styleLogicalWidth.isPositive()) && !styleLogicalWidth.isIntrinsic();
}
void LayoutTable::updateLogicalWidth() void LayoutTable::updateLogicalWidth()
{ {
recalcSectionsIfNeeded(); recalcSectionsIfNeeded();
...@@ -272,7 +278,7 @@ void LayoutTable::updateLogicalWidth() ...@@ -272,7 +278,7 @@ void LayoutTable::updateLogicalWidth()
LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth;
Length styleLogicalWidth = style()->logicalWidth(); Length styleLogicalWidth = style()->logicalWidth();
if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || styleLogicalWidth.isIntrinsic()) { if (!isLogicalWidthAuto()) {
setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidth, containerWidthInInlineDirection)); setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidth, containerWidthInInlineDirection));
} else { } else {
// Subtract out any fixed margins from our available width for auto width tables. // Subtract out any fixed margins from our available width for auto width tables.
......
...@@ -363,6 +363,8 @@ public: ...@@ -363,6 +363,8 @@ public:
void subtractCaptionRect(LayoutRect&) const; void subtractCaptionRect(LayoutRect&) const;
bool isLogicalWidthAuto() const;
const char* name() const override { return "LayoutTable"; } const char* name() const override { return "LayoutTable"; }
protected: protected:
......
...@@ -195,7 +195,7 @@ static bool shouldScaleColumns(LayoutTable* table) ...@@ -195,7 +195,7 @@ static bool shouldScaleColumns(LayoutTable* table)
if (cb && cb->isTableCell() if (cb && cb->isTableCell()
&& (cb->style()->width().isAuto() || cb->style()->width().hasPercent())) { && (cb->style()->width().isAuto() || cb->style()->width().hasPercent())) {
LayoutTableCell* cell = toLayoutTableCell(cb); LayoutTableCell* cell = toLayoutTableCell(cb);
if (cell->colSpan() > 1 || cell->table()->style()->width().isAuto()) if (cell->colSpan() > 1 || cell->table()->isLogicalWidthAuto())
scale = false; scale = false;
else else
table = cell->table(); table = cell->table();
......
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