CTTE: RenderNamedFlowThread always has a WebKitNamedFlow.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Feb 2014 00:08:16 +0000 (00:08 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Feb 2014 00:08:16 +0000 (00:08 +0000)
<https://webkit.org/b/128623>

Codify the fact that RenderNamedFlowThread always has a corresponding
WebKitNamedFlow by storing it in a Ref, and adding an accessor that
returns a reference to get rid of all the ->'s.

Also removed some unnecessary assertions exposed by this.

Reviewed by Antti Koivisto.

* dom/NamedFlowCollection.cpp:
(WebCore::NamedFlowCollection::ensureFlowWithName):
* dom/NamedFlowCollection.h:
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
(WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
(WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
(WebCore::RenderNamedFlowThread::flowThreadName):
(WebCore::RenderNamedFlowThread::dispatchRegionLayoutUpdateEvent):
(WebCore::RenderNamedFlowThread::dispatchRegionOversetChangeEvent):
(WebCore::RenderNamedFlowThread::regionLayoutUpdateEventTimerFired):
(WebCore::RenderNamedFlowThread::regionOversetChangeEventTimerFired):
(WebCore::RenderNamedFlowThread::setMarkForDestruction):
(WebCore::RenderNamedFlowThread::resetMarkForDestruction):
(WebCore::RenderNamedFlowThread::isMarkedForDestruction):
* rendering/RenderNamedFlowThread.h:

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

Source/WebCore/ChangeLog
Source/WebCore/dom/NamedFlowCollection.cpp
Source/WebCore/dom/NamedFlowCollection.h
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderNamedFlowThread.h

index 43b5049..50b4cb4 100644 (file)
@@ -1,3 +1,33 @@
+2014-02-11  Andreas Kling  <akling@apple.com>
+
+        CTTE: RenderNamedFlowThread always has a WebKitNamedFlow.
+        <https://webkit.org/b/128623>
+
+        Codify the fact that RenderNamedFlowThread always has a corresponding
+        WebKitNamedFlow by storing it in a Ref, and adding an accessor that
+        returns a reference to get rid of all the ->'s.
+
+        Also removed some unnecessary assertions exposed by this.
+
+        Reviewed by Antti Koivisto.
+
+        * dom/NamedFlowCollection.cpp:
+        (WebCore::NamedFlowCollection::ensureFlowWithName):
+        * dom/NamedFlowCollection.h:
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
+        (WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
+        (WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
+        (WebCore::RenderNamedFlowThread::flowThreadName):
+        (WebCore::RenderNamedFlowThread::dispatchRegionLayoutUpdateEvent):
+        (WebCore::RenderNamedFlowThread::dispatchRegionOversetChangeEvent):
+        (WebCore::RenderNamedFlowThread::regionLayoutUpdateEventTimerFired):
+        (WebCore::RenderNamedFlowThread::regionOversetChangeEventTimerFired):
+        (WebCore::RenderNamedFlowThread::setMarkForDestruction):
+        (WebCore::RenderNamedFlowThread::resetMarkForDestruction):
+        (WebCore::RenderNamedFlowThread::isMarkedForDestruction):
+        * rendering/RenderNamedFlowThread.h:
+
 2014-02-10  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Convert position:fixed property to position:absolute upon copy
index c879816..e140e4c 100644 (file)
@@ -66,14 +66,14 @@ WebKitNamedFlow* NamedFlowCollection::flowByName(const String& flowName)
     return *it;
 }
 
-PassRefPtr<WebKitNamedFlow> NamedFlowCollection::ensureFlowWithName(const String& flowName)
+PassRef<WebKitNamedFlow> NamedFlowCollection::ensureFlowWithName(const String& flowName)
 {
     NamedFlowSet::iterator it = m_namedFlows.find<String, NamedFlowHashTranslator>(flowName);
     if (it != m_namedFlows.end()) {
         WebKitNamedFlow* namedFlow = *it;
         ASSERT(namedFlow->flowState() == WebKitNamedFlow::FlowStateNull);
 
-        return namedFlow;
+        return *namedFlow;
     }
 
     RefPtr<WebKitNamedFlow> newFlow = WebKitNamedFlow::create(this, flowName);
@@ -81,7 +81,7 @@ PassRefPtr<WebKitNamedFlow> NamedFlowCollection::ensureFlowWithName(const String
 
     InspectorInstrumentation::didCreateNamedFlow(document(), newFlow.get());
 
-    return newFlow.release();
+    return newFlow.releaseNonNull();
 }
 
 void NamedFlowCollection::discardNamedFlow(WebKitNamedFlow* namedFlow)
index 0bb0649..2c0d9c8 100644 (file)
@@ -49,7 +49,7 @@ public:
 
     Vector<RefPtr<WebKitNamedFlow>> namedFlows();
     WebKitNamedFlow* flowByName(const String&);
-    PassRefPtr<WebKitNamedFlow> ensureFlowWithName(const String&);
+    PassRef<WebKitNamedFlow> ensureFlowWithName(const String&);
 
     void discardNamedFlow(WebKitNamedFlow*);
 
index d06c145..25f71aa 100644 (file)
 
 namespace WebCore {
 
-RenderNamedFlowThread::RenderNamedFlowThread(Document& document, PassRef<RenderStyle> style, PassRefPtr<WebKitNamedFlow> namedFlow)
+RenderNamedFlowThread::RenderNamedFlowThread(Document& document, PassRef<RenderStyle> style, PassRef<WebKitNamedFlow> namedFlow)
     : RenderFlowThread(document, std::move(style))
     , m_flowThreadChildList(adoptPtr(new FlowThreadChildList()))
     , m_overset(true)
     , m_hasRegionsWithStyling(false)
-    , m_namedFlow(namedFlow)
+    , m_namedFlow(std::move(namedFlow))
     , m_regionLayoutUpdateEventTimer(this, &RenderNamedFlowThread::regionLayoutUpdateEventTimerFired)
     , m_regionOversetChangeEventTimer(this, &RenderNamedFlowThread::regionOversetChangeEventTimerFired)
 {
@@ -436,13 +436,13 @@ void RenderNamedFlowThread::registerNamedFlowContentElement(Element& contentElem
         unsigned short position = contentElement.compareDocumentPosition(element);
         if (position & Node::DOCUMENT_POSITION_FOLLOWING) {
             m_contentElements.insertBefore(element, &contentElement);
-            InspectorInstrumentation::didRegisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement, element);
+            InspectorInstrumentation::didRegisterNamedFlowContentElement(&document(), &namedFlow(), &contentElement, element);
             return;
         }
     }
 
     m_contentElements.add(&contentElement);
-    InspectorInstrumentation::didRegisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement);
+    InspectorInstrumentation::didRegisterNamedFlowContentElement(&document(), &namedFlow(), &contentElement);
 }
 
 void RenderNamedFlowThread::unregisterNamedFlowContentElement(Element& contentElement)
@@ -457,7 +457,7 @@ void RenderNamedFlowThread::unregisterNamedFlowContentElement(Element& contentEl
     if (canBeDestroyed())
         setMarkForDestruction();
 
-    InspectorInstrumentation::didUnregisterNamedFlowContentElement(&document(), m_namedFlow.get(), &contentElement);
+    InspectorInstrumentation::didUnregisterNamedFlowContentElement(&document(), &namedFlow(), &contentElement);
 }
 
 bool RenderNamedFlowThread::hasContentElement(Element& contentElement) const
@@ -467,7 +467,7 @@ bool RenderNamedFlowThread::hasContentElement(Element& contentElement) const
     
 const AtomicString& RenderNamedFlowThread::flowThreadName() const
 {
-    return m_namedFlow->name();
+    return namedFlow().name();
 }
 
 bool RenderNamedFlowThread::isChildAllowed(const RenderObject& child, const RenderStyle& style) const
@@ -487,57 +487,53 @@ bool RenderNamedFlowThread::isChildAllowed(const RenderObject& child, const Rend
 void RenderNamedFlowThread::dispatchRegionLayoutUpdateEvent()
 {
     RenderFlowThread::dispatchRegionLayoutUpdateEvent();
-    InspectorInstrumentation::didUpdateRegionLayout(&document(), m_namedFlow.get());
+    InspectorInstrumentation::didUpdateRegionLayout(&document(), &namedFlow());
 
-    if (!m_regionLayoutUpdateEventTimer.isActive() && m_namedFlow->hasEventListeners())
+    if (!m_regionLayoutUpdateEventTimer.isActive() && namedFlow().hasEventListeners())
         m_regionLayoutUpdateEventTimer.startOneShot(0);
 }
 
 void RenderNamedFlowThread::dispatchRegionOversetChangeEvent()
 {
     RenderFlowThread::dispatchRegionOversetChangeEvent();
-    InspectorInstrumentation::didChangeRegionOverset(&document(), m_namedFlow.get());
+    InspectorInstrumentation::didChangeRegionOverset(&document(), &namedFlow());
     
-    if (!m_regionOversetChangeEventTimer.isActive() && m_namedFlow->hasEventListeners())
+    if (!m_regionOversetChangeEventTimer.isActive() && namedFlow().hasEventListeners())
         m_regionOversetChangeEventTimer.startOneShot(0);
 }
 
 void RenderNamedFlowThread::regionLayoutUpdateEventTimerFired(Timer<RenderNamedFlowThread>&)
 {
-    ASSERT(m_namedFlow);
-
-    m_namedFlow->dispatchRegionLayoutUpdateEvent();
+    namedFlow().dispatchRegionLayoutUpdateEvent();
 }
 
 void RenderNamedFlowThread::regionOversetChangeEventTimerFired(Timer<RenderNamedFlowThread>&)
 {
-    ASSERT(m_namedFlow);
-    
-    m_namedFlow->dispatchRegionOversetChangeEvent();
+    namedFlow().dispatchRegionOversetChangeEvent();
 }
 
 void RenderNamedFlowThread::setMarkForDestruction()
 {
-    if (m_namedFlow->flowState() == WebKitNamedFlow::FlowStateNull)
+    if (namedFlow().flowState() == WebKitNamedFlow::FlowStateNull)
         return;
 
-    m_namedFlow->setRenderer(0);
+    namedFlow().setRenderer(nullptr);
     // After this call ends, the renderer can be safely destroyed.
     // The NamedFlow object may outlive its renderer if it's referenced from a script and may be reatached to one if the named flow is recreated in the stylesheet.
 }
 
 void RenderNamedFlowThread::resetMarkForDestruction()
 {
-    if (m_namedFlow->flowState() == WebKitNamedFlow::FlowStateCreated)
+    if (namedFlow().flowState() == WebKitNamedFlow::FlowStateCreated)
         return;
 
-    m_namedFlow->setRenderer(this);
+    namedFlow().setRenderer(this);
 }
 
 bool RenderNamedFlowThread::isMarkedForDestruction() const
 {
     // Flow threads in the "NULL" state can be destroyed.
-    return m_namedFlow->flowState() == WebKitNamedFlow::FlowStateNull;
+    return namedFlow().flowState() == WebKitNamedFlow::FlowStateNull;
 }
 
 static bool isContainedInElements(const Vector<Element*>& others, Element* element)
index b2d91ce..1bb36e9 100644 (file)
@@ -45,7 +45,7 @@ typedef ListHashSet<Element*> NamedFlowContentElements;
 
 class RenderNamedFlowThread final : public RenderFlowThread {
 public:
-    RenderNamedFlowThread(Document&, PassRef<RenderStyle>, PassRefPtr<WebKitNamedFlow>);
+    RenderNamedFlowThread(Document&, PassRef<RenderStyle>, PassRef<WebKitNamedFlow>);
     virtual ~RenderNamedFlowThread();
 
     const AtomicString& flowThreadName() const;
@@ -116,7 +116,9 @@ private:
     void clearContentElements();
     void updateWritingMode();
 
-private:
+    WebKitNamedFlow& namedFlow() { return m_namedFlow.get(); }
+    const WebKitNamedFlow& namedFlow() const { return m_namedFlow.get(); }
+
     // 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.
@@ -139,7 +141,7 @@ private:
     bool m_hasRegionsWithStyling : 1;
 
     // The DOM Object that represents a named flow.
-    RefPtr<WebKitNamedFlow> m_namedFlow;
+    Ref<WebKitNamedFlow> m_namedFlow;
 
     Timer<RenderNamedFlowThread> m_regionLayoutUpdateEventTimer;
     Timer<RenderNamedFlowThread> m_regionOversetChangeEventTimer;