Title: [162334] trunk
Revision
162334
Author
commit-qu...@webkit.org
Date
2014-01-20 03:59:14 -0800 (Mon, 20 Jan 2014)

Log Message

Col width is not honored when dynamically updated and it would make table narrower
https://bugs.webkit.org/show_bug.cgi?id=104711

Patch by Gurpreet Kaur <k.gurpr...@samsung.com> on 2014-01-20
Reviewed by Antti Koivisto.

Source/WebCore:

Increasing the table width by increasing the colgroup width
was working but decreasing the table width by decreasing the
colgroup width is not working.

Test: fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html

* rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::styleDidChange):
When colgroup width is defined table cell should adjust according to
that. On decreasing colgroup width the cells maxPreferredLogicalWidth
was still set to the earlier value. Setting the
setPreferredLogicalWidthsDirty to true so that cells pref width is
calculated again.

LayoutTests:

* fast/dom/HTMLTableColElement/resize-table-width-using-col-width-expected.txt: Added.
* fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html: Added.
Added new test case to verify that table cell width decreases by
decreasing the colgroup width.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (162333 => 162334)


--- trunk/LayoutTests/ChangeLog	2014-01-20 11:58:27 UTC (rev 162333)
+++ trunk/LayoutTests/ChangeLog	2014-01-20 11:59:14 UTC (rev 162334)
@@ -1,3 +1,15 @@
+2014-01-20  Gurpreet Kaur  <k.gurpr...@samsung.com>
+
+        Col width is not honored when dynamically updated and it would make table narrower
+        https://bugs.webkit.org/show_bug.cgi?id=104711
+
+        Reviewed by Antti Koivisto.
+
+        * fast/dom/HTMLTableColElement/resize-table-width-using-col-width-expected.txt: Added.
+        * fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html: Added.
+        Added new test case to verify that table cell width decreases by
+        decreasing the colgroup width.
+
 2014-01-20  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width-expected.txt (0 => 162334)


--- trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width-expected.txt	2014-01-20 11:59:14 UTC (rev 162334)
@@ -0,0 +1,10 @@
+Tests that the width of table cell changes on changing the colgroup width to new width which is less than its originally defined width. New width should be 100
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById('colWidth').offsetWidth is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html (0 => 162334)


--- trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html	2014-01-20 11:59:14 UTC (rev 162334)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+           col {
+                width: 200px;
+            }
+            td {
+                background-color: #66f;
+                height: 25px;
+            }
+        </style>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that the width of table cell changes on changing the colgroup width to new width which is less than its originally defined width. New width should be 100');
+
+                setTimeout(function() {
+                    var col = document.getElementById('thecol');
+	                col.style.width="100px";
+                    shouldBe("document.getElementById('colWidth').offsetWidth","100");
+                    finishJSTest();
+                }, 0);
+            }
+            var jsTestIsAsync = true;
+        </script>
+    </head>
+   <body _onload_="runTest()">
+        <table>
+            <colgroup>
+                <col id="thecol">
+            </colgroup>
+            <tbody>
+            <tr>
+                <td id="colWidth"></td>
+            </tr>
+            </tbody>
+        </table>
+        <script src=""
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (162333 => 162334)


--- trunk/Source/WebCore/ChangeLog	2014-01-20 11:58:27 UTC (rev 162333)
+++ trunk/Source/WebCore/ChangeLog	2014-01-20 11:59:14 UTC (rev 162334)
@@ -1,3 +1,24 @@
+2014-01-20  Gurpreet Kaur  <k.gurpr...@samsung.com>
+
+        Col width is not honored when dynamically updated and it would make table narrower
+        https://bugs.webkit.org/show_bug.cgi?id=104711
+
+        Reviewed by Antti Koivisto.
+
+        Increasing the table width by increasing the colgroup width
+        was working but decreasing the table width by decreasing the
+        colgroup width is not working.
+
+        Test: fast/dom/HTMLTableColElement/resize-table-width-using-col-width.html
+
+        * rendering/RenderTableCol.cpp:
+        (WebCore::RenderTableCol::styleDidChange):
+        When colgroup width is defined table cell should adjust according to
+        that. On decreasing colgroup width the cells maxPreferredLogicalWidth
+        was still set to the earlier value. Setting the
+        setPreferredLogicalWidthsDirty to true so that cells pref width is
+        calculated again.
+
 2014-01-20  Edit Balint  <edbal...@inf.u-szeged.hu>
 
         [CoordinatedGraphics] Segmentation fault at  CoordinatedGraphicsScene::clearImageBackingContents

Modified: trunk/Source/WebCore/rendering/RenderTableCol.cpp (162333 => 162334)


--- trunk/Source/WebCore/rendering/RenderTableCol.cpp	2014-01-20 11:58:27 UTC (rev 162333)
+++ trunk/Source/WebCore/rendering/RenderTableCol.cpp	2014-01-20 11:59:14 UTC (rev 162334)
@@ -28,6 +28,7 @@
 
 #include "HTMLNames.h"
 #include "HTMLTableColElement.h"
+#include "RenderIterator.h"
 #include "RenderTable.h"
 #include "RenderTableCell.h"
 
@@ -53,6 +54,20 @@
         RenderTable* table = this->table();
         if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style().border())
             table->invalidateCollapsedBorders();
+        else if (oldStyle->width() != style().width()) {
+            for (auto& section : childrenOfType<RenderTableSection>(*table)) {
+                unsigned nEffCols = table->numEffCols();
+                for (unsigned j = 0; j < nEffCols; j++) {
+                    unsigned rowCount = section.numRows();
+                    for (unsigned i = 0; i < rowCount; i++) {
+                        RenderTableCell* cell = section.primaryCellAt(i, j);
+                        if (!cell)
+                            continue;
+                        cell->setPreferredLogicalWidthsDirty(true);
+                    }
+                }
+            }
+        }
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to