[CSSRegions]Implement NamedFlow::getRegionsByContentNode
authormihnea@adobe.com <mihnea@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 10:08:26 +0000 (10:08 +0000)
committermihnea@adobe.com <mihnea@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 10:08:26 +0000 (10:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77746

Reviewed by David Hyatt.

The list of regions returned is a static node list.

Source/WebCore:

Tests: fast/regions/get-regions-by-content-node-horiz-bt.html
       fast/regions/get-regions-by-content-node-horiz-tb.html
       fast/regions/get-regions-by-content-node-vert-lr.html
       fast/regions/get-regions-by-content-node-vert-rl.html
       fast/regions/get-regions-by-content-node.html
       fast/regions/get-regions-by-content-node2.html

* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::getRegionsByContentNode):
(WebCore):
* dom/WebKitNamedFlow.h:
(WebKitNamedFlow):
* dom/WebKitNamedFlow.idl:
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::regionInRange):
(WebCore):
(WebCore::RenderFlowThread::objectInFlowRegion):
* rendering/RenderFlowThread.h:
* rendering/RenderRegion.h:
(WebCore::RenderRegion::flowThread):

LayoutTests:

* fast/regions/get-regions-by-content-node-expected.txt: Added.
* fast/regions/get-regions-by-content-node-horiz-bt-expected.txt: Added.
* fast/regions/get-regions-by-content-node-horiz-bt.html: Added.
* fast/regions/get-regions-by-content-node-horiz-tb-expected.txt: Added.
* fast/regions/get-regions-by-content-node-horiz-tb.html: Added.
* fast/regions/get-regions-by-content-node-vert-lr-expected.txt: Added.
* fast/regions/get-regions-by-content-node-vert-lr.html: Added.
* fast/regions/get-regions-by-content-node-vert-rl-expected.txt: Added.
* fast/regions/get-regions-by-content-node-vert-rl.html: Added.
* fast/regions/get-regions-by-content-node.html: Added.
* fast/regions/get-regions-by-content-node2-expected.txt: Added.
* fast/regions/get-regions-by-content-node2.html: Added.

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/regions/get-regions-by-content-node-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-horiz-bt-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-horiz-bt.html [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-horiz-tb-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-horiz-tb.html [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-vert-lr-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-vert-lr.html [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-vert-rl-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node-vert-rl.html [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node.html [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node2-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/get-regions-by-content-node2.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/WebKitNamedFlow.cpp
Source/WebCore/dom/WebKitNamedFlow.h
Source/WebCore/dom/WebKitNamedFlow.idl
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderRegion.h

index dc79b5c..4cf9acb 100644 (file)
@@ -1,3 +1,25 @@
+2012-03-20  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+        https://bugs.webkit.org/show_bug.cgi?id=77746
+
+        Reviewed by David Hyatt.
+
+        The list of regions returned is a static node list.
+
+        * fast/regions/get-regions-by-content-node-expected.txt: Added.
+        * fast/regions/get-regions-by-content-node-horiz-bt-expected.txt: Added.
+        * fast/regions/get-regions-by-content-node-horiz-bt.html: Added.
+        * fast/regions/get-regions-by-content-node-horiz-tb-expected.txt: Added.
+        * fast/regions/get-regions-by-content-node-horiz-tb.html: Added.
+        * fast/regions/get-regions-by-content-node-vert-lr-expected.txt: Added.
+        * fast/regions/get-regions-by-content-node-vert-lr.html: Added.
+        * fast/regions/get-regions-by-content-node-vert-rl-expected.txt: Added.
+        * fast/regions/get-regions-by-content-node-vert-rl.html: Added.
+        * fast/regions/get-regions-by-content-node.html: Added.
+        * fast/regions/get-regions-by-content-node2-expected.txt: Added.
+        * fast/regions/get-regions-by-content-node2.html: Added.
+
 2012-03-20  Keishi Hattori  <keishi@webkit.org>
 
         [chromium] Fixing mime type for test expectation png files.
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-expected.txt b/LayoutTests/fast/regions/get-regions-by-content-node-expected.txt
new file mode 100644 (file)
index 0000000..516c9b6
--- /dev/null
@@ -0,0 +1,17 @@
+Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS regionList.length is 1
+PASS regionList.item(0).id is "region"
+PASS regionList.length is 2
+PASS regionList.item(0).id is "region21"
+PASS regionList.item(1).id is "region22"
+PASS regionList.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-horiz-bt-expected.txt b/LayoutTests/fast/regions/get-regions-by-content-node-horiz-bt-expected.txt
new file mode 100644 (file)
index 0000000..94e9a95
--- /dev/null
@@ -0,0 +1,49 @@
+Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS regionListArticle is non-null.
+PASS regionListArticle.length is 2
+PASS regionListArticle.item(0).id is "region"
+PASS regionListArticle.item(1).id is "region2"
+PASS regionListSpan is non-null.
+PASS regionListSpan.length is 1
+PASS regionListSpan.item(0).id is "region"
+PASS regionListSpan2 is non-null.
+PASS regionListSpan2.length is 2
+PASS regionListSpan3 is non-null.
+PASS regionListSpan3.length is 1
+PASS regionListSpan3.item(0).id is "region2"
+PASS regionListTextNode is non-null.
+PASS regionListTextNode.length is 1
+PASS regionListTextNode.item(0).id is "region2"
+PASS regionListTextNode2 is non-null.
+PASS regionListTextNode2.length is 1
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode3 is non-null.
+PASS regionListTextNode3.length is 1
+PASS regionListTextNode3.item(0).id is "region2"
+PASS regionListTextNode2.length is 2
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode2.item(1).id is "region3"
+PASS regionListTextNode32.length is 1
+PASS regionListTextNode32.item(0).id is "region3"
+PASS regionListP1 is non-null.
+PASS regionListP1.length is 1
+PASS regionListP1.item(0).id is "region4"
+PASS regionListP2 is non-null.
+PASS regionListP2.length is 1
+PASS regionListP2.item(0).id is "region4"
+PASS regionListP3 is non-null.
+PASS regionListP3.length is 1
+PASS regionListP3.item(0).id is "region4"
+PASS regionListP22.length is 1
+PASS regionListP22.item(0).id is "region5"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-horiz-bt.html b/LayoutTests/fast/regions/get-regions-by-content-node-horiz-bt.html
new file mode 100644 (file)
index 0000000..e83ea64
--- /dev/null
@@ -0,0 +1,151 @@
+<!doctype html>
+<html>
+    <head>
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+        <style>
+            html { -webkit-writing-mode: horizontal-bt; }
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; }
+            #region { -webkit-flow-from: flow; width: 250px; height: 50px; }
+            #region2 { -webkit-flow-from: flow; width: 250px; height: 50px; }
+            #region3 { -webkit-flow-from: flow; width: 250px; height: 50px; }
+
+            #article2 { -webkit-flow-into: flow2; }
+            #region4 { -webkit-flow-from: flow2; width: 250px; height: 50px; }
+            #region5 { -webkit-flow-from: flow2; width: 250px; height: 50px; }
+
+            .noRegion { -webkit-flow-from: none; }
+        </style>
+    </head>
+    <body>
+        <!-- some tests with inline elements -->
+        <div id="article">
+            <span id="spanNode">Text inside span.</span>
+            Text outside span. Text outside span. Text outside span.
+            <span id="spanNode2">Text inside span2.</span>
+            <span id="spanNode3">Text inside span3</span>
+        </div>
+        <div id="region"></div>
+        <div id="region2"></div>
+
+        <!-- some tests with block elements -->
+        <div id="article2">
+            <p id="p1">Text inside paragraph p1.</p>
+        </div>
+        <div id="region4"></region>
+        <script>
+            if (window.layoutTestController)
+                window.layoutTestController.dumpAsText();
+            description("Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode");
+            var namedFlow = document.webkitGetFlowByName("flow");
+
+            function hideRegions()
+            {
+                document.getElementById("article").style.visibility = "hidden";
+                document.getElementById("article2").style.visibility = "hidden";
+                document.getElementById("region").style.visibility = "hidden";
+                document.getElementById("region2").style.visibility = "hidden";
+                document.getElementById("region3").style.visibility = "hidden";
+                document.getElementById("region4").style.visibility = "hidden";
+                document.getElementById("region5").style.visibility = "hidden";
+            }
+
+            var regionListArticle = namedFlow.getRegionsByContentNode(document.getElementById("article"));
+            shouldBeNonNull("regionListArticle");
+            shouldEvaluateTo("regionListArticle.length", 2);
+            shouldBeEqualToString("regionListArticle.item(0).id", "region");
+            shouldBeEqualToString("regionListArticle.item(1).id", "region2");
+
+            var spanNode = document.getElementById("spanNode");
+            var regionListSpan = namedFlow.getRegionsByContentNode(spanNode);
+            shouldBeNonNull("regionListSpan");
+            shouldEvaluateTo("regionListSpan.length", 1);
+            shouldBeEqualToString("regionListSpan.item(0).id", "region");
+
+            var spanNode2 = document.getElementById("spanNode2");
+            var regionListSpan2 = namedFlow.getRegionsByContentNode(spanNode2);
+            shouldBeNonNull("regionListSpan2");
+            shouldEvaluateTo("regionListSpan2.length", 2);
+
+            var spanNode3 = document.getElementById("spanNode3");
+            var regionListSpan3 = namedFlow.getRegionsByContentNode(spanNode3);
+            shouldBeNonNull("regionListSpan3");
+            shouldEvaluateTo("regionListSpan3.length", 1);
+            shouldBeEqualToString("regionListSpan3.item(0).id", "region2");
+
+            var textNode = document.createTextNode("Text node. Text node. Text node. Text node. Text node. Text node. Text node. ");
+            document.getElementById("article").appendChild(textNode);
+            var regionListTextNode = namedFlow.getRegionsByContentNode(textNode);
+            shouldBeNonNull("regionListTextNode");
+            shouldEvaluateTo("regionListTextNode.length", 1);
+            shouldBeEqualToString("regionListTextNode.item(0).id", "region2");
+
+            // Add another text node that will overflow the region2.
+            var textNode2 = document.createTextNode("Text node2.");
+            document.getElementById("article").appendChild(textNode2);
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode2);
+            shouldBeNonNull("regionListTextNode2");
+            shouldEvaluateTo("regionListTextNode2.length", 1);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+
+            // Add another text node that is in the overflow of the last region.
+            var textNode3 = document.createTextNode("Text node3.");
+            document.getElementById("article").appendChild(textNode3);
+            var regionListTextNode3 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldBeNonNull("regionListTextNode3");
+            shouldEvaluateTo("regionListTextNode3.length", 1);
+            shouldBeEqualToString("regionListTextNode3.item(0).id", "region2");
+
+            // Add another region to take the overflowing elements from second region.
+            var region3 = document.createElement("div");
+            region3.id = "region3";
+            document.body.appendChild(region3);
+
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode);
+            shouldEvaluateTo("regionListTextNode2.length", 2);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+            shouldBeEqualToString("regionListTextNode2.item(1).id", "region3");
+
+            var regionListTextNode32 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldEvaluateTo("regionListTextNode32.length", 1);
+            shouldBeEqualToString("regionListTextNode32.item(0).id", "region3");
+
+            var namedFlow2 = document.webkitGetFlowByName("flow2");
+            var regionListP1 = namedFlow2.getRegionsByContentNode(document.getElementById("p1"));
+            shouldBeNonNull("regionListP1");
+            shouldEvaluateTo("regionListP1.length", 1);
+            shouldBeEqualToString("regionListP1.item(0).id", "region4");
+
+            var p2 = document.createElement("p");
+            p2.id = "p2";
+            p2.appendChild(document.createTextNode("Text inside paragraph p2."));
+            document.getElementById("article2").appendChild(p2);
+            var regionListP2 = namedFlow2.getRegionsByContentNode(p2);
+            shouldBeNonNull("regionListP2");
+            shouldEvaluateTo("regionListP2.length", 1);
+            shouldBeEqualToString("regionListP2.item(0).id", "region4");
+            // add another element p, in the overflow part of the region4
+            var p3 = document.createElement("p");
+            p3.id = "p3";
+            p3.appendChild(document.createTextNode("Text inside paragraph p3."));
+            document.getElementById("article2").appendChild(p3);
+            var regionListP3 = namedFlow2.getRegionsByContentNode(p3);
+            shouldBeNonNull("regionListP3");
+            shouldEvaluateTo("regionListP3.length", 1);
+            shouldBeEqualToString("regionListP3.item(0).id", "region4");
+
+            // add another region to flow2, p2 and p3 go to region5
+            var region5 = document.createElement("div");
+            region5.id = "region5";
+            document.body.appendChild(region5);
+
+            var regionListP22 = namedFlow2.getRegionsByContentNode(p2);
+            shouldEvaluateTo("regionListP22.length", 1);
+            shouldBeEqualToString("regionListP22.item(0).id", "region5");
+
+            hideRegions();
+        </script>
+        <script src="../../fast/js/resources/js-test-post.js"></script>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-horiz-tb-expected.txt b/LayoutTests/fast/regions/get-regions-by-content-node-horiz-tb-expected.txt
new file mode 100644 (file)
index 0000000..617c9ed
--- /dev/null
@@ -0,0 +1,49 @@
+Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS regionListArticle  is non-null.
+PASS regionListArticle.length is 2
+PASS regionListArticle.item(0).id is "region"
+PASS regionListArticle.item(1).id is "region2"
+PASS regionListSpan is non-null.
+PASS regionListSpan.length is 1
+PASS regionListSpan.item(0).id is "region"
+PASS regionListSpan2 is non-null.
+PASS regionListSpan2.length is 2
+PASS regionListSpan3 is non-null.
+PASS regionListSpan3.length is 1
+PASS regionListSpan3.item(0).id is "region2"
+PASS regionListTextNode is non-null.
+PASS regionListTextNode.length is 1
+PASS regionListTextNode.item(0).id is "region2"
+PASS regionListTextNode2 is non-null.
+PASS regionListTextNode2.length is 1
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode3 is non-null.
+PASS regionListTextNode3.length is 1
+PASS regionListTextNode3.item(0).id is "region2"
+PASS regionListTextNode2.length is 2
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode2.item(1).id is "region3"
+PASS regionListTextNode32.length is 1
+PASS regionListTextNode32.item(0).id is "region3"
+PASS regionListP1 is non-null.
+PASS regionListP1.length is 1
+PASS regionListP1.item(0).id is "region4"
+PASS regionListP2 is non-null.
+PASS regionListP2.length is 1
+PASS regionListP2.item(0).id is "region4"
+PASS regionListP3 is non-null.
+PASS regionListP3.length is 1
+PASS regionListP3.item(0).id is "region4"
+PASS regionListP22.length is 1
+PASS regionListP22.item(0).id is "region5"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-horiz-tb.html b/LayoutTests/fast/regions/get-regions-by-content-node-horiz-tb.html
new file mode 100644 (file)
index 0000000..1fa1522
--- /dev/null
@@ -0,0 +1,154 @@
+<!doctype html>
+<html>
+    <head>
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+        <style>
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; }
+            #region { -webkit-flow-from: flow; width: 250px; height: 50px; }
+            #region2 { -webkit-flow-from: flow; width: 250px; height: 50px; }
+            #region3 { -webkit-flow-from: flow; width: 250px; height: 50px; }
+
+            #article2 { -webkit-flow-into: flow2; }
+            #region4 { -webkit-flow-from: flow2; width: 250px; height: 50px; }
+            #region5 { -webkit-flow-from: flow2; width: 250px; height: 50px; }
+
+            .noRegion { -webkit-flow-from: none; }
+        </style>
+    </head>
+    <body>
+        <!-- some tests with inline elements -->
+        <div id="article">
+            <span id="spanNode">Text inside span.</span>
+            Text outside span. Text outside span. Text outside span.
+            <span id="spanNode2">Text inside span2.</span>
+            <span id="spanNode3">Text inside span3</span>
+        </div>
+        <div id="region"></div>
+        <div id="region2"></div>
+
+        <!-- some tests with block elements -->
+        <div id="article2">
+            <p id="p1">Text inside paragraph p1.</p>
+        </div>
+        <div id="region4"></region>
+
+        <script>
+            if (window.layoutTestController)
+                window.layoutTestController.dumpAsText();
+
+            description("Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode");
+
+            function hideRegions()
+            {
+                document.getElementById("article").style.visibility = "hidden";
+                document.getElementById("article2").style.visibility = "hidden";
+                document.getElementById("region").style.visibility = "hidden";
+                document.getElementById("region2").style.visibility = "hidden";
+                document.getElementById("region3").style.visibility = "hidden";
+                document.getElementById("region4").style.visibility = "hidden";
+                document.getElementById("region5").style.visibility = "hidden";
+            }
+
+            var namedFlow = document.webkitGetFlowByName("flow");
+
+            var regionListArticle = namedFlow.getRegionsByContentNode(document.getElementById("article"));
+            shouldBeNonNull("regionListArticle ");
+            shouldEvaluateTo("regionListArticle.length", 2);
+            shouldBeEqualToString("regionListArticle.item(0).id", "region");
+            shouldBeEqualToString("regionListArticle.item(1).id", "region2");
+
+            var spanNode = document.getElementById("spanNode");
+            var regionListSpan = namedFlow.getRegionsByContentNode(spanNode);
+            shouldBeNonNull("regionListSpan");
+            shouldEvaluateTo("regionListSpan.length", 1);
+            shouldBeEqualToString("regionListSpan.item(0).id", "region");
+
+            var spanNode2 = document.getElementById("spanNode2");
+            var regionListSpan2 = namedFlow.getRegionsByContentNode(spanNode2);
+            shouldBeNonNull("regionListSpan2");
+            shouldEvaluateTo("regionListSpan2.length", 2);
+
+            var spanNode3 = document.getElementById("spanNode3");
+            var regionListSpan3 = namedFlow.getRegionsByContentNode(spanNode3);
+            shouldBeNonNull("regionListSpan3");
+            shouldEvaluateTo("regionListSpan3.length", 1);
+            shouldBeEqualToString("regionListSpan3.item(0).id", "region2");
+
+            var textNode = document.createTextNode("Text node. Text node. Text node. Text node. Text node. Text node. Text node. ");
+            document.getElementById("article").appendChild(textNode);
+            var regionListTextNode = namedFlow.getRegionsByContentNode(textNode);
+            shouldBeNonNull("regionListTextNode");
+            shouldEvaluateTo("regionListTextNode.length", 1);
+            shouldBeEqualToString("regionListTextNode.item(0).id", "region2");
+
+            // Add another text node that will overflow the region2.
+            var textNode2 = document.createTextNode("Text node2.");
+            document.getElementById("article").appendChild(textNode2);
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode2);
+            shouldBeNonNull("regionListTextNode2");
+            shouldEvaluateTo("regionListTextNode2.length", 1);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+
+            // Add another text node that is in the overflow of the last region.
+            var textNode3 = document.createTextNode("Text node3.");
+            document.getElementById("article").appendChild(textNode3);
+            var regionListTextNode3 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldBeNonNull("regionListTextNode3");
+            shouldEvaluateTo("regionListTextNode3.length", 1);
+            shouldBeEqualToString("regionListTextNode3.item(0).id", "region2");
+
+            // Add another region to take the overflowing elements from second region.
+            var region3 = document.createElement("div");
+            region3.id = "region3";
+            document.body.appendChild(region3);
+
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode);
+            shouldEvaluateTo("regionListTextNode2.length", 2);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+            shouldBeEqualToString("regionListTextNode2.item(1).id", "region3");
+
+            var regionListTextNode32 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldEvaluateTo("regionListTextNode32.length", 1);
+            shouldBeEqualToString("regionListTextNode32.item(0).id", "region3");
+
+            var namedFlow2 = document.webkitGetFlowByName("flow2");
+            var regionListP1 = namedFlow2.getRegionsByContentNode(document.getElementById("p1"));
+            shouldBeNonNull("regionListP1");
+            shouldEvaluateTo("regionListP1.length", 1);
+            shouldBeEqualToString("regionListP1.item(0).id", "region4");
+
+            var p2 = document.createElement("p");
+            p2.id = "p2";
+            p2.appendChild(document.createTextNode("Text inside paragraph p2."));
+            document.getElementById("article2").appendChild(p2);
+            var regionListP2 = namedFlow2.getRegionsByContentNode(p2);
+            shouldBeNonNull("regionListP2");
+            shouldEvaluateTo("regionListP2.length", 1);
+            shouldBeEqualToString("regionListP2.item(0).id", "region4");
+            // add another element p, in the overflow part of the region4
+            var p3 = document.createElement("p");
+            p3.id = "p3";
+            p3.appendChild(document.createTextNode("Text inside paragraph p3."));
+            document.getElementById("article2").appendChild(p3);
+            var regionListP3 = namedFlow2.getRegionsByContentNode(p3);
+            shouldBeNonNull("regionListP3");
+            shouldEvaluateTo("regionListP3.length", 1);
+            shouldBeEqualToString("regionListP3.item(0).id", "region4");
+
+            // add another region to flow2, p2 and p3 go to region5
+            var region5 = document.createElement("div");
+            region5.id = "region5";
+            document.body.appendChild(region5);
+
+            var regionListP22 = namedFlow2.getRegionsByContentNode(p2);
+            shouldEvaluateTo("regionListP22.length", 1);
+            shouldBeEqualToString("regionListP22.item(0).id", "region5");
+
+            hideRegions();
+        </script>
+        <script src="../../fast/js/resources/js-test-post.js"></script>
+    </body>
+</html>
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-vert-lr-expected.txt b/LayoutTests/fast/regions/get-regions-by-content-node-vert-lr-expected.txt
new file mode 100644 (file)
index 0000000..94e9a95
--- /dev/null
@@ -0,0 +1,49 @@
+Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS regionListArticle is non-null.
+PASS regionListArticle.length is 2
+PASS regionListArticle.item(0).id is "region"
+PASS regionListArticle.item(1).id is "region2"
+PASS regionListSpan is non-null.
+PASS regionListSpan.length is 1
+PASS regionListSpan.item(0).id is "region"
+PASS regionListSpan2 is non-null.
+PASS regionListSpan2.length is 2
+PASS regionListSpan3 is non-null.
+PASS regionListSpan3.length is 1
+PASS regionListSpan3.item(0).id is "region2"
+PASS regionListTextNode is non-null.
+PASS regionListTextNode.length is 1
+PASS regionListTextNode.item(0).id is "region2"
+PASS regionListTextNode2 is non-null.
+PASS regionListTextNode2.length is 1
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode3 is non-null.
+PASS regionListTextNode3.length is 1
+PASS regionListTextNode3.item(0).id is "region2"
+PASS regionListTextNode2.length is 2
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode2.item(1).id is "region3"
+PASS regionListTextNode32.length is 1
+PASS regionListTextNode32.item(0).id is "region3"
+PASS regionListP1 is non-null.
+PASS regionListP1.length is 1
+PASS regionListP1.item(0).id is "region4"
+PASS regionListP2 is non-null.
+PASS regionListP2.length is 1
+PASS regionListP2.item(0).id is "region4"
+PASS regionListP3 is non-null.
+PASS regionListP3.length is 1
+PASS regionListP3.item(0).id is "region4"
+PASS regionListP22.length is 1
+PASS regionListP22.item(0).id is "region5"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-vert-lr.html b/LayoutTests/fast/regions/get-regions-by-content-node-vert-lr.html
new file mode 100644 (file)
index 0000000..2e66f4c
--- /dev/null
@@ -0,0 +1,154 @@
+<!doctype html>
+<html>
+    <head>
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+        <style>
+            html { -webkit-writing-mode: vertical-lr; }
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; }
+            .regionBox {  height: 250px; width: 50px; }
+            #region { -webkit-flow-from: flow; }
+            #region2 { -webkit-flow-from: flow; }
+            #region3 { -webkit-flow-from: flow; }
+
+            #article2 { -webkit-flow-into: flow2; }
+            #region4 { -webkit-flow-from: flow2; }
+            #region5 { -webkit-flow-from: flow2; }
+
+            .noRegion { -webkit-flow-from: none; }
+        </style>
+    </head>
+    <body>
+        <!-- some tests with inline elements -->
+        <div id="article">
+            <span id="spanNode">Text inside span.</span>
+            Text outside span. Text outside span. Text outside span.
+            <span id="spanNode2">Text inside span2. Text.</span>
+            <span id="spanNode3">Text inside span3</span>
+        </div>
+        <div id="region" class="regionBox"></div>
+        <div id="region2" class="regionBox"></div>
+
+        <!-- some tests with block elements -->
+        <div id="article2">
+            <p id="p1">Text inside paragraph p1.</p>
+        </div>
+        <div id="region4" class="regionBox"></region>
+        <script>
+            if (window.layoutTestController)
+                window.layoutTestController.dumpAsText();
+            description("Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode");
+            var namedFlow = document.webkitGetFlowByName("flow");
+
+            function hideRegions()
+            {
+                document.getElementById("article").style.visibility = "hidden";
+                document.getElementById("article2").style.visibility = "hidden";
+                document.getElementById("region").style.visibility = "hidden";
+                document.getElementById("region2").style.visibility = "hidden";
+                document.getElementById("region3").style.visibility = "hidden";
+                document.getElementById("region4").style.visibility = "hidden";
+                document.getElementById("region5").style.visibility = "hidden";
+            }
+
+            var regionListArticle = namedFlow.getRegionsByContentNode(document.getElementById("article"));
+            shouldBeNonNull("regionListArticle");
+            shouldEvaluateTo("regionListArticle.length", 2);
+            shouldBeEqualToString("regionListArticle.item(0).id", "region");
+            shouldBeEqualToString("regionListArticle.item(1).id", "region2");
+
+            var spanNode = document.getElementById("spanNode");
+            var regionListSpan = namedFlow.getRegionsByContentNode(spanNode);
+            shouldBeNonNull("regionListSpan");
+            shouldEvaluateTo("regionListSpan.length", 1);
+            shouldBeEqualToString("regionListSpan.item(0).id", "region");
+
+            var spanNode2 = document.getElementById("spanNode2");
+            var regionListSpan2 = namedFlow.getRegionsByContentNode(spanNode2);
+            shouldBeNonNull("regionListSpan2");
+            shouldEvaluateTo("regionListSpan2.length", 2);
+
+            var spanNode3 = document.getElementById("spanNode3");
+            var regionListSpan3 = namedFlow.getRegionsByContentNode(spanNode3);
+            shouldBeNonNull("regionListSpan3");
+            shouldEvaluateTo("regionListSpan3.length", 1);
+            shouldBeEqualToString("regionListSpan3.item(0).id", "region2");
+
+            var textNode = document.createTextNode("Text node. Text node. Text node. Text node. Text node. Text node. Text node. ");
+            document.getElementById("article").appendChild(textNode);
+            var regionListTextNode = namedFlow.getRegionsByContentNode(textNode);
+            shouldBeNonNull("regionListTextNode");
+            shouldEvaluateTo("regionListTextNode.length", 1);
+            shouldBeEqualToString("regionListTextNode.item(0).id", "region2");
+
+            // Add another text node that will overflow the region2.
+            var textNode2 = document.createTextNode("Text node2.");
+            document.getElementById("article").appendChild(textNode2);
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode2);
+            shouldBeNonNull("regionListTextNode2");
+            shouldEvaluateTo("regionListTextNode2.length", 1);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+
+            // Add another text node that is in the overflow of the last region.
+            var textNode3 = document.createTextNode("Text node3.");
+            document.getElementById("article").appendChild(textNode3);
+            var regionListTextNode3 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldBeNonNull("regionListTextNode3");
+            shouldEvaluateTo("regionListTextNode3.length", 1);
+            shouldBeEqualToString("regionListTextNode3.item(0).id", "region2");
+
+            // Add another region to take the overflowing elements from second region.
+            var region3 = document.createElement("div");
+            region3.id = "region3";
+            region3.className = "regionBox";
+            document.body.appendChild(region3);
+
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode);
+            shouldEvaluateTo("regionListTextNode2.length", 2);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+            shouldBeEqualToString("regionListTextNode2.item(1).id", "region3");
+
+            var regionListTextNode32 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldEvaluateTo("regionListTextNode32.length", 1);
+            shouldBeEqualToString("regionListTextNode32.item(0).id", "region3");
+
+            var namedFlow2 = document.webkitGetFlowByName("flow2");
+            var regionListP1 = namedFlow2.getRegionsByContentNode(document.getElementById("p1"));
+            shouldBeNonNull("regionListP1");
+            shouldEvaluateTo("regionListP1.length", 1);
+            shouldBeEqualToString("regionListP1.item(0).id", "region4");
+
+            var p2 = document.createElement("p");
+            p2.id = "p2";
+            p2.appendChild(document.createTextNode("Text inside paragraph p2."));
+            document.getElementById("article2").appendChild(p2);
+            var regionListP2 = namedFlow2.getRegionsByContentNode(p2);
+            shouldBeNonNull("regionListP2");
+            shouldEvaluateTo("regionListP2.length", 1);
+            shouldBeEqualToString("regionListP2.item(0).id", "region4");
+            // add another element p, in the overflow part of the region4
+            var p3 = document.createElement("p");
+            p3.id = "p3";
+            p3.appendChild(document.createTextNode("Text inside paragraph p3."));
+            document.getElementById("article2").appendChild(p3);
+            var regionListP3 = namedFlow2.getRegionsByContentNode(p3);
+            shouldBeNonNull("regionListP3");
+            shouldEvaluateTo("regionListP3.length", 1);
+            shouldBeEqualToString("regionListP3.item(0).id", "region4");
+
+            // add another region to flow2, p2 and p3 go to region5
+            var region5 = document.createElement("div");
+            region5.id = "region5";
+            region5.className = "regionBox";
+            document.body.appendChild(region5);
+
+            var regionListP22 = namedFlow2.getRegionsByContentNode(p2);
+            shouldEvaluateTo("regionListP22.length", 1);
+            shouldBeEqualToString("regionListP22.item(0).id", "region5");
+
+            hideRegions();
+        </script>
+        <script src="../../fast/js/resources/js-test-post.js"></script>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-vert-rl-expected.txt b/LayoutTests/fast/regions/get-regions-by-content-node-vert-rl-expected.txt
new file mode 100644 (file)
index 0000000..94e9a95
--- /dev/null
@@ -0,0 +1,49 @@
+Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS regionListArticle is non-null.
+PASS regionListArticle.length is 2
+PASS regionListArticle.item(0).id is "region"
+PASS regionListArticle.item(1).id is "region2"
+PASS regionListSpan is non-null.
+PASS regionListSpan.length is 1
+PASS regionListSpan.item(0).id is "region"
+PASS regionListSpan2 is non-null.
+PASS regionListSpan2.length is 2
+PASS regionListSpan3 is non-null.
+PASS regionListSpan3.length is 1
+PASS regionListSpan3.item(0).id is "region2"
+PASS regionListTextNode is non-null.
+PASS regionListTextNode.length is 1
+PASS regionListTextNode.item(0).id is "region2"
+PASS regionListTextNode2 is non-null.
+PASS regionListTextNode2.length is 1
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode3 is non-null.
+PASS regionListTextNode3.length is 1
+PASS regionListTextNode3.item(0).id is "region2"
+PASS regionListTextNode2.length is 2
+PASS regionListTextNode2.item(0).id is "region2"
+PASS regionListTextNode2.item(1).id is "region3"
+PASS regionListTextNode32.length is 1
+PASS regionListTextNode32.item(0).id is "region3"
+PASS regionListP1 is non-null.
+PASS regionListP1.length is 1
+PASS regionListP1.item(0).id is "region4"
+PASS regionListP2 is non-null.
+PASS regionListP2.length is 1
+PASS regionListP2.item(0).id is "region4"
+PASS regionListP3 is non-null.
+PASS regionListP3.length is 1
+PASS regionListP3.item(0).id is "region4"
+PASS regionListP22.length is 1
+PASS regionListP22.item(0).id is "region5"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node-vert-rl.html b/LayoutTests/fast/regions/get-regions-by-content-node-vert-rl.html
new file mode 100644 (file)
index 0000000..2f2f3fd
--- /dev/null
@@ -0,0 +1,154 @@
+<!doctype html>
+<html>
+    <head>
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+        <style>
+            html { -webkit-writing-mode: vertical-rl; }
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; }
+            .regionBox {  height: 250px; width: 50px; }
+            #region { -webkit-flow-from: flow; }
+            #region2 { -webkit-flow-from: flow; }
+            #region3 { -webkit-flow-from: flow; }
+
+            #article2 { -webkit-flow-into: flow2; }
+            #region4 { -webkit-flow-from: flow2; }
+            #region5 { -webkit-flow-from: flow2; }
+
+            .noRegion { -webkit-flow-from: none; }
+        </style>
+    </head>
+    <body>
+        <!-- some tests with inline elements -->
+        <div id="article">
+            <span id="spanNode">Text inside span.</span>
+            Text outside span. Text outside span. Text outside span.
+            <span id="spanNode2">Text inside span2. Text.</span>
+            <span id="spanNode3">Text inside span3</span>
+        </div>
+        <div id="region" class="regionBox"></div>
+        <div id="region2" class="regionBox"></div>
+
+        <!-- some tests with block elements -->
+        <div id="article2">
+            <p id="p1">Text inside paragraph p1.</p>
+        </div>
+        <div id="region4" class="regionBox"></region>
+        <script>
+            if (window.layoutTestController)
+                window.layoutTestController.dumpAsText();
+            description("Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode");
+            var namedFlow = document.webkitGetFlowByName("flow");
+
+            function hideRegions()
+            {
+                document.getElementById("article").style.visibility = "hidden";
+                document.getElementById("article2").style.visibility = "hidden";
+                document.getElementById("region").style.visibility = "hidden";
+                document.getElementById("region2").style.visibility = "hidden";
+                document.getElementById("region3").style.visibility = "hidden";
+                document.getElementById("region4").style.visibility = "hidden";
+                document.getElementById("region5").style.visibility = "hidden";
+            }
+
+            var regionListArticle = namedFlow.getRegionsByContentNode(document.getElementById("article"));
+            shouldBeNonNull("regionListArticle");
+            shouldEvaluateTo("regionListArticle.length", 2);
+            shouldBeEqualToString("regionListArticle.item(0).id", "region");
+            shouldBeEqualToString("regionListArticle.item(1).id", "region2");
+
+            var spanNode = document.getElementById("spanNode");
+            var regionListSpan = namedFlow.getRegionsByContentNode(spanNode);
+            shouldBeNonNull("regionListSpan");
+            shouldEvaluateTo("regionListSpan.length", 1);
+            shouldBeEqualToString("regionListSpan.item(0).id", "region");
+
+            var spanNode2 = document.getElementById("spanNode2");
+            var regionListSpan2 = namedFlow.getRegionsByContentNode(spanNode2);
+            shouldBeNonNull("regionListSpan2");
+            shouldEvaluateTo("regionListSpan2.length", 2);
+
+            var spanNode3 = document.getElementById("spanNode3");
+            var regionListSpan3 = namedFlow.getRegionsByContentNode(spanNode3);
+            shouldBeNonNull("regionListSpan3");
+            shouldEvaluateTo("regionListSpan3.length", 1);
+            shouldBeEqualToString("regionListSpan3.item(0).id", "region2");
+
+            var textNode = document.createTextNode("Text node. Text node. Text node. Text node. Text node. Text node. Text node. ");
+            document.getElementById("article").appendChild(textNode);
+            var regionListTextNode = namedFlow.getRegionsByContentNode(textNode);
+            shouldBeNonNull("regionListTextNode");
+            shouldEvaluateTo("regionListTextNode.length", 1);
+            shouldBeEqualToString("regionListTextNode.item(0).id", "region2");
+
+            // Add another text node that will overflow the region2.
+            var textNode2 = document.createTextNode("Text node2.");
+            document.getElementById("article").appendChild(textNode2);
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode2);
+            shouldBeNonNull("regionListTextNode2");
+            shouldEvaluateTo("regionListTextNode2.length", 1);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+
+            // Add another text node that is in the overflow of the last region.
+            var textNode3 = document.createTextNode("Text node3.");
+            document.getElementById("article").appendChild(textNode3);
+            var regionListTextNode3 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldBeNonNull("regionListTextNode3");
+            shouldEvaluateTo("regionListTextNode3.length", 1);
+            shouldBeEqualToString("regionListTextNode3.item(0).id", "region2");
+
+            // Add another region to take the overflowing elements from second region.
+            var region3 = document.createElement("div");
+            region3.id = "region3";
+            region3.className = "regionBox";
+            document.body.appendChild(region3);
+
+            var regionListTextNode2 = namedFlow.getRegionsByContentNode(textNode);
+            shouldEvaluateTo("regionListTextNode2.length", 2);
+            shouldBeEqualToString("regionListTextNode2.item(0).id", "region2");
+            shouldBeEqualToString("regionListTextNode2.item(1).id", "region3");
+
+            var regionListTextNode32 = namedFlow.getRegionsByContentNode(textNode3);
+            shouldEvaluateTo("regionListTextNode32.length", 1);
+            shouldBeEqualToString("regionListTextNode32.item(0).id", "region3");
+
+            var namedFlow2 = document.webkitGetFlowByName("flow2");
+            var regionListP1 = namedFlow2.getRegionsByContentNode(document.getElementById("p1"));
+            shouldBeNonNull("regionListP1");
+            shouldEvaluateTo("regionListP1.length", 1);
+            shouldBeEqualToString("regionListP1.item(0).id", "region4");
+
+            var p2 = document.createElement("p");
+            p2.id = "p2";
+            p2.appendChild(document.createTextNode("Text inside paragraph p2."));
+            document.getElementById("article2").appendChild(p2);
+            var regionListP2 = namedFlow2.getRegionsByContentNode(p2);
+            shouldBeNonNull("regionListP2");
+            shouldEvaluateTo("regionListP2.length", 1);
+            shouldBeEqualToString("regionListP2.item(0).id", "region4");
+            // add another element p, in the overflow part of the region4
+            var p3 = document.createElement("p");
+            p3.id = "p3";
+            p3.appendChild(document.createTextNode("Text inside paragraph p3."));
+            document.getElementById("article2").appendChild(p3);
+            var regionListP3 = namedFlow2.getRegionsByContentNode(p3);
+            shouldBeNonNull("regionListP3");
+            shouldEvaluateTo("regionListP3.length", 1);
+            shouldBeEqualToString("regionListP3.item(0).id", "region4");
+
+            // add another region to flow2, p2 and p3 go to region5
+            var region5 = document.createElement("div");
+            region5.id = "region5";
+            region5.className = "regionBox";
+            document.body.appendChild(region5);
+
+            var regionListP22 = namedFlow2.getRegionsByContentNode(p2);
+            shouldEvaluateTo("regionListP22.length", 1);
+            shouldBeEqualToString("regionListP22.item(0).id", "region5");
+
+            hideRegions();
+        </script>
+        <script src="../../fast/js/resources/js-test-post.js"></script>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node.html b/LayoutTests/fast/regions/get-regions-by-content-node.html
new file mode 100644 (file)
index 0000000..a0cdf4d
--- /dev/null
@@ -0,0 +1,66 @@
+<!doctype html>
+<html>
+    <head>
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+        <style>
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; }
+            .border { border: 1px solid red; }
+            #region { -webkit-flow-from: flow; width: 250px; height: 50px; position: absolute; left: 10px; top: 200px; }
+
+            #article2 { -webkit-flow-into: flow2; }
+            #region21 { -webkit-flow-from: flow2; width: 250px; height: 50px; position: absolute; left: 20px; top: 300px;}
+            #region22 { -webkit-flow-from: flow2; width: 250px; height: 50px; position: absolute; left: 20px; top: 350px;}
+        </style>
+    </head>
+    <body>
+        <div id="article">
+            <p id="p1">Text flown into region.</p>
+        </div>
+        <div id="region" class="border"></div>
+
+        <div id="article2">
+            <p id="p2">Text flown in two regions. Text flown in two regions. Text flown in two regions.</p>
+        </div>
+        <div id="region21" class="border"></div>
+        <div id="region22" class="border"></div>
+        <script>
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+
+            description("Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode.");
+
+            var namedFlow = document.webkitGetFlowByName("flow");
+            var targetNode = document.getElementById("p1");
+            var regionList = namedFlow.getRegionsByContentNode(targetNode);
+
+            shouldEvaluateTo("regionList.length", 1);
+            shouldBeEqualToString("regionList.item(0).id", "region");
+
+            namedFlow = document.webkitGetFlowByName("flow2");
+            // Test that the p2 element is flown into 2 regions
+            targetNode = document.getElementById("p2");
+            regionList = namedFlow.getRegionsByContentNode(targetNode);
+
+            shouldEvaluateTo("regionList.length", 2);
+            shouldBeEqualToString("regionList.item(0).id", "region21");
+            shouldBeEqualToString("regionList.item(1).id", "region22");
+
+            // Test that p1 element is not in flow2
+            targetNode = document.getElementById("p1");
+            regionList = namedFlow.getRegionsByContentNode(targetNode);
+            shouldEvaluateTo("regionList.length", 0);
+
+            function hideRegionsAndFlows() {
+                document.getElementById("article").style.visibility = "hidden";
+                document.getElementById("article2").style.visibility = "hidden";
+                document.getElementById("region").style.visibility = "hidden";
+                document.getElementById("region21").style.visibility = "hidden";
+                document.getElementById("region22").style.visibility = "hidden";
+            }
+
+            hideRegionsAndFlows();
+        </script>
+        <script src="../../fast/js/resources/js-test-post.js"></script>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node2-expected.txt b/LayoutTests/fast/regions/get-regions-by-content-node2-expected.txt
new file mode 100644 (file)
index 0000000..f7468ec
--- /dev/null
@@ -0,0 +1,29 @@
+Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS regionList is null
+PASS regionList2 is non-null.
+PASS regionList2.length is 0
+PASS regionList != regionList2 is true
+PASS regionList3 is non-null.
+PASS regionList3.length is 0
+PASS regionList4 is non-null.
+PASS regionList4.length is 1
+PASS regionList4.item(0).id is "region"
+PASS regionList5 is non-null.
+PASS regionList5.length is 0
+PASS regionList6 is non-null.
+PASS regionList6.length is 1
+PASS regionList6.item(0).id is "region"
+PASS regionList7 is non-null.
+PASS regionList7.length is 0
+PASS regionList8 is non-null.
+PASS regionList8.length is 0
+PASS regionList9 is non-null.
+PASS regionList9.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/regions/get-regions-by-content-node2.html b/LayoutTests/fast/regions/get-regions-by-content-node2.html
new file mode 100644 (file)
index 0000000..bf7ea7e
--- /dev/null
@@ -0,0 +1,90 @@
+<!doctype html>
+<html>
+    <head>
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+        <style>
+            body { font-family: monospace; }
+            #region, #region2 { width: 250px; height: 50px; }
+            .article { -webkit-flow-into: flow; }
+            .article2 { -webkit-flow-into: flow2; }
+            .region { -webkit-flow-from: flow; }
+            .region2 { -webkit-flow-from: flow2; }
+            .noRegion { -webkit-flow-from: none; }
+        </style>
+    </head>
+    <body>
+        <div id="console"></div>
+        <div id="article" class="article"></div>
+        <div id="region" class="region"></div>
+        <div id="region2"></div>
+        <script>
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+            description("Test for 77746: [CSSRegions]Implement NamedFlow::getRegionsByContentNode");
+
+            var namedFlow = document.webkitGetFlowByName("flow");
+
+            // Getting the regions for a non existant node should return null.
+            var pElement;
+            var regionList = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNull("regionList");
+
+            // Getting the regions for an element that was not added to the dom should return an empty list.
+            pElement = document.createElement("p");
+
+            var regionList2 = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList2");
+            shouldEvaluateTo("regionList2.length", 0);
+            shouldBeTrue("regionList != regionList2");
+
+            // Add the element to the dom but not in the flow. The region list should be empty.
+            document.body.appendChild(pElement);
+            var regionList3 = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList3");
+            shouldEvaluateTo("regionList3.length", 0);
+
+            // Add the same element to the flow. The region list should contain one region.
+            document.body.removeChild(pElement);
+            document.getElementById("article").appendChild(pElement);
+            var regionList4 = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList4");
+            shouldEvaluateTo("regionList4.length", 1);
+            shouldBeEqualToString("regionList4.item(0).id", "region");
+
+            // Remove the region node and get the region list. The list should be empty.
+            document.getElementById("region").className = "noRegion";
+            var regionList5 = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList5");
+            shouldEvaluateTo("regionList5.length", 0);
+
+            // Bring back the region and get the region list. The list should have one element.
+            document.getElementById("region").className = "region";
+            var regionList6 = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList6");
+            shouldEvaluateTo("regionList6.length", 1);
+            shouldBeEqualToString("regionList6.item(0).id", "region");
+
+            // Remove the named flow, the region list should be empty.
+            document.getElementById("article").className = "";
+            var regionList7 = namedFlow.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList7");
+            shouldEvaluateTo("regionList7.length", 0);
+
+            // Move the article to another named flow, the region list should be empty.
+            document.getElementById("article").className = "article2";
+            var namedFlow2 = document.webkitGetFlowByName("flow2");
+            var regionList8 = namedFlow2.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList8");
+            shouldEvaluateTo("regionList8.length", 0);
+
+            // Add a region to the second named flow, the region list should contain one element
+            // since the p element is a child of article that is collected by flow2.
+            document.getElementById("region2").className = "region2";
+            var regionList9 = namedFlow2.getRegionsByContentNode(pElement);
+            shouldBeNonNull("regionList9");
+            shouldEvaluateTo("regionList9.length", 1);
+        </script>
+        <script src="../../fast/js/resources/js-test-post.js"></script>
+    </body>
+</html>
+
index 406b0b9..769545b 100644 (file)
@@ -1,3 +1,33 @@
+2012-03-20  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSSRegions]Implement NamedFlow::getRegionsByContentNode
+        https://bugs.webkit.org/show_bug.cgi?id=77746
+
+        Reviewed by David Hyatt.
+
+        The list of regions returned is a static node list.
+
+        Tests: fast/regions/get-regions-by-content-node-horiz-bt.html
+               fast/regions/get-regions-by-content-node-horiz-tb.html
+               fast/regions/get-regions-by-content-node-vert-lr.html
+               fast/regions/get-regions-by-content-node-vert-rl.html
+               fast/regions/get-regions-by-content-node.html
+               fast/regions/get-regions-by-content-node2.html
+
+        * dom/WebKitNamedFlow.cpp:
+        (WebCore::WebKitNamedFlow::getRegionsByContentNode):
+        (WebCore):
+        * dom/WebKitNamedFlow.h:
+        (WebKitNamedFlow):
+        * dom/WebKitNamedFlow.idl:
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::regionInRange):
+        (WebCore):
+        (WebCore::RenderFlowThread::objectInFlowRegion):
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderRegion.h:
+        (WebCore::RenderRegion::flowThread):
+
 2012-03-20  Luke Macpherson  <macpherson@chromium.org>
 
         Remove min and max parameters from CSSPrimitiveValue's roundForImpreciseConversion function.
