[CSS Regions] Fix the lifecycle for the flow objects and their renderers

https://bugs.webkit.org/show_bug.cgi?id=89000

Patch by Andrei Bucur <abucur@adobe.com> on 2012-07-13
Reviewed by Eric Seidel.

Source/WebCore:

This patch adds the concept of a NamedFlowCollection, owned by the document, that keeps track of
all the named flows that exist in the Document. This collection contains a ListHashSet of weak references to
all the existing NamedFlows in the document. This is not a managed set because the CREATED flows are referenced from the renderer and
the NULL flows are only cached, they should be destructible.
Two named flows are considered to be equal if they have the same name.
I've changed the NamedFlow state to depend on the existence of its renderer. A flow thread that has a renderer will also have a NamedFlow object.
A flow thread without a renderer can have a NamedFlow object, but only in the NULL state. It's possible for a NamedFlow object to jump from the
NULL state to the CREATED state if it was not destroyed (e.g. it was referenced from JS). Keeping track of the NULL state flows that have listeners will be important
so when they go back to the CREATED state, the listeners would still be there.

Link to spec: http://www.w3.org/TR/2012/WD-css3-regions-20120503/

Tests: The old tests have been modified to take into account the new behavior

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore):
(WebCore::Document::webkitGetFlowByName):
(WebCore::Document::namedFlows):
* dom/Document.h:
(WebCore):
(Document):
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::WebKitNamedFlow):
(WebCore::WebKitNamedFlow::~WebKitNamedFlow):
(WebCore::WebKitNamedFlow::create):
(WebCore):
(WebCore::WebKitNamedFlow::name):
(WebCore::WebKitNamedFlow::overset):
(WebCore::nodeInFlowThread):
(WebCore::WebKitNamedFlow::getRegionsByContentNode):
(WebCore::WebKitNamedFlow::getContent):
(WebCore::WebKitNamedFlow::setRenderer):
* dom/WebKitNamedFlow.h:
(WebCore):
(WebKitNamedFlow):
(WebCore::WebKitNamedFlow::getFlowState):
(WebCore::WebKitNamedFlow::switchFlowState):
* dom/WebKitNamedFlowCollection.cpp: Added.
(WebCore):
(WebCore::WebKitNamedFlowCollection::WebKitNamedFlowCollection):
(WebCore::WebKitNamedFlowCollection::length): An O(1) operation
(WebCore::WebKitNamedFlowCollection::item): An O(N) operation
(WebCore::WebKitNamedFlowCollection::flowByName): An O(1) operation
(WebCore::WebKitNamedFlowCollection::ensureNamedFlowInCreatedState): An O(1) operation
(WebCore::WebKitNamedFlowCollection::moveNamedFlowToNullState): An O(1) operation
(WebCore::WebKitNamedFlowCollection::discardNamedFlow): An O(1) operation
(WebCore::WebKitNamedFlowCollection::documentDestroyed):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashFunctions::hash):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashFunctions::equal):
(WebKitNamedFlowCollection::NamedFlowHashFunctions):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashTranslator::hash):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashTranslator::equal):
* dom/WebKitNamedFlowCollection.h: Copied from Source/WebCore/dom/WebKitNamedFlow.h.
(WebCore):
(WebKitNamedFlowCollection):
(WebCore::WebKitNamedFlowCollection::create):
(WebCore::WebKitNamedFlowCollection::document):
* rendering/FlowThreadController.cpp:
(WebCore::FlowThreadController::ensureRenderFlowThreadWithName):
(WebCore::FlowThreadController::removeFlowThread):
(WebCore):
* rendering/FlowThreadController.h:
(FlowThreadController):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
(WebCore):
(WebCore::RenderNamedFlowThread::~RenderNamedFlowThread):
(WebCore::RenderNamedFlowThread::removeRegionFromThread):
(WebCore::RenderNamedFlowThread::unregisterNamedFlowContentNode):
(WebCore::RenderNamedFlowThread::flowThreadName):
(WebCore::RenderNamedFlowThread::willBeDestroyed):
* rendering/RenderNamedFlowThread.h:
(RenderNamedFlowThread):
(WebCore::RenderNamedFlowThread::contentNodes):
(WebCore::RenderNamedFlowThread::canBeDestroyed):

