Reduce uses of PassRefPtr in WebCore/dom - 6
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2016 06:05:49 +0000 (06:05 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2016 06:05:49 +0000 (06:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155579

Reviewed by Darin Adler.

* dom/MessagePortChannel.h:
* dom/default/PlatformMessagePortChannel.cpp:
(WebCore::PlatformMessagePortChannel::EventData::EventData):
(WebCore::MessagePortChannel::createChannel):
(WebCore::MessagePortChannel::MessagePortChannel):
(WebCore::MessagePortChannel::postMessageToRemote):
(WebCore::PlatformMessagePortChannel::create):
(WebCore::PlatformMessagePortChannel::PlatformMessagePortChannel):
* dom/default/PlatformMessagePortChannel.h:
(WebCore::PlatformMessagePortChannel::EventData::message):

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/DocumentMarker.cpp
Source/WebCore/dom/DocumentMarker.h
Source/WebCore/dom/DocumentMarkerController.cpp
Source/WebCore/dom/DocumentMarkerController.h
Source/WebCore/dom/EventContext.cpp
Source/WebCore/dom/EventContext.h
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/MessagePort.cpp
Source/WebCore/dom/MessagePort.h
Source/WebCore/dom/MessagePortChannel.h
Source/WebCore/dom/StaticNodeList.h
Source/WebCore/dom/default/PlatformMessagePortChannel.cpp
Source/WebCore/dom/default/PlatformMessagePortChannel.h

index e4d8d24..c716b31 100644 (file)
@@ -1,3 +1,21 @@
+2016-03-20  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Reduce uses of PassRefPtr in WebCore/dom - 6
+        https://bugs.webkit.org/show_bug.cgi?id=155579
+
+        Reviewed by Darin Adler.
+
+        * dom/MessagePortChannel.h:
+        * dom/default/PlatformMessagePortChannel.cpp:
+        (WebCore::PlatformMessagePortChannel::EventData::EventData):
+        (WebCore::MessagePortChannel::createChannel):
+        (WebCore::MessagePortChannel::MessagePortChannel):
+        (WebCore::MessagePortChannel::postMessageToRemote):
+        (WebCore::PlatformMessagePortChannel::create):
+        (WebCore::PlatformMessagePortChannel::PlatformMessagePortChannel):
+        * dom/default/PlatformMessagePortChannel.h:
+        (WebCore::PlatformMessagePortChannel::EventData::message):
+
 2016-03-20  Jinwoo Jeong  <jw00.jeong@samsung.com>
 
         The setter of binaryType attribute in WebSocket should raise the exception.
index 5b9f909..7f1d4ca 100644 (file)
@@ -125,7 +125,7 @@ DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, bool ac
     ASSERT(m_details);
 }
 
-DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, PassRefPtr<DocumentMarkerDetails> details)
+DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, RefPtr<DocumentMarkerDetails>&& details)
     : m_type(type)
     , m_startOffset(startOffset)
     , m_endOffset(endOffset)
index 9c66e33..dae0b6e 100644 (file)
@@ -122,7 +122,7 @@ public:
     DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const String& description, const Vector<String>& alternatives, RetainPtr<id> metadata);
 #endif
     DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);
-    DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, PassRefPtr<DocumentMarkerDetails>);
+    DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, RefPtr<DocumentMarkerDetails>&&);
 
     MarkerType type() const { return m_type; }
     unsigned startOffset() const { return m_startOffset; }
index 9d4b652..3822925 100644 (file)
@@ -83,9 +83,9 @@ void DocumentMarkerController::addMarkerToNode(Node* node, unsigned startOffset,
     addMarker(node, DocumentMarker(type, startOffset, startOffset + length));
 }
 
-void DocumentMarkerController::addMarkerToNode(Node* node, unsigned startOffset, unsigned length, DocumentMarker::MarkerType type, PassRefPtr<DocumentMarkerDetails> details)
+void DocumentMarkerController::addMarkerToNode(Node* node, unsigned startOffset, unsigned length, DocumentMarker::MarkerType type, RefPtr<DocumentMarkerDetails>&& details)
 {
-    addMarker(node, DocumentMarker(type, startOffset, startOffset + length, details));
+    addMarker(node, DocumentMarker(type, startOffset, startOffset + length, WTFMove(details)));
 }
 
 
