Title: [93944] trunk
Revision
93944
Author
[email protected]
Date
2011-08-27 14:03:41 -0700 (Sat, 27 Aug 2011)

Log Message

The child div element with position:absolute will overlap with its parent div when a 'break' element is present in between
https://bugs.webkit.org/show_bug.cgi?id=21934

Reviewed by David Hyatt.

Source/WebCore:

Test: fast/block/positioning/absolute-appended-to-inline.html

Appending a positioned child node to an inline flow should dirty the lines in the flow, just as
inserting a positioned child node does. Treating an appended and inserted node differently meant that updating the display type
from 'none' to 'block' for the following markup would result in the div getting positioned correctly under
the line block:

    <div><a _onMouseOver_="mopen()">Hover</a><div style="display:none; position:absolute; background:#4682b4; height:10px; width:20px"><br></div></div>

but this would not happen with the following markup (the <br> is before the child div rather than after it):

    <div><a _onMouseOver_="mopen()">Hover</a><br><div style="display:none; position:absolute; background:#4682b4; height:10px; width:20px"></div></div>

This problem is specific to cases where an object is appended to a line block whose last child is a <br>. When the line is relaid out after appending
the positioned object the last line in the line block is always considered dirty unless it broke cleanly (ie. with a <br>, see RenderBlock::determineStartPosition),
So in the second case above, the clean break and failing to dirty any lines in the block when appending the object means that the line block doesn't get relaid out
to position the new positioned object relative to its containing line block.

So the change could special-case appending a node when the previous sibling isBR(), but it seems just as well to behave the same way as insertChildNode().

* rendering/RenderObjectChildList.cpp:
(WebCore::RenderObjectChildList::appendChildNode):
    Call dirtyLinesFromChangedChild() if the child is positioned, just like insertChildNode().

LayoutTests:

* fast/block/positioning/absolute-appended-to-inline-expected.txt: Added.
* fast/block/positioning/absolute-appended-to-inline.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93943 => 93944)


--- trunk/LayoutTests/ChangeLog	2011-08-27 20:22:35 UTC (rev 93943)
+++ trunk/LayoutTests/ChangeLog	2011-08-27 21:03:41 UTC (rev 93944)
@@ -1,3 +1,13 @@
+2011-08-07  Robert Hogan  <[email protected]>
+
+        The child div element with position:absolute will overlap with its parent div when a 'break' element is present in between
+        https://bugs.webkit.org/show_bug.cgi?id=21934
+
+        Reviewed by David Hyatt.
+
+        * fast/block/positioning/absolute-appended-to-inline-expected.txt: Added.
+        * fast/block/positioning/absolute-appended-to-inline.html: Added.
+
 2011-08-27  Anders Carlsson  <[email protected]>
 
         iChat: Receiving a message containing only a single-quote (') causes bubble to fail

Added: trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline-expected.txt (0 => 93944)


--- trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline-expected.txt	2011-08-27 21:03:41 UTC (rev 93944)
@@ -0,0 +1,2 @@
+Hover mouse over text. Blue block should appear below.
+SUCCESS
Property changes on: trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline.html (0 => 93944)


--- trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline.html	2011-08-27 21:03:41 UTC (rev 93944)
@@ -0,0 +1,31 @@
+<html>
+<head>
+    <script>
+        if (window.layoutTestController) {
+            layoutTestController.dumpAsText();
+            layoutTestController.waitUntilDone();
+        }
+
+        function measureBlockPosition() {
+            if (document.getElementById("block").offsetTop == 28)
+              document.getElementById("console").innerHTML = "SUCCESS";
+            layoutTestController.notifyDone();
+        }
+
+        function updateBlock() {
+            document.getElementById("block").style.display='block';
+            window.setTimeout(measureBlockPosition(),10);
+        }
+
+        function test(){
+            var element = document.getElementById('hover');
+            if (window.layoutTestController) {
+                eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+            }
+        }
+    </script>
+</head>
+<body _onload_="test();">
+    <div id="hover"><a _onMouseOver_="updateBlock()">Hover mouse over text. Blue block should appear below.</a><br><div id="block" style="display:none; position:absolute; background:#4682b4; height:10px; width:20px"></div></div>
+    <div id="console">FAILURE</div>
+</body></html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/block/positioning/absolute-appended-to-inline.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (93943 => 93944)


--- trunk/Source/WebCore/ChangeLog	2011-08-27 20:22:35 UTC (rev 93943)
+++ trunk/Source/WebCore/ChangeLog	2011-08-27 21:03:41 UTC (rev 93944)
@@ -1,3 +1,34 @@
+2011-08-07  Robert Hogan  <[email protected]>
+
+        The child div element with position:absolute will overlap with its parent div when a 'break' element is present in between
+        https://bugs.webkit.org/show_bug.cgi?id=21934
+
+        Reviewed by David Hyatt.
+
+        Test: fast/block/positioning/absolute-appended-to-inline.html
+
+        Appending a positioned child node to an inline flow should dirty the lines in the flow, just as
+        inserting a positioned child node does. Treating an appended and inserted node differently meant that updating the display type
+        from 'none' to 'block' for the following markup would result in the div getting positioned correctly under
+        the line block:
+
+            <div><a _onMouseOver_="mopen()">Hover</a><div style="display:none; position:absolute; background:#4682b4; height:10px; width:20px"><br></div></div>
+
+        but this would not happen with the following markup (the <br> is before the child div rather than after it):
+
+            <div><a _onMouseOver_="mopen()">Hover</a><br><div style="display:none; position:absolute; background:#4682b4; height:10px; width:20px"></div></div>
+
+        This problem is specific to cases where an object is appended to a line block whose last child is a <br>. When the line is relaid out after appending
+        the positioned object the last line in the line block is always considered dirty unless it broke cleanly (ie. with a <br>, see RenderBlock::determineStartPosition),
+        So in the second case above, the clean break and failing to dirty any lines in the block when appending the object means that the line block doesn't get relaid out
+        to position the new positioned object relative to its containing line block.
+
+        So the change could special-case appending a node when the previous sibling isBR(), but it seems just as well to behave the same way as insertChildNode().
+
+        * rendering/RenderObjectChildList.cpp:
+        (WebCore::RenderObjectChildList::appendChildNode):
+            Call dirtyLinesFromChangedChild() if the child is positioned, just like insertChildNode().
+
 2011-08-27  Anders Carlsson  <[email protected]>
 
         iChat: Receiving a message containing only a single-quote (') causes bubble to fail

Modified: trunk/Source/WebCore/rendering/RenderObjectChildList.cpp (93943 => 93944)


--- trunk/Source/WebCore/rendering/RenderObjectChildList.cpp	2011-08-27 20:22:35 UTC (rev 93943)
+++ trunk/Source/WebCore/rendering/RenderObjectChildList.cpp	2011-08-27 21:03:41 UTC (rev 93944)
@@ -191,7 +191,7 @@
         if (newChild->isListItem())
             toRenderListItem(newChild)->updateListMarkerNumbers();
 
-        if (!newChild->isFloatingOrPositioned() && owner->childrenInline())
+        if (!newChild->isFloating() && owner->childrenInline())
             owner->dirtyLinesFromChangedChild(newChild);
 
         if (newChild->isRenderRegion())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to