Skip to content
  • commit-queue@webkit.org's avatar
    [CSS Regions] Fix the lifecycle for the flow objects and their renderers · 5323f76d
    commit-queue@webkit.org authored
    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
    5323f76d