Title: [279548] trunk
Revision
279548
Author
[email protected]
Date
2021-07-04 07:10:24 -0700 (Sun, 04 Jul 2021)

Log Message

[LFC][TFC] 100% percent width column(s) make the table stretch
https://bugs.webkit.org/show_bug.cgi?id=227667

Reviewed by Antti Koivisto.

Source/WebCore:

This patch addresses the odd transition of going from 99% to 100% in accumulated percent width.

Test: fast/layoutformattingcontext/table-space-width-100-percent-quirk.html

* layout/formattingContexts/table/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::computedPreferredWidthForColumns):

LayoutTests:

* fast/layoutformattingcontext/table-space-width-100-percent-quirk-expected.html: Added.
* fast/layoutformattingcontext/table-space-width-100-percent-quirk.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (279547 => 279548)


--- trunk/LayoutTests/ChangeLog	2021-07-03 21:29:20 UTC (rev 279547)
+++ trunk/LayoutTests/ChangeLog	2021-07-04 14:10:24 UTC (rev 279548)
@@ -1,3 +1,13 @@
+2021-07-04  Alan Bujtas  <[email protected]>
+
+        [LFC][TFC] 100% percent width column(s) make the table stretch
+        https://bugs.webkit.org/show_bug.cgi?id=227667
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/table-space-width-100-percent-quirk-expected.html: Added.
+        * fast/layoutformattingcontext/table-space-width-100-percent-quirk.html: Added.
+
 2021-07-03  Alexey Shvayka  <[email protected]>
 
         [WebIDL] Rework runtime enabled properties leveraging PropertyCallback

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-space-width-100-percent-quirk-expected.html (0 => 279548)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-space-width-100-percent-quirk-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-space-width-100-percent-quirk-expected.html	2021-07-04 14:10:24 UTC (rev 279548)
@@ -0,0 +1,25 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+body {
+  font-size: 16px;
+  overflow: hidden;
+}
+
+div {
+  height: 10px;
+  background-color: blue;
+}
+
+.inner {
+  background-color: green;
+}
+</style>
+
+<div style="width: 2px"><div class=inner style="width: 1px"></div></div>
+<div style="width: 100px"><div class=inner style="width: 10px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 5px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 0px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 0px"></div></div>
+<div style="width: 500px"><div class=inner style="float: right; width: 50px"></div></div>
+<div style="width: 500px"><div class=inner style="float: right; width: 50px; margin-right: 50px;"></div></div>
+<div style="width: 500px"><div class=inner style="width: 0px"></div></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/table-space-width-100-percent-quirk.html (0 => 279548)


--- trunk/LayoutTests/fast/layoutformattingcontext/table-space-width-100-percent-quirk.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-space-width-100-percent-quirk.html	2021-07-04 14:10:24 UTC (rev 279548)
@@ -0,0 +1,30 @@
+<!DOCTYPE html><!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+td {
+  height: 10px;
+  background-color: blue;
+  padding: 0px;
+}
+
+table {
+  border-spacing: 0px;
+}
+
+body {
+  background-color: white;
+}
+
+td:nth-child(odd) {
+  background-color: green;
+}
+</style>
+<div style="width: 500px;">
+<table><tr><td style="width: 1px;"></td><td style="width: 50%;"></td></td></tr></table>
+<table><tr><td style="width: 10px;"></td><td style="width: 90%;"></td></td></tr></table>
+<table><tr><td style="width: 100px;"></td><td style="width: 99%;"></td></td></tr></table>
+<table><tr><td style="width: 1px;"></td><td style="width: 100%;"></td></td></tr></table>
+<table><tr><td style="width: 10px;"></td><td style="width: 100%;"></td></td></tr></table>
+<table><tr><td style="width: 100px;"></td><td style="width: 90%;"></td><td style="width: 10%;"></td></tr></table>
+<table><tr><td style="width: 100px;"></td><td style="width: 80%;"></td><td style="width: 10%;"></td><td style="width: 10%;"></td></tr></table>
+<table><tr><td style="width: 1px;"></td><td style="width: 200%;"></td></td></tr></table>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (279547 => 279548)


--- trunk/Source/WebCore/ChangeLog	2021-07-03 21:29:20 UTC (rev 279547)
+++ trunk/Source/WebCore/ChangeLog	2021-07-04 14:10:24 UTC (rev 279548)
@@ -1,3 +1,17 @@
+2021-07-04  Alan Bujtas  <[email protected]>
+
+        [LFC][TFC] 100% percent width column(s) make the table stretch
+        https://bugs.webkit.org/show_bug.cgi?id=227667
+
+        Reviewed by Antti Koivisto.
+
+        This patch addresses the odd transition of going from 99% to 100% in accumulated percent width.
+
+        Test: fast/layoutformattingcontext/table-space-width-100-percent-quirk.html
+
+        * layout/formattingContexts/table/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::computedPreferredWidthForColumns):
+
 2021-07-01  Dean Jackson  <[email protected]>
 
         Move BottomControlsBarHeight and InsideMargin to be computed at runtime

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp (279547 => 279548)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2021-07-03 21:29:20 UTC (rev 279547)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2021-07-04 14:10:24 UTC (rev 279548)
@@ -451,7 +451,7 @@
         // Resolve the percent values as follows
         // - the percent value is resolved against the column maximum width (fixed or content based) as if the max value represented the percentage value
         //   e.g 50% with the maximum width of 100px produces a resolved width of 200px for the column.
-        // - find the largest resolved value across the columns and used that as the maxiumum width for the precent based columns.
+        // - find the largest resolved value across the columns and used that as the maximum width for the percent based columns.
         // - Compute the non-percent based columns width by using the remaining percent value (e.g 50% and 10% columns would leave 40% for the rest of the columns)
         for (size_t columnIndex = 0; columnIndex < columnList.size(); ++columnIndex) {
             auto nonPercentColumnWidth = columnIntrinsicWidths[columnIndex].maximum;
@@ -472,6 +472,15 @@
         auto adjustedMaximumWidth = percentMaximumWidth;
         if (remainingPercent)
             adjustedMaximumWidth = std::max(adjustedMaximumWidth, LayoutUnit { nonPercentColumnsWidth * 100.0f / remainingPercent });
+        else {
+            // When the table has percent width column(s) and they add up to (or over) 100%, the maximum width is computed to
+            // only constrained by the available horizontal width.
+            // This is a very odd transition of going from 99.9% to 100%, where 99.9% computes normally (see above)
+            // but as soon as we hit the 100% mark, the table suddenly stretches all the way to the horizontal available space.
+            // It may very well be an ancient bug we need to support (it maps to the epsilon value in AutoTableLayout::computeIntrinsicLogicalWidths which is to avoid division by zero).
+            adjustedMaximumWidth = LayoutUnit::max();
+        }
+
         tableWidthConstraints.maximum = std::max(tableWidthConstraints.maximum, adjustedMaximumWidth);
     }
     // Expand the preferred width with leading and trailing cell spacing (note that column spanners count as one cell).
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to