Title: [118297] trunk
Revision
118297
Author
[email protected]
Date
2012-05-23 18:31:06 -0700 (Wed, 23 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.html: Added.
* fast/block/float/floats-with-margin-should-not-wrap.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (118296 => 118297)


--- trunk/LayoutTests/ChangeLog	2012-05-24 01:29:10 UTC (rev 118296)
+++ trunk/LayoutTests/ChangeLog	2012-05-24 01:31:06 UTC (rev 118297)
@@ -1,3 +1,16 @@
+2012-05-23  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.html: Added.
+        * fast/block/float/floats-with-margin-should-not-wrap.html: Added.
+
 2012-05-23  Eric Seidel  <[email protected]>
 
         Add seamless layout code (and pass most of the remaining seamless tests)

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


--- trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/floats-with-margin-should-not-wrap-expected.html	2012-05-24 01:31:06 UTC (rev 118297)
@@ -0,0 +1,22 @@
+<!DOCTYPE>
+<html>
+<head>
+<style>
+    body { zoom: 150%; }
+    .container { float: left; position: relative; left: -1px; }
+    .container > div { float: left; width: 19px; background: orange; }
+    .bottom { clear: both; }
+</style>
+</head>
+<body>
+
+<div class="container">
+    <div>1</div>
+    <div>2</div>
+    <div style="width: 20px;">3</div>
+</div>
+
+<div class="bottom">The three blocks above should all be on the same line.</div>
+
+</body>
+</html>

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


--- 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-24 01:31:06 UTC (rev 118297)
@@ -0,0 +1,22 @@
+<!DOCTYPE>
+<html>
+<head>
+<style>
+    body { zoom: 150%; }
+    .container { float: left; }
+    .container > div { float: left; width: 20px; margin-left: -1px; background: orange; }
+    .bottom { clear: both; }
+</style>
+</head>
+<body>
+
+<div class="container">
+    <div>1</div>
+    <div>2</div>
+    <div>3</div>
+</div>
+
+<div class="bottom">The three blocks above should all be on the same line.</div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (118296 => 118297)


--- trunk/Source/WebCore/ChangeLog	2012-05-24 01:29:10 UTC (rev 118296)
+++ trunk/Source/WebCore/ChangeLog	2012-05-24 01:31:06 UTC (rev 118297)
@@ -1,3 +1,25 @@
+2012-05-23  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-23  Huang Dongsung  <[email protected]>
 
         Remove unused declarations in MemoryCache.h

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (118296 => 118297)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-24 01:29:10 UTC (rev 118296)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-24 01:31:06 UTC (rev 118297)
@@ -5523,7 +5523,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