Title: [150108] trunk
Revision
150108
Author
[email protected]
Date
2013-05-15 03:54:24 -0700 (Wed, 15 May 2013)

Log Message

[CSSRegions] Implement offsetParent for elements inside named flow
https://bugs.webkit.org/show_bug.cgi?id=113276

Source/WebCore:

In the offsetParent algorithm, the nearest ancestor search skips from the topmost named flow elements directly to the body element.
http://dev.w3.org/csswg/css-regions/#cssomview-offset-attributes

As a result of this change, the DumpRenderTree tool would crash in
WebCore::RenderBoxModelObject::adjustedPositionRelativeToOffsetParent when running the selecting-text-through-different-region-flows.html
test. The RenderObjects inside a flow are attached to the RenderFlowThread. However, the RenderFlowThread is attached to the
RenderView directly, meaning that we are going to bypass the <body>'s RenderObject while iterating the parents.

Patch by Radu Stavila <[email protected]> on 2013-05-15
Reviewed by Darin Adler.

Tests: fast/regions/offsetParent-body-in-flow-thread.html
       fast/regions/offsetParent-in-flow-thread.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::adjustedPositionRelativeToOffsetParent):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::offsetParent):

LayoutTests:

Patch by Radu Stavila <[email protected]> on 2013-05-15
Reviewed by Darin Adler.

In the offsetParent algorithm, the nearest ancestor search skips from the topmost named flow elements directly to the body element.

Added new test for offsetParent when body is flowed into a region.
Updated existing offsetParent test.

* fast/regions/offsetParent-body-in-flow-thread-expected.txt: Added.
* fast/regions/offsetParent-body-in-flow-thread.html: Added.
* fast/regions/offsetParent-in-flow-thread-expected.txt:
* fast/regions/offsetParent-in-flow-thread.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (150107 => 150108)


--- trunk/LayoutTests/ChangeLog	2013-05-15 09:43:18 UTC (rev 150107)
+++ trunk/LayoutTests/ChangeLog	2013-05-15 10:54:24 UTC (rev 150108)
@@ -1,3 +1,20 @@
+2013-05-15  Radu Stavila  <[email protected]>
+
+        [CSSRegions] Implement offsetParent for elements inside named flow
+        https://bugs.webkit.org/show_bug.cgi?id=113276
+
+        Reviewed by Darin Adler.
+
+        In the offsetParent algorithm, the nearest ancestor search skips from the topmost named flow elements directly to the body element.
+
+        Added new test for offsetParent when body is flowed into a region.
+        Updated existing offsetParent test.
+
+        * fast/regions/offsetParent-body-in-flow-thread-expected.txt: Added.
+        * fast/regions/offsetParent-body-in-flow-thread.html: Added.
+        * fast/regions/offsetParent-in-flow-thread-expected.txt:
+        * fast/regions/offsetParent-in-flow-thread.html:
+
 2013-05-14  Hans Muller  <[email protected]>
 
         [CSS Exclusions] Some layout tests fail to account for inline pixel snapping

Added: trunk/LayoutTests/fast/regions/offsetParent-body-in-flow-thread-expected.txt (0 => 150108)


--- trunk/LayoutTests/fast/regions/offsetParent-body-in-flow-thread-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/offsetParent-body-in-flow-thread-expected.txt	2013-05-15 10:54:24 UTC (rev 150108)
@@ -0,0 +1,15 @@
+Test offsetParent for body in a named flow.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS article.offsetParent is document.body
+PASS chapter.offsetParent is document.body
+PASS chapter.offsetParent is article
+PASS tdChild.offsetParent is td
+PASS tdChild.offsetParent is document.body
+PASS document.body.offsetParent is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/fast/regions/offsetParent-body-in-flow-thread.html (from rev 150107, trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread.html) (0 => 150108)


--- trunk/LayoutTests/fast/regions/offsetParent-body-in-flow-thread.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/offsetParent-body-in-flow-thread.html	2013-05-15 10:54:24 UTC (rev 150108)
@@ -0,0 +1,54 @@
+<!doctype html>
+<html>
+    <head>
+        <script src=""
+    </head>
+
+    <style>
+
+        #region {
+            -webkit-flow-from: flow;
+        }
+
+    </style>
+
+    <body>
+        <script>
+            description("Test offsetParent for body in a named flow.")
+
+            document.body.style.webkitFlowInto = "flow";
+            
+            var article = document.createElement("div");
+            document.body.appendChild(article);
+            shouldBe("article.offsetParent", "document.body");
+
+            var chapter = document.createElement("div");
+            article.appendChild(chapter);
+            shouldBe("chapter.offsetParent", "document.body");
+
+            article.style.position = "relative";
+            shouldBe("chapter.offsetParent", "article");
+
+            var table = document.createElement("table");
+            document.body.appendChild(table);
+
+            var td = document.createElement("td");
+            table.appendChild(td);
+
+            var tdChild = document.createElement("div");
+            td.appendChild(tdChild);
+            shouldBe("tdChild.offsetParent", "td");
+
+            tdChild.style.webkitFlowInto = "flow";
+            shouldBe("tdChild.offsetParent", "document.body");
+
+            shouldBeNull("document.body.offsetParent");
+
+            document.body.style.webkitFlowInto = null;
+        </script>
+        <script src=""
+
+        <div id="region"/>
+    </body>
+</html>
+

Modified: trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread-expected.txt (150107 => 150108)


--- trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread-expected.txt	2013-05-15 09:43:18 UTC (rev 150107)
+++ trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread-expected.txt	2013-05-15 10:54:24 UTC (rev 150108)
@@ -3,11 +3,12 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS article.offsetParent is null
-PASS chapter.offsetParent is null
+PASS article.offsetParent is document.body
+PASS chapter.offsetParent is document.body
 PASS chapter.offsetParent is article
 PASS tdChild.offsetParent is td
-PASS tdChild.offsetParent is null
+PASS tdChild.offsetParent is document.body
+PASS document.body.offsetParent is null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread.html (150107 => 150108)


--- trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread.html	2013-05-15 09:43:18 UTC (rev 150107)
+++ trunk/LayoutTests/fast/regions/offsetParent-in-flow-thread.html	2013-05-15 10:54:24 UTC (rev 150108)
@@ -10,11 +10,11 @@
             var article = document.createElement("div");
             document.body.appendChild(article);
             article.style.webkitFlowInto = "flow";
-            shouldBeNull("article.offsetParent");
+            shouldBe("article.offsetParent", "document.body");
 
             var chapter = document.createElement("div");
             article.appendChild(chapter);
-            shouldBeNull("chapter.offsetParent");
+            shouldBe("chapter.offsetParent", "document.body");
 
             article.style.position = "relative";
             shouldBe("chapter.offsetParent", "article");
@@ -30,7 +30,9 @@
             shouldBe("tdChild.offsetParent", "td");
 
             tdChild.style.webkitFlowInto = "flow";
-            shouldBeNull("tdChild.offsetParent");
+            shouldBe("tdChild.offsetParent", "document.body");
+
+            shouldBeNull("document.body.offsetParent");
         </script>
         <script src=""
     </body>

Modified: trunk/Source/WebCore/ChangeLog (150107 => 150108)


--- trunk/Source/WebCore/ChangeLog	2013-05-15 09:43:18 UTC (rev 150107)
+++ trunk/Source/WebCore/ChangeLog	2013-05-15 10:54:24 UTC (rev 150108)
@@ -1,3 +1,26 @@
+2013-05-15  Radu Stavila  <[email protected]>
+
+        [CSSRegions] Implement offsetParent for elements inside named flow
+        https://bugs.webkit.org/show_bug.cgi?id=113276
+
+        In the offsetParent algorithm, the nearest ancestor search skips from the topmost named flow elements directly to the body element.
+        http://dev.w3.org/csswg/css-regions/#cssomview-offset-attributes
+
+        As a result of this change, the DumpRenderTree tool would crash in 
+        WebCore::RenderBoxModelObject::adjustedPositionRelativeToOffsetParent when running the selecting-text-through-different-region-flows.html
+        test. The RenderObjects inside a flow are attached to the RenderFlowThread. However, the RenderFlowThread is attached to the 
+        RenderView directly, meaning that we are going to bypass the <body>'s RenderObject while iterating the parents.
+
+        Reviewed by Darin Adler.
+
+        Tests: fast/regions/offsetParent-body-in-flow-thread.html
+               fast/regions/offsetParent-in-flow-thread.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::adjustedPositionRelativeToOffsetParent):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::offsetParent):
+
 2013-05-15  Darin Adler  <[email protected]>
 
         [Mac] Make Clipboard::createDragImage non-virtual

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (150107 => 150108)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-05-15 09:43:18 UTC (rev 150107)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-05-15 10:54:24 UTC (rev 150108)
@@ -496,8 +496,15 @@
                 referencePoint.move(relativePositionOffset());
             else if (isStickyPositioned())
                 referencePoint.move(stickyPositionOffset());
+            
+            // FIXME: The offset position for elements inside named flow threads is not correctly computed when the offsetParent is body
+            // See https://bugs.webkit.org/show_bug.cgi?id=115899
+            
+            // CSS regions specification says that region flows should return the body element as their offsetParent.
+            // Since we will bypass the body’s renderer anyway, just end the loop if we encounter a region flow (named flow thread).
+            // See http://dev.w3.org/csswg/css-regions/#cssomview-offset-attributes
             const RenderObject* curr = parent();
-            while (curr != offsetParent) {
+            while (curr != offsetParent && !curr->isRenderNamedFlowThread()) {
                 // FIXME: What are we supposed to do inside SVG content?
                 if (curr->isBox() && !curr->isTableRow())
                     referencePoint.moveBy(toRenderBox(curr)->topLeftLocation());

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (150107 => 150108)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2013-05-15 09:43:18 UTC (rev 150107)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2013-05-15 10:54:24 UTC (rev 150108)
@@ -2987,10 +2987,6 @@
     // If A is an area HTML element which has a map HTML element somewhere in the ancestor
     // chain return the nearest ancestor map HTML element and stop this algorithm.
     // FIXME: Implement!
-
-    // FIXME: Stop the search at the flow thread boundary until we figure out the right
-    // behavior for elements inside a flow thread.
-    // https://bugs.webkit.org/show_bug.cgi?id=113276
     
     // Return the nearest ancestor element of A for which at least one of the following is
     // true and stop this algorithm if such an ancestor is found:
@@ -3014,7 +3010,12 @@
         currZoom = newZoom;
         curr = curr->parent();
     }
-    return curr && curr->isBoxModelObject() && !curr->isRenderNamedFlowThread() ? toRenderBoxModelObject(curr) : 0;
+    
+    // CSS regions specification says that region flows should return the body element as their offsetParent.
+    if (curr && curr->isRenderNamedFlowThread())
+        curr = document()->body() ? document()->body()->renderer() : 0;
+    
+    return curr && curr->isBoxModelObject() ? toRenderBoxModelObject(curr) : 0;
 }
 
 VisiblePosition RenderObject::createVisiblePosition(int offset, EAffinity affinity)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to