LayoutTests:

These tests expected getFlowByName() to return a valid object even for the NULL flows. They've been modified to
reflect the new behavior.

* fast/regions/get-regions-by-content-node2-expected.txt:
* fast/regions/get-regions-by-content-node2.html:
* fast/regions/webkit-named-flow-flow-added.html:
* fast/regions/webkit-named-flow-get-content-expected.txt:
* fast/regions/webkit-named-flow-get-content.html:
* fast/regions/webkit-named-flow-invalid-name.html:
* fast/regions/webkit-named-flow-modified-flow.html:
* fast/regions/webkit-named-flow-non-existing-flow.html:
* fast/regions/webkit-named-flow-removed-flow.html:
* platform/chromium-win/fast/regions/region-style-block-background-color2-expected.txt:
* platform/mac/fast/regions/region-style-block-background-color2-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122556 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 00dcbd63
2012-07-13 Andrei Bucur <abucur@adobe.com>
[CSS Regions] Fix the lifecycle for the flow objects and their renderers
https://bugs.webkit.org/show_bug.cgi?id=89000
Reviewed by Eric Seidel.
These tests expected getFlowByName() to return a valid object even for the NULL flows. They've been modified to
reflect the new behavior.
* fast/regions/get-regions-by-content-node2-expected.txt:
* fast/regions/get-regions-by-content-node2.html:
* fast/regions/webkit-named-flow-flow-added.html:
* fast/regions/webkit-named-flow-get-content-expected.txt:
* fast/regions/webkit-named-flow-get-content.html:
* fast/regions/webkit-named-flow-invalid-name.html:
* fast/regions/webkit-named-flow-modified-flow.html:
* fast/regions/webkit-named-flow-non-existing-flow.html:
* fast/regions/webkit-named-flow-removed-flow.html:
* platform/chromium-win/fast/regions/region-style-block-background-color2-expected.txt:
* platform/mac/fast/regions/region-style-block-background-color2-expected.txt:
2012-07-13 Yoshifumi Inoue <yosin@chromium.org>
REGRESSION(r119948): [Forms] Spin button Up/Down actions make value to zero for input type "number" when step mismatched
......@@ -3,7 +3,8 @@ Test for 90759: [CSSRegions] Rename NamedFlow::getRegionsByContentNode to NamedF
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS regionList is null
PASS regionList is non-null.
PASS regionList.length is 0
PASS regionList2 is non-null.
PASS regionList2.length is 0
PASS regionList != regionList2 is true
......
......@@ -27,7 +27,8 @@
// Getting the regions for a non existant node should return null.
var pElement;
var regionList = namedFlow.getRegionsByContent(pElement);
shouldBeNull("regionList");
shouldBeNonNull("regionList");
shouldBeZero("regionList.length");
// Getting the regions for an element that was not added to the dom should return an empty list.
pElement = document.createElement("p");
......
......@@ -43,7 +43,7 @@
function test()
{
namedFlow2 = document.webkitGetFlowByName("flow");
if (namedFlow && namedFlow2) {
if (!namedFlow && namedFlow2) {
document.getElementById("result").innerText = "PASS";
document.getElementById("result").className = "pass";
}
......
......@@ -3,10 +3,7 @@ Test for 90163: [CSSRegions]Rename NamedFlow::contentNodes to NamedFlow::getCont
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS namedFlowContent is non-null.
PASS namedFlowContent.length is 0
PASS namedFlowContent instanceof NodeList is true
PASS namedFlowContent2.length is 0
PASS document.webkitGetFlowByName("flow") is null
PASS namedFlowContent3.length is 1
PASS namedFlowContent3.item(0).id is "article"
PASS namedFlowContent4.length is 1
......@@ -26,12 +23,13 @@ PASS namedFlowContent10.item(0).id is "article"
PASS namedFlowContent11.length is 5
PASS namedFlowContent12.length is 1
PASS namedFlowContent12.item(0).id is "article"
PASS namedFlowContent10.length is 0
PASS namedFlowContent11.length is 0
PASS namedFlowContent12.length is 1
PASS namedFlowContent12.item(0).id is "article"
PASS document.webkitGetFlowByName("flow2") is null
PASS namedFlowContent13.length is 0
PASS namedFlowContent14.length is 0
PASS namedFlowContent15.length is 1
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -21,18 +21,12 @@
window.layoutTestController.dumpAsText();
description("Test for 90163: [CSSRegions]Rename NamedFlow::contentNodes to NamedFlow::getContent()");
// First time ask for a named flow object, the contentNodes should be empty.
var namedFlowContent = document.webkitGetFlowByName("flow").getContent();
shouldBeNonNull("namedFlowContent");
shouldEvaluateTo("namedFlowContent.length", 0);
shouldBeTrue("namedFlowContent instanceof NodeList");
// Add an element that would be collected by the named flow but do not add it to the DOM, the contentNodes should be empty.
var article = document.createElement("div");
article.id = "article";
article.style.webkitFlowInto = "flow";
var namedFlowContent2 = document.webkitGetFlowByName("flow").getContent();
shouldEvaluateTo("namedFlowContent2.length", 0);
shouldBeNull('document.webkitGetFlowByName("flow")');
// Append the above element to the DOM. It will be collected by the flow, therefore the contentNodes should have 1 element.
document.body.appendChild(article);
......@@ -58,8 +52,8 @@
var namedFlowContent5 = document.webkitGetFlowByName("flow").getContent();
shouldEvaluateTo("namedFlowContent5.length", 2);
shouldBeEqualToString("namedFlowContent5.item(0).id", "article2");
shouldBeEqualToString("namedFlowContent5.item(1).id", "article");
shouldBeEqualToString("namedFlowContent5.item(0).id", "article2");
shouldBeEqualToString("namedFlowContent5.item(1).id", "article");
// Adding a region element to flow content into should not influence the content nodes collection.
var regionNode = document.createElement("div");
......@@ -89,16 +83,16 @@
document.getElementById("article").style.display = "none";
var namedFlowContent9 = document.webkitGetFlowByName("flow").getContent();
shouldEvaluateTo("namedFlowContent9.length", 3);
shouldBeEqualToString("namedFlowContent9.item(0).id", "article2");
shouldBeEqualToString("namedFlowContent9.item(1).id", "span1");
shouldBeEqualToString("namedFlowContent9.item(2).id", "article");
shouldBeEqualToString("namedFlowContent9.item(0).id", "article2");
shouldBeEqualToString("namedFlowContent9.item(1).id", "span1");
shouldBeEqualToString("namedFlowContent9.item(2).id", "article");
// Take 'article' node from last position and insert it before 'article2'
article = document.getElementById("article");
document.body.insertBefore(document.body.removeChild(article), article2);
var namedFlowContent10 = document.webkitGetFlowByName("flow").getContent();
shouldEvaluateTo("namedFlowContent10.length", 3);
shouldBeEqualToString("namedFlowContent10.item(0).id", "article");
shouldBeEqualToString("namedFlowContent10.item(0).id", "article");
// Clone 'article2' including its children.
var article2Clone = document.getElementById("article2").cloneNode(true);
......@@ -110,14 +104,11 @@
document.body.removeChild(article2Clone);
var namedFlowContent12 = document.webkitGetFlowByName("flow").getContent();
shouldEvaluateTo("namedFlowContent12.length", 1);
shouldBeEqualToString("namedFlowContent12.item(0).id", "article");
// Get the content nodes for another flow, flow2.
var namedFlowContent10 = document.webkitGetFlowByName("flow2").getContent();
shouldEvaluateTo("namedFlowContent10.length", "0");
shouldBeEqualToString("namedFlowContent12.item(0).id", "article");
// Move the content node 'article' from named flow 'flow' to named flow 'flow2'
document.getElementById("article").style.webkitFlowInto = "flow2";
var flow2 = document.webkitGetFlowByName("flow2");
var namedFlowContent11 = document.webkitGetFlowByName("flow").getContent();
var namedFlowContent12 = document.webkitGetFlowByName("flow2").getContent();
shouldEvaluateTo("namedFlowContent11.length", "0");
......@@ -126,10 +117,16 @@
// Remove the content node from dom, content nodes for both 'flow' and 'flow2' should be empty
document.body.removeChild(document.getElementById("article"));
shouldBeNull('document.webkitGetFlowByName("flow2")');
var namedFlowContent13 = document.webkitGetFlowByName("flow").getContent();
var namedFlowContent14 = document.webkitGetFlowByName("flow2").getContent();
shouldEvaluateTo("namedFlowContent13.length", "0");
var namedFlowContent14 = flow2.getContent();
shouldEvaluateTo("namedFlowContent14.length", "0");
document.body.appendChild(article);
var namedFlowContent15 = flow2.getContent();
shouldEvaluateTo("namedFlowContent15.length", "1");
document.getElementById("region").style.visibility = "hidden";
</script>
......
......@@ -22,9 +22,9 @@
assert(nullNamedFlow == null, "Named flow for " + arrFlowInvalidNames[i] + " should be null");
}
// It should be possible to get the named flow object for a valid flow name.
// It should not be possible to get the NamedFlow object for a missing flow.
var namedFlow = document.webkitGetFlowByName("flow");
assert(namedFlow != null, "Named flow for flow should not be null");
assert(namedFlow == null, "Named flow for flow should be null");
</script>
</body>
</html>
......
......@@ -47,7 +47,7 @@
{
var namedFlow = document.webkitGetFlowByName("flow");
var namedFlow2 = document.webkitGetFlowByName("flow2");
if (namedFlow && namedFlow2) {
if (!namedFlow && namedFlow2) {
document.getElementById("result").innerText = "PASS";
document.getElementById("result").className = "pass";
}
......
......@@ -29,7 +29,7 @@
layoutTestController.dumpAsText();
var namedFlow = document.webkitGetFlowByName("flow");
if (namedFlow) {
if (!namedFlow) {
document.getElementById("result").innerText = "PASS";
document.getElementById("result").className = "pass";
}
......
......@@ -43,7 +43,7 @@
function test()
{
namedFlow2 = document.webkitGetFlowByName("flow");
if (namedFlow && namedFlow2) {
if (namedFlow && !namedFlow2) {
document.getElementById("result").innerText = "PASS";
document.getElementById("result").className = "pass";
}
......
......@@ -29,7 +29,6 @@ Flow Threads
text run at (0,0) width 245: "Green background text styled in region1."
Regions for flow 'flow1'
RenderRegion {DIV} #region1 region style: 1
Thread with flow-name 'flow2'
Thread with flow-name 'flow3'
layer at (0,0) size 280x80
RenderNamedFlowThread at (0,0) size 280x80
......
......@@ -29,7 +29,6 @@ Flow Threads
text run at (0,0) width 258: "Green background text styled in region1."
Regions for flow 'flow1'
RenderRegion {DIV} #region1 region style: 1
Thread with flow-name 'flow2'
Thread with flow-name 'flow3'
layer at (0,0) size 280x80
RenderNamedFlowThread at (0,0) size 280x80
......
......@@ -674,6 +674,7 @@ SET(WebCore_SOURCES
dom/ViewportArguments.cpp
dom/WebKitAnimationEvent.cpp
dom/WebKitNamedFlow.cpp
dom/WebKitNamedFlowCollection.cpp
dom/WebKitTransitionEvent.cpp
dom/WheelEvent.cpp
dom/WindowEventContext.cpp
......
2012-07-13 Andrei Bucur <abucur@adobe.com>
[CSS Regions] Fix the lifecycle for the flow objects and their renderers
https://bugs.webkit.org/show_bug.cgi?id=89000
Reviewed by Eric Seidel.
This patch adds the concept of a NamedFlowCollection, owned by the document, that keeps track of
all the named flows that exist in the Document. This collection contains a ListHashSet of weak references to
all the existing NamedFlows in the document. This is not a managed set because the CREATED flows are referenced from the renderer and
the NULL flows are only cached, they should be destructible.
Two named flows are considered to be equal if they have the same name.
I've changed the NamedFlow state to depend on the existence of its renderer. A flow thread that has a renderer will also have a NamedFlow object.
A flow thread without a renderer can have a NamedFlow object, but only in the NULL state. It's possible for a NamedFlow object to jump from the
NULL state to the CREATED state if it was not destroyed (e.g. it was referenced from JS). Keeping track of the NULL state flows that have listeners will be important
so when they go back to the CREATED state, the listeners would still be there.
Link to spec: http://www.w3.org/TR/2012/WD-css3-regions-20120503/
Tests: The old tests have been modified to take into account the new behavior
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore):
(WebCore::Document::webkitGetFlowByName):
(WebCore::Document::namedFlows):
* dom/Document.h:
(WebCore):
(Document):
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::WebKitNamedFlow):
(WebCore::WebKitNamedFlow::~WebKitNamedFlow):
(WebCore::WebKitNamedFlow::create):
(WebCore):
(WebCore::WebKitNamedFlow::name):
(WebCore::WebKitNamedFlow::overset):
(WebCore::nodeInFlowThread):
(WebCore::WebKitNamedFlow::getRegionsByContentNode):
(WebCore::WebKitNamedFlow::getContent):
(WebCore::WebKitNamedFlow::setRenderer):
* dom/WebKitNamedFlow.h:
(WebCore):
(WebKitNamedFlow):
(WebCore::WebKitNamedFlow::getFlowState):
(WebCore::WebKitNamedFlow::switchFlowState):
* dom/WebKitNamedFlowCollection.cpp: Added.
(WebCore):
(WebCore::WebKitNamedFlowCollection::WebKitNamedFlowCollection):
(WebCore::WebKitNamedFlowCollection::length): An O(1) operation
(WebCore::WebKitNamedFlowCollection::item): An O(N) operation
(WebCore::WebKitNamedFlowCollection::flowByName): An O(1) operation
(WebCore::WebKitNamedFlowCollection::ensureNamedFlowInCreatedState): An O(1) operation
(WebCore::WebKitNamedFlowCollection::moveNamedFlowToNullState): An O(1) operation
(WebCore::WebKitNamedFlowCollection::discardNamedFlow): An O(1) operation
(WebCore::WebKitNamedFlowCollection::documentDestroyed):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashFunctions::hash):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashFunctions::equal):
(WebKitNamedFlowCollection::NamedFlowHashFunctions):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashTranslator::hash):
(WebCore::WebKitNamedFlowCollection::NamedFlowHashTranslator::equal):
* dom/WebKitNamedFlowCollection.h: Copied from Source/WebCore/dom/WebKitNamedFlow.h.
(WebCore):
(WebKitNamedFlowCollection):
(WebCore::WebKitNamedFlowCollection::create):
(WebCore::WebKitNamedFlowCollection::document):
* rendering/FlowThreadController.cpp:
(WebCore::FlowThreadController::ensureRenderFlowThreadWithName):
(WebCore::FlowThreadController::removeFlowThread):
(WebCore):
* rendering/FlowThreadController.h:
(FlowThreadController):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
(WebCore):
(WebCore::RenderNamedFlowThread::~RenderNamedFlowThread):
(WebCore::RenderNamedFlowThread::removeRegionFromThread):
(WebCore::RenderNamedFlowThread::unregisterNamedFlowContentNode):
(WebCore::RenderNamedFlowThread::flowThreadName):
(WebCore::RenderNamedFlowThread::willBeDestroyed):
* rendering/RenderNamedFlowThread.h:
(RenderNamedFlowThread):
(WebCore::RenderNamedFlowThread::contentNodes):
(WebCore::RenderNamedFlowThread::canBeDestroyed):
2012-07-13 Vineet Chaudhary <rgf748@motorola.com>
[V8Bindings] Implement generalised method to validates that the passed object is a sequence type.
......@@ -2077,6 +2077,8 @@ webcore_sources += \
Source/WebCore/dom/WebKitAnimationEvent.h \
Source/WebCore/dom/WebKitNamedFlow.cpp \
Source/WebCore/dom/WebKitNamedFlow.h \
Source/WebCore/dom/WebKitNamedFlowCollection.cpp \
Source/WebCore/dom/WebKitNamedFlowCollection.h \
Source/WebCore/dom/WebKitTransitionEvent.cpp \
Source/WebCore/dom/WebKitTransitionEvent.h \
Source/WebCore/dom/WheelEvent.cpp \
......
......@@ -638,6 +638,7 @@ SOURCES += \
dom/ViewportArguments.cpp \
dom/WebKitAnimationEvent.cpp \
dom/WebKitNamedFlow.cpp \
dom/WebKitNamedFlowCollection.cpp \
dom/WebKitTransitionEvent.cpp \
dom/WheelEvent.cpp \
dom/WindowEventContext.cpp \
......@@ -1820,6 +1821,7 @@ HEADERS += \
dom/ViewportArguments.h \
dom/WebKitAnimationEvent.h \
dom/WebKitNamedFlow.h \
dom/WebKitNamedFlowCollection.h \
dom/WebKitTransitionEvent.h \
dom/WheelEvent.h \
editing/AlternativeTextController.h \
......
......@@ -5298,6 +5298,8 @@
'dom/WebKitAnimationEvent.h',
'dom/WebKitNamedFlow.cpp',
'dom/WebKitNamedFlow.h',
'dom/WebKitNamedFlowCollection.cpp',
'dom/WebKitNamedFlowCollection.h',
'dom/WebKitTransitionEvent.cpp',
'dom/WebKitTransitionEvent.h',
'dom/WheelEvent.cpp',
......
......@@ -54510,6 +54510,62 @@
RelativePath="..\dom\WebKitNamedFlow.h"
>
</File>
<File
RelativePath="..\dom\WebKitNamedFlowCollection.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Cairo_CFLite|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Cairo_CFLite|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_All|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Production|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dom\WebKitNamedFlowCollection.h"
>
</File>
<File
RelativePath="..\dom\WebKitTransitionEvent.cpp"
>
......@@ -281,6 +281,8 @@
0FF50271102BA96A0066F39A /* StyleMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF5026E102BA9660066F39A /* StyleMedia.cpp */; };
0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF5026F102BA96A0066F39A /* StyleMedia.h */; };
10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; };
12F35EB6158745A40035CB63 /* WebKitNamedFlowCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 12F35EB4158745A40035CB63 /* WebKitNamedFlowCollection.h */; };
12F35EB7158745A40035CB63 /* WebKitNamedFlowCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F35EB5158745A40035CB63 /* WebKitNamedFlowCollection.cpp */; };
1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1402645D0AFDC19B005919E2 /* LoggingMac.mm */; };
1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1403B99609EB13AF00797C7F /* DOMWindow.cpp */; };
......@@ -7233,6 +7235,8 @@
0FF5026F102BA96A0066F39A /* StyleMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleMedia.h; sourceTree = "<group>"; };
0FF50270102BA96A0066F39A /* StyleMedia.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = StyleMedia.idl; sourceTree = "<group>"; };
10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = "<group>"; };
12F35EB4158745A40035CB63 /* WebKitNamedFlowCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNamedFlowCollection.h; sourceTree = "<group>"; };
12F35EB5158745A40035CB63 /* WebKitNamedFlowCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitNamedFlowCollection.cpp; sourceTree = "<group>"; };
1402645D0AFDC19B005919E2 /* LoggingMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingMac.mm; sourceTree = "<group>"; };
1403B90C09EB124500797C7F /* DOMWindow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindow.idl; sourceTree = "<group>"; };
1403B99509EB13AF00797C7F /* DOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindow.h; sourceTree = "<group>"; };
......@@ -21630,6 +21634,8 @@
93EEC1F709C2877700C515D1 /* WheelEvent.idl */,
4123E568127B3041000FEEA7 /* WindowEventContext.cpp */,
4123E567127B3041000FEEA7 /* WindowEventContext.h */,
12F35EB4158745A40035CB63 /* WebKitNamedFlowCollection.h */,
12F35EB5158745A40035CB63 /* WebKitNamedFlowCollection.cpp */,
);
path = dom;
sourceTree = "<group>";
......@@ -25090,6 +25096,7 @@
0562F9471573ECEB0031CA16 /* WebKitCSSSVGDocumentValue.h in Headers */,
BC9ADD230CC4032600098C4C /* WebKitCSSTransformValue.h in Headers */,
89878566122CA064003AABDA /* WebKitFlags.h in Headers */,
12F35EB6158745A40035CB63 /* WebKitNamedFlowCollection.h in Headers */,
494BD7950F55C8EE00747828 /* WebKitPoint.h in Headers */,
31C0FF250E4CEB6E007D6FE5 /* WebKitTransitionEvent.h in Headers */,
0FCF332F0F2B9A25004B6795 /* WebLayer.h in Headers */,
......@@ -28159,6 +28166,7 @@
BC9ADD800CC4092200098C4C /* WebKitCSSTransformValue.cpp in Sources */,
1A1414B513A0F0500019996C /* WebKitFontFamilyNames.cpp in Sources */,
D7613A501474F13F00DB8606 /* WebKitNamedFlow.cpp in Sources */,
12F35EB7158745A40035CB63 /* WebKitNamedFlowCollection.cpp in Sources */,
31C0FF240E4CEB6E007D6FE5 /* WebKitTransitionEvent.cpp in Sources */,
0FCF332E0F2B9A25004B6795 /* WebLayer.mm in Sources */,
E1A3162E134BC32D007C9A4F /* WebNSAttributedStringExtras.mm in Sources */,
......@@ -144,6 +144,7 @@
#include "ViewportArguments.cpp"
#include "WebKitAnimationEvent.cpp"
#include "WebKitNamedFlow.cpp"
#include "WebKitNamedFlowCollection.cpp"
#include "WebKitTransitionEvent.cpp"
#include "WheelEvent.cpp"
#include "WindowEventContext.cpp"
......
......@@ -157,6 +157,7 @@
#include "UndoManager.h"
#include "UserContentURLPattern.h"
#include "WebKitNamedFlow.h"
#include "WebKitNamedFlowCollection.h"
#include "XMLDocumentParser.h"
#include "XMLHttpRequest.h"
#include "XMLNSNames.h"
......@@ -618,6 +619,9 @@ Document::~Document()
if (m_styleSheets)
m_styleSheets->documentDestroyed();
if (m_namedFlows)
m_namedFlows->documentDestroyed();
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
if (m_pageUserSheet)
......@@ -1126,44 +1130,26 @@ bool Document::cssGridLayoutEnabled() const
#if ENABLE(CSS_REGIONS)
static bool validFlowName(const String& flowName)
{
if (equalIgnoringCase(flowName, "auto")
|| equalIgnoringCase(flowName, "default")
|| equalIgnoringCase(flowName, "inherit")
|| equalIgnoringCase(flowName, "initial")
|| equalIgnoringCase(flowName, "none"))
return false;
return true;
}
PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName)
{
return webkitGetFlowByName(flowName, CheckFlowNameForInvalidValues);
}
PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName, FlowNameCheck flowNameCheck)
{
if (!cssRegionsEnabled() || !renderer())
return 0;
if (flowNameCheck == CheckFlowNameForInvalidValues) {
if (flowName.isEmpty() || !validFlowName(flowName))
return 0;
// Make a slower check for invalid flow name.
CSSParser parser(document());
if (!parser.parseFlowThread(flowName))
return 0;
}
// It's possible to have pending styles not applied that affect the existing flows.
updateStyleIfNeeded();
if (RenderView* view = renderer()->view())
return view->flowThreadController()->ensureRenderFlowThreadWithName(flowName)->ensureNamedFlow();
return 0;
return namedFlows()->flowByName(flowName);
}
#endif
WebKitNamedFlowCollection* Document::namedFlows()
{
if (!m_namedFlows)
m_namedFlows = WebKitNamedFlowCollection::create(this);
return m_namedFlows.get();
}
PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode& ec)
{
String prefix, localName;
......
......@@ -137,6 +137,7 @@ class TextResourceDecoder;
class TreeWalker;
class UndoManager;
class WebKitNamedFlow;
class WebKitNamedFlowCollection;
class XMLHttpRequest;
class XPathEvaluator;
class XPathExpression;
......@@ -347,14 +348,11 @@ public:
bool cssRegionsEnabled() const;
#if ENABLE(CSS_REGIONS)
enum FlowNameCheck {
CheckFlowNameForInvalidValues,
DoNotCheckFlowNameForInvalidValues
};
PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&);
PassRefPtr<WebKitNamedFlow> webkitGetFlowByName(const String&, FlowNameCheck);
#endif
WebKitNamedFlowCollection* namedFlows();
bool regionBasedColumnsEnabled() const;
bool cssGridLayoutEnabled() const;
......@@ -1533,6 +1531,8 @@ private:
bool m_visualUpdatesAllowed;
Timer<Document> m_visualUpdatesSuppressionTimer;
RefPtr<WebKitNamedFlowCollection> m_namedFlows;
#ifndef NDEBUG
bool m_didDispatchViewportPropertiesChanged;
#endif
......
......@@ -33,32 +33,56 @@
#include "RenderNamedFlowThread.h"
#include "RenderRegion.h"
#include "StaticNodeList.h"
#include "WebKitNamedFlowCollection.h"
namespace WebCore {
WebKitNamedFlow::WebKitNamedFlow(RenderNamedFlowThread* parentFlowThread)
: m_parentFlowThread(parentFlowThread)
WebKitNamedFlow::WebKitNamedFlow(PassRefPtr<WebKitNamedFlowCollection> manager, const AtomicString& flowThreadName)
: m_flowThreadName(flowThreadName)
, m_flowManager(manager)
, m_parentFlowThread(0)
, m_state(FlowStateCreated)
{
}
WebKitNamedFlow::~WebKitNamedFlow()
{
// The named flow is not "strong" referenced from anywhere at this time so it shouldn't be reused if the named flow is recreated.
m_flowManager->discardNamedFlow(this);
}
String WebKitNamedFlow::name() const
PassRefPtr<WebKitNamedFlow> WebKitNamedFlow::create(PassRefPtr<WebKitNamedFlowCollection> manager, const AtomicString& flowThreadName)
{
return m_parentFlowThread->flowThreadName();
return adoptRef(new WebKitNamedFlow(manager, flowThreadName));
}
const AtomicString& WebKitNamedFlow::name() const
{