Return Ref instead of PassRefPtr in create() factory functions of WebCore/dom
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 May 2015 00:30:29 +0000 (00:30 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 May 2015 00:30:29 +0000 (00:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144904

Reviewed by Andreas Kling.

We return Ref when we're sure if pointer can't be null. If not, we use RefPtr instead PassRefPtr.

No new tests, no behavior changes.

* dom/AutocompleteErrorEvent.h:
* dom/DOMNamedFlowCollection.h:
(WebCore::DOMNamedFlowCollection::create):
* dom/MessageChannel.h:
(WebCore::MessageChannel::create):
* dom/MessagePort.h:
* dom/MutationObserver.cpp:
(WebCore::MutationObserver::create):
* dom/MutationObserver.h:
* dom/NamedFlowCollection.h:
* dom/NodeFilter.h:
(WebCore::NodeFilter::create):
* dom/NodeIterator.h:
(WebCore::NodeIterator::create):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::create):
* dom/ProcessingInstruction.h:
* dom/ScriptedAnimationController.h:
(WebCore::ScriptedAnimationController::create):
* dom/SecurityPolicyViolationEvent.h:
* dom/StaticNodeList.h:
* dom/TemplateContentDocumentFragment.h:
* dom/Touch.cpp:
(WebCore::Touch::cloneWithNewTarget):
* dom/Touch.h:
(WebCore::Touch::create):
* dom/TouchEvent.h:
* dom/TouchList.h:
(WebCore::TouchList::create):
* dom/TreeWalker.h:
(WebCore::TreeWalker::create):
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::create):
* dom/WebKitNamedFlow.h:
* dom/default/PlatformMessagePortChannel.cpp:
(WebCore::PlatformMessagePortChannel::create):
* dom/default/PlatformMessagePortChannel.h:
(WebCore::PlatformMessagePortChannel::MessagePortQueue::create):

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

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/AutocompleteErrorEvent.h
Source/WebCore/dom/DOMNamedFlowCollection.h
Source/WebCore/dom/MessageChannel.h
Source/WebCore/dom/MessagePort.h
Source/WebCore/dom/MutationObserver.cpp
Source/WebCore/dom/MutationObserver.h
Source/WebCore/dom/NamedFlowCollection.h
Source/WebCore/dom/NodeFilter.h
Source/WebCore/dom/NodeIterator.h
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/ProcessingInstruction.h
Source/WebCore/dom/ScriptedAnimationController.h
Source/WebCore/dom/SecurityPolicyViolationEvent.h
Source/WebCore/dom/StaticNodeList.h
Source/WebCore/dom/TemplateContentDocumentFragment.h
Source/WebCore/dom/Touch.cpp
Source/WebCore/dom/Touch.h
Source/WebCore/dom/TouchEvent.h
Source/WebCore/dom/TouchList.h
Source/WebCore/dom/TreeWalker.h
Source/WebCore/dom/WebKitNamedFlow.cpp
Source/WebCore/dom/WebKitNamedFlow.h
Source/WebCore/dom/default/PlatformMessagePortChannel.cpp
Source/WebCore/dom/default/PlatformMessagePortChannel.h

