[CSS Regions]Add helper class for flow threads info in RenderView
authormihnea@adobe.com <mihnea@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 09:41:37 +0000 (09:41 +0000)
committermihnea@adobe.com <mihnea@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 09:41:37 +0000 (09:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83464

Reviewed by David Hyatt.

This patch creates a new helper class FlowThreadController that will accommodate all the flow thread
related info from RenderView and moves all the data structures/methods from RenderView into this new class.
There is only one FlowThreadController object per RenderView and it can be retrieved using flowThreadController() method from RenderView.
The flow thread controller object is owned by the RenderView and it is created on demand only if there are flowing
threads in the page.

Since there is no change in functionality, there are no new tests added.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::webkitGetFlowByName):
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::moveToFlowThreadIfNeeded):
* rendering/FlowThreadController.cpp: Added.
(WebCore):
(WebCore::FlowThreadController::create):
(WebCore::FlowThreadController::FlowThreadController):
(WebCore::FlowThreadController::~FlowThreadController):
(WebCore::FlowThreadController::ensureRenderFlowThreadWithName):
(WebCore::FlowThreadController::layoutRenderNamedFlowThreads):
* rendering/FlowThreadController.h: Added.
(WebCore):
(FlowThreadController):
(WebCore::FlowThreadController::currentRenderFlowThread):
(WebCore::FlowThreadController::setCurrentRenderFlowThread):
(WebCore::FlowThreadController::isRenderNamedFlowThreadOrderDirty):
(WebCore::FlowThreadController::setIsRenderNamedFlowThreadOrderDirty):
(WebCore::FlowThreadController::renderNamedFlowThreadList):
(WebCore::FlowThreadController::hasRenderNamedFlowThreads):
* rendering/RenderFlowThread.cpp:
(WebCore::CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer):
(WebCore::CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer):
(WebCore::CurrentRenderFlowThreadDisabler::CurrentRenderFlowThreadDisabler):
(WebCore::CurrentRenderFlowThreadDisabler::~CurrentRenderFlowThreadDisabler):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::nextRendererForNode):
(WebCore::RenderNamedFlowThread::previousRendererForNode):
(WebCore::RenderNamedFlowThread::removeRegionFromThread):
(WebCore::RenderNamedFlowThread::addDependencyOnFlowThread):
(WebCore::RenderNamedFlowThread::removeDependencyOnFlowThread):
* rendering/RenderNamedFlowThread.h:
(RenderNamedFlowThread):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::createObject):
(WebCore::RenderObject::enclosingRenderFlowThread):
(WebCore::RenderObject::willBeDestroyed):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeRenderNamedFlowThreads):
* rendering/RenderView.cpp:
(WebCore::RenderView::RenderView):
(WebCore::RenderView::layout):
(WebCore::RenderView::hasRenderNamedFlowThreads):
(WebCore::RenderView::flowThreadController):
* rendering/RenderView.h:
(WebCore):
(RenderView):

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

18 files changed:
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/Document.cpp
Source/WebCore/dom/NodeRenderingContext.cpp
Source/WebCore/rendering/FlowThreadController.cpp [new file with mode: 0644]
Source/WebCore/rendering/FlowThreadController.h [new file with mode: 0644]
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderNamedFlowThread.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h

