Title: [201234] trunk
Revision
201234
Author
[email protected]
Date
2016-05-20 16:56:34 -0700 (Fri, 20 May 2016)

Log Message

`width: 1%` on nested table cell causes its table to hog horizontal space
https://bugs.webkit.org/show_bug.cgi?id=144696
<rdar://problem/20839572>

Reviewed by David Hyatt and Tim Horton.

This patch is based on https://chromium.googlesource.com/chromium/src/+/9428cfb16993a2329e87c65da096ca295132ef0f

Source/WebCore:

Tests: fast/table/inner-percent-width-affects-outer-floated-div.html
       fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html

* rendering/AutoTableLayout.cpp:
(WebCore::shouldScaleColumnsForParent):
(WebCore::shouldScaleColumnsForSelf):
(WebCore::AutoTableLayout::computeIntrinsicLogicalWidths):
(WebCore::shouldScaleColumns): Deleted.
* rendering/AutoTableLayout.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::updateLogicalWidth):
* rendering/TableLayout.h:
(WebCore::TableLayout::scaledWidthFromPercentColumns):

LayoutTests:

* fast/table/inner-percent-width-affects-outer-floated-div-expected.html: Added.
* fast/table/inner-percent-width-affects-outer-floated-div.html: Added.
* fast/table/inner-percent-width-doesnt-affect-ancestor-columns-expected.html: Added.
* fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html: Added.
* platform/mac/fast/table/border-collapsing/cached-change-row-border-width-expected.txt:
* platform/mac/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt:
* platform/mac/fast/table/max-width-integer-overflow-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (201233 => 201234)


--- trunk/LayoutTests/ChangeLog	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/ChangeLog	2016-05-20 23:56:34 UTC (rev 201234)
@@ -1,3 +1,21 @@
+2016-05-20  Zalan Bujtas  <[email protected]>
+
+        `width: 1%` on nested table cell causes its table to hog horizontal space
+        https://bugs.webkit.org/show_bug.cgi?id=144696
+        <rdar://problem/20839572>
+
+        Reviewed by David Hyatt and Tim Horton.
+        
+        This patch is based on https://chromium.googlesource.com/chromium/src/+/9428cfb16993a2329e87c65da096ca295132ef0f
+
+        * fast/table/inner-percent-width-affects-outer-floated-div-expected.html: Added.
+        * fast/table/inner-percent-width-affects-outer-floated-div.html: Added.
+        * fast/table/inner-percent-width-doesnt-affect-ancestor-columns-expected.html: Added.
+        * fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html: Added.
+        * platform/mac/fast/table/border-collapsing/cached-change-row-border-width-expected.txt:
+        * platform/mac/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt:
+        * platform/mac/fast/table/max-width-integer-overflow-expected.txt:
+
 2016-05-20  Brady Eidson  <[email protected]>
 
         Modern IDB: Properly handle blobs in Workers.

Added: trunk/LayoutTests/fast/table/inner-percent-width-affects-outer-floated-div-expected.html (0 => 201234)


--- trunk/LayoutTests/fast/table/inner-percent-width-affects-outer-floated-div-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/inner-percent-width-affects-outer-floated-div-expected.html	2016-05-20 23:56:34 UTC (rev 201234)
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<p>There should be a blue square below. Inner table's percent-driven width
+should affect the shrink-to-fit div.</p>
+<div style="width: 200px; height: 200px; background: blue;"></div>

Added: trunk/LayoutTests/fast/table/inner-percent-width-affects-outer-floated-div.html (0 => 201234)


--- trunk/LayoutTests/fast/table/inner-percent-width-affects-outer-floated-div.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/inner-percent-width-affects-outer-floated-div.html	2016-05-20 23:56:34 UTC (rev 201234)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<p>There should be a blue square below. Inner table's percent-driven width
+should affect the shrink-to-fit div.</p>
+<div style="float:left; background:blue;">
+    <table cellspacing="0" cellpadding="0">
+        <td style="width:20%;">
+            <div style="width:40px; height:200px;"></div>
+        </td>
+        <td></td>
+    </table>
+</div>

Added: trunk/LayoutTests/fast/table/inner-percent-width-doesnt-affect-ancestor-columns-expected.html (0 => 201234)