index 1c90f7d..4bc0690 100644 (file)
@@ -53,7 +53,7 @@ public:
     void addMarker(Range*, DocumentMarker::MarkerType);
     void addMarker(Range*, DocumentMarker::MarkerType, const String& description);
     void addMarkerToNode(Node*, unsigned startOffset, unsigned length, DocumentMarker::MarkerType);
-    void addMarkerToNode(Node*, unsigned startOffset, unsigned length, DocumentMarker::MarkerType, PassRefPtr<DocumentMarkerDetails>);
+    void addMarkerToNode(Node*, unsigned startOffset, unsigned length, DocumentMarker::MarkerType, RefPtr<DocumentMarkerDetails>&&);
     WEBCORE_EXPORT void addTextMatchMarker(const Range*, bool activeMatch);
 #if PLATFORM(IOS)
     void addMarker(Range*, DocumentMarker::MarkerType, const String& description, const Vector<String>& interpretations, const RetainPtr<id>& metadata);
index d33634d..91f7af9 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-EventContext::EventContext(PassRefPtr<Node> node, PassRefPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target)
+EventContext::EventContext(Node* node, EventTarget* currentTarget, EventTarget* target)
     : m_node(node)
     , m_currentTarget(currentTarget)
     , m_target(target)
@@ -64,7 +64,7 @@ bool EventContext::isTouchEventContext() const
     return false;
 }
 
-MouseOrFocusEventContext::MouseOrFocusEventContext(PassRefPtr<Node> node, PassRefPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target)
+MouseOrFocusEventContext::MouseOrFocusEventContext(Node* node, EventTarget* currentTarget, EventTarget* target)
     : EventContext(node, currentTarget, target)
 {
 }
@@ -91,7 +91,7 @@ bool MouseOrFocusEventContext::isMouseOrFocusEventContext() const
 }
 
 #if ENABLE(TOUCH_EVENTS)
-TouchEventContext::TouchEventContext(PassRefPtr<Node> node, PassRefPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target)
+TouchEventContext::TouchEventContext(Node* node, EventTarget* currentTarget, EventTarget* target)
     : EventContext(node, currentTarget, target)
     , m_touches(TouchList::create())
     , m_targetTouches(TouchList::create())
index a8aedab..f4ea8df 100644 (file)
@@ -43,7 +43,7 @@ class EventContext {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     // FIXME: Use ContainerNode instead of Node.
-    EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target);
+    EventContext(Node*, EventTarget* currentTarget, EventTarget*);
     virtual ~EventContext();
 
     Node* node() const { return m_node.get(); }
@@ -66,7 +66,7 @@ protected:
 
 class MouseOrFocusEventContext final : public EventContext {
 public:
-    MouseOrFocusEventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target);
+    MouseOrFocusEventContext(Node*, EventTarget* currentTarget, EventTarget*);
     virtual ~MouseOrFocusEventContext();
     EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
     void setRelatedTarget(PassRefPtr<EventTarget>);
@@ -81,7 +81,7 @@ private:
 #if ENABLE(TOUCH_EVENTS)
 class TouchEventContext final : public EventContext {
 public:
-    TouchEventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target);
+    TouchEventContext(Node*, EventTarget* currentTarget, EventTarget*);
     virtual ~TouchEventContext();
 
     void handleLocalEvents(Event&) const override;
index ddd769a..1c93a4a 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore {
 
 class WindowEventContext {
 public:
-    WindowEventContext(PassRefPtr<Node>, const EventContext*);
+    WindowEventContext(Node*, const EventContext*);
 
     DOMWindow* window() const { return m_window.get(); }
     EventTarget* target() const { return m_target.get(); }
@@ -52,14 +52,14 @@ private:
     RefPtr<EventTarget> m_target;
 };
 
-WindowEventContext::WindowEventContext(PassRefPtr<Node> node, const EventContext* topEventContext)
+WindowEventContext::WindowEventContext(Node* node, const EventContext* topEventContext)
 {
-    Node* topLevelContainer = topEventContext ? topEventContext->node() : node.get();
+    Node* topLevelContainer = topEventContext ? topEventContext->node() : node;
     if (!is<Document>(*topLevelContainer))
         return;
 
     m_window = downcast<Document>(*topLevelContainer).domWindow();
-    m_target = topEventContext ? topEventContext->target() : node.get();
+    m_target = topEventContext ? topEventContext->target() : node;
 }
 
 bool WindowEventContext::handleLocalEvents(Event& event)
index e0c2d02..2f5612a 100644 (file)
@@ -52,15 +52,15 @@ MessagePort::~MessagePort()
         m_scriptExecutionContext->destroyedMessagePort(*this);
 }
 
