WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2007 21:19:00 +0000 (21:19 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2007 21:19:00 +0000 (21:19 +0000)
        Reviewed by Dave Hyatt.

        - fix <rdar://problem/5609337> Making a float shorter does not remove it from the floating object list of a nested block it intruded into

        Test: fast/dynamic/float-withdrawal-2.html

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::layoutBlockChildren): When a float may have
        been withdrawn from a child, mark all descendants if necessary and not
        just the child.

LayoutTests:

        Reviewed by Dave Hyatt.

        - test for <rdar://problem/5609337> Making a float shorter does not remove it from the floating object list of a nested block it intruded into

        * fast/dynamic/float-withdrawal-2.html: Added.
        * platform/mac/fast/dynamic/float-withdrawal-2-expected.checksum: Added.
        * platform/mac/fast/dynamic/float-withdrawal-2-expected.png: Added.
        * platform/mac/fast/dynamic/float-withdrawal-2-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/dynamic/float-withdrawal-2.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBlock.cpp

index 019a981beeee70c9605e62b8580c99fc4d46f168..e03b5108dd85d54b873de73b26ee1916537a4d41 100644 (file)
@@ -1,3 +1,14 @@
+2007-11-26  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        - test for <rdar://problem/5609337> Making a float shorter does not remove it from the floating object list of a nested block it intruded into
+
+        * fast/dynamic/float-withdrawal-2.html: Added.
+        * platform/mac/fast/dynamic/float-withdrawal-2-expected.checksum: Added.
+        * platform/mac/fast/dynamic/float-withdrawal-2-expected.png: Added.
+        * platform/mac/fast/dynamic/float-withdrawal-2-expected.txt: Added.
+
 2007-11-25  Adam Roben  <aroben@apple.com>
 
         * platform/win/Skipped: Add a known failure.
diff --git a/LayoutTests/fast/dynamic/float-withdrawal-2.html b/LayoutTests/fast/dynamic/float-withdrawal-2.html
new file mode 100644 (file)
index 0000000..e23f517
--- /dev/null
@@ -0,0 +1,19 @@
+<html>
+<head>
+    <title>Test for rdar://problem/5609337</title>
+</head>
+<body>
+    <div style="z-index: -1; position: absolute; top: 58px; left: 8px; background-color: red; width: 100px; height: 50px;"></div>
+    <div style="height: 50px;">
+        <div style="float: left; display: block; width: 100px; height: 150px; background-color: green;" id="target">
+        </div>
+    </div>
+    <div>
+        <div><div style="display: inline-block; width: 100px; height: 50px; background-color: green;"></div></div>
+    </div>
+    <script>
+        document.body.offsetTop;
+        document.getElementById("target").style.height = "50px";
+    </script>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.checksum b/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.checksum
new file mode 100644 (file)
index 0000000..ae7a7bd
--- /dev/null
@@ -0,0 +1 @@
+18f1f64eab31dfb69467a497de9442d7
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.png b/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.png
new file mode 100644 (file)
index 0000000..fc96c0b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.txt b/LayoutTests/platform/mac/fast/dynamic/float-withdrawal-2-expected.txt
new file mode 100644 (file)
index 0000000..36145f8
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600 layerType: background only
+layer at (8,58) size 100x50
+  RenderBlock (positioned) zI: -1 {DIV} at (8,58) size 100x50 [bgcolor=#FF0000]
+layer at (0,0) size 800x600 layerType: foreground only
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x50
+        RenderBlock (floating) {DIV} at (0,0) size 100x50 [bgcolor=#008000]
+      RenderBlock {DIV} at (0,50) size 784x50
+        RenderBlock {DIV} at (0,0) size 784x50
+          RenderBlock {DIV} at (0,0) size 100x50 [bgcolor=#008000]
index d545679a6c04c5657373db52ea1ab2759f3b90df..ca8f15e683109b61eccdcb3516937d099c25fb86 100644 (file)
@@ -1,3 +1,16 @@
+2007-11-26  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        - fix <rdar://problem/5609337> Making a float shorter does not remove it from the floating object list of a nested block it intruded into
+
+        Test: fast/dynamic/float-withdrawal-2.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::layoutBlockChildren): When a float may have
+        been withdrawn from a child, mark all descendants if necessary and not
+        just the child.
+
 2007-11-26  Steve Falkenburg  <sfalken@apple.com>
 
         Build fix.
index 33feb66d57b61a371b5d4cccd4f2f01f8701c13d..a8e35f80a6deecb0af454d834bc05690db16e5ec 100644 (file)
@@ -1200,14 +1200,6 @@ void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom
         // be correct.  Only if we're wrong (when we compute the real y position)
         // will we have to potentially relayout.
         int yPosEstimate = estimateVerticalPosition(child, marginInfo);
-        
-        // If an element might be affected by the presence of floats, then always mark it for
-        // layout.
-        if (!child->avoidsFloats() || child->shrinkToAvoidFloats()) {
-            int fb = max(previousFloatBottom, floatBottom());
-            if (fb > m_height || fb > yPosEstimate)
-                child->setChildNeedsLayout(true, false);
-        }
 
         // Cache our old rect so that we can dirty the proper repaint rects if the child moves.
         IntRect oldRect(child->xPos(), child->yPos() , child->width(), child->height());
@@ -1215,7 +1207,19 @@ void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom
         // Go ahead and position the child as though it didn't collapse with the top.
         view()->addLayoutDelta(IntSize(0, child->yPos() - yPosEstimate));
         child->setPos(child->xPos(), yPosEstimate);
+
+        bool markDescendantsWithFloats = false;
         if (yPosEstimate != oldRect.y() && !child->avoidsFloats() && child->containsFloats())
+            markDescendantsWithFloats = true;
+        else if (!child->avoidsFloats() || child->shrinkToAvoidFloats()) {
+            // If an element might be affected by the presence of floats, then always mark it for
+            // layout.
+            int fb = max(previousFloatBottom, floatBottom());
+            if (fb > m_height || fb > yPosEstimate)
+                markDescendantsWithFloats = true;
+        }
+
+        if (markDescendantsWithFloats)
             child->markAllDescendantsWithFloatsForLayout();
 
         if (child->isRenderBlock())