index 32a4979..b157405 100644 (file)
@@ -33,6 +33,7 @@
 #include "Node.h"
 #include "NodeList.h"
 #include "RenderFlowThread.h"
+#include "RenderRegion.h"
 #include "StaticNodeList.h"
 
 namespace WebCore {
@@ -85,5 +86,28 @@ void WebKitNamedFlow::registerContentNode(Node* contentNode)
     m_contentNodes.add(contentNode);
 }
 
+PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContentNode(Node* contentNode)
+{
+    if (!contentNode)
+        return 0;
+
+    m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
+
+    Vector<RefPtr<Node> > regionNodes;
+    if (contentNode->renderer()
+        && contentNode->renderer()->inRenderFlowThread()
+        && m_parentFlowThread == contentNode->renderer()->enclosingRenderFlowThread()) {
+        const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
+        for (RenderRegionList::const_iterator iter = regionList.begin(); iter != regionList.end(); ++iter) {
+            const RenderRegion* renderRegion = *iter;
+            if (!renderRegion->isValid())
+                continue;
+            if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), renderRegion))
+                regionNodes.append(renderRegion->node());
+        }
+    }
+    return StaticNodeList::adopt(regionNodes);
+}
+
 } // namespace WebCore
 
index dd33b41..5b65160 100644 (file)
@@ -51,6 +51,7 @@ public:
 
     bool overflow() const;
     PassRefPtr<NodeList> contentNodes() const;
