Title: [118395] trunk
Revision
118395
Author
[email protected]
Date
2012-05-24 11:14:36 -0700 (Thu, 24 May 2012)

Log Message

Negative margin block doesn't properly clear a float enclosed by a previous sibling
https://bugs.webkit.org/show_bug.cgi?id=10900

Reviewed by David Hyatt.

Source/WebCore:

Tests: fast/css/clear-float-sibling.html

Parent blocks keep a list of child floats that extend out of the parent block and
by implication overhang into the parent's siblings. But this doesn't work if the
sibling has collapsing margins - it will not find the float in the previous block's
list so will ignore the float and fail to clear it.

RenderBlock:collapseMargins() needs to check if a child's collapsing margin has
reduced the height of the parent up past the bottom of its previous sibling's lowest float
and add the now overhanging float to the parent's float list if appropriate.

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

LayoutTests:

* fast/css/clear-float-sibling-expected.html: Added.
* fast/css/clear-float-sibling.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (118394 => 118395)


--- trunk/LayoutTests/ChangeLog	2012-05-24 18:08:21 UTC (rev 118394)
+++ trunk/LayoutTests/ChangeLog	2012-05-24 18:14:36 UTC (rev 118395)
@@ -1,3 +1,13 @@
+2012-05-24  Robert Hogan  <[email protected]>
+
+        Negative margin block doesn't properly clear a float enclosed by a previous sibling
+        https://bugs.webkit.org/show_bug.cgi?id=10900
+
+        Reviewed by David Hyatt.
+
+        * fast/css/clear-float-sibling-expected.html: Added.
+        * fast/css/clear-float-sibling.html: Added.
+
 2012-05-24  Jessie Berlin  <[email protected]>
 
         Clean up the Windows Skipped list a bit.

Added: trunk/LayoutTests/fast/css/clear-float-sibling-expected.html (0 => 118395)


--- trunk/LayoutTests/fast/css/clear-float-sibling-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/clear-float-sibling-expected.html	2012-05-24 18:14:36 UTC (rev 118395)
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <title>CSS Test: Clear set to 'right' and negative margin with earlier right floated boxes</title>
+        <link rel="author" title="WebKit" href=""
+        <link rel="help" href=""
+        <meta name="flags" content="">
+        <meta name="assert" content="Boxes with 'clear: both' and collapsing margins need to clear earlier right floated boxes.">
+        <style type="text/css">
+            div
+            {
+                width: 2in;
+            }
+            div
+            {
+                height: 1in;
+                width: 1in;
+            }
+            #div1
+            {
+                float: right;
+                background-color: orange;
+            }
+            #div2
+            {
+                background: blue;
+                clear: both;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if the blue box is directly below the orange box.</p>
+        <div>
+            <div id="div1"></div>
+        </div>
+        <div id="div2"></div>
+    </body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/css/clear-float-sibling.html (0 => 118395)


--- trunk/LayoutTests/fast/css/clear-float-sibling.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/clear-float-sibling.html	2012-05-24 18:14:36 UTC (rev 118395)
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <title>CSS Test: Clear set to 'right' and negative margin with earlier right floated boxes</title>
+        <link rel="author" title="WebKit" href=""
+        <link rel="help" href=""
+        <meta name="flags" content="">
+        <meta name="assert" content="Boxes with 'clear: both' and collapsing margins need to clear earlier right floated boxes.">
+        <style type="text/css">
+            div
+            {
+                width: 2in;
+            }
+            div
+            {
+                height: 1in;
+                width: 1in;
+            }
+            #div1
+            {
+                float: right;
+                background-color: orange;
+            }
+            #div2
+            {
+                margin-top: -0.5in;
+                background: blue;
+                clear: both;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if the blue box is directly below the orange box.</p>
+        <div>
+            <div id="div1"></div>
+        </div>
+        <div id="div2"></div>
+    </body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (118394 => 118395)


--- trunk/Source/WebCore/ChangeLog	2012-05-24 18:08:21 UTC (rev 118394)
+++ trunk/Source/WebCore/ChangeLog	2012-05-24 18:14:36 UTC (rev 118395)
@@ -1,3 +1,24 @@
+2012-05-24  Robert Hogan  <[email protected]>
+
+        Negative margin block doesn't properly clear a float enclosed by a previous sibling
+        https://bugs.webkit.org/show_bug.cgi?id=10900
+
+        Reviewed by David Hyatt.
+
+        Tests: fast/css/clear-float-sibling.html
+
+        Parent blocks keep a list of child floats that extend out of the parent block and
+        by implication overhang into the parent's siblings. But this doesn't work if the
+        sibling has collapsing margins - it will not find the float in the previous block's
+        list so will ignore the float and fail to clear it.
+
+        RenderBlock:collapseMargins() needs to check if a child's collapsing margin has 
+        reduced the height of the parent up past the bottom of its previous sibling's lowest float
+        and add the now overhanging float to the parent's float list if appropriate.
+        
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::collapseMargins):
+
 2012-05-24  Kinuko Yasuda  <[email protected]>
 
         Cleanup: introduce toFile() to reduce static cast from Blob to File

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (118394 => 118395)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-24 18:08:21 UTC (rev 118394)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-05-24 18:14:36 UTC (rev 118395)
@@ -2015,6 +2015,16 @@
         logicalTop = min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop));
         setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
     }
+
+    // If we have collapsed into a previous sibling and so reduced the height of the parent, ensure any floats that now
+    // overhang from the previous sibling are added to our parent
+    RenderObject* prev = child->previousSibling();
+    if (prev && prev->isRenderBlock()) {
+        RenderBlock* block = toRenderBlock(prev);
+        if (block->m_floatingObjects && block->lowestFloatLogicalBottom() > logicalTop) 
+            addOverhangingFloats(block, false);
+    }
+
     return logicalTop;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to