Border changes on tables with collapsed borders doesn't relayout table cells
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2013 21:18:00 +0000 (21:18 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2013 21:18:00 +0000 (21:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109774

Reviewed by David Hyatt.

Source/WebCore:

Test: fast/table/border-collapsing/dynamic-border-width-change.html

Changes to border top and border bottom on table rows also changes the size
of the table cell causing a relayout to be needed.

* rendering/RenderTableRow.cpp:
(WebCore::borderWidthChanged): Also include border top and bottom.
(WebCore::RenderTableRow::styleDidChange): Remove logical from the helper function name.

LayoutTests:

* fast/table/border-collapsing/dynamic-border-width-change-expected.txt: Added.
* fast/table/border-collapsing/dynamic-border-width-change.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143377 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/table/border-collapsing/dynamic-border-width-change-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/border-collapsing/dynamic-border-width-change.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderTableRow.cpp

index 9638953..722b01f 100644 (file)
@@ -1,3 +1,13 @@
+2013-02-19  Tony Chang  <tony@chromium.org>
+
+        Border changes on tables with collapsed borders doesn't relayout table cells
+        https://bugs.webkit.org/show_bug.cgi?id=109774
+
+        Reviewed by David Hyatt.
+
+        * fast/table/border-collapsing/dynamic-border-width-change-expected.txt: Added.
+        * fast/table/border-collapsing/dynamic-border-width-change.html: Added.
+
 2013-02-19  Simon Fraser  <simon.fraser@apple.com>
 
         Add a test result missed in r143074.
diff --git a/LayoutTests/fast/table/border-collapsing/dynamic-border-width-change-expected.txt b/LayoutTests/fast/table/border-collapsing/dynamic-border-width-change-expected.txt
new file mode 100644 (file)
index 0000000..aecea5d
--- /dev/null
@@ -0,0 +1,3 @@
+This test passes if no red is showing.
+
+PASS
diff --git a/LayoutTests/fast/table/border-collapsing/dynamic-border-width-change.html b/LayoutTests/fast/table/border-collapsing/dynamic-border-width-change.html
new file mode 100644 (file)
index 0000000..c74bf84
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+table {
+    border-collapse:collapse;
+    width: 100px;
+}
+td {
+    background-color: red;
+    width: 100%;
+    padding-top: 0;
+    padding-bottom: 0;
+}
+</style>
+<script src="../../../resources/check-layout.js"></script>
+<script>
+window.onload = function()
+{
+    document.body.offsetLeft;
+    document.getElementById("row1").style.borderTop = "50px solid green";
+    document.getElementById("row2").style.borderBottom = "50px solid green";
+    checkLayout("#container");
+}
+</script>
+</head>
+<body>
+<p>This test passes if no red is showing.</p>
+
+<div id="container">
+<table data-expected-height="50">
+<tr id="row1" data-expected-height="25">
+  <td data-expected-height="25"></td>
+</tr>
+</table>
+
+<table data-expected-height="50">
+<tr id="row2" data-expected-height="25">
+  <td data-expected-height="25"></td>
+</tr>
+</table>
+</div>
+
+</body>
+</html>
index 26b399e..ed96292 100644 (file)
@@ -1,3 +1,19 @@
+2013-02-19  Tony Chang  <tony@chromium.org>
+
+        Border changes on tables with collapsed borders doesn't relayout table cells
+        https://bugs.webkit.org/show_bug.cgi?id=109774
+
+        Reviewed by David Hyatt.
+
+        Test: fast/table/border-collapsing/dynamic-border-width-change.html
+
+        Changes to border top and border bottom on table rows also changes the size
+        of the table cell causing a relayout to be needed.
+
+        * rendering/RenderTableRow.cpp:
+        (WebCore::borderWidthChanged): Also include border top and bottom.
+        (WebCore::RenderTableRow::styleDidChange): Remove logical from the helper function name.
+
 2013-02-19  Kentaro Hara  <haraken@chromium.org>
 
         Unreviewed. Rebaselined run-bindings-tests.
index 479cf66..25cc6dc 100644 (file)
@@ -54,13 +54,11 @@ void RenderTableRow::willBeRemovedFromTree()
     section()->setNeedsCellRecalc();
 }
 
-static bool borderLogicalWidthChanged(const RenderStyle* oldStyle, const RenderStyle* newStyle)
+static bool borderWidthChanged(const RenderStyle* oldStyle, const RenderStyle* newStyle)
 {
-    if (newStyle->isHorizontalWritingMode())
-        return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth()
-            || oldStyle->borderRightWidth() != newStyle->borderRightWidth();
-
-    return oldStyle->borderTopWidth() != newStyle->borderTopWidth()
+    return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth()
+        || oldStyle->borderTopWidth() != newStyle->borderTopWidth()
+        || oldStyle->borderRightWidth() != newStyle->borderRightWidth()
         || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth();
 }
 
@@ -80,7 +78,7 @@ void RenderTableRow::styleDidChange(StyleDifference diff, const RenderStyle* old
         if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style()->border())
             table->invalidateCollapsedBorders();
         
-        if (table && oldStyle && diff == StyleDifferenceLayout && needsLayout() && table->collapseBorders() && borderLogicalWidthChanged(oldStyle, style())) {
+        if (table && oldStyle && diff == StyleDifferenceLayout && needsLayout() && table->collapseBorders() && borderWidthChanged(oldStyle, style())) {
             // If the border width changes on a row, we need to make sure the cells in the row know to lay out again.
             // This only happens when borders are collapsed, since they end up affecting the border sides of the cell
             // itself.