Positioned Floats: Assertion hit in fast/block/positioning/positioned-float-layout...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Dec 2011 02:51:46 +0000 (02:51 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Dec 2011 02:51:46 +0000 (02:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67759

Reviewed by Darin Adler.

Source/WebCore:

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

Positioned floats are both floating and positioned. Made the following functions treat them as
positioned rather than as floats by reordering code.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::skipTrailingWhitespace):
(WebCore::RenderBlock::LineBreaker::skipLeadingWhitespace):
(WebCore::RenderBlock::LineBreaker::nextLineBreak):

LayoutTests:

Re-added this test from r94695.

* fast/block/positioning/positioned-float-layout-after-image-load-expected.txt: Copied from LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt.
* fast/block/positioning/positioned-float-layout-after-image-load.html: Copied from LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html.
* fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html: Copied from LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html [new file with mode: 0644]
LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 9d5a51f22a51e445c69c0a6ac28c278aebe2d711..b1a00210aaffef4ff5299d4e0c3e8a04afc9a9bf 100644 (file)
@@ -1,3 +1,16 @@
+2011-12-18  Dan Bernstein  <mitz@apple.com>
+
+        Positioned Floats: Assertion hit in fast/block/positioning/positioned-float-layout-after-image-load.html
+        https://bugs.webkit.org/show_bug.cgi?id=67759
+
+        Reviewed by Darin Adler.
+
+        Re-added this test from r94695.
+
+        * fast/block/positioning/positioned-float-layout-after-image-load-expected.txt: Copied from LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt.
+        * fast/block/positioning/positioned-float-layout-after-image-load.html: Copied from LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html.
+        * fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html: Copied from LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html.
+
 2011-12-18  Hajime Morrita  <morrita@chromium.org>
 
         Unreviewed expectations update.
diff --git a/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt b/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load-expected.txt
new file mode 100644 (file)
index 0000000..64e2ca5
--- /dev/null
@@ -0,0 +1,3 @@
+
+[1]
+SUCCESS
diff --git a/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html b/LayoutTests/fast/block/positioning/positioned-float-layout-after-image-load.html
new file mode 100644 (file)
index 0000000..4263e18
--- /dev/null
@@ -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>
+
diff --git a/LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html b/LayoutTests/fast/block/positioning/resources/positioned-float-layout-after-image-load-2.html
new file mode 100644 (file)
index 0000000..21f150c
--- /dev/null
@@ -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="icon-gold.png" alt="Book cover." title="">
+</div>
+
+<div class="footnote"><a id="anchor1"></a><a href="http://www.gutenberg.org/files/33439/33439-h/33439-h.htm#FNanchor_1"><span id="spantext" class="label">[1]</span></a></div>
+
+<div id="console">FAILURE</div>
+</body></html>
+
index d5a5f0bde6ee6a020c4d9b567da7dd489519ea8c..a4917e63483b728d75ecb0cce830b249dfde956b 100644 (file)
@@ -1,3 +1,20 @@
+2011-12-18  Dan Bernstein  <mitz@apple.com>
+
+        Positioned Floats: Assertion hit in fast/block/positioning/positioned-float-layout-after-image-load.html
+        https://bugs.webkit.org/show_bug.cgi?id=67759
+
+        Reviewed by Darin Adler.
+
+        Test: fast/block/positioning/positioned-float-layout-after-image-load.html
+
+        Positioned floats are both floating and positioned. Made the following functions treat them as
+        positioned rather than as floats by reordering code.
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::LineBreaker::skipTrailingWhitespace):
+        (WebCore::RenderBlock::LineBreaker::skipLeadingWhitespace):
+        (WebCore::RenderBlock::LineBreaker::nextLineBreak):
+
 2011-12-18  Benjamin Poulain  <bpoulain@apple.com>
 
         Add support for 8 bits strings to Document::isValidName()
index 178081bc4fe1547c6b1a1b7df9e30af00dc15652..ad5b9bc9033f065ee269cf8c0bd7f19ada0b1727 100755 (executable)
@@ -1861,10 +1861,10 @@ void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator,
 {
     while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhitespace)) {
         RenderObject* object = iterator.m_obj;
-        if (object->isFloating()) {
-            m_block->insertFloatingObject(toRenderBox(object));
-        } else if (object->isPositioned())
+        if (object->isPositioned())
             setStaticPositions(m_block, toRenderBox(object));
+        else if (object->isFloating())
+            m_block->insertFloatingObject(toRenderBox(object));
         iterator.increment();
     }
 }
@@ -1874,10 +1874,10 @@ void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
 {
     while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), lineInfo, LeadingWhitespace)) {
         RenderObject* object = resolver.position().m_obj;
-        if (object->isFloating())
-            m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, lineInfo, width);
-        else if (object->isPositioned())
+        if (object->isPositioned())
             setStaticPositions(m_block, toRenderBox(object));
+        else if (object->isFloating())
+            m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, lineInfo, width);
         resolver.increment();
     }
     resolver.commitExplicitEmbedding();
@@ -2156,21 +2156,7 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
             goto end;
         }
 
-        if (current.m_obj->isFloating()) {
-            RenderBox* floatBox = toRenderBox(current.m_obj);
-            FloatingObject* f = m_block->insertFloatingObject(floatBox);
-            // check if it fits in the current line.
-            // If it does, position it now, otherwise, position
-            // it after moving to next line (in newLine() func)
-            if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloat(f))) {
-                m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, lineInfo, width);
-                if (lBreak.m_obj == current.m_obj) {
-                    ASSERT(!lBreak.m_pos);
-                    lBreak.increment();
-                }
-            } else
-                floatsFitOnLine = false;
-        } else if (current.m_obj->isPositioned()) {
+        if (current.m_obj->isPositioned()) {
             // If our original display wasn't an inline type, then we can
             // go ahead and determine our static inline position now.
             RenderBox* box = toRenderBox(current.m_obj);
@@ -2195,6 +2181,20 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
                 trailingObjects.appendBoxIfNeeded(box);
             } else
                 m_positionedObjects.append(box);
+        } else if (current.m_obj->isFloating()) {
+            RenderBox* floatBox = toRenderBox(current.m_obj);
+            FloatingObject* f = m_block->insertFloatingObject(floatBox);
+            // check if it fits in the current line.
+            // If it does, position it now, otherwise, position
+            // it after moving to next line (in newLine() func)
+            if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloat(f))) {
+                m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, lineInfo, width);
+                if (lBreak.m_obj == current.m_obj) {
+                    ASSERT(!lBreak.m_pos);
+                    lBreak.increment();
+                }
+            } else
+                floatsFitOnLine = false;
         } else if (current.m_obj->isRenderInline()) {
             // Right now, we should only encounter empty inlines here.
             ASSERT(!current.m_obj->firstChild());