Use Ref instead of PassRefPtr in WebCore/bindings
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2015 05:55:22 +0000 (05:55 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2015 05:55:22 +0000 (05:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144981

Reviewed by Darin Adler.

As a step to purge PassRefPtr, remove PassRefPtr in WebCore/bindings.

No new tests, no behavior changes.

* bindings/gobject/GObjectNodeFilterCondition.h:
(WebCore::GObjectNodeFilterCondition::create):
* bindings/gobject/GObjectXPathNSResolver.h:
(WebCore::GObjectXPathNSResolver::create):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::create):
* bindings/js/JSCustomXPathNSResolver.h:
* bindings/js/JSDOMGlobalObjectTask.cpp:
* bindings/js/JSErrorHandler.h:
(WebCore::JSErrorHandler::create):
* bindings/js/JSLazyEventListener.cpp:
(WebCore::JSLazyEventListener::createForNode):
(WebCore::JSLazyEventListener::createForDOMWindow):
* bindings/js/JSLazyEventListener.h:
* bindings/js/JSMutationCallback.h:
(WebCore::JSMutationCallback::create):
* bindings/js/JSNodeFilterCondition.h:
(WebCore::JSNodeFilterCondition::create):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::create):
(WebCore::SerializedScriptValue::numberValue):
(WebCore::SerializedScriptValue::undefinedValue):
(WebCore::SerializedScriptValue::nullValue):
* bindings/js/SerializedScriptValue.h:
* bindings/objc/ObjCEventListener.h:
* bindings/objc/ObjCEventListener.mm:
(WebCore::ObjCEventListener::wrap):
* bindings/objc/ObjCNodeFilterCondition.h:
(WebCore::ObjCNodeFilterCondition::create):

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.h
Source/WebCore/bindings/gobject/GObjectXPathNSResolver.h
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSCustomXPathNSResolver.h
Source/WebCore/bindings/js/JSDOMGlobalObjectTask.cpp
Source/WebCore/bindings/js/JSErrorHandler.h
Source/WebCore/bindings/js/JSLazyEventListener.cpp
Source/WebCore/bindings/js/JSLazyEventListener.h
Source/WebCore/bindings/js/JSMutationCallback.h
Source/WebCore/bindings/js/JSNodeFilterCondition.h
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/bindings/js/SerializedScriptValue.h
Source/WebCore/bindings/objc/ObjCEventListener.h
Source/WebCore/bindings/objc/ObjCEventListener.mm
Source/WebCore/bindings/objc/ObjCNodeFilterCondition.h

index 6c1610f..de46fcf 100644 (file)
@@ -1,3 +1,44 @@
+2015-05-18  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Use Ref instead of PassRefPtr in WebCore/bindings
+        https://bugs.webkit.org/show_bug.cgi?id=144981
+
+        Reviewed by Darin Adler.
+
+        As a step to purge PassRefPtr, remove PassRefPtr in WebCore/bindings.
+
+        No new tests, no behavior changes.
+
+        * bindings/gobject/GObjectNodeFilterCondition.h:
+        (WebCore::GObjectNodeFilterCondition::create):
+        * bindings/gobject/GObjectXPathNSResolver.h:
+        (WebCore::GObjectXPathNSResolver::create):
+        * bindings/js/JSCustomXPathNSResolver.cpp:
+        (WebCore::JSCustomXPathNSResolver::create):
+        * bindings/js/JSCustomXPathNSResolver.h:
+        * bindings/js/JSDOMGlobalObjectTask.cpp:
+        * bindings/js/JSErrorHandler.h:
+        (WebCore::JSErrorHandler::create):
+        * bindings/js/JSLazyEventListener.cpp:
+        (WebCore::JSLazyEventListener::createForNode):
+        (WebCore::JSLazyEventListener::createForDOMWindow):
+        * bindings/js/JSLazyEventListener.h:
+        * bindings/js/JSMutationCallback.h:
+        (WebCore::JSMutationCallback::create):
+        * bindings/js/JSNodeFilterCondition.h:
+        (WebCore::JSNodeFilterCondition::create):
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::SerializedScriptValue::create):
+        (WebCore::SerializedScriptValue::numberValue):
+        (WebCore::SerializedScriptValue::undefinedValue):
+        (WebCore::SerializedScriptValue::nullValue):
+        * bindings/js/SerializedScriptValue.h:
+        * bindings/objc/ObjCEventListener.h:
+        * bindings/objc/ObjCEventListener.mm:
+        (WebCore::ObjCEventListener::wrap):
+        * bindings/objc/ObjCNodeFilterCondition.h:
+        (WebCore::ObjCNodeFilterCondition::create):
+
 2015-05-18  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Fix uninitialized warnings in RealtimeMediaSourceCenterOwr.cpp
