Title: [142889] trunk
Revision
142889
Author
t...@chromium.org
Date
2013-02-14 09:53:16 -0800 (Thu, 14 Feb 2013)

Log Message

Padding and border changes doesn't trigger relayout of children
https://bugs.webkit.org/show_bug.cgi?id=109639

Reviewed by Kent Tamura.

Source/WebCore:

In RenderBlock::layoutBlock, we only relayout our children if our logical width
changes. This misses cases where our logical width doesn't change (i.e., padding
or border changes), but our content width does change.

This is a more general case of bug 104997.

Test: fast/block/dynamic-padding-border.html

* rendering/RenderBox.cpp:
(WebCore::borderOrPaddingLogicalWidthChanged): Only check if the logical width changed.
(WebCore::RenderBox::styleDidChange): Drop the border-box condition since this can happen
even without border-box box sizing.

LayoutTests:

* fast/block/dynamic-padding-border-expected.txt: Added.
* fast/block/dynamic-padding-border.html: Added.
* fast/table/border-collapsing/cached-change-row-border-width-expected.txt: We should have been relaying
out the table when the border changed. The pixel results in this case is the same, but the
render tree shows the difference.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142888 => 142889)


--- trunk/LayoutTests/ChangeLog	2013-02-14 17:52:04 UTC (rev 142888)
+++ trunk/LayoutTests/ChangeLog	2013-02-14 17:53:16 UTC (rev 142889)
@@ -1,3 +1,16 @@
+2013-02-14  Tony Chang  <t...@chromium.org>
+
+        Padding and border changes doesn't trigger relayout of children
+        https://bugs.webkit.org/show_bug.cgi?id=109639
+
+        Reviewed by Kent Tamura.
+
+        * fast/block/dynamic-padding-border-expected.txt: Added.
+        * fast/block/dynamic-padding-border.html: Added.
+        * fast/table/border-collapsing/cached-change-row-border-width-expected.txt: We should have been relaying
+        out the table when the border changed. The pixel results in this case is the same, but the
+        render tree shows the difference.
+
 2013-02-14  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: [Regression] When several consecutive characters are typed each of them is marked as undoable state.

Added: trunk/LayoutTests/fast/block/dynamic-padding-border-expected.txt (0 => 142889)


--- trunk/LayoutTests/fast/block/dynamic-padding-border-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/dynamic-padding-border-expected.txt	2013-02-14 17:53:16 UTC (rev 142889)
@@ -0,0 +1,6 @@
+This test passes if there is no red showing.
+
+PASS
+PASS
+PASS
+PASS

Added: trunk/LayoutTests/fast/block/dynamic-padding-border.html (0 => 142889)


