Title: [94695] trunk
Revision
94695
Author
[email protected]
Date
2011-09-07 11:59:55 -0700 (Wed, 07 Sep 2011)

Log Message

Elements with position:absolute don't move to correct position after images load
https://bugs.webkit.org/show_bug.cgi?id=54611

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/block/positioning/absolute-layout-after-image-load.html
      fast/block/positioning/positioned-float-layout-after-image-load.html

In the test the 'label' block is an absolutely positioned child of an inline flow. So during layout,
this RenderBlock::layoutPositionedObjects fails to dirty it for rendering because it requires
the parent to be a BlockFlow. The code to do this was introduced in http://trac.webkit.org/changeset/8284.
There doesn't seem to be a good reason for requiring a BlockFlow, so remove the check. Do the same
for positioned floats in RenderBlock::positionedFloatsNeedRelayout(), although currently layoutPositionedObjects()
takes care of it this at least ensures no regression in future.

Note: Although the issue is encountered only on first load without a fragment identifier, it
happens reliably when you include the fragment identifier in the url (#Footnote_1). This is so
because scrolling to the fragment always happens before the image has loaded, rendering the page
and clearing the initial dirty bits in the positioned element's renderer. When the image finally
loads in this scenario, the positioned element is otherwise clean and relies on the above code to get
re-rendered.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::layoutPositionedObjects): remove the check for r->parent()->isBlockFlow() when
                                                 deciding whether to mark children for layout
(WebCore::RenderBlock::positionedFloatsNeedRelayout): ditto

LayoutTests:

* fast/block/positioning/absolute-layout-after-image-load-expected.txt: Added.
* fast/block/positioning/absolute-layout-after-image-load.html: Added.
* fast/block/positioning/resources/absolute-layout-after-image-load-2.html: Added.
* fast/block/positioning/positioned-float-layout-after-image-load-expected.txt: Added.
* fast/block/positioning/positioned-float-layout-after-image-load.html: Added.
* fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94694 => 94695)


--- trunk/LayoutTests/ChangeLog	2011-09-07 18:50:35 UTC (rev 94694)
+++ trunk/LayoutTests/ChangeLog	2011-09-07 18:59:55 UTC (rev 94695)
@@ -1,3 +1,17 @@
+2011-09-03  Robert Hogan  <[email protected]>
+
+        Elements with position:absolute don't move to correct position after images load
+        https://bugs.webkit.org/show_bug.cgi?id=54611
+
+        Reviewed by Simon Fraser.
+
+        * fast/block/positioning/absolute-layout-after-image-load-expected.txt: Added.
+        * fast/block/positioning/absolute-layout-after-image-load.html: Added.
+        * fast/block/positioning/resources/absolute-layout-after-image-load-2.html: Added.
+        * fast/block/positioning/positioned-float-layout-after-image-load-expected.txt: Added.
+        * fast/block/positioning/positioned-float-layout-after-image-load.html: Added.
+        * fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html: Added.
+
 2011-09-07  Pavel Podivilov  <[email protected]>
 
         Unreviewed, build fix after r94674.

Added: trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load-expected.txt (0 => 94695)


--- trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load-expected.txt	2011-09-07 18:59:55 UTC (rev 94695)
@@ -0,0 +1,3 @@
+
+[1]
+SUCCESS
Property changes on: trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load.html (0 => 94695)


--- trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load.html	2011-09-07 18:59:55 UTC (rev 94695)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+     }
+
+    //   https://bugs.webkit.org/show_bug.cgi?id=54611
+    //   When navigating to absolute-layout-after-image-load-2.html#anchor1 directly, the anchor should be positioned below 
+    //   the image on first load. The test is sensitive to caching of the image, so you should reload 
+    //   absolute-layout-after-image-load-2.html#anchor1 if testing manually.
+
+    function test(){
+        setTimeout(location.assign("resources/absolute-layout-after-image-load-2.html#anchor1"),0);
+    }
+</script>
+</head>
+<body _onload_="test();">
+</body></html>
+
Property changes on: trunk/LayoutTests/fast/block/positioning/absolute-layout-after-image-load.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt (0 => 94695)


--- trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt	2011-09-07 18:59:55 UTC (rev 94695)
@@ -0,0 +1,3 @@
+
+[1]
+SUCCESS
Property changes on: trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html (0 => 94695)


--- trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html	2011-09-07 18:59:55 UTC (rev 94695)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+     }
+
+    //   https://bugs.webkit.org/show_bug.cgi?id=54611
+    //   When navigating to positioned-float-layout-after-image-load-2.html#anchor1 directly, the anchor should be positioned below 
+    //   the image on first load. The test is sensitive to caching of the image, so you should reload 
+    //   positioned-float-layout-after-image-load-2.html#anchor1 if testing manually.
+
+    function test(){
+        setTimeout(location.assign("resources/positioned-float-layout-after-image-load-2.html#anchor1"),0);
+    }
+</script>
+</head>
+<body _onload_="test();">
+</body></html>
+
Property changes on: trunk/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/block/positioning/resources/absolute-layout-after-image-load-2.html (0 => 94695)


--- trunk/LayoutTests/fast/block/positioning/resources/absolute-layout-after-image-load-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/resources/absolute-layout-after-image-load-2.html	2011-09-07 18:59:55 UTC (rev 94695)
@@ -0,0 +1,37 @@
+<html>
+<head>
+<style type="text/css">
+  body { margin-left: 10%; margin-right: 10%;}
+  h1,h2,h3,h4,h5,h6 { text-align: center; clear: both;}
+  h1 span { display: block; padding-bottom: 0.5em; }
+  .figcenter   { margin: auto; text-align: center;}
+  .footnotes        {border: dashed 1px;}
+  .footnote         {margin-left: 10%; margin-right: 10%; font-size: 0.9em;}
+  .footnote .label  {position: absolute; right: 84%; text-align: right;}
+</style>
+
+<script>
+    //   https://bugs.webkit.org/show_bug.cgi?id=54611
+    //   When navigating to the anchor directly, the anchor should be positioned below 
+    //   the image on first load.
+
+    function test(){
+        var bottomOfImage = document.getElementById("image").offsetTop + document.getElementById("image").offsetHeight;
+        var footnotePosition = document.getElementById("spantext").offsetTop;
+        if (footnotePosition >= bottomOfImage)
+          document.getElementById("console").innerHTML = "SUCCESS";
+        layoutTestController.notifyDone();
+    }
+</script>
+
+</head>
+<body _onload_="test();">
+<div class="figcenter">
+  <img id="image" src="" alt="Book cover." title="">
+</div>
+
+<div class="footnote"><a id="anchor1"></a><a href="" id="spantext" class="label">[1]</span></a></div>
+
+<div id="console">FAILURE</div>
+</body></html>
+
Property changes on: trunk/LayoutTests/fast/block/positioning/resources/absolute-layout-after-image-load-2.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html (0 => 94695)


--- trunk/LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html	2011-09-07 18:59:55 UTC (rev 94695)
@@ -0,0 +1,36 @@
+<html>
+<head>
+<style type="text/css">
+  body { margin-left: 10%; margin-right: 10%;}
+  h1,h2,h3,h4,h5,h6 { text-align: center; clear: both;}
+  h1 span { display: block; padding-bottom: 0.5em; }
+  .figcenter   { margin: auto; text-align: center;}
+  .footnote         {margin-left: 10%; margin-right: 10%; font-size: 0.9em;}
+  .footnote .label  {position: absolute; float: -webkit-positioned; right: 84%; text-align: right; width: 200px}
+</style>
+
+<script>
+    //   https://bugs.webkit.org/show_bug.cgi?id=54611
+    //   When navigating to the anchor directly, the anchor should be positioned below 
+    //   the image on first load.
+
+    function test(){
+        var bottomOfImage = document.getElementById("image").offsetTop + document.getElementById("image").offsetHeight;
+        var footnotePosition = document.getElementById("spantext").offsetTop;
+        if (footnotePosition >= bottomOfImage)
+          document.getElementById("console").innerHTML = "SUCCESS";
+        layoutTestController.notifyDone();
+    }
+</script>
+
+</head>
+<body _onload_="test();">
+<div class="figcenter">
+  <img id="image" src="" alt="Book cover." title="">
+</div>
+
+<div class="footnote"><a id="anchor1"></a><a href="" id="spantext" class="label">[1]</span></a></div>
+
+<div id="console">FAILURE</div>
+</body></html>
+
Property changes on: trunk/LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (94694 => 94695)


