Use RetainPtr::autorelease in some places where it seems appropriate
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Aug 2014 22:43:33 +0000 (22:43 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Aug 2014 22:43:33 +0000 (22:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136280

Reviewed by Darin Adler.

Source/JavaScriptCore:

* API/JSContext.mm:
(-[JSContext name]): Use RetainPtr::autorelease() in place of ObjC autorelease.
* API/JSValue.mm:
(valueToString): Make appropriate use of RetainPtr

Source/WebCore:

* platform/mac/URLMac.mm:
(WebCore::URL::operator NSURL *): Use autorelease() instead of
CFBridgingRelease(leakRef())

Source/WebKit/mac:

* WebView/WebHTMLView.mm:
(imageFromRect): Use RetainPtr in this function.
* WebView/WebPDFRepresentation.mm:
(-[WebPDFRepresentation convertPostScriptDataSourceToPDF:]): Use RetainPtr
in this method.

Source/WebKit2:

* Shared/Cocoa/WKNSURLExtras.mm:
(urlWithWTFString): Use autorelease() instead of CFBridgingRelease(leakRef())

Source/WTF:

* wtf/text/mac/StringImplMac.mm:
(WTF::StringImpl::operator NSString *): Use autorelease() instead of
CFBridgingRelease(leakRef())

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

12 files changed:
Source/JavaScriptCore/API/JSContext.mm
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/text/mac/StringImplMac.mm
Source/WebCore/ChangeLog
Source/WebCore/platform/mac/URLMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebPDFRepresentation.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Cocoa/WKNSURLExtras.mm

index 701bdd1..b3a4b7a 100644 (file)
     if (!name)
         return nil;
 
-    return [(NSString *)JSStringCopyCFString(kCFAllocatorDefault, name) autorelease];
+    return (NSString *)adoptCF(JSStringCopyCFString(kCFAllocatorDefault, name)).autorelease();
 }
 
 - (void)setName:(NSString *)name
index 11019ad..c2dc514 100644 (file)
@@ -767,9 +767,9 @@ id valueToString(JSGlobalContextRef context, JSValueRef value, JSValueRef* excep
         return nil;
     }
 
-    NSString *stringNS = CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, jsstring));
+    RetainPtr<CFStringRef> stringCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, jsstring));
     JSStringRelease(jsstring);
-    return stringNS;
+    return (NSString *)stringCF.autorelease();
 }
 
 id valueToDate(JSGlobalContextRef context, JSValueRef value, JSValueRef* exception)
index 368ae91..14d51e6 100644 (file)
@@ -1,3 +1,15 @@
+2014-08-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Use RetainPtr::autorelease in some places where it seems appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=136280
+
+        Reviewed by Darin Adler.
+
+        * API/JSContext.mm:
+        (-[JSContext name]): Use RetainPtr::autorelease() in place of ObjC autorelease.
+        * API/JSValue.mm:
+        (valueToString): Make appropriate use of RetainPtr
+
 2014-08-29  Akos Kiss  <akiss@inf.u-szeged.hu>
 
         Ensure that the call frame passed from doVMEntry to the called function always contains the valid scope chain.
index f5a3ee1..eaf7f0f 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Use RetainPtr::autorelease in some places where it seems appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=136280
+
+        Reviewed by Darin Adler.
+
+        * wtf/text/mac/StringImplMac.mm:
+        (WTF::StringImpl::operator NSString *): Use autorelease() instead of
+        CFBridgingRelease(leakRef())
+
 2014-08-29  Joseph Pecoraro  <pecoraro@apple.com>
 
         JavaScriptCore: Use ASCIILiteral where possible
index 1e88b29..a00ec0d 100644 (file)
@@ -28,7 +28,7 @@ namespace WTF {
 
 StringImpl::operator NSString *()
 {
-    return CFBridgingRelease(createCFString().leakRef());
+    return (NSString *)createCFString().autorelease();
 }
 
 }
index c015ba4..0044c7c 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Use RetainPtr::autorelease in some places where it seems appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=136280
+
+        Reviewed by Darin Adler.
+
+        * platform/mac/URLMac.mm:
+        (WebCore::URL::operator NSURL *): Use autorelease() instead of
+        CFBridgingRelease(leakRef())
+
 2014-08-30  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         CSS: Refactor :visited handling in SelectorChecker
index c5ab891..06a6a08 100644 (file)
@@ -49,7 +49,7 @@ URL::operator NSURL *() const
 {
     // Creating a toll-free bridged CFURL, because a real NSURL would not preserve the original string.
     // We'll need fidelity when round-tripping via CFURLGetBytes().
-    return CFBridgingRelease(createCFURL().leakRef());
+    return (NSURL *)createCFURL().autorelease();
 }
 
 RetainPtr<CFURLRef> URL::createCFURL() const
