- Revision
- 261924
- Author
- [email protected]
- Date
- 2020-05-20 09:05:43 -0700 (Wed, 20 May 2020)
Log Message
Fix table sizing when 'max-width' is used
https://bugs.webkit.org/show_bug.cgi?id=115156
Reviewed by Zalan Bujtas.
Source/WebCore:
Based on previous patch by László Langó <[email protected]>
Test: fast/table/html-table-width-max-width-constrained.html
A table should always be wide enough to contain its content (preferred logical width).
This constraint should be stronger than the table style's specified min-width/width.
The behavior matches the spec, and behavior on Firefox/Chrome.
* rendering/RenderTable.cpp:
(WebCore::RenderTable::updateLogicalWidth):
Max-width should only affect the table's max preferred width.
(WebCore::RenderTable::computePreferredLogicalWidths):
Change the order of constraints so that content constraint is stronger than style width/max-width constraint.
LayoutTests:
Based on a previous patch by László Langó <[email protected]>
* fast/table/css-table-max-width-expected.txt:
* fast/table/css-table-max-width.html:
Change in behavior, test was expecting buggy behavior.
* fast/table/html-table-width-max-width-constrained-expected.txt: Added.
* fast/table/html-table-width-max-width-constrained.html: Added.
Test the desired behavior with content-constrained tables.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (261923 => 261924)
--- trunk/LayoutTests/ChangeLog 2020-05-20 15:59:59 UTC (rev 261923)
+++ trunk/LayoutTests/ChangeLog 2020-05-20 16:05:43 UTC (rev 261924)
@@ -1,3 +1,20 @@
+2020-05-20 Noam Rosenthal <[email protected]>
+
+ Fix table sizing when 'max-width' is used
+ https://bugs.webkit.org/show_bug.cgi?id=115156
+
+ Reviewed by Zalan Bujtas.
+
+ Based on a previous patch by László Langó <[email protected]>
+
+ * fast/table/css-table-max-width-expected.txt:
+ * fast/table/css-table-max-width.html:
+ Change in behavior, test was expecting buggy behavior.
+
+ * fast/table/html-table-width-max-width-constrained-expected.txt: Added.
+ * fast/table/html-table-width-max-width-constrained.html: Added.
+ Test the desired behavior with content-constrained tables.
+
2020-05-20 Philippe Normand <[email protected]>
[GStreamer] <img> tag needs to support video formats
Modified: trunk/LayoutTests/fast/table/css-table-max-width-expected.txt (261923 => 261924)
--- trunk/LayoutTests/fast/table/css-table-max-width-expected.txt 2020-05-20 15:59:59 UTC (rev 261923)
+++ trunk/LayoutTests/fast/table/css-table-max-width-expected.txt 2020-05-20 16:05:43 UTC (rev 261924)
@@ -10,11 +10,11 @@
PASS maxGreatThanMinWidthAutoLayout.getBoundingClientRect().width is 202
PASS minGreatThanMaxWidthAutoLayout.getBoundingClientRect().width is 202
PASS onlyMaxWidthAutoLayout.getBoundingClientRect().width is 202
-PASS maxWidthZeroAutoLayout.getBoundingClientRect().width is 0
+PASS maxWidthZeroAutoLayout.getBoundingClientRect().width is 182
PASS maxGreatThanMinWidthFixedLayout.getBoundingClientRect().width is 202
PASS minGreatThanMaxWidthFixedLayout.getBoundingClientRect().width is 202
PASS onlyMaxWidthFixedLayout.getBoundingClientRect().width is 202
-PASS maxWidthZeroFixedLayout.getBoundingClientRect().width is 0
+PASS maxWidthZeroFixedLayout.getBoundingClientRect().width is 2
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/table/css-table-max-width.html (261923 => 261924)
--- trunk/LayoutTests/fast/table/css-table-max-width.html 2020-05-20 15:59:59 UTC (rev 261923)
+++ trunk/LayoutTests/fast/table/css-table-max-width.html 2020-05-20 16:05:43 UTC (rev 261924)
@@ -42,7 +42,7 @@
fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.
</div>
- <div id="maxWidthZeroAutoLayout" class="child" style="display:table; max-width:0; width:100%;">
+ <div id="maxWidthZeroAutoLayout" class="child" style="display:table; max-width:0; width:100%; font: 10px/1 Ahem;">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
@@ -97,7 +97,7 @@
_onlyMaxWidthAutoLayout_ = document.getElementById("onlyMaxWidthAutoLayout");
shouldBe("onlyMaxWidthAutoLayout.getBoundingClientRect().width","202");
maxWidthZeroAutoLayout = document.getElementById("maxWidthZeroAutoLayout");
-shouldBe("maxWidthZeroAutoLayout.getBoundingClientRect().width","0");
+shouldBe("maxWidthZeroAutoLayout.getBoundingClientRect().width","182");
maxGreatThanMinWidthFixedLayout = document.getElementById("maxGreatThanMinWidthFixedLayout");
shouldBe("maxGreatThanMinWidthFixedLayout.getBoundingClientRect().width","202");
minGreatThanMaxWidthFixedLayout = document.getElementById("minGreatThanMaxWidthFixedLayout");
@@ -105,7 +105,7 @@
_onlyMaxWidthFixedLayout_ = document.getElementById("onlyMaxWidthFixedLayout");
shouldBe("onlyMaxWidthFixedLayout.getBoundingClientRect().width","202");
maxWidthZeroFixedLayout = document.getElementById("maxWidthZeroFixedLayout");
-shouldBe("maxWidthZeroFixedLayout.getBoundingClientRect().width","0");
+shouldBe("maxWidthZeroFixedLayout.getBoundingClientRect().width","2");
document.body.removeChild(document.getElementById('container'));
</script>
Added: trunk/LayoutTests/fast/table/html-table-width-max-width-constrained-expected.txt (0 => 261924)
--- trunk/LayoutTests/fast/table/html-table-width-max-width-constrained-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/table/html-table-width-max-width-constrained-expected.txt 2020-05-20 16:05:43 UTC (rev 261924)
@@ -0,0 +1,4 @@
+This test checks that a fixed table layout with max-width doesn't over-constraint the cell (ie the content width still wins over max-width per the specification).
+For this test to pass, the second cell shouldn't bleed out of the table.
+Cell text Cell text text text text
+PASS
Added: trunk/LayoutTests/fast/table/html-table-width-max-width-constrained.html (0 => 261924)
--- trunk/LayoutTests/fast/table/html-table-width-max-width-constrained.html (rev 0)
+++ trunk/LayoutTests/fast/table/html-table-width-max-width-constrained.html 2020-05-20 16:05:43 UTC (rev 261924)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+table {
+ font: 20px/1 Ahem;
+ border-collapse: separate;
+ table-layout: fixed;
+ max-width: 300px;
+ width: 300px;
+ border: 1px solid #dddddd;
+ border-spacing: 0px;
+}
+
+td {
+ padding: 0px;
+ width: 200px;
+ border-left: 1px solid #dddddd;
+}
+</style>
+<script src=""
+</head>
+<body _onload_="checkLayout('table')">
+ <div>This test checks that a fixed table layout with max-width doesn't over-constraint the cell (ie the content width still wins over max-width per the specification).</div>
+ <div>For this test to pass, the second cell shouldn't bleed out of the table.</div>
+ <table data-expected-width="404">
+ <tbody>
+ <tr>
+ <td>Cell text</td>
+ <td>Cell text text text text</td>
+ </tr>
+ </tbody>
+ </table>
+</body></html>
Modified: trunk/Source/WebCore/ChangeLog (261923 => 261924)
--- trunk/Source/WebCore/ChangeLog 2020-05-20 15:59:59 UTC (rev 261923)
+++ trunk/Source/WebCore/ChangeLog 2020-05-20 16:05:43 UTC (rev 261924)
@@ -1,3 +1,26 @@
+2020-05-20 Noam Rosenthal <[email protected]>
+
+ Fix table sizing when 'max-width' is used
+ https://bugs.webkit.org/show_bug.cgi?id=115156
+
+ Reviewed by Zalan Bujtas.
+
+ Based on previous patch by László Langó <[email protected]>
+
+ Test: fast/table/html-table-width-max-width-constrained.html
+
+ A table should always be wide enough to contain its content (preferred logical width).
+ This constraint should be stronger than the table style's specified min-width/width.
+
+ The behavior matches the spec, and behavior on Firefox/Chrome.
+
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::updateLogicalWidth):
+ Max-width should only affect the table's max preferred width.
+
+ (WebCore::RenderTable::computePreferredLogicalWidths):
+ Change the order of constraints so that content constraint is stronger than style width/max-width constraint.
+
2020-05-20 Carlos Garcia Campos <[email protected]>
REGRESSION(r261554): [GTK] Version 2.29.1 crashes using drag-n-drop API
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (261923 => 261924)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2020-05-20 15:59:59 UTC (rev 261923)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2020-05-20 16:05:43 UTC (rev 261924)
@@ -280,10 +280,6 @@
setLogicalWidth(std::min(availableContentLogicalWidth, maxWidth));
}
- // Ensure we aren't smaller than our min preferred width.
- setLogicalWidth(std::max(logicalWidth(), minPreferredLogicalWidth()));
-
-
// Ensure we aren't bigger than our max-width style.
Length styleMaxLogicalWidth = style().logicalMaxWidth();
if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative()) || styleMaxLogicalWidth.isIntrinsic()) {
@@ -291,6 +287,9 @@
setLogicalWidth(std::min(logicalWidth(), computedMaxLogicalWidth));
}
+ // Ensure we aren't smaller than our min preferred width.
+ setLogicalWidth(std::max(logicalWidth(), minPreferredLogicalWidth()));
+
// Ensure we aren't smaller than our min-width style.
Length styleMinLogicalWidth = style().logicalMinWidth();
if ((styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative()) || styleMinLogicalWidth.isIntrinsic()) {
@@ -827,7 +826,7 @@
// FIXME: This should probably be checking for isSpecified since you should be able to use percentage or calc values for maxWidth.
if (styleToUse.logicalMaxWidth().isFixed()) {
m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
- m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
+ m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, m_minPreferredLogicalWidth);
}
// FIXME: We should be adding borderAndPaddingLogicalWidth here, but m_tableLayout->computePreferredLogicalWidths already does,