index 10c185f..8c6bdf0 100644 (file)
@@ -1285,6 +1285,7 @@ SET(WebCore_SOURCES
     rendering/EllipsisBox.cpp
     rendering/FilterEffectRenderer.cpp
     rendering/FixedTableLayout.cpp
+    rendering/FlowThreadController.cpp
     rendering/HitTestingTransformState.cpp
     rendering/HitTestResult.cpp
     rendering/InlineBox.cpp
index 51ca55a..04705eb 100644 (file)
@@ -1,3 +1,72 @@
+2012-04-11  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSS Regions]Add helper class for flow threads info in RenderView
+        https://bugs.webkit.org/show_bug.cgi?id=83464
+
+        Reviewed by David Hyatt.
+
+        This patch creates a new helper class FlowThreadController that will accommodate all the flow thread
+        related info from RenderView and moves all the data structures/methods from RenderView into this new class.
+        There is only one FlowThreadController object per RenderView and it can be retrieved using flowThreadController() method from RenderView.
+        The flow thread controller object is owned by the RenderView and it is created on demand only if there are flowing
+        threads in the page.
+
+        Since there is no change in functionality, there are no new tests added.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::Document::webkitGetFlowByName):
+        * dom/NodeRenderingContext.cpp:
+        (WebCore::NodeRenderingContext::moveToFlowThreadIfNeeded):
+        * rendering/FlowThreadController.cpp: Added.
+        (WebCore):
+        (WebCore::FlowThreadController::create):
+        (WebCore::FlowThreadController::FlowThreadController):
+        (WebCore::FlowThreadController::~FlowThreadController):
+        (WebCore::FlowThreadController::ensureRenderFlowThreadWithName):
+        (WebCore::FlowThreadController::layoutRenderNamedFlowThreads):
+        * rendering/FlowThreadController.h: Added.
+        (WebCore):
+        (FlowThreadController):
+        (WebCore::FlowThreadController::currentRenderFlowThread):
+        (WebCore::FlowThreadController::setCurrentRenderFlowThread):
+        (WebCore::FlowThreadController::isRenderNamedFlowThreadOrderDirty):
+        (WebCore::FlowThreadController::setIsRenderNamedFlowThreadOrderDirty):
+        (WebCore::FlowThreadController::renderNamedFlowThreadList):
+        (WebCore::FlowThreadController::hasRenderNamedFlowThreads):
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer):
+        (WebCore::CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer):
+        (WebCore::CurrentRenderFlowThreadDisabler::CurrentRenderFlowThreadDisabler):
+        (WebCore::CurrentRenderFlowThreadDisabler::~CurrentRenderFlowThreadDisabler):
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::nextRendererForNode):
+        (WebCore::RenderNamedFlowThread::previousRendererForNode):
+        (WebCore::RenderNamedFlowThread::removeRegionFromThread):
+        (WebCore::RenderNamedFlowThread::addDependencyOnFlowThread):
+        (WebCore::RenderNamedFlowThread::removeDependencyOnFlowThread):
+        * rendering/RenderNamedFlowThread.h:
+        (RenderNamedFlowThread):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::createObject):
+        (WebCore::RenderObject::enclosingRenderFlowThread):
+        (WebCore::RenderObject::willBeDestroyed):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::writeRenderNamedFlowThreads):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::RenderView):
+        (WebCore::RenderView::layout):
+        (WebCore::RenderView::hasRenderNamedFlowThreads):
+        (WebCore::RenderView::flowThreadController):
+        * rendering/RenderView.h:
+        (WebCore):
+        (RenderView):
+
 2012-04-11  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: [Device Metrics] Implement dimension swapping
index be78d6e..9d78218 100644 (file)
@@ -3674,6 +3674,8 @@ webcore_sources += \
        Source/WebCore/rendering/FilterEffectRenderer.h \
        Source/WebCore/rendering/FixedTableLayout.cpp \
        Source/WebCore/rendering/FixedTableLayout.h \
+       Source/WebCore/rendering/FlowThreadController.cpp \
+       Source/WebCore/rendering/FlowThreadController.h \
        Source/WebCore/rendering/GapRects.h \
        Source/WebCore/rendering/HitTestRequest.h \
        Source/WebCore/rendering/HitTestingTransformState.cpp \
index 9e6ab93..c217622 100644 (file)
@@ -1213,6 +1213,7 @@ SOURCES += \
     rendering/EllipsisBox.cpp \
     rendering/FilterEffectRenderer.cpp \
     rendering/FixedTableLayout.cpp \
+    rendering/FlowThreadController.cpp \
     rendering/HitTestingTransformState.cpp \
     rendering/HitTestResult.cpp \
     rendering/InlineBox.cpp \
index f19d0cf..ad2defb 100644 (file)
             'plugins/nptypes.h',
             'rendering/ColumnInfo.h',
             'rendering/GapRects.h',
+            'rendering/FlowThreadController.h',
             'rendering/HitTestRequest.h',
             'rendering/HitTestResult.h',
             'rendering/InlineBox.h',
             'rendering/FilterEffectRenderer.h',
             'rendering/FixedTableLayout.cpp',
             'rendering/FixedTableLayout.h',
+            'rendering/FlowThreadController.cpp',
+            'rendering/FlowThreadController.h',
             'rendering/HitTestingTransformState.cpp',
             'rendering/HitTestingTransformState.h',
             'rendering/HitTestResult.cpp',
index 0edd165..c5e2727 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\rendering\FlowThreadController.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\rendering\FlowThreadController.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\rendering\GapRects.h"
                                >
                        </File>
