Diff
Modified: trunk/LayoutTests/ChangeLog (122095 => 122096)
--- trunk/LayoutTests/ChangeLog 2012-07-09 07:07:29 UTC (rev 122095)
+++ trunk/LayoutTests/ChangeLog 2012-07-09 08:08:39 UTC (rev 122096)
@@ -1,3 +1,15 @@
+2012-07-09 Andrei Onea <[email protected]>
+
+ [CSSRegions] Implement NamedFlow::firstEmptyRegionIndex attribute
+ https://bugs.webkit.org/show_bug.cgi?id=90608
+
+ Reviewed by Andreas Kling.
+
+ Added tests for NamedFlow::firstEmptyRegionIndex.
+
+ * fast/regions/webkit-named-flow-first-empty-region-index-expected.txt: Added.
+ * fast/regions/webkit-named-flow-first-empty-region-index.html: Added.
+
2012-07-09 Kristóf Kosztyó <[email protected]>
[Qt] Unreviewed gardening. Skip the failing test.
Added: trunk/LayoutTests/fast/regions/webkit-named-flow-first-empty-region-index-expected.txt (0 => 122096)
--- trunk/LayoutTests/fast/regions/webkit-named-flow-first-empty-region-index-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/regions/webkit-named-flow-first-empty-region-index-expected.txt 2012-07-09 08:08:39 UTC (rev 122096)
@@ -0,0 +1,16 @@
+Test for 90608: [CSSRegions]Implement NamedFlow::firstEmptyRegionIndex attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS namedFlow.firstEmptyRegionIndex is -1
+PASS namedFlow.firstEmptyRegionIndex is -1
+PASS namedFlow.firstEmptyRegionIndex is 1
+PASS namedFlow.firstEmptyRegionIndex is 2
+PASS namedFlow.firstEmptyRegionIndex is -1
+PASS namedFlow.firstEmptyRegionIndex is 0
+PASS namedFlow.firstEmptyRegionIndex is -1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/regions/webkit-named-flow-first-empty-region-index.html (0 => 122096)
--- trunk/LayoutTests/fast/regions/webkit-named-flow-first-empty-region-index.html (rev 0)
+++ trunk/LayoutTests/fast/regions/webkit-named-flow-first-empty-region-index.html 2012-07-09 08:08:39 UTC (rev 122096)
@@ -0,0 +1,87 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<style>
+ body { font-family: monospace }
+ .content { -webkit-flow-into: flow }
+ .region { -webkit-flow-from: flow}
+ #region, #region2, region3 {width: 250px; height: 50px}
+</style>
+</head>
+<body>
+<div id="article" class="content">
+<p>Content inside article</p>
+</div>
+<script>
+ description("Test for 90608: [CSSRegions]Implement NamedFlow::firstEmptyRegionIndex attribute.");
+
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ // Named flow does not have any regions yet
+ var namedFlow = document.webkitGetFlowByName("flow");
+
+ // FirstEmptyRegionIndex should be -1 for an empty named flow
+ shouldBe("namedFlow.firstEmptyRegionIndex", "-1");
+
+ // Add a region to take the content, firstEmptyRegionIndex should still be -1.
+ var region = document.createElement("div");
+ document.body.appendChild(region);
+ region.id = "region";
+ region.className = "region";
+
+ // FirstEmptyRegions should be -1, since there are no empty regions
+ shouldBe("namedFlow.firstEmptyRegionIndex", "-1");
+
+ // Add another region, firstEmptyRegionIndex should be 1 since content only flows within the first region.
+ var region2 = document.createElement("div");
+ document.body.appendChild(region2);
+ region2.id = "region2";
+ region2.className = "region";
+
+ // FirstEmptyRegionIndex should be 1
+ shouldBe("namedFlow.firstEmptyRegionIndex", "1");
+
+ // Add content until some is flowed inside second region
+ while (region2.webkitRegionOverflow == "empty") {
+ var p = document.createElement("p");
+ p.appendChild(document.createTextNode("Content inside article"));
+ document.getElementById("article").appendChild(p);
+ }
+ // Add the third region, firstEmptyRegionIndex should be 2.
+ var region3 = document.createElement("div");
+ document.body.appendChild(region3);
+ region3.id = "region3";
+ region3.className = "region";
+
+ // FirstEmptyRegionIndex should be 2 since the content fits in the first two regions.
+ shouldBe("namedFlow.firstEmptyRegionIndex", "2");
+
+ // Remove the first region from the flow, firstEmptyRegionIndex should be -1.
+ region.className = "";
+
+ // Overset should be true since the content does not fit the regions
+ shouldBe("namedFlow.firstEmptyRegionIndex", "-1");
+
+ // Remove the content from the flow, firstEmptyRegionIndex should be 0.
+ document.getElementById("article").className = "";
+
+ // FirstEmptyRegionIndex should be 0, since there is no more content.
+ shouldBe("namedFlow.firstEmptyRegionIndex", "0");
+
+ // Remove all the regions from the flow
+ region2.className = region3.className = "";
+
+ // FirstEmptyRegionIndex should be -1, since there are no more regions in the named flow.
+ shouldBe("namedFlow.firstEmptyRegionIndex", "-1");
+
+ document.getElementById("article").style.display = "none";
+ region.style.display = "none";
+ region2.style.display = "none";
+ region3.style.display = "none";
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (122095 => 122096)
--- trunk/Source/WebCore/ChangeLog 2012-07-09 07:07:29 UTC (rev 122095)
+++ trunk/Source/WebCore/ChangeLog 2012-07-09 08:08:39 UTC (rev 122096)
@@ -1,3 +1,21 @@
+2012-07-09 Andrei Onea <[email protected]>
+
+ [CSSRegions] Implement NamedFlow::firstEmptyRegionIndex attribute
+ https://bugs.webkit.org/show_bug.cgi?id=90608
+
+ Reviewed by Andreas Kling.
+
+ Implemented NamedFlow::firstEmptyRegionIndex as per spec: http://www.w3.org/TR/css3-regions/#dom-named-flow
+
+ Test: fast/regions/webkit-named-flow-first-empty-region-index.html
+
+ * dom/WebKitNamedFlow.cpp:
+ (WebCore::WebKitNamedFlow::firstEmptyRegionIndex):
+ (WebCore):
+ * dom/WebKitNamedFlow.h:
+ (WebKitNamedFlow):
+ * dom/WebKitNamedFlow.idl:
+
2012-07-08 Yoshifumi Inoue <[email protected]>
[Platform-Mac] Derive LocaleMac.{cpp,h} and LocalizedDateMac.cpp from LocaleWin
Modified: trunk/Source/WebCore/dom/WebKitNamedFlow.cpp (122095 => 122096)
--- trunk/Source/WebCore/dom/WebKitNamedFlow.cpp 2012-07-09 07:07:29 UTC (rev 122095)
+++ trunk/Source/WebCore/dom/WebKitNamedFlow.cpp 2012-07-09 08:08:39 UTC (rev 122096)
@@ -56,6 +56,22 @@
return m_parentFlowThread->overset();
}
+int WebKitNamedFlow::firstEmptyRegionIndex() const
+{
+ m_parentFlowThread->document()->updateLayoutIgnorePendingStylesheets();
+
+ const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
+ if (regionList.isEmpty())
+ return -1;
+ RenderRegionList::const_iterator iter = regionList.begin();
+ for (int index = 0; iter != regionList.end(); ++index, ++iter) {
+ const RenderRegion* renderRegion = *iter;
+ if (renderRegion->regionState() == RenderRegion::RegionEmpty)
+ return index;
+ }
+ return -1;
+}
+
PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContentNode(Node* contentNode)
{
if (!contentNode)
Modified: trunk/Source/WebCore/dom/WebKitNamedFlow.h (122095 => 122096)
--- trunk/Source/WebCore/dom/WebKitNamedFlow.h 2012-07-09 07:07:29 UTC (rev 122095)
+++ trunk/Source/WebCore/dom/WebKitNamedFlow.h 2012-07-09 08:08:39 UTC (rev 122096)
@@ -51,6 +51,7 @@
String name() const;
bool overset() const;
+ int firstEmptyRegionIndex() const;
PassRefPtr<NodeList> getRegionsByContentNode(Node*);
PassRefPtr<NodeList> getContent();
Modified: trunk/Source/WebCore/dom/WebKitNamedFlow.idl (122095 => 122096)
--- trunk/Source/WebCore/dom/WebKitNamedFlow.idl 2012-07-09 07:07:29 UTC (rev 122095)
+++ trunk/Source/WebCore/dom/WebKitNamedFlow.idl 2012-07-09 08:08:39 UTC (rev 122096)
@@ -33,6 +33,7 @@
] WebKitNamedFlow {
readonly attribute DOMString name;
readonly attribute boolean overset;
+ readonly attribute int firstEmptyRegionIndex;
NodeList getRegionsByContentNode(in Node contentNode);
NodeList getContent();
};