+    PassRefPtr<NodeList> getRegionsByContentNode(Node*);
 
     void registerContentNode(Node* contentNode);
     void unregisterContentNode(Node* contentNode) { m_contentNodes.remove(contentNode); }
index 17a44c6..c8d3f2d 100644 (file)
@@ -33,6 +33,7 @@ module core {
     ] WebKitNamedFlow {
         readonly attribute boolean overflow;
         readonly attribute NodeList contentNodes;
+        NodeList getRegionsByContentNode(in Node contentNode);
     };
 }
 
index 11355cd..1c892c8 100644 (file)
@@ -952,5 +952,69 @@ void RenderFlowThread::regionLayoutUpdateEventTimerFired(Timer<RenderFlowThread>
     }
 }
 
-} // namespace WebCore
+bool RenderFlowThread::regionInRange(const RenderRegion* targetRegion, const RenderRegion* startRegion, const RenderRegion* endRegion) const
+{
+    ASSERT(targetRegion);
+
+    for (RenderRegionList::const_iterator it = m_regionList.find(const_cast<RenderRegion*>(startRegion)); it != m_regionList.end(); ++it) {
+        const RenderRegion* currRegion = *it;
+        if (!currRegion->isValid())
+            continue;
+        if (targetRegion == currRegion)
+            return true;
+        if (currRegion == endRegion)
+            break;
+    }
+
+    return false;
+}
+
+bool RenderFlowThread::objectInFlowRegion(const RenderObject* object, const RenderRegion* region) const
+{
+    ASSERT(object);
+    ASSERT(region);
+
+    if (!object->inRenderFlowThread())
+        return false;
+    if (object->enclosingRenderFlowThread() != this)
+        return false;
+    if (!m_regionList.contains(const_cast<RenderRegion*>(region)))
+        return false;
+
+    RenderBox* enclosingBox = object->enclosingBox();
+    RenderRegion* enclosingBoxStartRegion = 0;
+    RenderRegion* enclosingBoxEndRegion = 0;
+    getRegionRangeForBox(enclosingBox, enclosingBoxStartRegion, enclosingBoxEndRegion);
+    if (!regionInRange(region, enclosingBoxStartRegion, enclosingBoxEndRegion))
+       return false;
+
+    if (object->isBox())
+        return true;
 
+    LayoutRect objectABBRect = object->absoluteBoundingBoxRect(true);
+    if (!objectABBRect.width())
+        objectABBRect.setWidth(1);
+    if (!objectABBRect.height())
+        objectABBRect.setHeight(1); 
+    if (objectABBRect.intersects(region->absoluteBoundingBoxRect(true)))
+        return true;
+
+    if (region == lastRegion()) {
+        // If the object does not intersect any of the enclosing box regions
+        // then the object is in last region.
+        for (RenderRegionList::const_iterator it = m_regionList.find(enclosingBoxStartRegion); it != m_regionList.end(); ++it) {
+            const RenderRegion* currRegion = *it;
+            if (!region->isValid())
+                continue;
+            if (currRegion == region)
+                break;
+            if (objectABBRect.intersects(currRegion->absoluteBoundingBoxRect(true)))
+                return false;
+        }
+        return true;
+    }
+
+    return false;
+}
+
+} // namespace WebCore
index 2cf5a95..bd36f22 100644 (file)
@@ -137,6 +137,9 @@ public:
 
     bool overflow() const { return m_overflow; }
 
+    // Check if the object is in region and the region is part of this flow thread.
+    bool objectInFlowRegion(const RenderObject*, const RenderRegion*) const;
+
 private:
     virtual const char* renderName() const { return "RenderFlowThread"; }
 
@@ -147,6 +150,7 @@ private:
 
     bool shouldRepaint(const LayoutRect&) const;
     void regionLayoutUpdateEventTimerFired(Timer<RenderFlowThread>*);
+    bool regionInRange(const RenderRegion* targetRegion, const RenderRegion* startRegion, const RenderRegion* endRegion) const;
 
     typedef ListHashSet<RenderObject*> FlowThreadChildList;
     FlowThreadChildList m_flowThreadChildList;
index 741de65..97e61fe 100644 (file)
@@ -57,6 +57,7 @@ public:
     void detachRegion();
 
     RenderFlowThread* parentFlowThread() const { return m_parentFlowThread; }
+    RenderFlowThread* flowThread() const { return m_flowThread; }
 
     // Valid regions do not create circular dependencies with other flows.
     bool isValid() const { return m_isValid; }