index 9b58810..bc4afef 100644 (file)
@@ -1,3 +1,53 @@
+2015-05-12  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Return Ref instead of PassRefPtr in create() factory functions of WebCore/dom
+        https://bugs.webkit.org/show_bug.cgi?id=144904
+
+        Reviewed by Andreas Kling.
+
+        We return Ref when we're sure if pointer can't be null. If not, we use RefPtr instead PassRefPtr.
+
+        No new tests, no behavior changes.
+
+        * dom/AutocompleteErrorEvent.h:
+        * dom/DOMNamedFlowCollection.h:
+        (WebCore::DOMNamedFlowCollection::create):
+        * dom/MessageChannel.h:
+        (WebCore::MessageChannel::create):
+        * dom/MessagePort.h:
+        * dom/MutationObserver.cpp:
+        (WebCore::MutationObserver::create):
+        * dom/MutationObserver.h:
+        * dom/NamedFlowCollection.h:
+        * dom/NodeFilter.h:
+        (WebCore::NodeFilter::create):
+        * dom/NodeIterator.h:
+        (WebCore::NodeIterator::create):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::create):
+        * dom/ProcessingInstruction.h:
+        * dom/ScriptedAnimationController.h:
+        (WebCore::ScriptedAnimationController::create):
+        * dom/SecurityPolicyViolationEvent.h:
+        * dom/StaticNodeList.h:
+        * dom/TemplateContentDocumentFragment.h:
+        * dom/Touch.cpp:
+        (WebCore::Touch::cloneWithNewTarget):
+        * dom/Touch.h:
+        (WebCore::Touch::create):
+        * dom/TouchEvent.h:
+        * dom/TouchList.h:
+        (WebCore::TouchList::create):
+        * dom/TreeWalker.h:
+        (WebCore::TreeWalker::create):
+        * dom/WebKitNamedFlow.cpp:
+        (WebCore::WebKitNamedFlow::create):
+        * dom/WebKitNamedFlow.h:
+        * dom/default/PlatformMessagePortChannel.cpp:
+        (WebCore::PlatformMessagePortChannel::create):
+        * dom/default/PlatformMessagePortChannel.h:
+        (WebCore::PlatformMessagePortChannel::MessagePortQueue::create):
+
 2015-05-12  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: REGRESSION (r181625): Timeline recording started from console.profile is always empty
