REGRESSION (r155854 - r155967) block with margin-left adjacent to floated block cause...
authorbjonesbe@adobe.com <bjonesbe@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 01:31:11 +0000 (01:31 +0000)
committerbjonesbe@adobe.com <bjonesbe@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 01:31:11 +0000 (01:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121532

Reviewed by Andreas Kling.

Source/WebCore:

When refactoring the code, I ended up adding the margin in instead of
subtracting it in the case of an intruding float. This patch fixes
that so that the margin is properly handled.

Test: fast/block/float/intruding-float-sibling-with-margin.html

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

LayoutTests:

* fast/block/float/intruding-float-sibling-with-margin-expected.html: Added.
* fast/block/float/intruding-float-sibling-with-margin.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/float/intruding-float-sibling-with-margin-expected.html [new file with mode: 0644]
LayoutTests/fast/block/float/intruding-float-sibling-with-margin.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp

index 82d722e..4cf5f0f 100644 (file)
@@ -1,3 +1,13 @@
+2013-09-18  Bem Jones-Bey  <bjonesbe@adobe.com>
+
+        REGRESSION (r155854 - r155967) block with margin-left adjacent to floated block causes text of subsequent blocks to overlap the floated block.
+        https://bugs.webkit.org/show_bug.cgi?id=121532
+
+        Reviewed by Andreas Kling.
+
+        * fast/block/float/intruding-float-sibling-with-margin-expected.html: Added.
+        * fast/block/float/intruding-float-sibling-with-margin.html: Added.
+
 2013-09-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Merge HTMLBodyElement::didNotifySubtreeInsertions into HTMLBodyElement::insertedInto
diff --git a/LayoutTests/fast/block/float/intruding-float-sibling-with-margin-expected.html b/LayoutTests/fast/block/float/intruding-float-sibling-with-margin-expected.html
new file mode 100644 (file)
index 0000000..48746ff
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<style type="text/css">
+    #container {
+        font: 20px/1 Ahem;
+        line-height: 20px;
+        background-color: red;
+        width: 40px;
+        height: 40px;
+        color: green;
+    }
+    #float {
+        float: left;
+        width: 20px;
+        height: 40px;
+        background: green;
+    }
+</style>
+<body>
+    <p>You should see a single green square. You should not see any red.</p>
+    <div id="container">
+        <div id="float"></div>
+        <div id="text-margin">X</div>
+        <div id="text">X</div>
+    </div>
+</body>
diff --git a/LayoutTests/fast/block/float/intruding-float-sibling-with-margin.html b/LayoutTests/fast/block/float/intruding-float-sibling-with-margin.html
new file mode 100644 (file)
index 0000000..dbf8227
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<style type="text/css">
+    #container {
+        font: 20px/1 Ahem;
+        line-height: 20px;
+        background-color: red;
+        width: 40px;
+        height: 40px;
+        color: green;
+    }
+    #float {
+        float: left;
+        width: 20px;
+        height: 40px;
+        background: green;
+    }
+    #text-margin {
+        margin-left: 20px;
+    }
+</style>
+<body>
+    <p>You should see a single green square. You should not see any red.</p>
+    <div id="container">
+        <div id="float"></div>
+        <div id="text-margin">X</div>
+        <div id="text">X</div>
+    </div>
+</body>
index 0544050..1febb31 100644 (file)
@@ -1,3 +1,19 @@
+2013-09-18  Bem Jones-Bey  <bjonesbe@adobe.com>
+
+        REGRESSION (r155854 - r155967) block with margin-left adjacent to floated block causes text of subsequent blocks to overlap the floated block.
+        https://bugs.webkit.org/show_bug.cgi?id=121532
+
+        Reviewed by Andreas Kling.
+
+        When refactoring the code, I ended up adding the margin in instead of
+        subtracting it in the case of an intruding float. This patch fixes
+        that so that the margin is properly handled.
+
+        Test: fast/block/float/intruding-float-sibling-with-margin.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::addIntrudingFloats):
+
 2013-09-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Merge HTMLBodyElement::didNotifySubtreeInsertions into HTMLBodyElement::insertedInto
index 4b41a1e..194d77f 100644 (file)
@@ -3887,8 +3887,8 @@ void RenderBlock::addIntrudingFloats(RenderBlock* prev, LayoutUnit logicalLeftOf
                 // into account.  Only apply this code if prev is the parent, since otherwise the left margin
                 // will get applied twice.
                 LayoutSize offset = isHorizontalWritingMode()
-                    ? LayoutSize(logicalLeftOffset + (prev != parent() ? prev->marginLeft() : LayoutUnit()), logicalTopOffset)
-                    : LayoutSize(logicalTopOffset, logicalLeftOffset + (prev != parent() ? prev->marginTop() : LayoutUnit()));
+                    ? LayoutSize(logicalLeftOffset - (prev != parent() ? prev->marginLeft() : LayoutUnit()), logicalTopOffset)
+                    : LayoutSize(logicalTopOffset, logicalLeftOffset - (prev != parent() ? prev->marginTop() : LayoutUnit()));
 
                 m_floatingObjects->add(r->copyToNewContainer(offset));
             }