Reduce PassRefPtr uses in dom - 2
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Dec 2015 02:13:00 +0000 (02:13 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Dec 2015 02:13:00 +0000 (02:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151936

Reviewed by Darin Adler.

Change PassRefPtr with RefPtr<Foo>&&, WTF::move(), Foo*, and Foo&.

* dom/ScopedEventQueue.h:
* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::registerCallback):
* dom/ScriptedAnimationController.h:
* dom/StaticNodeList.h:
* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
* dom/Traversal.h:
* dom/TreeWalker.cpp:
(WebCore::TreeWalker::TreeWalker):
(WebCore::TreeWalker::setCurrentNode):
* dom/TreeWalker.h:
(WebCore::TreeWalker::create):
* dom/UserActionElementSet.h:
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::WebKitNamedFlow):
(WebCore::WebKitNamedFlow::create):
(WebCore::WebKitNamedFlow::getRegionsByContent):
(WebCore::WebKitNamedFlow::getRegions):
(WebCore::WebKitNamedFlow::getContent):
* dom/WebKitNamedFlow.h:
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent):
(WebCore::WheelEvent::initWheelEvent):
(WebCore::WheelEvent::initWebKitWheelEvent):
* dom/WheelEvent.h:

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/NamedFlowCollection.cpp
Source/WebCore/dom/NodeIterator.cpp
Source/WebCore/dom/ScopedEventQueue.h
Source/WebCore/dom/StaticNodeList.h
Source/WebCore/dom/Traversal.cpp
Source/WebCore/dom/Traversal.h
Source/WebCore/dom/TreeWalker.cpp
Source/WebCore/dom/TreeWalker.h
Source/WebCore/dom/UserActionElementSet.h
Source/WebCore/dom/WebKitNamedFlow.cpp
Source/WebCore/dom/WebKitNamedFlow.h
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h

index b006dd3..64ed367 100644 (file)
@@ -1,3 +1,39 @@
+2015-12-16  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Reduce PassRefPtr uses in dom - 2
+        https://bugs.webkit.org/show_bug.cgi?id=151936
+
+        Reviewed by Darin Adler.
+
+        Change PassRefPtr with RefPtr<Foo>&&, WTF::move(), Foo*, and Foo&.
+
+        * dom/ScopedEventQueue.h:
+        * dom/ScriptedAnimationController.cpp:
+        (WebCore::ScriptedAnimationController::registerCallback):
+        * dom/ScriptedAnimationController.h:
+        * dom/StaticNodeList.h:
+        * dom/Traversal.cpp:
+        (WebCore::NodeIteratorBase::NodeIteratorBase):
+        * dom/Traversal.h:
+        * dom/TreeWalker.cpp:
+        (WebCore::TreeWalker::TreeWalker):
+        (WebCore::TreeWalker::setCurrentNode):
+        * dom/TreeWalker.h:
+        (WebCore::TreeWalker::create):
+        * dom/UserActionElementSet.h:
+        * dom/WebKitNamedFlow.cpp:
+        (WebCore::WebKitNamedFlow::WebKitNamedFlow):
+        (WebCore::WebKitNamedFlow::create):
+        (WebCore::WebKitNamedFlow::getRegionsByContent):
+        (WebCore::WebKitNamedFlow::getRegions):
+        (WebCore::WebKitNamedFlow::getContent):
+        * dom/WebKitNamedFlow.h:
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::WheelEvent):
+        (WebCore::WheelEvent::initWheelEvent):
+        (WebCore::WheelEvent::initWebKitWheelEvent):
+        * dom/WheelEvent.h:
+
 2015-12-16  Simon Fraser  <simon.fraser@apple.com>
 
         Simplify isOverlayScrollbar() logic
index f5dbdbf..fbf4721 100644 (file)
@@ -1748,7 +1748,7 @@ RefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned long whatToSh
         ec = TypeError;
         return nullptr;
     }
-    return TreeWalker::create(root, whatToShow, WTF::move(filter));
+    return TreeWalker::create(*root, whatToShow, WTF::move(filter));
 }
 
 RefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned long whatToShow, ExceptionCode& ec)
index 1a14db4..24360dc 100644 (file)
@@ -76,7 +76,7 @@ Ref<WebKitNamedFlow> NamedFlowCollection::ensureFlowWithName(const String& flowN
         return *namedFlow;
     }
 