index 29197ed..c2a500d 100644 (file)
@@ -40,7 +40,7 @@ class AutocompleteErrorEvent final : public Event {
 public:
     static Ref<AutocompleteErrorEvent> create()
     {
-        return adoptRef(new AutocompleteErrorEvent);
+        return adoptRef(*new AutocompleteErrorEvent);
     }
 
     static Ref<AutocompleteErrorEvent> create(const String& reason)
index d223ea2..d9a798b 100644 (file)
@@ -42,9 +42,9 @@ class WebKitNamedFlow;
 
 class DOMNamedFlowCollection : public RefCounted<DOMNamedFlowCollection> {
 public:
-    static PassRefPtr<DOMNamedFlowCollection> create(const Vector<WebKitNamedFlow*>& namedFlows)
+    static Ref<DOMNamedFlowCollection> create(const Vector<WebKitNamedFlow*>& namedFlows)
     {
-        return adoptRef(new DOMNamedFlowCollection(namedFlows));
+        return adoptRef(*new DOMNamedFlowCollection(namedFlows));
     }
 
     unsigned long length() const;
index 52b316b..f37e74a 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 
     class MessageChannel : public RefCounted<MessageChannel> {
     public:
-        static PassRefPtr<MessageChannel> create(ScriptExecutionContext& context) { return adoptRef(new MessageChannel(context)); }
+        static Ref<MessageChannel> create(ScriptExecutionContext& context) { return adoptRef(*new MessageChannel(context)); }
         ~MessageChannel();
 
         MessagePort* port1() const { return m_port1.get(); }
index 97445d5..11fcf57 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
 
     class MessagePort final : public RefCounted<MessagePort>, public EventTargetWithInlineData {
     public:
-        static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(new MessagePort(scriptExecutionContext)); }
+        static Ref<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(*new MessagePort(scriptExecutionContext)); }
         virtual ~MessagePort();
 
         void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
index 77458f8..8220fe8 100644 (file)
@@ -45,10 +45,10 @@ namespace WebCore {
 
 static unsigned s_observerPriority = 0;
 
-PassRefPtr<MutationObserver> MutationObserver::create(PassRefPtr<MutationCallback> callback)
+Ref<MutationObserver> MutationObserver::create(PassRefPtr<MutationCallback> callback)
 {
     ASSERT(isMainThread());
-    return adoptRef(new MutationObserver(callback));
+    return adoptRef(*new MutationObserver(callback));
 }
 
 MutationObserver::MutationObserver(PassRefPtr<MutationCallback> callback)
index d35294a..3a7407e 100644 (file)
@@ -72,7 +72,7 @@ public:
         CharacterDataOldValue = 1 << 6,
     };
 
-    static PassRefPtr<MutationObserver> create(PassRefPtr<MutationCallback>);
+    static Ref<MutationObserver> create(PassRefPtr<MutationCallback>);
     static void deliverAllMutations();
 
     ~MutationObserver();
index 8ef2f7f..47501d7 100644 (file)
@@ -45,7 +45,7 @@ class DOMNamedFlowCollection;
 
 class NamedFlowCollection final : public RefCounted<NamedFlowCollection>, public ContextDestructionObserver {
 public:
-    static PassRefPtr<NamedFlowCollection> create(Document* doc) { return adoptRef(new NamedFlowCollection(doc)); }
+    static Ref<NamedFlowCollection> create(Document* doc) { return adoptRef(*new NamedFlowCollection(doc)); }
 
     Vector<RefPtr<WebKitNamedFlow>> namedFlows();
     WebKitNamedFlow* flowByName(const String&);
index 1aad6fe..96197d9 100644 (file)
@@ -65,14 +65,14 @@ namespace WebCore {
             SHOW_NOTATION                  = 0x00000800
         };
 
-        static PassRefPtr<NodeFilter> create(PassRefPtr<NodeFilterCondition> condition)
+        static Ref<NodeFilter> create(PassRefPtr<NodeFilterCondition> condition)
         {
-            return adoptRef(new NodeFilter(condition));
+            return adoptRef(*new NodeFilter(condition));
         }
 
-        static PassRefPtr<NodeFilter> create()
+        static Ref<NodeFilter> create()
         {
-            return adoptRef(new NodeFilter());
+            return adoptRef(*new NodeFilter());
         }
 
         short acceptNode(JSC::ExecState*, Node*) const;
index 710be45..acf1cd6 100644 (file)
@@ -37,9 +37,9 @@ namespace WebCore {
 
     class NodeIterator : public ScriptWrappable, public RefCounted<NodeIterator>, public NodeIteratorBase {
     public:
-        static PassRefPtr<NodeIterator> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
+        static Ref<NodeIterator> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
         {
-            return adoptRef(new NodeIterator(rootNode, whatToShow, filter, expandEntityReferences));
+            return adoptRef(*new NodeIterator(rootNode, whatToShow, filter, expandEntityReferences));
         }
         ~NodeIterator();
 
index e27f633..3ecb646 100644 (file)
@@ -52,9 +52,9 @@ inline ProcessingInstruction::ProcessingInstruction(Document& document, const St
 {
 }
 
-RefPtr<ProcessingInstruction> ProcessingInstruction::create(Document& document, const String& target, const String& data)
+Ref<ProcessingInstruction> ProcessingInstruction::create(Document& document, const String& target, const String& data)
 {
-    return adoptRef(new ProcessingInstruction(document, target, data));
+    return adoptRef(*new ProcessingInstruction(document, target, data));
 }
 
 ProcessingInstruction::~ProcessingInstruction()
index ab82f26..21fd9e9 100644 (file)
@@ -34,7 +34,7 @@ class CSSStyleSheet;
 
 class ProcessingInstruction final : public CharacterData, private CachedStyleSheetClient {
 public:
-    static RefPtr<ProcessingInstruction> create(Document&, const String& target, const String& data);
+    static Ref<ProcessingInstruction> create(Document&, const String& target, const String& data);
     virtual ~ProcessingInstruction();
 
     const String& target() const { return m_target; }
index 89ab019..eaf191b 100644 (file)
@@ -52,9 +52,9 @@ class ScriptedAnimationController : public RefCounted<ScriptedAnimationControlle
 #endif
 {
 public:
-    static PassRefPtr<ScriptedAnimationController> create(Document* document, PlatformDisplayID displayID)
+    static Ref<ScriptedAnimationController> create(Document* document, PlatformDisplayID displayID)
     {
-        return adoptRef(new ScriptedAnimationController(document, displayID));
+        return adoptRef(*new ScriptedAnimationController(document, displayID));
     }
     ~ScriptedAnimationController();
     void clearDocumentPointer() { m_document = 0; }
index 99f2278..f5b6585 100644 (file)
@@ -48,14 +48,14 @@ struct SecurityPolicyViolationEventInit : public EventInit {
 
 class SecurityPolicyViolationEvent final : public Event {
 public:
-    static PassRefPtr<SecurityPolicyViolationEvent> create()
+    static Ref<SecurityPolicyViolationEvent> create()
     {
-        return adoptRef(new SecurityPolicyViolationEvent());
+        return adoptRef(*new SecurityPolicyViolationEvent());
     }
 
-    static PassRefPtr<SecurityPolicyViolationEvent> create(const AtomicString& type, const SecurityPolicyViolationEventInit& initializer)
+    static Ref<SecurityPolicyViolationEvent> create(const AtomicString& type, const SecurityPolicyViolationEventInit& initializer)
     {
-        return adoptRef(new SecurityPolicyViolationEvent(type, initializer));
+        return adoptRef(*new SecurityPolicyViolationEvent(type, initializer));
     }
 
     const String& documentURI() const { return m_documentURI; }
index 7df0c81..260eb22 100644 (file)
@@ -46,9 +46,9 @@ public:
         return nodeList.release();
     }
 
-    static PassRefPtr<StaticNodeList> createEmpty()
+    static Ref<StaticNodeList> createEmpty()
     {
-        return adoptRef(new StaticNodeList);
+        return adoptRef(*new StaticNodeList);
     }
 
     virtual unsigned length() const override;
@@ -70,9 +70,9 @@ public:
         return nodeList.release();
     }
 
-    static PassRefPtr<StaticElementList> createEmpty()
+    static Ref<StaticElementList> createEmpty()
     {
-        return adoptRef(new StaticElementList);
+        return adoptRef(*new StaticElementList);
     }
 
     virtual unsigned length() const override;
index f8b6198..7bd1d7e 100644 (file)
@@ -35,9 +35,9 @@ namespace WebCore {
 
 class TemplateContentDocumentFragment final : public DocumentFragment {
 public:
-    static RefPtr<TemplateContentDocumentFragment> create(Document& document, const Element* host)
+    static Ref<TemplateContentDocumentFragment> create(Document& document, const Element* host)
     {
-        return adoptRef(new TemplateContentDocumentFragment(document, host));
+        return adoptRef(*new TemplateContentDocumentFragment(document, host));
     }
 
     const Element* host() const { return m_host; }
index 4540ee7..0ce8dd9 100644 (file)
@@ -90,9 +90,9 @@ Touch::Touch(EventTarget* target, unsigned identifier, int clientX, int clientY,
 {
 }
 
-PassRefPtr<Touch> Touch::cloneWithNewTarget(EventTarget* eventTarget) const
+Ref<Touch> Touch::cloneWithNewTarget(EventTarget* eventTarget) const
 {
-    return adoptRef(new Touch(eventTarget, m_identifier, m_clientX, m_clientY, m_screenX, m_screenY, m_pageX, m_pageY, m_radiusX, m_radiusY, m_rotationAngle, m_force, m_absoluteLocation));
+    return adoptRef(*new Touch(eventTarget, m_identifier, m_clientX, m_clientY, m_screenX, m_screenY, m_pageX, m_pageY, m_radiusX, m_radiusY, m_rotationAngle, m_force, m_absoluteLocation));
 }
 
 } // namespace WebCore
index b4f089b..307bd02 100644 (file)
@@ -42,11 +42,11 @@ class Frame;
 
 class Touch : public RefCounted<Touch> {
 public:
-    static PassRefPtr<Touch> create(Frame* frame, EventTarget* target,
+    static Ref<Touch> create(Frame* frame, EventTarget* target,
             unsigned identifier, int screenX, int screenY, int pageX, int pageY,
             int radiusX, int radiusY, float rotationAngle, float force)
     {
-        return adoptRef(new Touch(frame, target, identifier, screenX, 
+        return adoptRef(*new Touch(frame, target, identifier, screenX, 
                 screenY, pageX, pageY, radiusX, radiusY, rotationAngle, force));
     }
 
@@ -63,7 +63,7 @@ public:
     float webkitRotationAngle() const { return m_rotationAngle; }
     float webkitForce() const { return m_force; }
     const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }
-    PassRefPtr<Touch> cloneWithNewTarget(EventTarget*) const;
+    Ref<Touch> cloneWithNewTarget(EventTarget*) const;
 
 private:
     Touch(Frame* frame, EventTarget* target, unsigned identifier,
index 1515afd..5618ab0 100644 (file)
@@ -44,13 +44,13 @@ public:
     {
         return adoptRef(*new TouchEvent);
     }
-    static PassRefPtr<TouchEvent> create(TouchList* touches, 
+    static Ref<TouchEvent> create(TouchList* touches, 
             TouchList* targetTouches, TouchList* changedTouches, 
             const AtomicString& type, PassRefPtr<AbstractView> view,
             int screenX, int screenY, int pageX, int pageY,
             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
     {
-        return adoptRef(new TouchEvent(touches, targetTouches, changedTouches,
+        return adoptRef(*new TouchEvent(touches, targetTouches, changedTouches,
                 type, view, screenX, screenY, pageX, pageY,
                 ctrlKey, altKey, shiftKey, metaKey));
     }
index 9da01b6..562e3a1 100644 (file)
@@ -38,9 +38,9 @@ namespace WebCore {
 
 class TouchList : public RefCounted<TouchList> {
 public:
-    static PassRefPtr<TouchList> create()
+    static Ref<TouchList> create()
     {
-        return adoptRef(new TouchList);
+        return adoptRef(*new TouchList);
     }
 
     unsigned length() const { return m_values.size(); }
index 6cf575b..5f42ced 100644 (file)
@@ -37,9 +37,9 @@ namespace WebCore {
 
     class TreeWalker : public ScriptWrappable, public RefCounted<TreeWalker>, public NodeIteratorBase {
     public:
-        static PassRefPtr<TreeWalker> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
+        static Ref<TreeWalker> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
         {
-            return adoptRef(new TreeWalker(rootNode, whatToShow, filter, expandEntityReferences));
+            return adoptRef(*new TreeWalker(rootNode, whatToShow, filter, expandEntityReferences));
         }                            
 
         Node* currentNode() const { return m_current.get(); }
index 87c4e1f..3974bf7 100644 (file)
@@ -52,9 +52,9 @@ WebKitNamedFlow::~WebKitNamedFlow()
     m_flowManager->discardNamedFlow(this);
 }
 
-PassRefPtr<WebKitNamedFlow> WebKitNamedFlow::create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
+Ref<WebKitNamedFlow> WebKitNamedFlow::create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
 {
-    return adoptRef(new WebKitNamedFlow(manager, flowThreadName));
+    return adoptRef(*new WebKitNamedFlow(manager, flowThreadName));
 }
 
 const AtomicString& WebKitNamedFlow::name() const
index e5f4318..ff8611d 100644 (file)
@@ -48,7 +48,7 @@ class ScriptExecutionContext;
 
 class WebKitNamedFlow final : public RefCounted<WebKitNamedFlow>, public EventTargetWithInlineData {
 public:
-    static PassRefPtr<WebKitNamedFlow> create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName);
+    static Ref<WebKitNamedFlow> create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName);
 
     ~WebKitNamedFlow();
 
index 6cb0e15..c68611f 100644 (file)
@@ -146,9 +146,9 @@ MessagePort* MessagePortChannel::locallyEntangledPort(const ScriptExecutionConte
     return 0;
 }
 
-PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing)
+Ref<PlatformMessagePortChannel> PlatformMessagePortChannel::create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing)
 {
-    return adoptRef(new PlatformMessagePortChannel(incoming, outgoing));
+    return adoptRef(*new PlatformMessagePortChannel(incoming, outgoing));
 }
 
 PlatformMessagePortChannel::PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing)
index 954eb88..b703d12 100644 (file)
@@ -62,7 +62,7 @@ namespace WebCore {
         // Wrapper for MessageQueue that allows us to do thread safe sharing by two proxies.
         class MessagePortQueue : public ThreadSafeRefCounted<MessagePortQueue> {
         public:
-            static PassRefPtr<MessagePortQueue> create() { return adoptRef(new MessagePortQueue()); }
+            static Ref<MessagePortQueue> create() { return adoptRef(*new MessagePortQueue()); }
 
             std::unique_ptr<PlatformMessagePortChannel::EventData> tryGetMessage()
             {
@@ -87,7 +87,7 @@ namespace WebCore {
 
         ~PlatformMessagePortChannel();
 
-        static PassRefPtr<PlatformMessagePortChannel> create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
+        static Ref<PlatformMessagePortChannel> create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
         PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
 
         PassRefPtr<PlatformMessagePortChannel> entangledChannel();