-void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, ExceptionCode& ec)
+void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, MessagePort* port, ExceptionCode& ec)
 {
     MessagePortArray ports;
     if (port)
         ports.append(port);
-    postMessage(message, &ports, ec);
+    postMessage(WTFMove(message), &ports, ec);
 }
 
-void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec)
+void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray* ports, ExceptionCode& ec)
 {
     if (!isEntangled())
         return;
@@ -79,7 +79,7 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
         if (ec)
             return;
     }
-    m_entangledChannel->postMessageToRemote(message, WTFMove(channels));
+    m_entangledChannel->postMessageToRemote(WTFMove(message), WTFMove(channels));
 }
 
 std::unique_ptr<MessagePortChannel> MessagePort::disentangle()
index 2965926..bae01d5 100644 (file)
@@ -32,7 +32,6 @@
 #include "MessagePortChannel.h"
 #include <memory>
 #include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
@@ -51,9 +50,9 @@ namespace WebCore {
         static Ref<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(*new MessagePort(scriptExecutionContext)); }
         virtual ~MessagePort();
 
-        void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
+        void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);
         // Needed for Objective-C bindings (see bug 28774).
-        void postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort*, ExceptionCode&);
+        void postMessage(RefPtr<SerializedScriptValue>&& message, MessagePort*, ExceptionCode&);
 
         void start();
         void close();
index a711eff..985f1c5 100644 (file)
@@ -55,8 +55,8 @@ namespace WebCore {
     class MessagePortChannel {
         WTF_MAKE_NONCOPYABLE(MessagePortChannel); WTF_MAKE_FAST_ALLOCATED;
     public:
-        explicit MessagePortChannel(PassRefPtr<PlatformMessagePortChannel>);
-        static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>);
+        explicit MessagePortChannel(RefPtr<PlatformMessagePortChannel>&&);
+        static void createChannel(MessagePort*, MessagePort*);
 
         // Entangles the channel with a port (called when a port has been cloned, after the clone has been marshaled to its new owning thread and is ready to receive messages).
         // Returns false if the entanglement failed because the port was closed.
@@ -75,7 +75,7 @@ namespace WebCore {
         bool hasPendingActivity();
 
         // Sends a message and optional cloned port to the remote port.
-        void postMessageToRemote(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>);
+        void postMessageToRemote(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>);
 
         // Extracts a message from the message queue for this port.
         bool tryGetMessageFromRemote(RefPtr<SerializedScriptValue>&, std::unique_ptr<MessagePortChannelArray>&);
index b3f5dd0..e523c9b 100644 (file)
@@ -39,11 +39,11 @@ namespace WebCore {
 
 class WEBCORE_EXPORT StaticNodeList final : public NodeList {
 public:
-    static PassRefPtr<StaticNodeList> adopt(Vector<Ref<Node>>& nodes)
+    static Ref<StaticNodeList> adopt(Vector<Ref<Node>>& nodes)
     {
-        RefPtr<StaticNodeList> nodeList = adoptRef(new StaticNodeList);
+        Ref<StaticNodeList> nodeList = adoptRef(*new StaticNodeList);
         nodeList->m_nodes.swap(nodes);
-        return nodeList.release();
+        return nodeList;
     }
 
     static Ref<StaticNodeList> createEmpty()
index eee2577..de8d3dc 100644 (file)
 
 namespace WebCore {
 
-PlatformMessagePortChannel::EventData::EventData(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
-    : m_message(message)
+PlatformMessagePortChannel::EventData::EventData(RefPtr<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray> channels)
+    : m_message(WTFMove(message))
     , m_channels(WTFMove(channels))
 {
 }
 
-void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2)
+void MessagePortChannel::createChannel(MessagePort* port1, MessagePort* port2)
 {
-    RefPtr<PlatformMessagePortChannel::MessagePortQueue> queue1 = PlatformMessagePortChannel::MessagePortQueue::create();
-    RefPtr<PlatformMessagePortChannel::MessagePortQueue> queue2 = PlatformMessagePortChannel::MessagePortQueue::create();
+    Ref<PlatformMessagePortChannel::MessagePortQueue> queue1 = PlatformMessagePortChannel::MessagePortQueue::create();
+    Ref<PlatformMessagePortChannel::MessagePortQueue> queue2 = PlatformMessagePortChannel::MessagePortQueue::create();
 
-    auto channel1 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue1, queue2));
-    auto channel2 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue2, queue1));
+    auto channel1 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue1.ptr(), queue2.ptr()));
+    auto channel2 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue2.ptr(), queue1.ptr()));
 
     channel1->m_channel->m_entangledChannel = channel2->m_channel;
     channel2->m_channel->m_entangledChannel = channel1->m_channel;