--- trunk/LayoutTests/fast/block/dynamic-padding-border.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/dynamic-padding-border.html	2013-02-14 17:53:16 UTC (rev 142889)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.red {
+    background-color: red;
+}
+.green {
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<p>This test passes if there is no red showing.</p>
+
+<div class="container" style="width: 100px">
+    <div id="test1" class="red" style="padding-left: 50px" data-expected-width="100">
+        <div class="green" style="height: 20px" data-expected-width="100"></div>
+    </div>
+</div>
+
+<div class="container" style="-webkit-writing-mode: vertical-rl; height: 100px">
+    <div id="test2" class="red" style="padding-top: 50px" data-expected-height="100">
+        <div class="green" style="width: 20px" data-expected-height="100"></div>
+    </div>
+</div>
+
+<div class="container" style="width: 100px; -webkit-writing-mode: horizontal-bt;">
+    <div id="test3" class="red" style="border-left: 50px solid red" data-expected-width="100">
+        <div class="green" style="height: 20px" data-expected-width="100"></div>
+    </div>
+</div>
+
+<div class="container" style="-webkit-writing-mode: vertical-lr; height: 100px">
+    <div id="test4" class="red" style="border-top: 50px solid red" data-expected-height="100">
+        <div class="green" style="width: 20px" data-expected-height="100"></div>
+    </div>
+</div>
+
+<script src=""
+<script>
+document.body.offsetLeft;
+document.getElementById("test1").style.paddingLeft = "0";
+document.getElementById("test2").style.paddingTop = "0";
+document.getElementById("test3").style.borderWidth = "0";
+document.getElementById("test4").style.borderWidth = "0";
+checkLayout(".container");
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/table/border-collapsing/cached-change-row-border-width-expected.txt (142888 => 142889)


--- trunk/LayoutTests/fast/table/border-collapsing/cached-change-row-border-width-expected.txt	2013-02-14 17:52:04 UTC (rev 142888)
+++ trunk/LayoutTests/fast/table/border-collapsing/cached-change-row-border-width-expected.txt	2013-02-14 17:53:16 UTC (rev 142889)
@@ -6,6 +6,6 @@
       RenderTable {TABLE} at (0,0) size 56x103 [border: (2px solid #0000FF)]
         RenderTableSection {TBODY} at (1,2) size 54x100
           RenderTableRow {TR} at (0,0) size 54x50 [border: (4px solid #FFFF00)]
-            RenderTableCell {TD} at (0,23) size 54x4 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
+            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 54x3 [border: (2px none #000000)] [r=1 c=0 rs=1 cs=1]

Modified: trunk/Source/WebCore/ChangeLog (142888 => 142889)


--- trunk/Source/WebCore/ChangeLog	2013-02-14 17:52:04 UTC (rev 142888)
+++ trunk/Source/WebCore/ChangeLog	2013-02-14 17:53:16 UTC (rev 142889)
@@ -1,3 +1,23 @@
+2013-02-14  Tony Chang  <t...@chromium.org>
+
+        Padding and border changes doesn't trigger relayout of children
+        https://bugs.webkit.org/show_bug.cgi?id=109639
+
+        Reviewed by Kent Tamura.
+
+        In RenderBlock::layoutBlock, we only relayout our children if our logical width
+        changes. This misses cases where our logical width doesn't change (i.e., padding
+        or border changes), but our content width does change.
+
+        This is a more general case of bug 104997.
+
+        Test: fast/block/dynamic-padding-border.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::borderOrPaddingLogicalWidthChanged): Only check if the logical width changed.
+        (WebCore::RenderBox::styleDidChange): Drop the border-box condition since this can happen
+        even without border-box box sizing.
+
 2013-02-14  Peter Rybin  <pry...@chromium.org>
 
         Web Inspector: fix closure compilation warnings caused by setVariableValue change

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (142888 => 142889)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-02-14 17:52:04 UTC (rev 142888)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-02-14 17:53:16 UTC (rev 142889)
@@ -232,12 +232,18 @@
     RenderBoxModelObject::styleWillChange(diff, newStyle);
 }
 
-static bool borderWidthChanged(const RenderStyle* oldStyle, const RenderStyle* newStyle)
+static bool borderOrPaddingLogicalWidthChanged(const RenderStyle* oldStyle, const RenderStyle* newStyle)
 {
-    return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth()
-        || oldStyle->borderTopWidth() != newStyle->borderTopWidth()
-        || oldStyle->borderRightWidth() != newStyle->borderRightWidth()
-        || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth();
+    if (newStyle->isHorizontalWritingMode())
+        return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth()
+            || oldStyle->borderRightWidth() != newStyle->borderRightWidth()
+            || oldStyle->paddingLeft() != newStyle->paddingLeft()
+            || oldStyle->paddingRight() != newStyle->paddingRight();
+
+    return oldStyle->borderTopWidth() != newStyle->borderTopWidth()
+        || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth()
+        || oldStyle->paddingTop() != newStyle->paddingTop()
+        || oldStyle->paddingBottom() != newStyle->paddingBottom();
 }
 
 void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
@@ -314,8 +320,7 @@
     updateExclusionShapeOutsideInfoAfterStyleChange(style()->shapeOutside(), oldStyle ? oldStyle->shapeOutside() : 0);
 #endif
 
-    if (oldStyle && (newStyle->boxSizing() == BORDER_BOX || oldStyle->boxSizing() == BORDER_BOX) && diff == StyleDifferenceLayout
-        && (newStyle->paddingBox() != oldStyle->paddingBox() || borderWidthChanged(oldStyle, newStyle))) {
+    if (oldStyle && diff == StyleDifferenceLayout && borderOrPaddingLogicalWidthChanged(oldStyle, newStyle)) {
         ASSERT(needsLayout());
         for (RenderObject* child = firstChild(); child; child = child->nextSibling())
             child->setChildNeedsLayout(true, MarkOnlyThis);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to