Reduce PassRefPtr uses in dom - 2
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Dec 2015 02:10:49 +0000 (02:10 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Dec 2015 02:10:49 +0000 (02:10 +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@194324 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 ac1ee94..ee0df0a 100644 (file)
@@ -1,3 +1,39 @@
+2015-12-20  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-20  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [SOUP] Performs DNS prefetch when a proxy is configured (information leak)
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..3c6c997 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace WebCore {
 
-NodeIteratorBase::NodeIteratorBase(PassRefPtr<Node> rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& nodeFilter)
-    : m_root(rootNode)
+NodeIteratorBase::NodeIteratorBase(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& nodeFilter)
+    : m_root(&rootNode)
     , m_whatToShow(whatToShow)
     , m_filter(WTF::move(nodeFilter))
 {
index ffbd549..1c11607 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore {
         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:
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..fc671ca 100644 (file)
@@ -39,9 +39,9 @@
 
 namespace WebCore {
 
-WebKitNamedFlow::WebKitNamedFlow(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
+WebKitNamedFlow::WebKitNamedFlow(NamedFlowCollection& manager, const AtomicString& flowThreadName)
     : m_flowThreadName(flowThreadName)
-    , m_flowManager(manager)
+    , m_flowManager(&manager)
     , m_parentFlowThread(nullptr)
 {
 }
@@ -52,7 +52,7 @@ WebKitNamedFlow::~WebKitNamedFlow()
     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));
 }
@@ -117,7 +117,7 @@ int WebKitNamedFlow::firstEmptyRegionIndex() const
     return -1;
 }
 
-PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
+Ref<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
 {
     if (!contentNode)
         return StaticElementList::createEmpty();
@@ -151,7 +151,7 @@ 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();
@@ -178,7 +178,7 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
     return StaticElementList::adopt(regionElements);
 }
 
-PassRefPtr<NodeList> WebKitNamedFlow::getContent()
+Ref<NodeList> WebKitNamedFlow::getContent()
 {
     if (m_flowManager->document())
         m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
index ff8611d..ecefee3 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(); }
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;