index b975bff..49bfa96 100644 (file)
                D6FDAEF3149C06190037B1E1 /* HistogramSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D6FDAEF2149C06190037B1E1 /* HistogramSupport.cpp */; };
                D70AD65713E1342B005B50B4 /* RenderRegion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D70AD65513E1342B005B50B4 /* RenderRegion.cpp */; };
                D70AD65813E1342B005B50B4 /* RenderRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = D70AD65613E1342B005B50B4 /* RenderRegion.h */; };
+               D72F6D79153159A3001EE44E /* FlowThreadController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D72F6D77153159A3001EE44E /* FlowThreadController.cpp */; };
+               D72F6D7A153159A3001EE44E /* FlowThreadController.h in Headers */ = {isa = PBXBuildFile; fileRef = D72F6D78153159A3001EE44E /* FlowThreadController.h */; };
                D7613A501474F13F00DB8606 /* WebKitNamedFlow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D7613A4E1474F13F00DB8606 /* WebKitNamedFlow.cpp */; };
                D7613AC414753E5600DB8606 /* JSWebKitNamedFlow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D7613AC214753E5600DB8606 /* JSWebKitNamedFlow.cpp */; };
                D8B6152F1032495100C8554A /* Cookie.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B6152E1032495100C8554A /* Cookie.h */; settings = {ATTRIBUTES = (Private, ); }; };
                D6FDAEF2149C06190037B1E1 /* HistogramSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HistogramSupport.cpp; sourceTree = "<group>"; };
                D70AD65513E1342B005B50B4 /* RenderRegion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderRegion.cpp; sourceTree = "<group>"; };
                D70AD65613E1342B005B50B4 /* RenderRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderRegion.h; sourceTree = "<group>"; };
+               D72F6D77153159A3001EE44E /* FlowThreadController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlowThreadController.cpp; sourceTree = "<group>"; };
+               D72F6D78153159A3001EE44E /* FlowThreadController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlowThreadController.h; sourceTree = "<group>"; };
                D7613A4A1474EE9500DB8606 /* WebKitNamedFlow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitNamedFlow.idl; sourceTree = "<group>"; };
                D7613A4D1474F13F00DB8606 /* WebKitNamedFlow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNamedFlow.h; sourceTree = "<group>"; };
                D7613A4E1474F13F00DB8606 /* WebKitNamedFlow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitNamedFlow.cpp; sourceTree = "<group>"; };
                                31313F641443B35E006E2A90 /* FilterEffectRenderer.h */,
                                A8CFF0480A154F09000A4234 /* FixedTableLayout.cpp */,
                                A8CFF04A0A154F09000A4234 /* FixedTableLayout.h */,
+                               D72F6D77153159A3001EE44E /* FlowThreadController.cpp */,
+                               D72F6D78153159A3001EE44E /* FlowThreadController.h */,
                                935C477409AC4D8D00A6AAB4 /* GapRects.h */,
                                4969B0F013D0B33F00DF3521 /* HitTestingTransformState.cpp */,
                                4969B0F113D0B33F00DF3521 /* HitTestingTransformState.h */,
                                A07D3358152B632D001B6393 /* WebGLShaderPrecisionFormat.h in Headers */,
                                C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
                                CEDA12D7152CA1CB00D9E08D /* AlternativeTextClient.h in Headers */,
+                               D72F6D7A153159A3001EE44E /* FlowThreadController.h in Headers */,
                                5740E83D1532DE1700760628 /* TreeScopeAdjuster.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                A07D3355152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp in Sources */,
                                A08CF154152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp in Sources */,
                                C5A1EA7C152BCF04004D00B6 /* SimplifyMarkupCommand.cpp in Sources */,