@@ -58,8 +58,8 @@ void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr
     port2->entangle(WTFMove(channel1));
 }
 
-MessagePortChannel::MessagePortChannel(PassRefPtr<PlatformMessagePortChannel> channel)
-    : m_channel(channel)
+MessagePortChannel::MessagePortChannel(RefPtr<PlatformMessagePortChannel>&& channel)
+    : m_channel(WTFMove(channel))
 {
 }
 
@@ -86,12 +86,12 @@ void MessagePortChannel::disentangle()
         remote->setRemotePort(nullptr);
 }
 
-void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
+void MessagePortChannel::postMessageToRemote(RefPtr<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray> channels)
 {
     LockHolder lock(m_channel->m_mutex);
     if (!m_channel->m_outgoingQueue)
         return;
-    bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(std::make_unique<PlatformMessagePortChannel::EventData>(message, WTFMove(channels)));
+    bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(std::make_unique<PlatformMessagePortChannel::EventData>(WTFMove(message), WTFMove(channels)));
     if (wasEmpty && m_channel->m_remotePort)
         m_channel->m_remotePort->messageAvailable();
 }
@@ -146,12 +146,12 @@ MessagePort* MessagePortChannel::locallyEntangledPort(const ScriptExecutionConte
     return 0;
 }
 
-Ref<PlatformMessagePortChannel> PlatformMessagePortChannel::create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing)
+Ref<PlatformMessagePortChannel> PlatformMessagePortChannel::create(MessagePortQueue* incoming, MessagePortQueue* outgoing)
 {
     return adoptRef(*new PlatformMessagePortChannel(incoming, outgoing));
 }
 
-PlatformMessagePortChannel::PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing)
+PlatformMessagePortChannel::PlatformMessagePortChannel(MessagePortQueue* incoming, MessagePortQueue* outgoing)
     : m_incomingQueue(incoming)
     , m_outgoingQueue(outgoing)
 {
index f45ff22..35dd8e1 100644 (file)
@@ -34,7 +34,6 @@
 #include "MessagePortChannel.h"
 
 #include <wtf/MessageQueue.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/Threading.h>
 
 namespace WebCore {
@@ -49,9 +48,9 @@ namespace WebCore {
         class EventData {
             WTF_MAKE_NONCOPYABLE(EventData); WTF_MAKE_FAST_ALLOCATED;
         public:
-            EventData(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray>);
+            EventData(RefPtr<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>);
 
-            PassRefPtr<SerializedScriptValue> message() { return m_message; }
+            RefPtr<SerializedScriptValue> message() { return m_message; }
             std::unique_ptr<MessagePortChannelArray> channels() { return WTFMove(m_channels); }
 
         private:
@@ -87,8 +86,8 @@ namespace WebCore {
 
         ~PlatformMessagePortChannel();
 
-        static Ref<PlatformMessagePortChannel> create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
-        PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
+        static Ref<PlatformMessagePortChannel> create(MessagePortQueue* incoming, MessagePortQueue* outgoing);
+        PlatformMessagePortChannel(MessagePortQueue* incoming, MessagePortQueue* outgoing);
 
         RefPtr<PlatformMessagePortChannel> entangledChannel();