From 57db5a39a436534789cb2c3b68fb0f6ad1051b40 Mon Sep 17 00:00:00 2001 From: "gyuyoung.kim@webkit.org" Date: Mon, 21 Mar 2016 06:05:49 +0000 Subject: [PATCH] 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): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198483 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 18 +++++++++++++++ Source/WebCore/dom/DocumentMarker.cpp | 2 +- Source/WebCore/dom/DocumentMarker.h | 2 +- Source/WebCore/dom/DocumentMarkerController.cpp | 4 ++-- Source/WebCore/dom/DocumentMarkerController.h | 2 +- Source/WebCore/dom/EventContext.cpp | 6 ++--- Source/WebCore/dom/EventContext.h | 6 ++--- Source/WebCore/dom/EventDispatcher.cpp | 8 +++---- Source/WebCore/dom/MessagePort.cpp | 8 +++---- Source/WebCore/dom/MessagePort.h | 5 ++--- Source/WebCore/dom/MessagePortChannel.h | 6 ++--- Source/WebCore/dom/StaticNodeList.h | 6 ++--- .../dom/default/PlatformMessagePortChannel.cpp | 26 +++++++++++----------- .../dom/default/PlatformMessagePortChannel.h | 9 ++++---- 14 files changed, 62 insertions(+), 46 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index e4d8d24..c716b31 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2016-03-20 Gyuyoung Kim + + 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 The setter of binaryType attribute in WebSocket should raise the exception. diff --git a/Source/WebCore/dom/DocumentMarker.cpp b/Source/WebCore/dom/DocumentMarker.cpp index 5b9f909..7f1d4ca 100644 --- a/Source/WebCore/dom/DocumentMarker.cpp +++ b/Source/WebCore/dom/DocumentMarker.cpp @@ -125,7 +125,7 @@ DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, bool ac ASSERT(m_details); } -DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, PassRefPtr details) +DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, RefPtr&& details) : m_type(type) , m_startOffset(startOffset) , m_endOffset(endOffset) diff --git a/Source/WebCore/dom/DocumentMarker.h b/Source/WebCore/dom/DocumentMarker.h index 9c66e33..dae0b6e 100644 --- a/Source/WebCore/dom/DocumentMarker.h +++ b/Source/WebCore/dom/DocumentMarker.h @@ -122,7 +122,7 @@ public: DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const String& description, const Vector& alternatives, RetainPtr metadata); #endif DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); - DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, PassRefPtr); + DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, RefPtr&&); MarkerType type() const { return m_type; } unsigned startOffset() const { return m_startOffset; } diff --git a/Source/WebCore/dom/DocumentMarkerController.cpp b/Source/WebCore/dom/DocumentMarkerController.cpp index 9d4b652..3822925 100644 --- a/Source/WebCore/dom/DocumentMarkerController.cpp +++ b/Source/WebCore/dom/DocumentMarkerController.cpp @@ -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 details) +void DocumentMarkerController::addMarkerToNode(Node* node, unsigned startOffset, unsigned length, DocumentMarker::MarkerType type, RefPtr&& details) { - addMarker(node, DocumentMarker(type, startOffset, startOffset + length, details)); + addMarker(node, DocumentMarker(type, startOffset, startOffset + length, WTFMove(details))); } diff --git a/Source/WebCore/dom/DocumentMarkerController.h b/Source/WebCore/dom/DocumentMarkerController.h index 1c90f7d..4bc0690 100644 --- a/Source/WebCore/dom/DocumentMarkerController.h +++ b/Source/WebCore/dom/DocumentMarkerController.h @@ -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); + void addMarkerToNode(Node*, unsigned startOffset, unsigned length, DocumentMarker::MarkerType, RefPtr&&); WEBCORE_EXPORT void addTextMatchMarker(const Range*, bool activeMatch); #if PLATFORM(IOS) void addMarker(Range*, DocumentMarker::MarkerType, const String& description, const Vector& interpretations, const RetainPtr& metadata); diff --git a/Source/WebCore/dom/EventContext.cpp b/Source/WebCore/dom/EventContext.cpp index d33634d..91f7af9b 100644 --- a/Source/WebCore/dom/EventContext.cpp +++ b/Source/WebCore/dom/EventContext.cpp @@ -34,7 +34,7 @@ namespace WebCore { -EventContext::EventContext(PassRefPtr node, PassRefPtr currentTarget, PassRefPtr 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, PassRefPtr currentTarget, PassRefPtr 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, PassRefPtr currentTarget, PassRefPtr target) +TouchEventContext::TouchEventContext(Node* node, EventTarget* currentTarget, EventTarget* target) : EventContext(node, currentTarget, target) , m_touches(TouchList::create()) , m_targetTouches(TouchList::create()) diff --git a/Source/WebCore/dom/EventContext.h b/Source/WebCore/dom/EventContext.h index a8aedab..f4ea8df 100644 --- a/Source/WebCore/dom/EventContext.h +++ b/Source/WebCore/dom/EventContext.h @@ -43,7 +43,7 @@ class EventContext { WTF_MAKE_FAST_ALLOCATED; public: // FIXME: Use ContainerNode instead of Node. - EventContext(PassRefPtr, PassRefPtr currentTarget, PassRefPtr 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, PassRefPtr currentTarget, PassRefPtr target); + MouseOrFocusEventContext(Node*, EventTarget* currentTarget, EventTarget*); virtual ~MouseOrFocusEventContext(); EventTarget* relatedTarget() const { return m_relatedTarget.get(); } void setRelatedTarget(PassRefPtr); @@ -81,7 +81,7 @@ private: #if ENABLE(TOUCH_EVENTS) class TouchEventContext final : public EventContext { public: - TouchEventContext(PassRefPtr, PassRefPtr currentTarget, PassRefPtr target); + TouchEventContext(Node*, EventTarget* currentTarget, EventTarget*); virtual ~TouchEventContext(); void handleLocalEvents(Event&) const override; diff --git a/Source/WebCore/dom/EventDispatcher.cpp b/Source/WebCore/dom/EventDispatcher.cpp index ddd769aa..1c93a4a 100644 --- a/Source/WebCore/dom/EventDispatcher.cpp +++ b/Source/WebCore/dom/EventDispatcher.cpp @@ -41,7 +41,7 @@ namespace WebCore { class WindowEventContext { public: - WindowEventContext(PassRefPtr, 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 m_target; }; -WindowEventContext::WindowEventContext(PassRefPtr 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(*topLevelContainer)) return; m_window = downcast(*topLevelContainer).domWindow(); - m_target = topEventContext ? topEventContext->target() : node.get(); + m_target = topEventContext ? topEventContext->target() : node; } bool WindowEventContext::handleLocalEvents(Event& event) diff --git a/Source/WebCore/dom/MessagePort.cpp b/Source/WebCore/dom/MessagePort.cpp index e0c2d02..2f5612a 100644 --- a/Source/WebCore/dom/MessagePort.cpp +++ b/Source/WebCore/dom/MessagePort.cpp @@ -52,15 +52,15 @@ MessagePort::~MessagePort() m_scriptExecutionContext->destroyedMessagePort(*this); } -void MessagePort::postMessage(PassRefPtr message, MessagePort* port, ExceptionCode& ec) +void MessagePort::postMessage(RefPtr&& 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 message, const MessagePortArray* ports, ExceptionCode& ec) +void MessagePort::postMessage(RefPtr&& message, const MessagePortArray* ports, ExceptionCode& ec) { if (!isEntangled()) return; @@ -79,7 +79,7 @@ void MessagePort::postMessage(PassRefPtr message, const M if (ec) return; } - m_entangledChannel->postMessageToRemote(message, WTFMove(channels)); + m_entangledChannel->postMessageToRemote(WTFMove(message), WTFMove(channels)); } std::unique_ptr MessagePort::disentangle() diff --git a/Source/WebCore/dom/MessagePort.h b/Source/WebCore/dom/MessagePort.h index 2965926..bae01d5 100644 --- a/Source/WebCore/dom/MessagePort.h +++ b/Source/WebCore/dom/MessagePort.h @@ -32,7 +32,6 @@ #include "MessagePortChannel.h" #include #include -#include #include #include @@ -51,9 +50,9 @@ namespace WebCore { static Ref create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(*new MessagePort(scriptExecutionContext)); } virtual ~MessagePort(); - void postMessage(PassRefPtr message, const MessagePortArray*, ExceptionCode&); + void postMessage(RefPtr&& message, const MessagePortArray*, ExceptionCode&); // Needed for Objective-C bindings (see bug 28774). - void postMessage(PassRefPtr message, MessagePort*, ExceptionCode&); + void postMessage(RefPtr&& message, MessagePort*, ExceptionCode&); void start(); void close(); diff --git a/Source/WebCore/dom/MessagePortChannel.h b/Source/WebCore/dom/MessagePortChannel.h index a711eff..985f1c5 100644 --- a/Source/WebCore/dom/MessagePortChannel.h +++ b/Source/WebCore/dom/MessagePortChannel.h @@ -55,8 +55,8 @@ namespace WebCore { class MessagePortChannel { WTF_MAKE_NONCOPYABLE(MessagePortChannel); WTF_MAKE_FAST_ALLOCATED; public: - explicit MessagePortChannel(PassRefPtr); - static void createChannel(PassRefPtr, PassRefPtr); + explicit MessagePortChannel(RefPtr&&); + 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, std::unique_ptr); + void postMessageToRemote(RefPtr&&, std::unique_ptr); // Extracts a message from the message queue for this port. bool tryGetMessageFromRemote(RefPtr&, std::unique_ptr&); diff --git a/Source/WebCore/dom/StaticNodeList.h b/Source/WebCore/dom/StaticNodeList.h index b3f5dd0..e523c9b 100644 --- a/Source/WebCore/dom/StaticNodeList.h +++ b/Source/WebCore/dom/StaticNodeList.h @@ -39,11 +39,11 @@ namespace WebCore { class WEBCORE_EXPORT StaticNodeList final : public NodeList { public: - static PassRefPtr adopt(Vector>& nodes) + static Ref adopt(Vector>& nodes) { - RefPtr nodeList = adoptRef(new StaticNodeList); + Ref nodeList = adoptRef(*new StaticNodeList); nodeList->m_nodes.swap(nodes); - return nodeList.release(); + return nodeList; } static Ref createEmpty() diff --git a/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp b/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp index eee2577..de8d3dc 100644 --- a/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp +++ b/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp @@ -37,19 +37,19 @@ namespace WebCore { -PlatformMessagePortChannel::EventData::EventData(PassRefPtr message, std::unique_ptr channels) - : m_message(message) +PlatformMessagePortChannel::EventData::EventData(RefPtr&& message, std::unique_ptr channels) + : m_message(WTFMove(message)) , m_channels(WTFMove(channels)) { } -void MessagePortChannel::createChannel(PassRefPtr port1, PassRefPtr port2) +void MessagePortChannel::createChannel(MessagePort* port1, MessagePort* port2) { - RefPtr queue1 = PlatformMessagePortChannel::MessagePortQueue::create(); - RefPtr queue2 = PlatformMessagePortChannel::MessagePortQueue::create(); + Ref queue1 = PlatformMessagePortChannel::MessagePortQueue::create(); + Ref queue2 = PlatformMessagePortChannel::MessagePortQueue::create(); - auto channel1 = std::make_unique(PlatformMessagePortChannel::create(queue1, queue2)); - auto channel2 = std::make_unique(PlatformMessagePortChannel::create(queue2, queue1)); + auto channel1 = std::make_unique(PlatformMessagePortChannel::create(queue1.ptr(), queue2.ptr())); + auto channel2 = std::make_unique(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 port1, PassRefPtr port2->entangle(WTFMove(channel1)); } -MessagePortChannel::MessagePortChannel(PassRefPtr channel) - : m_channel(channel) +MessagePortChannel::MessagePortChannel(RefPtr&& channel) + : m_channel(WTFMove(channel)) { } @@ -86,12 +86,12 @@ void MessagePortChannel::disentangle() remote->setRemotePort(nullptr); } -void MessagePortChannel::postMessageToRemote(PassRefPtr message, std::unique_ptr channels) +void MessagePortChannel::postMessageToRemote(RefPtr&& message, std::unique_ptr channels) { LockHolder lock(m_channel->m_mutex); if (!m_channel->m_outgoingQueue) return; - bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(std::make_unique(message, WTFMove(channels))); + bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(std::make_unique(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::create(PassRefPtr incoming, PassRefPtr outgoing) +Ref PlatformMessagePortChannel::create(MessagePortQueue* incoming, MessagePortQueue* outgoing) { return adoptRef(*new PlatformMessagePortChannel(incoming, outgoing)); } -PlatformMessagePortChannel::PlatformMessagePortChannel(PassRefPtr incoming, PassRefPtr outgoing) +PlatformMessagePortChannel::PlatformMessagePortChannel(MessagePortQueue* incoming, MessagePortQueue* outgoing) : m_incomingQueue(incoming) , m_outgoingQueue(outgoing) { diff --git a/Source/WebCore/dom/default/PlatformMessagePortChannel.h b/Source/WebCore/dom/default/PlatformMessagePortChannel.h index f45ff22..35dd8e1 100644 --- a/Source/WebCore/dom/default/PlatformMessagePortChannel.h +++ b/Source/WebCore/dom/default/PlatformMessagePortChannel.h @@ -34,7 +34,6 @@ #include "MessagePortChannel.h" #include -#include #include namespace WebCore { @@ -49,9 +48,9 @@ namespace WebCore { class EventData { WTF_MAKE_NONCOPYABLE(EventData); WTF_MAKE_FAST_ALLOCATED; public: - EventData(PassRefPtr message, std::unique_ptr); + EventData(RefPtr&& message, std::unique_ptr); - PassRefPtr message() { return m_message; } + RefPtr message() { return m_message; } std::unique_ptr channels() { return WTFMove(m_channels); } private: @@ -87,8 +86,8 @@ namespace WebCore { ~PlatformMessagePortChannel(); - static Ref create(PassRefPtr incoming, PassRefPtr outgoing); - PlatformMessagePortChannel(PassRefPtr incoming, PassRefPtr outgoing); + static Ref create(MessagePortQueue* incoming, MessagePortQueue* outgoing); + PlatformMessagePortChannel(MessagePortQueue* incoming, MessagePortQueue* outgoing); RefPtr entangledChannel(); -- 1.8.3.1