--- trunk/Source/WebCore/ChangeLog	2011-09-07 18:50:35 UTC (rev 94694)
+++ trunk/Source/WebCore/ChangeLog	2011-09-07 18:59:55 UTC (rev 94695)
@@ -1,3 +1,32 @@
+2011-09-03  Robert Hogan  <[email protected]>
+
+        Elements with position:absolute don't move to correct position after images load
+        https://bugs.webkit.org/show_bug.cgi?id=54611
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/block/positioning/absolute-layout-after-image-load.html
+              fast/block/positioning/positioned-float-layout-after-image-load.html
+
+        In the test the 'label' block is an absolutely positioned child of an inline flow. So during layout, 
+        this RenderBlock::layoutPositionedObjects fails to dirty it for rendering because it requires 
+        the parent to be a BlockFlow. The code to do this was introduced in http://trac.webkit.org/changeset/8284. 
+        There doesn't seem to be a good reason for requiring a BlockFlow, so remove the check. Do the same
+        for positioned floats in RenderBlock::positionedFloatsNeedRelayout(), although currently layoutPositionedObjects()
+        takes care of it this at least ensures no regression in future.
+
+        Note: Although the issue is encountered only on first load without a fragment identifier, it 
+        happens reliably when you include the fragment identifier in the url (#Footnote_1). This is so 
+        because scrolling to the fragment always happens before the image has loaded, rendering the page 
+        and clearing the initial dirty bits in the positioned element's renderer. When the image finally 
+        loads in this scenario, the positioned element is otherwise clean and relies on the above code to get 
+        re-rendered.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::layoutPositionedObjects): remove the check for r->parent()->isBlockFlow() when 
+                                                         deciding whether to mark children for layout
+        (WebCore::RenderBlock::positionedFloatsNeedRelayout): ditto
+
 2011-09-07  Anna Cavender  <[email protected]>
 
         Moving platform/track to html/track to avoid layering violation.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (94694 => 94695)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-09-07 18:50:35 UTC (rev 94694)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-09-07 18:59:55 UTC (rev 94695)
@@ -2216,7 +2216,7 @@
         if (positionedObject->needsLayout())
             return true;
 
-        if (positionedObject->style()->hasStaticBlockPosition(isHorizontalWritingMode()) && positionedObject->parent() != this && positionedObject->parent()->isBlockFlow())
+        if (positionedObject->style()->hasStaticBlockPosition(isHorizontalWritingMode()) && positionedObject->parent() != this)
             return true;
         
         if (view()->layoutState()->pageLogicalHeightChanged() || (view()->layoutState()->pageLogicalHeight() && view()->layoutState()->pageLogicalOffset(logicalTop()) != pageLogicalOffset()))
@@ -2244,7 +2244,7 @@
         // non-positioned block.  Rather than trying to detect all of these movement cases, we just always lay out positioned
         // objects that are positioned implicitly like this.  Such objects are rare, and so in typical DHTML menu usage (where everything is
         // positioned explicitly) this should not incur a performance penalty.
-        if (relayoutChildren || (r->style()->hasStaticBlockPosition(isHorizontalWritingMode()) && r->parent() != this && r->parent()->isBlockFlow()))
+        if (relayoutChildren || (r->style()->hasStaticBlockPosition(isHorizontalWritingMode()) && r->parent() != this))
             r->setChildNeedsLayout(true, false);
             
         // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to