index 1d21bf7..911ed73 100644 (file)
@@ -32,9 +32,9 @@ class Node;
 class GObjectNodeFilterCondition : public NodeFilterCondition {
 public:
 
-    static PassRefPtr<GObjectNodeFilterCondition> create(WebKitDOMNodeFilter* filter)
+    static Ref<GObjectNodeFilterCondition> create(WebKitDOMNodeFilter* filter)
     {
-        return adoptRef(new GObjectNodeFilterCondition(filter));
+        return adoptRef(*new GObjectNodeFilterCondition(filter));
     }
 
     virtual short acceptNode(JSC::ExecState*, Node*) const;
index 66c11ae..eaa35f9 100644 (file)
@@ -29,9 +29,9 @@ namespace WebCore {
 class GObjectXPathNSResolver : public XPathNSResolver {
 public:
 
-    static PassRefPtr<GObjectXPathNSResolver> create(WebKitDOMXPathNSResolver* resolver)
+    static Ref<GObjectXPathNSResolver> create(WebKitDOMXPathNSResolver* resolver)
     {
-        return adoptRef(new GObjectXPathNSResolver(resolver));
+        return adoptRef(*new GObjectXPathNSResolver(resolver));
     }
 
     virtual ~GObjectXPathNSResolver();
index 54eb331..07d22df 100644 (file)
@@ -42,18 +42,18 @@ namespace WebCore {
 
 using namespace JSC;
 
-PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(ExecState* exec, JSValue value)
+RefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(ExecState* exec, JSValue value)
 {
     if (value.isUndefinedOrNull())
-        return 0;
+        return nullptr;
 
     JSObject* resolverObject = value.getObject();
     if (!resolverObject) {
         setDOMException(exec, TYPE_MISMATCH_ERR);
-        return 0;
+        return nullptr;
     }
 
-    return adoptRef(new JSCustomXPathNSResolver(exec, resolverObject, asJSDOMWindow(exec->vmEntryGlobalObject())));
+    return adoptRef(*new JSCustomXPathNSResolver(exec, resolverObject, asJSDOMWindow(exec->vmEntryGlobalObject())));
 }
 
 JSCustomXPathNSResolver::JSCustomXPathNSResolver(ExecState* exec, JSObject* customResolver, JSDOMWindow* globalObject)
index 7a402a0..adbc677 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 
     class JSCustomXPathNSResolver : public XPathNSResolver {
     public:
-        static PassRefPtr<JSCustomXPathNSResolver> create(JSC::ExecState*, JSC::JSValue);
+        static RefPtr<JSCustomXPathNSResolver> create(JSC::ExecState*, JSC::JSValue);
         
         virtual ~JSCustomXPathNSResolver();
 
index 242050b..1f21fc6 100644 (file)
@@ -38,9 +38,9 @@ namespace WebCore {
 
 class JSGlobalObjectCallback final : public RefCounted<JSGlobalObjectCallback>, private ActiveDOMCallback {
 public:
-    static PassRefPtr<JSGlobalObjectCallback> create(JSDOMGlobalObject* globalObject, PassRefPtr<Microtask> task)
+    static Ref<JSGlobalObjectCallback> create(JSDOMGlobalObject* globalObject, PassRefPtr<Microtask> task)
     {
-        return adoptRef(new JSGlobalObjectCallback(globalObject, task));
+        return adoptRef(*new JSGlobalObjectCallback(globalObject, task));
     }
 
     void call()
index 55d2d53..dfe13c2 100644 (file)
@@ -37,9 +37,9 @@ namespace WebCore {
 
 class JSErrorHandler : public JSEventListener {
 public:
-    static PassRefPtr<JSErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld& world)
+    static Ref<JSErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld& world)
     {
-        return adoptRef(new JSErrorHandler(listener, wrapper, isAttribute, world));
+        return adoptRef(*new JSErrorHandler(listener, wrapper, isAttribute, world));
     }
 
     virtual ~JSErrorHandler();
index cf1337f..6661a60 100644 (file)
@@ -142,7 +142,7 @@ static const String& eventParameterName(bool isSVGEvent)
     return isSVGEvent ? evtString : eventString;
 }
 
-PassRefPtr<JSLazyEventListener> JSLazyEventListener::createForNode(ContainerNode& node, const QualifiedName& attributeName, const AtomicString& attributeValue)
+RefPtr<JSLazyEventListener> JSLazyEventListener::createForNode(ContainerNode& node, const QualifiedName& attributeName, const AtomicString& attributeValue)
 {
     if (attributeValue.isNull())
         return nullptr;
@@ -159,12 +159,12 @@ PassRefPtr<JSLazyEventListener> JSLazyEventListener::createForNode(ContainerNode
         sourceURL = node.document().url().string();
     }
 
-    return adoptRef(new JSLazyEventListener(attributeName.localName().string(),
+    return adoptRef(*new JSLazyEventListener(attributeName.localName().string(),
         eventParameterName(node.isSVGElement()), attributeValue,
         &node, sourceURL, position, nullptr, mainThreadNormalWorld()));
 }
 
-PassRefPtr<JSLazyEventListener> JSLazyEventListener::createForDOMWindow(Frame& frame, const QualifiedName& attributeName, const AtomicString& attributeValue)
+RefPtr<JSLazyEventListener> JSLazyEventListener::createForDOMWindow(Frame& frame, const QualifiedName& attributeName, const AtomicString& attributeValue)
 {
     if (attributeValue.isNull())
         return nullptr;
@@ -172,7 +172,7 @@ PassRefPtr<JSLazyEventListener> JSLazyEventListener::createForDOMWindow(Frame& f
     if (!frame.script().canExecuteScripts(AboutToExecuteScript))
         return nullptr;
 
-    return adoptRef(new JSLazyEventListener(attributeName.localName().string(),
+    return adoptRef(*new JSLazyEventListener(attributeName.localName().string(),
         eventParameterName(frame.document()->isSVGDocument()), attributeValue,
         nullptr, frame.document()->url().string(), frame.script().eventHandlerPosition(),
         toJSDOMWindow(&frame, mainThreadNormalWorld()), mainThreadNormalWorld()));
index 3190017..d918d76 100644 (file)
@@ -32,8 +32,8 @@ namespace WebCore {
 
     class JSLazyEventListener final : public JSEventListener {
     public:
-        static PassRefPtr<JSLazyEventListener> createForNode(ContainerNode&, const QualifiedName& attributeName, const AtomicString& attributeValue);
-        static PassRefPtr<JSLazyEventListener> createForDOMWindow(Frame&, const QualifiedName& attributeName, const AtomicString& attributeValue);
+        static RefPtr<JSLazyEventListener> createForNode(ContainerNode&, const QualifiedName& attributeName, const AtomicString& attributeValue);
+        static RefPtr<JSLazyEventListener> createForDOMWindow(Frame&, const QualifiedName& attributeName, const AtomicString& attributeValue);
 
         virtual ~JSLazyEventListener();
 
index d7bd848..cb713f7 100644 (file)
@@ -39,9 +39,9 @@ class JSDOMGlobalObject;
 
 class JSMutationCallback : public MutationCallback, public ActiveDOMCallback {
 public:
-    static PassRefPtr<JSMutationCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
+    static Ref<JSMutationCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
-        return adoptRef(new JSMutationCallback(callback, globalObject));
+        return adoptRef(*new JSMutationCallback(callback, globalObject));
     }
 
     virtual ~JSMutationCallback();
index ae82191..a6a1be3 100644 (file)
@@ -34,9 +34,9 @@ namespace WebCore {
 
     class JSNodeFilterCondition : public NodeFilterCondition {
     public:
-        static PassRefPtr<JSNodeFilterCondition> create(JSC::VM& vm, NodeFilter* owner, JSC::JSValue filter)
+        static Ref<JSNodeFilterCondition> create(JSC::VM& vm, NodeFilter* owner, JSC::JSValue filter)
         {
-            return adoptRef(new JSNodeFilterCondition(vm, owner, filter));
+            return adoptRef(*new JSNodeFilterCondition(vm, owner, filter));
         }
 
     private:
index d96ed77..6994880 100644 (file)
@@ -2650,9 +2650,7 @@ std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScrip
     return contents;
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, JSValue value,
-                                                                MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
-                                                                SerializationErrorMode throwExceptions)
+RefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, JSValue value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, SerializationErrorMode throwExceptions)
 {
     Vector<uint8_t> buffer;
     Vector<String> blobURLs;
@@ -2667,32 +2665,32 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec,
         maybeThrowExceptionIfSerializationFailed(exec, code);
 
     if (!serializationDidCompleteSuccessfully(code))
-        return 0;
+        return nullptr;
 
-    return adoptRef(new SerializedScriptValue(buffer, blobURLs, WTF::move(arrayBufferContentsArray)));
+    return adoptRef(*new SerializedScriptValue(buffer, blobURLs, WTF::move(arrayBufferContentsArray)));
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& string)
+RefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& string)
 {
     Vector<uint8_t> buffer;
     if (!CloneSerializer::serialize(string, buffer))
-        return 0;
-    return adoptRef(new SerializedScriptValue(buffer));
+        return nullptr;
+    return adoptRef(*new SerializedScriptValue(buffer));
 }
 
 #if ENABLE(INDEXED_DATABASE)
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double value)
+Ref<SerializedScriptValue> SerializedScriptValue::numberValue(double value)
 {
     Vector<uint8_t> buffer;
     CloneSerializer::serializeNumber(value, buffer);
-    return adoptRef(new SerializedScriptValue(buffer));
+    return adoptRef(*new SerializedScriptValue(buffer));
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue()
+Ref<SerializedScriptValue> SerializedScriptValue::undefinedValue()
 {
     Vector<uint8_t> buffer;
     CloneSerializer::serializeUndefined(buffer);
-    return adoptRef(new SerializedScriptValue(buffer));
+    return adoptRef(*new SerializedScriptValue(buffer));
 }
 #endif
 
@@ -2742,10 +2740,10 @@ JSValueRef SerializedScriptValue::deserialize(JSContextRef destinationContext, J
     return toRef(exec, value);
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue()
+Ref<SerializedScriptValue> SerializedScriptValue::nullValue()
 {
     Vector<uint8_t> buffer;
-    return adoptRef(new SerializedScriptValue(buffer));
+    return adoptRef(*new SerializedScriptValue(buffer));
 }
 
 void SerializedScriptValue::maybeThrowExceptionIfSerializationFailed(ExecState* exec, SerializationReturnCode code)
index d366b30..21615a1 100644 (file)
@@ -67,15 +67,15 @@ class SerializedScriptValue :
     public RefCounted<SerializedScriptValue> {
 #endif
 public:
-    WEBCORE_EXPORT static PassRefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue, MessagePortArray*, ArrayBufferArray*, SerializationErrorMode = Throwing);
+    WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue, MessagePortArray*, ArrayBufferArray*, SerializationErrorMode = Throwing);
 
-    WEBCORE_EXPORT static PassRefPtr<SerializedScriptValue> create(const String&);
-    static PassRefPtr<SerializedScriptValue> adopt(Vector<uint8_t>& buffer)
+    WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(const String&);
+    static Ref<SerializedScriptValue> adopt(Vector<uint8_t>& buffer)
     {
-        return adoptRef(new SerializedScriptValue(buffer));
+        return adoptRef(*new SerializedScriptValue(buffer));
     }
 
-    static PassRefPtr<SerializedScriptValue> nullValue();
+    static Ref<SerializedScriptValue> nullValue();
 
     WEBCORE_EXPORT JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*, MessagePortArray*, SerializationErrorMode = Throwing);
 
@@ -93,13 +93,13 @@ public:
 
 #if ENABLE(INDEXED_DATABASE)
     // FIXME: Get rid of these. The only caller immediately deserializes the result, so it's a very roundabout way to create a JSValue.
-    static PassRefPtr<SerializedScriptValue> numberValue(double value);
-    static PassRefPtr<SerializedScriptValue> undefinedValue();
+    static Ref<SerializedScriptValue> numberValue(double value);
+    static Ref<SerializedScriptValue> undefinedValue();
 #endif
 
-    static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<uint8_t>& data)
+    static Ref<SerializedScriptValue> createFromWireBytes(const Vector<uint8_t>& data)
     {
-        return adoptRef(new SerializedScriptValue(data));
+        return adoptRef(*new SerializedScriptValue(data));
     }
     const Vector<uint8_t>& toWireBytes() const { return m_data; }
 
index 20cb969..f3e9843 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
     class ObjCEventListener : public EventListener {
     public:
         typedef id<DOMEventListener> ObjCListener;
-        static PassRefPtr<ObjCEventListener> wrap(ObjCListener);
+        static Ref<ObjCEventListener> wrap(ObjCListener);
 
         static const ObjCEventListener* cast(const EventListener* listener)
         {
index c8db254..099d455 100644 (file)
@@ -48,12 +48,12 @@ ObjCEventListener* ObjCEventListener::find(ObjCListener listener)
     return map->get(listener);
 }
 
-PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(ObjCListener listener)
+Ref<ObjCEventListener> ObjCEventListener::wrap(ObjCListener listener)
 {
     RefPtr<ObjCEventListener> wrapper = find(listener);
     if (wrapper)
-        return wrapper;
-    return adoptRef(new ObjCEventListener(listener));
+        return wrapper.releaseNonNull();
+    return adoptRef(*new ObjCEventListener(listener));
 }
 
 ObjCEventListener::ObjCEventListener(ObjCListener listener)
index 81a3720..cc077b3 100644 (file)
@@ -39,9 +39,9 @@ namespace WebCore {
 
     class ObjCNodeFilterCondition : public NodeFilterCondition {
     public:
-        static PassRefPtr<ObjCNodeFilterCondition> create(id <DOMNodeFilter> filter)
+        static Ref<ObjCNodeFilterCondition> create(id <DOMNodeFilter> filter)
         {
-            return adoptRef(new ObjCNodeFilterCondition(filter));
+            return adoptRef(*new ObjCNodeFilterCondition(filter));
         }
 
         virtual short acceptNode(JSC::ExecState*, Node*) const;