-    RefPtr<WebKitNamedFlow> newFlow = WebKitNamedFlow::create(this, flowName);
+    RefPtr<WebKitNamedFlow> newFlow = WebKitNamedFlow::create(*this, flowName);
     m_namedFlows.add(newFlow.get());
 
     InspectorInstrumentation::didCreateNamedFlow(document(), *newFlow);
index da9d023..038efc8 100644 (file)
@@ -77,7 +77,7 @@ bool NodeIterator::NodePointer::moveToPrevious(Node* root)
 }
 
 NodeIterator::NodeIterator(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
-    : NodeIteratorBase(rootNode, whatToShow, WTF::move(filter))
+    : NodeIteratorBase(*rootNode, whatToShow, WTF::move(filter))
     , m_referenceNode(root(), true)
 {
     root()->document().attachNodeIterator(this);
index 78bbc65..d76fa43 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
index 2a8a0ac..6e342b4 100644 (file)
@@ -62,11 +62,11 @@ private:
 
 class StaticElementList final : public NodeList {
 public:
-    static PassRefPtr<StaticElementList> adopt(Vector<Ref<Element>>& elements)
+    static Ref<StaticElementList> adopt(Vector<Ref<Element>>& elements)
     {
-        RefPtr<StaticElementList> nodeList = adoptRef(new StaticElementList);
+        Ref<StaticElementList> nodeList = adoptRef(*new StaticElementList);
         nodeList->m_elements.swap(elements);
-        return nodeList.release();
+        return nodeList;
     }
 
     static Ref<StaticElementList> createEmpty()
index 3c4a955..b5cfc84 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-NodeIteratorBase::NodeIteratorBase(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& nodeFilter)
+NodeIteratorBase::NodeIteratorBase(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& nodeFilter)
     : m_root(rootNode)
     , m_whatToShow(whatToShow)
     , m_filter(WTF::move(nodeFilter))
index ffbd549..6ab9781 100644 (file)
@@ -35,17 +35,17 @@ namespace WebCore {
 
     class NodeIteratorBase {
     public:
-        Node* root() const { return m_root.get(); }
+        Node* root() const { return &m_root; }
         unsigned long whatToShow() const { return m_whatToShow; }
         NodeFilter* filter() const { return m_filter.get(); }
         bool expandEntityReferences() const { return false; }
 
     protected:
-        NodeIteratorBase(PassRefPtr<Node>, unsigned long whatToShow, RefPtr<NodeFilter>&&);
+        NodeIteratorBase(Node&, unsigned long whatToShow, RefPtr<NodeFilter>&&);
         short acceptNode(Node*) const;
 
     private:
-        RefPtr<Node> m_root;
+        Node& m_root;
         unsigned long m_whatToShow;
         RefPtr<NodeFilter> m_filter;
     };
index ce7f1c1..be16ea1 100644 (file)
 
 namespace WebCore {
 
-TreeWalker::TreeWalker(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
+TreeWalker::TreeWalker(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
     : NodeIteratorBase(rootNode, whatToShow, WTF::move(filter))
     , m_current(root())
 {
 }
 
-void TreeWalker::setCurrentNode(PassRefPtr<Node> node, ExceptionCode& ec)
+void TreeWalker::setCurrentNode(Node* node, ExceptionCode& ec)
 {
     if (!node) {
         ec = NOT_SUPPORTED_ERR;
index 795eed1..1dbf5ce 100644 (file)
@@ -37,13 +37,13 @@ namespace WebCore {
 
     class TreeWalker : public ScriptWrappable, public RefCounted<TreeWalker>, public NodeIteratorBase {
     public:
-        static Ref<TreeWalker> create(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
+        static Ref<TreeWalker> create(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
         {
             return adoptRef(*new TreeWalker(rootNode, whatToShow, WTF::move(filter)));
         }                            
 
         Node* currentNode() const { return m_current.get(); }
-        void setCurrentNode(PassRefPtr<Node>, ExceptionCode&);
+        void setCurrentNode(Node*, ExceptionCode&);
 
         Node* parentNode();
         Node* firstChild();
@@ -54,7 +54,7 @@ namespace WebCore {
         Node* nextNode();
 
     private:
-        TreeWalker(PassRefPtr<Node>, unsigned long whatToShow, RefPtr<NodeFilter>&&);
+        TreeWalker(Node&, unsigned long whatToShow, RefPtr<NodeFilter>&&);
         enum class SiblingTraversalType { Previous, Next };
         template<SiblingTraversalType> Node* traverseSiblings();
         
index 07c77b2..eb486f0 100644 (file)
@@ -29,7 +29,6 @@
 #define UserActionElementSet_h
 
 #include <wtf/HashMap.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
index 3974bf7..870780c 100644 (file)
@@ -39,7 +39,7 @@
 
 namespace WebCore {
 
-WebKitNamedFlow::WebKitNamedFlow(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
+WebKitNamedFlow::WebKitNamedFlow(NamedFlowCollection& manager, const AtomicString& flowThreadName)
     : m_flowThreadName(flowThreadName)
     , m_flowManager(manager)
     , m_parentFlowThread(nullptr)
@@ -49,10 +49,10 @@ WebKitNamedFlow::WebKitNamedFlow(PassRefPtr<NamedFlowCollection> manager, const
 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);
+    m_flowManager.discardNamedFlow(this);
 }
 
-Ref<WebKitNamedFlow> WebKitNamedFlow::create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
+Ref<WebKitNamedFlow> WebKitNamedFlow::create(NamedFlowCollection& manager, const AtomicString& flowThreadName)
 {
     return adoptRef(*new WebKitNamedFlow(manager, flowThreadName));
 }
@@ -64,8 +64,8 @@ const AtomicString& WebKitNamedFlow::name() const
 
 bool WebKitNamedFlow::overset() const
 {
-    if (m_flowManager->document())
-        m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
+    if (m_flowManager.document())
+        m_flowManager.document()->updateLayoutIgnorePendingStylesheets();
 
     // The renderer may be destroyed or created after the style update.
     // Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
@@ -92,8 +92,8 @@ static inline bool inFlowThread(RenderObject* renderer, RenderNamedFlowThread* f
 
 int WebKitNamedFlow::firstEmptyRegionIndex() const
 {
-    if (m_flowManager->document())
-        m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
+    if (m_flowManager.document())
+        m_flowManager.document()->updateLayoutIgnorePendingStylesheets();
 
     if (!m_parentFlowThread)
         return -1;
@@ -117,13 +117,13 @@ int WebKitNamedFlow::firstEmptyRegionIndex() const
     return -1;
 }
 
-PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
+Ref<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
 {
     if (!contentNode)
         return StaticElementList::createEmpty();
 
-    if (m_flowManager->document())
-        m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
+    if (m_flowManager.document())
+        m_flowManager.document()->updateLayoutIgnorePendingStylesheets();
 
     // The renderer may be destroyed or created after the style update.
     // Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
@@ -151,10 +151,10 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
     return StaticElementList::adopt(regionElements);
 }
 
-PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
+Ref<NodeList> WebKitNamedFlow::getRegions()
 {
-    if (m_flowManager->document())
-        m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
+    if (m_flowManager.document())
+        m_flowManager.document()->updateLayoutIgnorePendingStylesheets();
 
     // The renderer may be destroyed or created after the style update.
     // Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
@@ -178,10 +178,10 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
     return StaticElementList::adopt(regionElements);
 }
 
-PassRefPtr<NodeList> WebKitNamedFlow::getContent()
+Ref<NodeList> WebKitNamedFlow::getContent()
 {
-    if (m_flowManager->document())
-        m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
+    if (m_flowManager.document())
+        m_flowManager.document()->updateLayoutIgnorePendingStylesheets();
 
     // The renderer may be destroyed or created after the style update.
     // Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
@@ -216,17 +216,17 @@ void WebKitNamedFlow::dispatchRegionOversetChangeEvent()
     if (flowState() == FlowStateNull)
         return;
 
-    dispatchEvent(UIEvent::create(eventNames().webkitregionoversetchangeEvent, false, false, m_flowManager->document()->defaultView(), 0));
+    dispatchEvent(UIEvent::create(eventNames().webkitregionoversetchangeEvent, false, false, m_flowManager.document()->defaultView(), 0));
 }
 
 ScriptExecutionContext* WebKitNamedFlow::scriptExecutionContext() const
 {
-    return m_flowManager->document();
+    return m_flowManager.document();
 }
 
 Node* WebKitNamedFlow::ownerNode() const
 {
-    return m_flowManager->document();
+    return m_flowManager.document();
 }
 
 } // namespace WebCore
index ff8611d..822ee0d 100644 (file)
@@ -48,16 +48,16 @@ class ScriptExecutionContext;
 
 class WebKitNamedFlow final : public RefCounted<WebKitNamedFlow>, public EventTargetWithInlineData {
 public:
-    static Ref<WebKitNamedFlow> create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName);
+    static Ref<WebKitNamedFlow> create(NamedFlowCollection& manager, const AtomicString& flowThreadName);
 
     ~WebKitNamedFlow();
 
     const AtomicString& name() const;
     bool overset() const;
     int firstEmptyRegionIndex() const;
-    PassRefPtr<NodeList> getRegionsByContent(Node*);
-    PassRefPtr<NodeList> getRegions();
-    PassRefPtr<NodeList> getContent();
+    Ref<NodeList> getRegionsByContent(Node*);
+    Ref<NodeList> getRegions();
+    Ref<NodeList> getContent();
 
     using RefCounted<WebKitNamedFlow>::ref;
     using RefCounted<WebKitNamedFlow>::deref;
@@ -81,7 +81,7 @@ public:
     void dispatchRegionOversetChangeEvent();
 
 private:
-    WebKitNamedFlow(PassRefPtr<NamedFlowCollection>, const AtomicString&);
+    WebKitNamedFlow(NamedFlowCollection&, const AtomicString&);
 
     // EventTarget implementation.
     virtual void refEventTarget() override { ref(); }
@@ -90,7 +90,7 @@ private:
     // The name of the flow thread as specified in CSS.
     AtomicString m_flowThreadName;
 
-    RefPtr<NamedFlowCollection> m_flowManager;
+    NamedFlowCollection& m_flowManager;
     RenderNamedFlowThread* m_parentFlowThread;
 };
 
index 5310388..2044235 100644 (file)
@@ -65,7 +65,7 @@ WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ
 {
 }
 
-WheelEvent::WheelEvent(const PlatformWheelEvent& event, PassRefPtr<AbstractView> view)
+WheelEvent::WheelEvent(const PlatformWheelEvent& event, AbstractView* view)
     : MouseEvent(eventNames().wheelEvent, true, true, event.timestamp(), view, 0, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y()
 #if ENABLE(POINTER_LOCK)
                 , 0, 0
@@ -81,7 +81,7 @@ WheelEvent::WheelEvent(const PlatformWheelEvent& event, PassRefPtr<AbstractView>
 {
 }
 
-void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
+void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, AbstractView* view, int screenX, int screenY, int pageX, int pageY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
 {
     if (dispatched())
         return;
@@ -104,7 +104,7 @@ void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac
     initCoordinates(IntPoint(pageX, pageY));
 }
 
-void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
+void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, AbstractView* view, int screenX, int screenY, int pageX, int pageY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
 {
     initWheelEvent(rawDeltaX, rawDeltaY, view, screenX, screenY, pageX, pageY, ctrlKey, altKey, shiftKey, metaKey);
 }
index 37fc680..3adb01c 100644 (file)
@@ -64,16 +64,16 @@ public:
         return adoptRef(*new WheelEvent(type, initializer));
     }
 
-    static Ref<WheelEvent> create(const PlatformWheelEvent& event, PassRefPtr<AbstractView> view)
+    static Ref<WheelEvent> create(const PlatformWheelEvent& event, AbstractView* view)
     {
         return adoptRef(*new WheelEvent(event, view));
     }
 
-    void initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
+    void initWheelEvent(int rawDeltaX, int rawDeltaY, AbstractView*,
         int screenX, int screenY, int pageX, int pageY,
         bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
 
-    void initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
+    void initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, AbstractView*,
         int screenX, int screenY, int pageX, int pageY,
         bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
 
@@ -100,7 +100,7 @@ public:
 private:
     WheelEvent();
     WheelEvent(const AtomicString&, const WheelEventInit&);
-    WheelEvent(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
+    WheelEvent(const PlatformWheelEvent&, AbstractView*);
 
     virtual bool isWheelEvent() const override;