Title: [118448] trunk
Revision
118448
Author
[email protected]
Date
2012-05-24 17:15:34 -0700 (Thu, 24 May 2012)

Log Message

REGRESSION (115573): Incorrect rounding of margins for floats
https://bugs.webkit.org/show_bug.cgi?id=87319

Reviewed by Eric Seidel.

Source/WebCore: 

In RenderBlock::computeInlinePreferredLogicalWidths we used a float to
accumulate margins for floating children while the children themselves
represent their margins as LayoutUnits. Due to lack of rounding this can
cause the block to be too small at certain certain zoom levels, causing
unwanted wrapping. 

This patch changes computeInlinePreferredLogicalWidths to use a
LayoutUnit to accumulate the margins and thus ensures that the margin
values are rounded the same way.

Test: fast/block/float/floats-with-margin-should-not-wrap.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeInlinePreferredLogicalWidths):

LayoutTests: 

Add new test ensuring that using margins with floats doesn't cause
undesired wrapping.

* fast/block/float/floats-with-margin-should-not-wrap-expected.txt: Added.
* fast/block/float/floats-with-margin-should-not-wrap.html: Added.
* platform/mac/fast/forms/001-expected.txt:
* platform/mac/fast/html/details-position-expected.txt:
* platform/mac/fast/replaced/width100percent-checkbox-expected.txt:
* platform/mac/fast/replaced/width100percent-radio-expected.txt:
* platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.txt:
* platform/mac/tables/mozilla/bugs/bug1318-expected.txt:
* platform/mac/tables/mozilla/bugs/bug4527-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (118447 => 118448)


--- trunk/LayoutTests/ChangeLog	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/ChangeLog	2012-05-25 00:15:34 UTC (rev 118448)
@@ -1,3 +1,23 @@
+2012-05-24  Emil A Eklund  <[email protected]>
+
+        REGRESSION (115573): Incorrect rounding of margins for floats
+        https://bugs.webkit.org/show_bug.cgi?id=87319
+
+        Reviewed by Eric Seidel.
+
+        Add new test ensuring that using margins with floats doesn't cause
+        undesired wrapping.
+
+        * fast/block/float/floats-with-margin-should-not-wrap-expected.txt: Added.
+        * fast/block/float/floats-with-margin-should-not-wrap.html: Added.
+        * platform/mac/fast/forms/001-expected.txt:
+        * platform/mac/fast/html/details-position-expected.txt:
+        * platform/mac/fast/replaced/width100percent-checkbox-expected.txt:
+        * platform/mac/fast/replaced/width100percent-radio-expected.txt:
+        * platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.txt:
+        * platform/mac/tables/mozilla/bugs/bug1318-expected.txt:
+        * platform/mac/tables/mozilla/bugs/bug4527-expected.txt:
+
 2012-05-24  Christophe Dumez  <[email protected]>
 
         postMessage and webkitPostMessage should behave the same way

Added: trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap-expected.txt (0 => 118448)


--- trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -0,0 +1,2 @@
+123
+PASS, the three blocks are all on the same line

Added: trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap.html (0 => 118448)


--- trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap.html	2012-05-25 00:15:34 UTC (rev 118448)
@@ -0,0 +1,37 @@
+<!DOCTYPE>
+<html>
+<head>
+<style>
+    body { zoom: 150%; }
+    #container { float: left; }
+    #container > div { float: left; height: 20px; width: 20px; margin-left: -1px; background: orange; }
+    #bottom { clear: both; }
+</style>
+</head>
+<body>
+
+<div id="container">
+    <div>1</div>
+    <div>2</div>
+    <div>3</div>
+</div>
+
+<div id="bottom">The three blocks above should all be on the same line.</div>
+
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var rect = document.getElementById('container').getBoundingClientRect();
+    var height = rect.bottom - rect.top;
+
+    if (height == 20)
+        str = 'PASS, the three blocks are all on the same line';
+    else
+        str = 'FAIL, expected the blocks to all be on one line';
+
+    document.getElementById('bottom').firstChild.nodeValue = str;
+</script>
+
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/fast/forms/001-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/fast/forms/001-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/fast/forms/001-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -19,16 +19,16 @@
         RenderTable {TABLE} at (0,0) size 784x24 [border: (2px outset #808080)]
           RenderTableSection {TBODY} at (2,2) size 780x20
             RenderTableRow {TR} at (0,0) size 780x20
-              RenderTableCell {TD} at (0,0) size 20x20 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderTableCell {TD} at (0,0) size 18x20 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
                 RenderBlock {INPUT} at (3,4) size 12x12
-              RenderTableCell {TD} at (20,9) size 760x2 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderTableCell {TD} at (18,9) size 762x2 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
       RenderBlock {P} at (0,200) size 784x24
         RenderTable {TABLE} at (0,0) size 784x24 [border: (2px outset #808080)]
           RenderTableSection {TBODY} at (2,2) size 780x20
             RenderTableRow {TR} at (0,0) size 780x20
-              RenderTableCell {TD} at (0,0) size 20x20 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderTableCell {TD} at (0,0) size 18x20 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
                 RenderBlock {INPUT} at (3,4) size 12x12
-              RenderTableCell {TD} at (20,9) size 760x2 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderTableCell {TD} at (18,9) size 762x2 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
       RenderBlock {P} at (0,240) size 784x28
         RenderTable {TABLE} at (0,0) size 784x28 [border: (2px outset #808080)]
           RenderTableSection {TBODY} at (2,2) size 780x24

Modified: trunk/LayoutTests/platform/mac/fast/html/details-position-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/fast/html/details-position-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/fast/html/details-position-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -6,8 +6,8 @@
       RenderBlock {DETAILS} at (0,0) size 784x0
       RenderBlock {DETAILS} at (0,0) size 784x18
       RenderBlock {DETAILS} at (0,18) size 784x0
-layer at (50,150) size 49x18
-  RenderBlock (positioned) {SUMMARY} at (50,150) size 49x18
+layer at (50,150) size 48x18
+  RenderBlock (positioned) {SUMMARY} at (50,150) size 48x18
     RenderDetailsMarker {DIV} at (0,4) size 10x10: right
     RenderText {#text} at (16,0) size 32x18
       text run at (16,0) width 32: "fixed"
@@ -16,8 +16,8 @@
     RenderDetailsMarker {DIV} at (0,4) size 10x10: right
     RenderText {#text} at (16,0) size 46x18
       text run at (16,0) width 46: "relative"
-layer at (250,150) size 69x18
-  RenderBlock (positioned) {SUMMARY} at (250,150) size 69x18
+layer at (250,150) size 68x18
+  RenderBlock (positioned) {SUMMARY} at (250,150) size 68x18
     RenderDetailsMarker {DIV} at (0,4) size 10x10: right
     RenderText {#text} at (16,0) size 52x18
       text run at (16,0) width 52: "absolute"

Modified: trunk/LayoutTests/platform/mac/fast/replaced/width100percent-checkbox-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/fast/replaced/width100percent-checkbox-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/fast/replaced/width100percent-checkbox-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -9,12 +9,12 @@
       RenderTable {TABLE} at (0,18) size 784x22
         RenderTableSection {TBODY} at (0,0) size 784x22
           RenderTableRow {TR} at (0,1) size 784x20
-            RenderTableCell {TD} at (1,1) size 8x20 [r=0 c=0 rs=1 cs=1]
-              RenderBlock {INPUT} at (3,4) size 6x12
-            RenderTableCell {TD} at (10,1) size 8x20 [r=0 c=1 rs=1 cs=1]
-              RenderBlock {INPUT} at (3,4) size 6x12
-            RenderTableCell {TD} at (19,1) size 8x20 [r=0 c=2 rs=1 cs=1]
-              RenderBlock {INPUT} at (3,4) size 6x12
-            RenderTableCell {TD} at (28,1) size 755x20 [r=0 c=3 rs=1 cs=1]
+            RenderTableCell {TD} at (1,1) size 6x20 [r=0 c=0 rs=1 cs=1]
+              RenderBlock {INPUT} at (3,4) size 4x12
+            RenderTableCell {TD} at (8,1) size 6x20 [r=0 c=1 rs=1 cs=1]
+              RenderBlock {INPUT} at (3,4) size 4x12
+            RenderTableCell {TD} at (15,1) size 6x20 [r=0 c=2 rs=1 cs=1]
+              RenderBlock {INPUT} at (3,4) size 4x12
+            RenderTableCell {TD} at (22,1) size 761x20 [r=0 c=3 rs=1 cs=1]
               RenderText {#text} at (1,1) size 4x18
                 text run at (1,1) width 4: " "

Modified: trunk/LayoutTests/platform/mac/fast/replaced/width100percent-radio-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/fast/replaced/width100percent-radio-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/fast/replaced/width100percent-radio-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -9,12 +9,12 @@
       RenderTable {TABLE} at (0,18) size 784x23
         RenderTableSection {TBODY} at (0,0) size 784x23
           RenderTableRow {TR} at (0,1) size 784x21
-            RenderTableCell {TD} at (1,1) size 8x21 [r=0 c=0 rs=1 cs=1]
-              RenderBlock {INPUT} at (3,4) size 6x13
-            RenderTableCell {TD} at (10,1) size 8x21 [r=0 c=1 rs=1 cs=1]
-              RenderBlock {INPUT} at (3,4) size 6x13
-            RenderTableCell {TD} at (19,1) size 8x21 [r=0 c=2 rs=1 cs=1]
-              RenderBlock {INPUT} at (3,4) size 6x13
-            RenderTableCell {TD} at (28,1) size 755x20 [r=0 c=3 rs=1 cs=1]
+            RenderTableCell {TD} at (1,1) size 6x21 [r=0 c=0 rs=1 cs=1]
+              RenderBlock {INPUT} at (3,4) size 4x13
+            RenderTableCell {TD} at (8,1) size 6x21 [r=0 c=1 rs=1 cs=1]
+              RenderBlock {INPUT} at (3,4) size 4x13
+            RenderTableCell {TD} at (15,1) size 6x21 [r=0 c=2 rs=1 cs=1]
+              RenderBlock {INPUT} at (3,4) size 4x13
+            RenderTableCell {TD} at (22,1) size 761x20 [r=0 c=3 rs=1 cs=1]
               RenderText {#text} at (1,1) size 4x18
                 text run at (1,1) width 4: " "

Modified: trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -30,10 +30,10 @@
             RenderSVGRoot {svg} at (0,0) size 102x26
               RenderSVGRect {rect} at (0,0) size 102x26 [stroke={[type=SOLID] [color=#008000] [stroke width=12.00]}] [fill={[type=SOLID] [color=#00FF00]}] [x=0.00] [y=0.00] [width=1000.00] [height=250.00]
               RenderSVGPath {path} at (15,5) size 72x16 [fill={[type=SOLID] [color=#008000]}] [data="" 500 50 L 150 200 L 850 200 Z"]
-      RenderTable at (1,256) size 139x45
-        RenderTableSection (anonymous) at (0,0) size 139x45
-          RenderTableRow (anonymous) at (0,0) size 139x45
-            RenderTableCell {P} at (0,0) size 139x45 [r=0 c=0 rs=1 cs=1]
+      RenderTable at (1,256) size 138x45
+        RenderTableSection (anonymous) at (0,0) size 138x45
+          RenderTableRow (anonymous) at (0,0) size 138x45
+            RenderTableCell {P} at (0,0) size 138x45 [r=0 c=0 rs=1 cs=1]
               RenderEmbeddedObject {OBJECT} at (9,0) size 120x44 [bgcolor=#FF0000] [border: (9px solid #0000FF)]
                 layer at (0,0) size 102x26
                   RenderView at (0,0) size 102x26
@@ -41,10 +41,10 @@
                   RenderSVGRoot {svg} at (0,0) size 102x26
                     RenderSVGRect {rect} at (0,0) size 102x26 [stroke={[type=SOLID] [color=#008000] [stroke width=12.00]}] [fill={[type=SOLID] [color=#00FF00]}] [x=0.00] [y=0.00] [width=1000.00] [height=250.00]
                     RenderSVGPath {path} at (15,5) size 72x16 [fill={[type=SOLID] [color=#008000]}] [data="" 500 50 L 150 200 L 850 200 Z"]
-      RenderTable {TABLE} at (1,356) size 139x45
-        RenderTableSection {TBODY} at (0,0) size 139x45
-          RenderTableRow {TR} at (0,0) size 139x45
-            RenderTableCell {TD} at (0,0) size 139x45 [r=0 c=0 rs=1 cs=1]
+      RenderTable {TABLE} at (1,356) size 138x45
+        RenderTableSection {TBODY} at (0,0) size 138x45
+          RenderTableRow {TR} at (0,0) size 138x45
+            RenderTableCell {TD} at (0,0) size 138x45 [r=0 c=0 rs=1 cs=1]
               RenderEmbeddedObject {OBJECT} at (9,0) size 120x44 [bgcolor=#FF0000] [border: (9px solid #0000FF)]
                 layer at (0,0) size 102x26
                   RenderView at (0,0) size 102x26

Modified: trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug1318-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug1318-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug1318-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -18,31 +18,31 @@
                 RenderBR {BR} at (392,55) size 0x17
               RenderText {#text} at (0,0) size 0x0
           RenderTableRow {TR} at (0,74) size 784x21
-            RenderTableCell {TD} at (0,76) size 551x17 [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (0,76) size 556x17 [r=1 c=0 rs=1 cs=1]
               RenderInline {FONT} at (0,0) size 140x15
-                RenderText {#text} at (410,1) size 140x15
-                  text run at (410,1) width 140: "I agree with the program"
+                RenderText {#text} at (415,1) size 140x15
+                  text run at (415,1) width 140: "I agree with the program"
               RenderText {#text} at (0,0) size 0x0
-            RenderTableCell {TD} at (551,74) size 71x21 [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (556,74) size 64x21 [r=1 c=1 rs=1 cs=1]
               RenderBlock {INPUT} at (3,4) size 12x13
           RenderTableRow {TR} at (0,95) size 784x21
-            RenderTableCell {TD} at (0,97) size 551x17 [r=2 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (0,97) size 556x17 [r=2 c=0 rs=1 cs=1]
               RenderInline {FONT} at (0,0) size 153x15
-                RenderText {#text} at (397,1) size 153x15
-                  text run at (397,1) width 153: "I think vouchers are wrong"
+                RenderText {#text} at (402,1) size 153x15
+                  text run at (402,1) width 153: "I think vouchers are wrong"
               RenderText {#text} at (0,0) size 0x0
-            RenderTableCell {TD} at (551,95) size 71x21 [r=2 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (556,95) size 64x21 [r=2 c=1 rs=1 cs=1]
               RenderBlock {INPUT} at (3,4) size 12x13
           RenderTableRow {TR} at (0,116) size 784x24
-            RenderTableCell {TD} at (0,119) size 622x17 [r=3 c=0 rs=1 cs=2]
+            RenderTableCell {TD} at (0,119) size 620x17 [r=3 c=0 rs=1 cs=2]
               RenderInline {A} at (0,0) size 76x18 [color=#0000EE]
                 RenderInline {FONT} at (0,0) size 76x15
-                  RenderText {#text} at (273,1) size 76x15
-                    text run at (273,1) width 76: "View Results"
+                  RenderText {#text} at (272,1) size 76x15
+                    text run at (272,1) width 76: "View Results"
               RenderInline {FONT} at (0,0) size 0x0
                 RenderText {#text} at (0,0) size 0x0
-            RenderTableCell {TD} at (622,116) size 162x24 [r=3 c=2 rs=1 cs=2]
-              RenderButton {INPUT} at (62,3) size 39x18 [bgcolor=#C0C0C0]
+            RenderTableCell {TD} at (620,116) size 164x24 [r=3 c=2 rs=1 cs=2]
+              RenderButton {INPUT} at (63,3) size 39x18 [bgcolor=#C0C0C0]
                 RenderBlock (anonymous) at (8,2) size 23x13
                   RenderText at (0,0) size 23x13
                     text run at (0,0) width 23: "vote"

Modified: trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug4527-expected.txt (118447 => 118448)


--- trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug4527-expected.txt	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug4527-expected.txt	2012-05-25 00:15:34 UTC (rev 118448)
@@ -33,17 +33,17 @@
               RenderImage {IMG} at (0,60) size 470x10
               RenderBR {BR} at (470,70) size 0x0
           RenderTableRow {TR} at (0,70) size 613x25
-            RenderTableCell {TD} at (126,70) size 245x25 [bgcolor=#CCCCCC] [r=1 c=1 rs=1 cs=1]
+            RenderTableCell {TD} at (126,70) size 247x25 [bgcolor=#CCCCCC] [r=1 c=1 rs=1 cs=1]
               RenderImage {IMG} at (0,0) size 232x25
-            RenderTableCell {TD} at (371,71) size 108x23 [bgcolor=#CCCCCC] [r=1 c=2 rs=1 cs=1]
-              RenderTextControl {INPUT} at (5,2) size 73x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-              RenderImage {INPUT} at (80,4) size 25x18
-            RenderTableCell {TD} at (479,70) size 134x25 [bgcolor=#CCCCCC] [r=1 c=3 rs=1 cs=1]
+            RenderTableCell {TD} at (373,71) size 109x23 [bgcolor=#CCCCCC] [r=1 c=2 rs=1 cs=1]
+              RenderTextControl {INPUT} at (6,2) size 73x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+              RenderImage {INPUT} at (81,4) size 25x18
+            RenderTableCell {TD} at (482,70) size 131x25 [bgcolor=#CCCCCC] [r=1 c=3 rs=1 cs=1]
               RenderBlock {INPUT} at (2,4) size 12x13
               RenderImage {IMG} at (16,0) size 40x25
               RenderBlock {INPUT} at (58,4) size 12x13
               RenderText {#text} at (72,1) size 4x18
                 text run at (72,1) width 4: " "
               RenderImage {IMG} at (76,0) size 46x25
-layer at (387,84) size 67x13
+layer at (390,84) size 67x13
   RenderBlock {DIV} at (3,3) size 67x13

Modified: trunk/Source/WebCore/ChangeLog (118447 => 118448)


--- trunk/Source/WebCore/ChangeLog	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/Source/WebCore/ChangeLog	2012-05-25 00:15:34 UTC (rev 118448)
@@ -1,3 +1,25 @@
+2012-05-24  Emil A Eklund  <[email protected]>
+
+        REGRESSION (115573): Incorrect rounding of margins for floats
+        https://bugs.webkit.org/show_bug.cgi?id=87319
+
+        Reviewed by Eric Seidel.
+
+        In RenderBlock::computeInlinePreferredLogicalWidths we used a float to
+        accumulate margins for floating children while the children themselves
+        represent their margins as LayoutUnits. Due to lack of rounding this can
+        cause the block to be too small at certain certain zoom levels, causing
+        unwanted wrapping. 
+
+        This patch changes computeInlinePreferredLogicalWidths to use a
+        LayoutUnit to accumulate the margins and thus ensures that the margin
+        values are rounded the same way.
+
+        Test: fast/block/float/floats-with-margin-should-not-wrap.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
+
 2012-05-24  Christophe Dumez  <[email protected]>
 
         postMessage and webkitPostMessage should behave the same way

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (118447 => 118448)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-25 00:03:14 UTC (rev 118447)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-25 00:15:34 UTC (rev 118448)
@@ -5533,7 +5533,7 @@
                     child->setPreferredLogicalWidthsDirty(false);
                 } else {
                     // Inline replaced elts add in their margins to their min/max values.
-                    float margins = 0;
+                    LayoutUnit margins = 0;
                     Length startMargin = childStyle->marginStart();
                     Length endMargin = childStyle->marginEnd();
                     if (startMargin.isFixed())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to