+                               D72F6D79153159A3001EE44E /* FlowThreadController.cpp in Sources */,
                                5740E83C1532DE1700760628 /* TreeScopeAdjuster.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
index 98c573d..bbe9443 100644 (file)
@@ -68,6 +68,7 @@
 #include "EventListener.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
+#include "FlowThreadController.h"
 #include "FocusController.h"
 #include "FormAssociatedElement.h"
 #include "Frame.h"
@@ -1083,7 +1084,7 @@ PassRefPtr<WebKitNamedFlow> Document::webkitGetFlowByName(const String& flowName
         return 0;
 
     if (RenderView* view = renderer()->view())
-        return view->ensureRenderFlowThreadWithName(flowName)->ensureNamedFlow();
+        return view->flowThreadController()->ensureRenderFlowThreadWithName(flowName)->ensureNamedFlow();
     return 0;
 }
 
index 2ef6fd4..1537de7 100644 (file)
@@ -27,6 +27,7 @@
 #include "NodeRenderingContext.h"
 
 #include "ContainerNode.h"
+#include "FlowThreadController.h"
 #include "HTMLContentElement.h"
 #include "HTMLContentSelector.h"
 #include "HTMLNames.h"
@@ -326,7 +327,7 @@ void NodeRenderingContext::moveToFlowThreadIfNeeded()
 
     m_flowThread = m_style->flowThread();
     ASSERT(m_node->document()->renderView());
-    m_parentFlowRenderer = m_node->document()->renderView()->ensureRenderFlowThreadWithName(m_flowThread);
+    m_parentFlowRenderer = m_node->document()->renderView()->flowThreadController()->ensureRenderFlowThreadWithName(m_flowThread);
 }
 
 NodeRendererFactory::NodeRendererFactory(Node* node)
diff --git a/Source/WebCore/rendering/FlowThreadController.cpp b/Source/WebCore/rendering/FlowThreadController.cpp
new file mode 100644 (file)
index 0000000..88030a7
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials
+ *    provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "FlowThreadController.h"
+
+#include "RenderFlowThread.h"
+#include "RenderNamedFlowThread.h"
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+PassOwnPtr<FlowThreadController> FlowThreadController::create(RenderView* view)
+{
+    return adoptPtr(new FlowThreadController(view));
+}
+
+FlowThreadController::FlowThreadController(RenderView* view)
+    : m_view(view)
+    , m_currentRenderFlowThread(0)
+    , m_isRenderNamedFlowThreadOrderDirty(false)
+{
+}
+
+FlowThreadController::~FlowThreadController()
+{
+}
+
+RenderNamedFlowThread* FlowThreadController::ensureRenderFlowThreadWithName(const AtomicString& name)
+{
+    if (!m_renderNamedFlowThreadList)
+        m_renderNamedFlowThreadList = adoptPtr(new RenderNamedFlowThreadList());
+    else {
+        for (RenderNamedFlowThreadList::iterator iter = m_renderNamedFlowThreadList->begin(); iter != m_renderNamedFlowThreadList->end(); ++iter) {
+            RenderNamedFlowThread* flowRenderer = *iter;
+            if (flowRenderer->flowThreadName() == name)
+                return flowRenderer;
+        }
+    }
+
+    RenderNamedFlowThread* flowRenderer = new (m_view->renderArena()) RenderNamedFlowThread(m_view->document(), name);
+    flowRenderer->setStyle(RenderFlowThread::createFlowThreadStyle(m_view->style()));
+    m_renderNamedFlowThreadList->add(flowRenderer);
+
+    // Keep the flow renderer as a child of RenderView.
+    m_view->addChild(flowRenderer);
+
+    setIsRenderNamedFlowThreadOrderDirty(true);
+
+    return flowRenderer;
+}
+
+void FlowThreadController::layoutRenderNamedFlowThreads()
+{
+    ASSERT(m_renderNamedFlowThreadList);
+
+    if (isRenderNamedFlowThreadOrderDirty()) {
+        // Arrange the thread list according to dependencies.
+        RenderNamedFlowThreadList sortedList;
+        for (RenderNamedFlowThreadList::iterator iter = m_renderNamedFlowThreadList->begin(); iter != m_renderNamedFlowThreadList->end(); ++iter) {
+            RenderNamedFlowThread* flowRenderer = *iter;
+            if (sortedList.contains(flowRenderer))
+                continue;
+            flowRenderer->pushDependencies(sortedList);
+            sortedList.add(flowRenderer);
+        }
+        m_renderNamedFlowThreadList->swap(sortedList);
+        setIsRenderNamedFlowThreadOrderDirty(false);
+    }
+
+    for (RenderNamedFlowThreadList::iterator iter = m_renderNamedFlowThreadList->begin(); iter != m_renderNamedFlowThreadList->end(); ++iter) {
+        RenderNamedFlowThread* flowRenderer = *iter;
+        flowRenderer->layoutIfNeeded();
+    }
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/rendering/FlowThreadController.h b/Source/WebCore/rendering/FlowThreadController.h
new file mode 100644 (file)
index 0000000..e3750ca
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials
+ *    provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef FlowThreadController_h
+#define FlowThreadController_h
+
+#include "RenderView.h"
+#include <wtf/ListHashSet.h>
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+class RenderFlowThread;
+class RenderNamedFlowThread;
+
+typedef ListHashSet<RenderNamedFlowThread*> RenderNamedFlowThreadList;
+
+class FlowThreadController {
+public:
+    static PassOwnPtr<FlowThreadController> create(RenderView*);
+    ~FlowThreadController();
+
+    RenderFlowThread* currentRenderFlowThread() const { return m_currentRenderFlowThread; }
+    void setCurrentRenderFlowThread(RenderFlowThread* flowThread) { m_currentRenderFlowThread = flowThread; }
+
+    bool isRenderNamedFlowThreadOrderDirty() const { return m_isRenderNamedFlowThreadOrderDirty; }
+    void setIsRenderNamedFlowThreadOrderDirty(bool dirty)
+    {
+        m_isRenderNamedFlowThreadOrderDirty = dirty;
+        if (dirty)
+            m_view->setNeedsLayout(true);
+    }
+
+    RenderNamedFlowThread* ensureRenderFlowThreadWithName(const AtomicString&);
+    const RenderNamedFlowThreadList* renderNamedFlowThreadList() const { return m_renderNamedFlowThreadList.get(); }
+    bool hasRenderNamedFlowThreads() const { return m_renderNamedFlowThreadList && !m_renderNamedFlowThreadList->isEmpty(); }
+    void layoutRenderNamedFlowThreads();
+
+protected:
+    FlowThreadController(RenderView*);
+
+private:
+    RenderView* m_view;
+    RenderFlowThread* m_currentRenderFlowThread;
+    bool m_isRenderNamedFlowThreadOrderDirty;
+    OwnPtr<RenderNamedFlowThreadList> m_renderNamedFlowThreadList;
+};
+
+}
+
+#endif
index 122b9e0..393964a 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "RenderFlowThread.h"
 
+#include "FlowThreadController.h"
 #include "HitTestRequest.h"
 #include "HitTestResult.h"
 #include "Node.h"
@@ -114,14 +115,14 @@ public:
         : m_renderFlowThread(renderFlowThread)
     {
         RenderView* view = m_renderFlowThread->view();
-        ASSERT(!view->currentRenderFlowThread());
-        view->setCurrentRenderFlowThread(m_renderFlowThread);
+        ASSERT(!view->flowThreadController()->currentRenderFlowThread());
+        view->flowThreadController()->setCurrentRenderFlowThread(m_renderFlowThread);
     }
     ~CurrentRenderFlowThreadMaintainer()
     {
         RenderView* view = m_renderFlowThread->view();
-        ASSERT(view->currentRenderFlowThread() == m_renderFlowThread);
-        view->setCurrentRenderFlowThread(0);
+        ASSERT(view->flowThreadController()->currentRenderFlowThread() == m_renderFlowThread);
+        view->flowThreadController()->setCurrentRenderFlowThread(0);
     }
 private:
     RenderFlowThread* m_renderFlowThread;
@@ -134,14 +135,14 @@ public:
         : m_view(view)
         , m_renderFlowThread(0)
     {
-        m_renderFlowThread = m_view->currentRenderFlowThread();
+        m_renderFlowThread = m_view->flowThreadController()->currentRenderFlowThread();
         if (m_renderFlowThread)
-            view->setCurrentRenderFlowThread(0);
+            view->flowThreadController()->setCurrentRenderFlowThread(0);
     }
     ~CurrentRenderFlowThreadDisabler()
     {
         if (m_renderFlowThread)
-            m_view->setCurrentRenderFlowThread(m_renderFlowThread);
+            m_view->flowThreadController()->setCurrentRenderFlowThread(m_renderFlowThread);
     }
 private:
     RenderView* m_view;
index dab5d7b..948deb0 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "RenderNamedFlowThread.h"
 
+#include "FlowThreadController.h"
 #include "RenderRegion.h"
 #include "RenderView.h"
 #include "WebKitNamedFlow.h"
@@ -48,7 +49,7 @@ RenderObject* RenderNamedFlowThread::nextRendererForNode(Node* node) const
 {
     FlowThreadChildList::const_iterator it = m_flowThreadChildList.begin();
     FlowThreadChildList::const_iterator end = m_flowThreadChildList.end();
-    
+
     for (; it != end; ++it) {
         RenderObject* child = *it;
         ASSERT(child->node());
@@ -56,7 +57,7 @@ RenderObject* RenderNamedFlowThread::nextRendererForNode(Node* node) const
         if (position & Node::DOCUMENT_POSITION_FOLLOWING)
             return child;
     }
-    
+
     return 0;
 }
 
@@ -64,11 +65,11 @@ RenderObject* RenderNamedFlowThread::previousRendererForNode(Node* node) const
 {
     if (m_flowThreadChildList.isEmpty())
         return 0;
-    
+
     FlowThreadChildList::const_iterator begin = m_flowThreadChildList.begin();
     FlowThreadChildList::const_iterator end = m_flowThreadChildList.end();
     FlowThreadChildList::const_iterator it = end;
-    
+
     do {
         --it;
         RenderObject* child = *it;
@@ -77,7 +78,7 @@ RenderObject* RenderNamedFlowThread::previousRendererForNode(Node* node) const
         if (position & Node::DOCUMENT_POSITION_PRECEDING)
             return child;
     } while (it != begin);
-    
+
     return 0;
 }
 
@@ -180,7 +181,7 @@ void RenderNamedFlowThread::removeRegionFromThread(RenderRegion* renderRegion)
         }
         removeDependencyOnFlowThread(renderRegion->parentNamedFlowThread());
     }
-    
+
     invalidateRegions();
 }
 
@@ -220,7 +221,7 @@ void RenderNamedFlowThread::addDependencyOnFlowThread(RenderNamedFlowThread* oth
     RenderNamedFlowThreadCountedSet::AddResult result = m_layoutBeforeThreadsSet.add(otherFlowThread);
     if (result.isNewEntry) {
         // This is the first time we see this dependency. Make sure we recalculate all the dependencies.
-        view()->setIsRenderNamedFlowThreadOrderDirty(true);
+        view()->flowThreadController()->setIsRenderNamedFlowThreadOrderDirty(true);
     }
 }
 
@@ -229,7 +230,7 @@ void RenderNamedFlowThread::removeDependencyOnFlowThread(RenderNamedFlowThread*
     bool removed = m_layoutBeforeThreadsSet.remove(otherFlowThread);
     if (removed) {
         checkInvalidRegions();
-        view()->setIsRenderNamedFlowThreadOrderDirty(true);
+        view()->flowThreadController()->setIsRenderNamedFlowThreadOrderDirty(true);
     }
 }
 
index ce8befd..3da9d41 100644 (file)
@@ -43,9 +43,9 @@ typedef HashCountedSet<RenderNamedFlowThread*> RenderNamedFlowThreadCountedSet;
 class RenderNamedFlowThread : public RenderFlowThread {
 public:
     RenderNamedFlowThread(Node*, const AtomicString&);
-    
+
     AtomicString flowThreadName() const { return m_flowThreadName; }
-    
+
     RenderObject* nextRendererForNode(Node*) const;
     RenderObject* previousRendererForNode(Node*) const;
 
@@ -57,7 +57,7 @@ public:
 #endif
 
     void pushDependencies(RenderNamedFlowThreadList&);
-    
+
     virtual void addRegionToThread(RenderRegion*) OVERRIDE;
     virtual void removeRegionFromThread(RenderRegion*) OVERRIDE;
 
@@ -75,7 +75,7 @@ private:
 private:
     // The name of the flow thread as specified in CSS.
     AtomicString m_flowThreadName;
-        
+
     // Observer flow threads have invalid regions that depend on the state of this thread
     // to re-validate their regions. Keeping a set of observer threads make it easy
     // to notify them when a region was removed from this flow.
@@ -89,7 +89,7 @@ private:
     // Holds the sorted children of a named flow. This is the only way we can get the ordering right.
     typedef ListHashSet<RenderObject*> FlowThreadChildList;
     FlowThreadChildList m_flowThreadChildList;
-    
+
     // The DOM Object that represents a named flow.
     RefPtr<WebKitNamedFlow> m_namedFlow;
 };
index c3e2d55..f1e00ba 100755 (executable)
@@ -35,6 +35,7 @@
 #include "DashArray.h"
 #include "EditingBoundary.h"
 #include "FloatQuad.h"
+#include "FlowThreadController.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
@@ -161,7 +162,7 @@ RenderObject* RenderObject::createObject(Node* node, RenderStyle* style)
     case COMPACT:
         // Only non-replaced block elements can become a region.
         if (doc->cssRegionsEnabled() && !style->regionThread().isEmpty() && doc->renderView())
-            return new (arena) RenderRegion(node, doc->renderView()->ensureRenderFlowThreadWithName(style->regionThread()));
+            return new (arena) RenderRegion(node, doc->renderView()->flowThreadController()->ensureRenderFlowThreadWithName(style->regionThread()));
         if ((!style->hasAutoColumnCount() || !style->hasAutoColumnWidth()) && doc->regionBasedColumnsEnabled())
             return new (arena) RenderMultiColumnBlock(node);
         return new (arena) RenderBlock(node);
@@ -564,7 +565,7 @@ RenderFlowThread* RenderObject::enclosingRenderFlowThread() const
         return 0;
     
     // See if we have the thread cached because we're in the middle of layout.
-    RenderFlowThread* flowThread = view()->currentRenderFlowThread();
+    RenderFlowThread* flowThread = view()->flowThreadController()->currentRenderFlowThread();
     if (flowThread)
         return flowThread;
     
@@ -2289,7 +2290,7 @@ void RenderObject::willBeDestroyed()
 #ifndef NDEBUG
     if (!documentBeingDestroyed() && view() && view()->hasRenderNamedFlowThreads()) {
         // After remove, the object and the associated information should not be in any flow thread.
-        const RenderNamedFlowThreadList* flowThreadList = view()->renderNamedFlowThreadList();
+        const RenderNamedFlowThreadList* flowThreadList = view()->flowThreadController()->renderNamedFlowThreadList();
         for (RenderNamedFlowThreadList::const_iterator iter = flowThreadList->begin(); iter != flowThreadList->end(); ++iter) {
             const RenderNamedFlowThread* renderFlowThread = *iter;
             ASSERT(!renderFlowThread->hasChild(this));
index eff2d1a..265b59a 100644 (file)
@@ -27,6 +27,7 @@
 #include "RenderTreeAsText.h"
 
 #include "Document.h"
+#include "FlowThreadController.h"
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "FrameView.h"
@@ -645,10 +646,11 @@ static void write(TextStream& ts, RenderLayer& l,
 static void writeRenderNamedFlowThreads(TextStream& ts, RenderView* renderView, const RenderLayer* rootLayer,
                         const IntRect& paintRect, int indent, RenderAsTextBehavior behavior)
 {
-    const RenderNamedFlowThreadList* list = renderView->renderNamedFlowThreadList();
-    if (!list || list->isEmpty())
+    if (!renderView->hasRenderNamedFlowThreads())
         return;
 
+    const RenderNamedFlowThreadList* list = renderView->flowThreadController()->renderNamedFlowThreadList();
+
     writeIndent(ts, indent);
     ts << "Flow Threads\n";
 
index dd7b65b..4ba2afa 100644 (file)
@@ -25,6 +25,7 @@
 #include "Document.h"
 #include "Element.h"
 #include "FloatQuad.h"
+#include "FlowThreadController.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
@@ -54,10 +55,8 @@ RenderView::RenderView(Node* node, FrameView* view)
     , m_maximalOutlineSize(0)
     , m_pageLogicalHeight(0)
     , m_pageLogicalHeightChanged(false)
-    , m_isRenderNamedFlowThreadOrderDirty(false)
     , m_layoutState(0)
     , m_layoutStateDisableCount(0)
-    , m_currentRenderFlowThread(0)
 {
     // Clear our anonymous bit, set because RenderObject assumes
     // any renderer with document as the node is anonymous.
@@ -138,7 +137,7 @@ void RenderView::layout()
     if (needsLayout()) {
         RenderBlock::layout();
         if (hasRenderNamedFlowThreads())
-            layoutRenderNamedFlowThreads();
+            flowThreadController()->layoutRenderNamedFlowThreads();
     }
 
     ASSERT(layoutDelta() == LayoutSize());
@@ -896,50 +895,17 @@ void RenderView::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
     }
 }
 
-RenderNamedFlowThread* RenderView::ensureRenderFlowThreadWithName(const AtomicString& name)
+bool RenderView::hasRenderNamedFlowThreads() const
 {
-    if (!m_renderNamedFlowThreadList)
-        m_renderNamedFlowThreadList = adoptPtr(new RenderNamedFlowThreadList());
-    else {
-        for (RenderNamedFlowThreadList::iterator iter = m_renderNamedFlowThreadList->begin(); iter != m_renderNamedFlowThreadList->end(); ++iter) {
-            RenderNamedFlowThread* flowRenderer = *iter;
-            if (flowRenderer->flowThreadName() == name)
-                return flowRenderer;
-        }
-    }
-
-    RenderNamedFlowThread* flowRenderer = new (renderArena()) RenderNamedFlowThread(document(), name);
-    flowRenderer->setStyle(RenderFlowThread::createFlowThreadStyle(style()));
-    addChild(flowRenderer);
-
-    m_renderNamedFlowThreadList->add(flowRenderer);
-    setIsRenderNamedFlowThreadOrderDirty(true);
-
-    return flowRenderer;
+    return m_flowThreadController && m_flowThreadController->hasRenderNamedFlowThreads();
 }
 
-void RenderView::layoutRenderNamedFlowThreads()
+FlowThreadController* RenderView::flowThreadController()
 {
-    ASSERT(m_renderNamedFlowThreadList);
+    if (!m_flowThreadController)
+        m_flowThreadController = FlowThreadController::create(this);
 
-    if (isRenderNamedFlowThreadOrderDirty()) {
-        // Arrange the thread list according to dependencies.
-        RenderNamedFlowThreadList sortedList;
-        for (RenderNamedFlowThreadList::iterator iter = m_renderNamedFlowThreadList->begin(); iter != m_renderNamedFlowThreadList->end(); ++iter) {
-            RenderNamedFlowThread* flowRenderer = *iter;
-            if (sortedList.contains(flowRenderer))
-                continue;
-            flowRenderer->pushDependencies(sortedList);
-            sortedList.add(flowRenderer);
-        }
-        m_renderNamedFlowThreadList->swap(sortedList);
-        setIsRenderNamedFlowThreadOrderDirty(false);
-    }
-
-    for (RenderNamedFlowThreadList::iterator iter = m_renderNamedFlowThreadList->begin(); iter != m_renderNamedFlowThreadList->end(); ++iter) {
-        RenderNamedFlowThread* flowRenderer = *iter;
-        flowRenderer->layoutIfNeeded();
-    }
+    return m_flowThreadController.get();
 }
 
 RenderBlock::IntervalArena* RenderView::intervalArena()
index 021a79d..bb82c18 100644 (file)
 #include "LayoutState.h"
 #include "PODFreeListArena.h"
 #include "RenderBlock.h"
-#include <wtf/ListHashSet.h>
 #include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
-class RenderNamedFlowThread;
+class FlowThreadController;
 class RenderWidget;
 
 #if USE(ACCELERATED_COMPOSITING)
 class RenderLayerCompositor;
 #endif
 
-typedef ListHashSet<RenderNamedFlowThread*> RenderNamedFlowThreadList;
-
 class RenderView : public RenderBlock {
 public:
     RenderView(Node*, FrameView*);
@@ -172,20 +169,8 @@ public:
 
     IntRect documentRect() const;
 
-    RenderNamedFlowThread* ensureRenderFlowThreadWithName(const AtomicString&);
-    bool hasRenderNamedFlowThreads() const { return m_renderNamedFlowThreadList && !m_renderNamedFlowThreadList->isEmpty(); }
-    void layoutRenderNamedFlowThreads();
-    bool isRenderNamedFlowThreadOrderDirty() const { return m_isRenderNamedFlowThreadOrderDirty; }
-    void setIsRenderNamedFlowThreadOrderDirty(bool dirty)
-    {
-        m_isRenderNamedFlowThreadOrderDirty = dirty;
-        if (dirty)
-            setNeedsLayout(true);
-    }
-    const RenderNamedFlowThreadList* renderNamedFlowThreadList() const { return m_renderNamedFlowThreadList.get(); }
-
-    RenderFlowThread* currentRenderFlowThread() const { return m_currentRenderFlowThread; }
-    void setCurrentRenderFlowThread(RenderFlowThread* flowThread) { m_currentRenderFlowThread = flowThread; }
+    bool hasRenderNamedFlowThreads() const;
+    FlowThreadController* flowThreadController();
 
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
@@ -271,14 +256,12 @@ protected:
 private:
     unsigned m_pageLogicalHeight;
     bool m_pageLogicalHeightChanged;
-    bool m_isRenderNamedFlowThreadOrderDirty;
     LayoutState* m_layoutState;
     unsigned m_layoutStateDisableCount;
 #if USE(ACCELERATED_COMPOSITING)
     OwnPtr<RenderLayerCompositor> m_compositor;
 #endif
-    OwnPtr<RenderNamedFlowThreadList> m_renderNamedFlowThreadList;
-    RenderFlowThread* m_currentRenderFlowThread;
+    OwnPtr<FlowThreadController> m_flowThreadController;
     RefPtr<IntervalArena> m_intervalArena;
 };