--- trunk/LayoutTests/fast/table/inner-percent-width-doesnt-affect-ancestor-columns-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/inner-percent-width-doesnt-affect-ancestor-columns-expected.html	2016-05-20 23:56:34 UTC (rev 201234)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<table style="width: 300px" cellspacing="0" cellpadding="0">
+    <td style="background: yellow;">
+        <div style="width: 20px; height: 150px;"></div>
+    </td>
+    <td style="background: green;">
+        <div style="width: 40px; height: 150px;"></div>
+    </td>
+</table>

Added: trunk/LayoutTests/fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html (0 => 201234)


--- trunk/LayoutTests/fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html	2016-05-20 23:56:34 UTC (rev 201234)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<table style="width: 300px" cellspacing="0" cellpadding="0">
+    <td style="background: red;">
+      <div style="background: blue">
+        <table cellspacing="0" cellpadding="0">
+            <td style="width:1%; background: yellow;">
+                <div style="width:20px; height:150px;"></div>
+            </td>
+        </table>
+      </div>
+    </td>
+    <td style="background: green;">
+        <div style="width:40px; height: 150px;"></div>
+    </td>
+</table>

Modified: trunk/LayoutTests/platform/ios-simulator/fast/table/border-collapsing/cached-change-row-border-width-expected.txt (201233 => 201234)