index eafbc63..cf0781b 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Use RetainPtr::autorelease in some places where it seems appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=136280
+
+        Reviewed by Darin Adler.
+
+        * WebView/WebHTMLView.mm:
+        (imageFromRect): Use RetainPtr in this function.
+        * WebView/WebPDFRepresentation.mm:
+        (-[WebPDFRepresentation convertPostScriptDataSourceToPDF:]): Use RetainPtr
+        in this method.
+
 2014-08-29  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Unreviwed, remove empty directories.
index 0c229d7..79662e5 100644 (file)
@@ -6631,12 +6631,12 @@ static CGImageRef imageFromRect(Frame* frame, CGRect rect)
     
     CGContextRestoreGState(contextRef);
     
-    CGImageRef resultImage = CGBitmapContextCreateImage(contextRef);
+    RetainPtr<CGImageRef> resultImage = adoptCF(CGBitmapContextCreateImage(contextRef));
     
     WKSetCurrentGraphicsContext(oldContext);
     frame->view()->setPaintBehavior(oldPaintBehavior);
     
-    return (CGImageRef)CFBridgingRelease(resultImage);
+    return resultImage.autorelease();
     
     END_BLOCK_OBJC_EXCEPTIONS;
 
index fdd06e7..cbd6679 100644 (file)
 #import "WebPDFDocumentExtras.h"
 #import "WebPDFView.h"
 #import "WebTypesInternal.h"
-#import <wtf/Assertions.h>
-#import <wtf/ObjcRuntimeExtras.h>
 #import <JavaScriptCore/JSContextRef.h>
 #import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
+#import <wtf/Assertions.h>
+#import <wtf/ObjcRuntimeExtras.h>
+#import <wtf/RetainPtr.h>
 
 @implementation WebPDFRepresentation
 
     // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_ps_convert/chapter_16_section_1.html
 
     CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 };    
-    CGPSConverterRef converter = CGPSConverterCreate(0, &callbacks, 0);
-    ASSERT(converter);
+    RetainPtr<CGPSConverterRef> converter = adoptCF(CGPSConverterCreate(0, &callbacks, 0));
+    ASSERT(converter.get());
 
-    CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)data);
-    ASSERT(provider);
+    RetainPtr<CGDataProviderRef> provider = adoptCF(CGDataProviderCreateWithCFData((CFDataRef)data));
+    ASSERT(provider.get());
 
-    CFMutableDataRef result = CFDataCreateMutable(kCFAllocatorDefault, 0);
-    ASSERT(result);
+    RetainPtr<CFMutableDataRef> result = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));
+    ASSERT(result.get());
 
-    CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(result);
-    ASSERT(consumer);
+    RetainPtr<CGDataConsumerRef> consumer = adoptCF(CGDataConsumerCreateWithCFData(result.get()));
+    ASSERT(consumer.get());
 
     // Error handled by detecting zero-length 'result' in caller
-    CGPSConverterConvert(converter, provider, consumer, 0);
-
-    CFRelease(converter);
-    CFRelease(provider);
-    CFRelease(consumer);
+    CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0);
 
-    return CFBridgingRelease(result);
+    return (NSData *)result.autorelease();
 }
 
 - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
index 4e11f53..620b8f2 100644 (file)
@@ -1,3 +1,13 @@
+2014-08-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Use RetainPtr::autorelease in some places where it seems appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=136280
+
+        Reviewed by Darin Adler.
+
+        * Shared/Cocoa/WKNSURLExtras.mm:
+        (urlWithWTFString): Use autorelease() instead of CFBridgingRelease(leakRef())
+
 2014-08-29  Tim Horton  <timothy_horton@apple.com>
 
         More occasional crashes in ServicesController::resfreshExistingServices
index cb2efe3..56d4910 100644 (file)
@@ -40,7 +40,7 @@ static inline NSURL *urlWithWTFString(const String& string, NSURL *baseURL = nil
         return nil;
 
     CString buffer = string.utf8();
-    return CFBridgingRelease(createCFURLFromBuffer(buffer.data(), buffer.length(), (CFURLRef)baseURL).leakRef());
+    return (NSURL *)createCFURLFromBuffer(buffer.data(), buffer.length(), (CFURLRef)baseURL).autorelease();
 }
 
 + (instancetype)_web_URLWithWTFString:(const String&)string