[CSS Regions] Fix the lifecycle for the flow objects and their renderers
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2012 10:01:38 +0000 (10:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2012 10:01:38 +0000 (10:01 +0000)
commit462bbed9db88a63df22203e8753de99951fcef81
tree46b97477cdc8acfebe1ec5924a72ae9f6fd4bc5a
parent8fe4bc9efb17b365989a13351b0bc25fcb154903
[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: https://svn.webkit.org/repository/webkit/trunk@122556 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/regions/get-regions-by-content2-expected.txt
LayoutTests/fast/regions/get-regions-by-content2.html
LayoutTests/fast/regions/webkit-named-flow-flow-added.html
LayoutTests/fast/regions/webkit-named-flow-get-content-expected.txt
LayoutTests/fast/regions/webkit-named-flow-get-content.html
LayoutTests/fast/regions/webkit-named-flow-invalid-name.html
LayoutTests/fast/regions/webkit-named-flow-modified-flow.html
LayoutTests/fast/regions/webkit-named-flow-non-existing-flow.html
LayoutTests/fast/regions/webkit-named-flow-removed-flow.html
LayoutTests/platform/chromium-win/fast/regions/region-style-block-background-color2-expected.txt
LayoutTests/platform/mac/fast/regions/region-style-block-background-color2-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/WebKitNamedFlow.cpp
Source/WebCore/dom/WebKitNamedFlow.h
Source/WebCore/dom/WebKitNamedFlowCollection.cpp [new file with mode: 0644]
Source/WebCore/dom/WebKitNamedFlowCollection.h [new file with mode: 0644]
Source/WebCore/rendering/FlowThreadController.cpp
Source/WebCore/rendering/FlowThreadController.h
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderNamedFlowThread.h