--- trunk/LayoutTests/platform/ios-simulator/fast/table/border-collapsing/cached-change-row-border-width-expected.txt	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/platform/ios-simulator/fast/table/border-collapsing/cached-change-row-border-width-expected.txt	2016-05-20 23:56:34 UTC (rev 201234)
@@ -3,9 +3,9 @@
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 56x103 [border: (2px solid #0000FF)]
-        RenderTableSection {TBODY} at (2,2) size 52x100
-          RenderTableRow {TR} at (0,0) size 52x50 [border: (4px solid #FFFF00)]
-            RenderTableCell {TD} at (0,22) size 52x6 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
-          RenderTableRow {TR} at (0,50) size 52x50
-            RenderTableCell {TD} at (0,72) size 52x6 [border: (2px none #000000)] [r=1 c=0 rs=1 cs=1]
+      RenderTable {TABLE} at (0,0) size 58x103 [border: (2px solid #0000FF)]
+        RenderTableSection {TBODY} at (2,2) size 54x100
+          RenderTableRow {TR} at (0,0) size 54x50 [border: (4px solid #FFFF00)]
+            RenderTableCell {TD} at (0,22) size 54x6 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
+          RenderTableRow {TR} at (0,50) size 54x50
+            RenderTableCell {TD} at (0,73) size 54x4 [border: (2px none #000000)] [r=1 c=0 rs=1 cs=1]

Modified: trunk/LayoutTests/platform/ios-simulator/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt (201233 => 201234)


--- trunk/LayoutTests/platform/ios-simulator/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/platform/ios-simulator/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt	2016-05-20 23:56:34 UTC (rev 201234)
@@ -3,15 +3,15 @@
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 109x153 [border: (2px solid #0000FF)]
-        RenderTableSection {TBODY} at (2,2) size 105x100 [border: (4px solid #FFFF00)]
-          RenderTableRow {TR} at (0,0) size 105x50
-            RenderTableCell {TD} at (0,22) size 53x6 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (52,23) size 53x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
-          RenderTableRow {TR} at (0,50) size 105x50
-            RenderTableCell {TD} at (0,72) size 53x6 [border: (1px none #000000)] [r=1 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (52,73) size 53x4 [border: none] [r=1 c=1 rs=1 cs=1]
-        RenderTableSection {TBODY} at (2,102) size 105x50
-          RenderTableRow {TR} at (0,0) size 105x50
-            RenderTableCell {TD} at (0,22) size 53x6 [border: (2px none #000000)] [r=0 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (52,22) size 53x6 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
+      RenderTable {TABLE} at (0,0) size 112x153 [border: (2px solid #0000FF)]
+        RenderTableSection {TBODY} at (2,2) size 108x100 [border: (4px solid #FFFF00)]
+          RenderTableRow {TR} at (0,0) size 108x50
+            RenderTableCell {TD} at (0,23) size 54x4 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (54,23) size 54x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
+          RenderTableRow {TR} at (0,50) size 108x50
+            RenderTableCell {TD} at (0,73) size 54x4 [border: (1px none #000000)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (54,73) size 54x4 [border: none] [r=1 c=1 rs=1 cs=1]
+        RenderTableSection {TBODY} at (2,102) size 108x50
+          RenderTableRow {TR} at (0,0) size 108x50
+            RenderTableCell {TD} at (0,23) size 54x4 [border: (2px none #000000)] [r=0 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (54,23) size 54x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]

Modified: trunk/LayoutTests/platform/ios-simulator/fast/table/max-width-integer-overflow-expected.txt (201233 => 201234)


--- trunk/LayoutTests/platform/ios-simulator/fast/table/max-width-integer-overflow-expected.txt	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/platform/ios-simulator/fast/table/max-width-integer-overflow-expected.txt	2016-05-20 23:56:34 UTC (rev 201234)
@@ -6,16 +6,16 @@
       RenderTable {TABLE} at (0,0) size 780x24 [bgcolor=#FF0000]
         RenderTableSection {TBODY} at (0,0) size 780x24
           RenderTableRow {TR} at (0,0) size 780x24
-            RenderTableCell {TD} at (0,0) size 770x24 [r=0 c=0 rs=1 cs=1]
-              RenderTable {TABLE} at (0,0) size 770x24
-                RenderTableSection {TBODY} at (0,0) size 770x24
-                  RenderTableRow {TR} at (0,0) size 770x24
-                    RenderTableCell {TD} at (0,0) size 770x24 [r=0 c=0 rs=1 cs=1]
-                      RenderBlock {DIV} at (0,0) size 770x24
-                        RenderTable {TABLE} at (0,0) size 770x24 [bgcolor=#008000]
-                          RenderTableSection {TBODY} at (0,0) size 770x24
-                            RenderTableRow {TR} at (0,2) size 770x20
-                              RenderTableCell {TD} at (2,11) size 762x2 [r=0 c=0 rs=1 cs=1]
-                              RenderTableCell {TD} at (766,11) size 2x2 [r=0 c=1 rs=1 cs=1]
-            RenderTableCell {TD} at (770,0) size 10x24 [r=0 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (0,0) size 756x24 [r=0 c=0 rs=1 cs=1]
+              RenderTable {TABLE} at (0,0) size 310x24
+                RenderTableSection {TBODY} at (0,0) size 310x24
+                  RenderTableRow {TR} at (0,0) size 310x24
+                    RenderTableCell {TD} at (0,0) size 310x24 [r=0 c=0 rs=1 cs=1]
+                      RenderBlock {DIV} at (0,0) size 310x24
+                        RenderTable {TABLE} at (0,0) size 310x24 [bgcolor=#008000]
+                          RenderTableSection {TBODY} at (0,0) size 310x24
+                            RenderTableRow {TR} at (0,2) size 310x20
+                              RenderTableCell {TD} at (2,11) size 302x2 [r=0 c=0 rs=1 cs=1]
+                              RenderTableCell {TD} at (306,11) size 2x2 [r=0 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (755,0) size 25x24 [r=0 c=1 rs=1 cs=1]
               RenderBlock {DIV} at (0,0) size 10x24 [bgcolor=#008000]

Modified: trunk/LayoutTests/platform/mac/fast/table/border-collapsing/cached-change-row-border-width-expected.txt (201233 => 201234)


--- trunk/LayoutTests/platform/mac/fast/table/border-collapsing/cached-change-row-border-width-expected.txt	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/platform/mac/fast/table/border-collapsing/cached-change-row-border-width-expected.txt	2016-05-20 23:56:34 UTC (rev 201234)
@@ -3,9 +3,9 @@
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 56x103 [border: (2px solid #0000FF)]
-        RenderTableSection {TBODY} at (2,2) size 52x100
-          RenderTableRow {TR} at (0,0) size 52x50 [border: (4px solid #FFFF00)]
-            RenderTableCell {TD} at (0,22) size 52x6 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
-          RenderTableRow {TR} at (0,50) size 52x50
-            RenderTableCell {TD} at (0,73) size 52x4 [border: (2px none #000000)] [r=1 c=0 rs=1 cs=1]
+      RenderTable {TABLE} at (0,0) size 58x103 [border: (2px solid #0000FF)]
+        RenderTableSection {TBODY} at (2,2) size 54x100
+          RenderTableRow {TR} at (0,0) size 54x50 [border: (4px solid #FFFF00)]
+            RenderTableCell {TD} at (0,22) size 54x6 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
+          RenderTableRow {TR} at (0,50) size 54x50
+            RenderTableCell {TD} at (0,73) size 54x4 [border: (2px none #000000)] [r=1 c=0 rs=1 cs=1]

Modified: trunk/LayoutTests/platform/mac/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt (201233 => 201234)


--- trunk/LayoutTests/platform/mac/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/platform/mac/fast/table/border-collapsing/cached-change-tbody-border-width-expected.txt	2016-05-20 23:56:34 UTC (rev 201234)
@@ -3,15 +3,15 @@
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 109x153 [border: (2px solid #0000FF)]
-        RenderTableSection {TBODY} at (2,2) size 105x100 [border: (4px solid #FFFF00)]
-          RenderTableRow {TR} at (0,0) size 105x50
-            RenderTableCell {TD} at (0,22) size 53x6 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (53,23) size 52x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
-          RenderTableRow {TR} at (0,50) size 105x50
-            RenderTableCell {TD} at (0,72) size 53x6 [border: (1px none #000000)] [r=1 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (53,73) size 52x4 [border: none] [r=1 c=1 rs=1 cs=1]
-        RenderTableSection {TBODY} at (2,102) size 105x50
-          RenderTableRow {TR} at (0,0) size 105x50
-            RenderTableCell {TD} at (0,23) size 53x4 [border: (2px none #000000)] [r=0 c=0 rs=1 cs=1]
-            RenderTableCell {TD} at (53,23) size 52x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
+      RenderTable {TABLE} at (0,0) size 111x153 [border: (2px solid #0000FF)]
+        RenderTableSection {TBODY} at (2,2) size 107x100 [border: (4px solid #FFFF00)]
+          RenderTableRow {TR} at (0,0) size 107x50
+            RenderTableCell {TD} at (0,23) size 54x4 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (54,23) size 53x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
+          RenderTableRow {TR} at (0,50) size 107x50
+            RenderTableCell {TD} at (0,73) size 54x4 [border: (1px none #000000)] [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (54,74) size 53x2 [border: none] [r=1 c=1 rs=1 cs=1]
+        RenderTableSection {TBODY} at (2,102) size 107x50
+          RenderTableRow {TR} at (0,0) size 107x50
+            RenderTableCell {TD} at (0,23) size 54x4 [border: (2px none #000000)] [r=0 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (54,23) size 53x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]

Modified: trunk/LayoutTests/platform/mac/fast/table/max-width-integer-overflow-expected.txt (201233 => 201234)


--- trunk/LayoutTests/platform/mac/fast/table/max-width-integer-overflow-expected.txt	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/LayoutTests/platform/mac/fast/table/max-width-integer-overflow-expected.txt	2016-05-20 23:56:34 UTC (rev 201234)
@@ -6,16 +6,16 @@
       RenderTable {TABLE} at (0,0) size 780x24 [bgcolor=#FF0000]
         RenderTableSection {TBODY} at (0,0) size 780x24
           RenderTableRow {TR} at (0,0) size 780x24
-            RenderTableCell {TD} at (0,0) size 770x24 [r=0 c=0 rs=1 cs=1]
-              RenderTable {TABLE} at (0,0) size 770x24
-                RenderTableSection {TBODY} at (0,0) size 770x24
-                  RenderTableRow {TR} at (0,0) size 770x24
-                    RenderTableCell {TD} at (0,0) size 770x24 [r=0 c=0 rs=1 cs=1]
-                      RenderBlock {DIV} at (0,0) size 770x24
-                        RenderTable {TABLE} at (0,0) size 770x24 [bgcolor=#008000]
-                          RenderTableSection {TBODY} at (0,0) size 770x24
-                            RenderTableRow {TR} at (0,2) size 770x20
-                              RenderTableCell {TD} at (2,11) size 762x2 [r=0 c=0 rs=1 cs=1]
-                              RenderTableCell {TD} at (766,11) size 2x2 [r=0 c=1 rs=1 cs=1]
-            RenderTableCell {TD} at (770,0) size 10x24 [r=0 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (0,0) size 756x24 [r=0 c=0 rs=1 cs=1]
+              RenderTable {TABLE} at (0,0) size 310x24
+                RenderTableSection {TBODY} at (0,0) size 310x24
+                  RenderTableRow {TR} at (0,0) size 310x24
+                    RenderTableCell {TD} at (0,0) size 310x24 [r=0 c=0 rs=1 cs=1]
+                      RenderBlock {DIV} at (0,0) size 310x24
+                        RenderTable {TABLE} at (0,0) size 310x24 [bgcolor=#008000]
+                          RenderTableSection {TBODY} at (0,0) size 310x24
+                            RenderTableRow {TR} at (0,2) size 310x20
+                              RenderTableCell {TD} at (2,11) size 302x2 [r=0 c=0 rs=1 cs=1]
+                              RenderTableCell {TD} at (306,11) size 2x2 [r=0 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (755,0) size 25x24 [r=0 c=1 rs=1 cs=1]
               RenderBlock {DIV} at (0,0) size 10x24 [bgcolor=#008000]

Modified: trunk/Source/WebCore/ChangeLog (201233 => 201234)


--- trunk/Source/WebCore/ChangeLog	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/Source/WebCore/ChangeLog	2016-05-20 23:56:34 UTC (rev 201234)
@@ -1,3 +1,27 @@
+2016-05-20  Zalan Bujtas  <[email protected]>
+
+        `width: 1%` on nested table cell causes its table to hog horizontal space
+        https://bugs.webkit.org/show_bug.cgi?id=144696
+        <rdar://problem/20839572>
+
+        Reviewed by David Hyatt and Tim Horton.
+        
+        This patch is based on https://chromium.googlesource.com/chromium/src/+/9428cfb16993a2329e87c65da096ca295132ef0f
+
+        Tests: fast/table/inner-percent-width-affects-outer-floated-div.html
+               fast/table/inner-percent-width-doesnt-affect-ancestor-columns.html
+
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::shouldScaleColumnsForParent):
+        (WebCore::shouldScaleColumnsForSelf):
+        (WebCore::AutoTableLayout::computeIntrinsicLogicalWidths):
+        (WebCore::shouldScaleColumns): Deleted.
+        * rendering/AutoTableLayout.h:
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::updateLogicalWidth):
+        * rendering/TableLayout.h:
+        (WebCore::TableLayout::scaledWidthFromPercentColumns):
+
 2016-05-20  Jer Noble  <[email protected]>
 
         Inconsistent state in playback controls

Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (201233 => 201234)


--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2016-05-20 23:56:34 UTC (rev 201234)
@@ -182,9 +182,27 @@
         recalcColumn(i);
 }
 
+static bool shouldScaleColumnsForParent(const RenderTable& table)
+{
+    RenderBlock* containingBlock = table.containingBlock();
+    while (containingBlock && !is<RenderView>(containingBlock)) {
+        // It doesn't matter if our table is auto or fixed: auto means we don't
+        // scale. Fixed doesn't care if we do or not because it doesn't depend
+        // on the cell contents' preferred widths.
+        if (is<RenderTableCell>(containingBlock))
+            return false;
+        containingBlock = containingBlock->containingBlock();
+    }
+    return true;
+}
+
 // FIXME: This needs to be adapted for vertical writing modes.
-static bool shouldScaleColumns(RenderTable* table)
+static bool shouldScaleColumnsForSelf(RenderTable* table)
 {
+    // Normally, scale all columns to satisfy this from CSS2.2:
+    // "A percentage value for a column width is relative to the table width.
+    // If the table has 'width: auto', a percentage represents a constraint on the column's width"
+
     // A special case.  If this table is not fixed width and contained inside
     // a cell, then don't bloat the maxwidth by examining percentage growth.
     bool scale = true;
@@ -221,7 +239,7 @@
     maxWidth = 0;
     float maxPercent = 0;
     float maxNonPercent = 0;
-    bool scaleColumns = shouldScaleColumns(m_table);
+    bool scaleColumnsForSelf = shouldScaleColumnsForSelf(m_table);
 
     // We substitute 0 percent by (epsilon / percentScaleFactor) percent in two places below to avoid division by zero.
     // FIXME: Handle the 0% cases properly.
@@ -231,7 +249,7 @@
     for (size_t i = 0; i < m_layoutStruct.size(); ++i) {
         minWidth += m_layoutStruct[i].effectiveMinLogicalWidth;
         maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth;
-        if (scaleColumns) {
+        if (scaleColumnsForSelf) {
             if (m_layoutStruct[i].effectiveLogicalWidth.isPercent()) {
                 float percent = std::min(m_layoutStruct[i].effectiveLogicalWidth.percent(), remainingPercent);
                 float logicalWidth = m_layoutStruct[i].effectiveMaxLogicalWidth * 100 / std::max(percent, epsilon);
@@ -242,10 +260,12 @@
         }
     }
 
-    if (scaleColumns) {
+    if (scaleColumnsForSelf) {
         maxNonPercent = maxNonPercent * 100 / std::max(remainingPercent, epsilon);
-        maxWidth = std::max(maxWidth, LayoutUnit(std::min<float>(maxNonPercent, tableMaxWidth)));
-        maxWidth = std::max(maxWidth, LayoutUnit(std::min<float>(maxPercent, tableMaxWidth)));
+        m_scaledWidthFromPercentColumns = LayoutUnit(std::min<float>(maxNonPercent, tableMaxWidth));
+        m_scaledWidthFromPercentColumns = std::max(m_scaledWidthFromPercentColumns, LayoutUnit(std::min<float>(maxPercent, tableMaxWidth)));
+        if (m_scaledWidthFromPercentColumns > maxWidth && shouldScaleColumnsForParent(*m_table))
+            maxWidth = m_scaledWidthFromPercentColumns;
     }
 
     maxWidth = std::max(maxWidth, LayoutUnit(spanMaxLogicalWidth));

Modified: trunk/Source/WebCore/rendering/AutoTableLayout.h (201233 => 201234)


--- trunk/Source/WebCore/rendering/AutoTableLayout.h	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.h	2016-05-20 23:56:34 UTC (rev 201234)
@@ -37,6 +37,7 @@
     virtual ~AutoTableLayout();
 
     void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) override;
+    LayoutUnit scaledWidthFromPercentColumns() const override { return m_scaledWidthFromPercentColumns; }
     void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const override;
     void layout() override;
 
@@ -63,6 +64,7 @@
     Vector<RenderTableCell*, 4> m_spanCells;
     bool m_hasPercent : 1;
     mutable bool m_effectiveLogicalWidthDirty : 1;
+    LayoutUnit m_scaledWidthFromPercentColumns;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (201233 => 201234)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2016-05-20 23:56:34 UTC (rev 201234)
@@ -297,6 +297,13 @@
 
         // Ensure we aren't bigger than our available width.
         setLogicalWidth(std::min(availableContentLogicalWidth, maxPreferredLogicalWidth()));
+        LayoutUnit maxWidth = maxPreferredLogicalWidth();
+        // scaledWidthFromPercentColumns depends on m_layoutStruct in TableLayoutAlgorithmAuto, which
+        // maxPreferredLogicalWidth fills in. So scaledWidthFromPercentColumns has to be called after
+        // maxPreferredLogicalWidth.
+        LayoutUnit scaledWidth = m_tableLayout->scaledWidthFromPercentColumns() + bordersPaddingAndSpacingInRowDirection();
+        maxWidth = std::max(scaledWidth, maxWidth);
+        setLogicalWidth(std::min(availableContentLogicalWidth, maxWidth));
     }
 
     // Ensure we aren't smaller than our min preferred width.

Modified: trunk/Source/WebCore/rendering/TableLayout.h (201233 => 201234)


--- trunk/Source/WebCore/rendering/TableLayout.h	2016-05-20 23:46:06 UTC (rev 201233)
+++ trunk/Source/WebCore/rendering/TableLayout.h	2016-05-20 23:56:34 UTC (rev 201234)
@@ -21,6 +21,7 @@
 #ifndef TableLayout_h
 #define TableLayout_h
 
+#include "LayoutUnit.h"
 #include <wtf/FastMalloc.h>
 #include <wtf/Noncopyable.h>
 
@@ -39,6 +40,7 @@
     virtual ~TableLayout() { }
 
     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
+    virtual LayoutUnit scaledWidthFromPercentColumns() const { return LayoutUnit(0); }
     virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const = 0;
     virtual void layout() = 0;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to