WebKit Bugzilla
Attachment 342440 Details for
Bug 186526
: [Cocoa] Make some RetainPtr refinements to get more ready for ARC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186526-20180611100544.patch (text/plain), 14.84 KB, created by
Darin Adler
on 2018-06-11 10:05:45 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2018-06-11 10:05:45 PDT
Size:
14.84 KB
patch
obsolete
>Subversion Revision: 232720 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 43a7f596b05e11b11df643b8f033babe902fd461..5d86eb574634e486389d68ace7c6caef47964eb3 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,20 @@ >+2018-06-11 Darin Adler <darin@apple.com> >+ >+ [Cocoa] Make some RetainPtr refinements to get more ready for ARC >+ https://bugs.webkit.org/show_bug.cgi?id=186526 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/RetainPtr.h: Added autoreleaseCF and bridgingAutorelease. >+ The existing autorelease is for autorelease of an Objective-C type. >+ The two new ones are for autorelease of CF types: We can use >+ autoreleaseCF when we want an autoreleased CF type, and we can >+ use bridgingAutorelease when we want to autorelease as part of >+ converting from a CF type to an Objective-C type. >+ >+ * wtf/text/mac/StringImplMac.mm: >+ (WTF::StringImpl::operator NSString *): Use bridgingAutorelease. >+ > 2018-06-11 Michael Saboff <msaboff@apple.com> > > JavaScriptCore: Disable 32-bit JIT on Windows >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c8e099d1e235fec314a27af5cba310fa4e4ae4e2..ae20c3de1ba677acdfc0a9b894969907e30c93bf 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,13 @@ >+2018-06-11 Darin Adler <darin@apple.com> >+ >+ [Cocoa] Make some RetainPtr refinements to get more ready for ARC >+ https://bugs.webkit.org/show_bug.cgi?id=186526 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/mac/URLMac.mm: >+ (WebCore::URL::operator NSURL * const): Use bridgingAutorelease. >+ > 2018-06-11 Chris Dumez <cdumez@apple.com> > > Crash under com.apple.WebKit.Networking at WebCore: WebCore::NetworkStorageSession::hasStorageAccess const >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f1afd16924c7fee46c204759ed1075673e07b98d..9472a8e12196ae2dd9c2778300cbeb661d7c7ca5 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,17 @@ >+2018-06-11 Darin Adler <darin@apple.com> >+ >+ [Cocoa] Make some RetainPtr refinements to get more ready for ARC >+ https://bugs.webkit.org/show_bug.cgi?id=186526 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Platform/cf/ModuleCF.cpp: >+ (WebKit::Module::load): Use move assignment instead of adoptCF/leakRef. >+ >+ * Shared/Cocoa/WKNSURLExtras.mm: >+ (+[NSURL _web_URLWithWTFString:]): Use bridgingAutorelease. >+ (+[NSURL _web_URLWithWTFString:relativeToURL:]): Ditto. >+ > 2018-06-10 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][WPE] Add API run run javascript from a WebKitWebView in an isolated world >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 4205ea3a36b20217d4ba487b873176cfe62b471a..983f6c72a9a30982139a8829febad6e65bf2c097 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,25 @@ >+2018-06-11 Darin Adler <darin@apple.com> >+ >+ [Cocoa] Make some RetainPtr refinements to get more ready for ARC >+ https://bugs.webkit.org/show_bug.cgi?id=186526 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DOM/DOM.mm: >+ (-[DOMNode getPreviewSnapshotImage:andRects:]): Use autoreleaseCF. >+ >+ * Plugins/Hosted/NetscapePluginHostManager.mm: >+ (WebKit::preferredBundleLocalizationName): Use bridgingAutorelease. >+ >+ * Plugins/Hosted/WebHostedNetscapePluginView.mm: >+ (-[WebHostedNetscapePluginView createPluginLayer]): Use move >+ assignment rather than adoptNS/leakRef. >+ * Plugins/WebNetscapePluginView.mm: >+ (-[WebNetscapePluginView createPlugin]): Ditto. >+ >+ * WebView/WebPDFRepresentation.mm: >+ (-[WebPDFRepresentation convertPostScriptDataSourceToPDF:]): Use bridgingAutorelease. >+ > 2018-06-09 Dan Bernstein <mitz@apple.com> > > [Xcode] Clean up and modernize some build setting definitions >diff --git a/Source/WTF/wtf/RetainPtr.h b/Source/WTF/wtf/RetainPtr.h >index 545ec398ac0ad28e152a3f917ce21a3913022d2f..c161b22811155c45a49de71a938aba1ffe252594 100644 >--- a/Source/WTF/wtf/RetainPtr.h >+++ b/Source/WTF/wtf/RetainPtr.h >@@ -83,7 +83,11 @@ public: > > void clear(); > PtrType leakRef() WARN_UNUSED_RETURN; >+ PtrType autoreleaseCF(); >+#ifdef __OBJC__ > PtrType autorelease(); >+ id bridgingAutorelease(); >+#endif > > PtrType get() const { return fromStorageType(m_ptr); } > PtrType operator->() const { return fromStorageType(m_ptr); } >@@ -115,7 +119,7 @@ private: > > static PtrType hashTableDeletedValue() { return reinterpret_cast<PtrType>(-1); } > >-#if defined (__OBJC__) && __has_feature(objc_arc) >+#if defined(__OBJC__) && __has_feature(objc_arc) > template<typename U> > typename std::enable_if<std::is_convertible<U, id>::value, PtrType>::type > fromStorageTypeHelper(StorageType ptr) const >@@ -144,15 +148,15 @@ private: > StorageType m_ptr; > }; > >+// Helper function for creating a RetainPtr using template argument deduction. >+template<typename T> RetainPtr<T> retainPtr(T) WARN_UNUSED_RETURN; >+ > template<typename T> inline RetainPtr<T>::~RetainPtr() > { > if (StorageType ptr = std::exchange(m_ptr, nullptr)) > CFRelease(ptr); > } > >-// Helper function for creating a RetainPtr using template argument deduction. >-template<typename T> inline RetainPtr<T> retainPtr(T) WARN_UNUSED_RETURN; >- > template<typename T> template<typename U> inline RetainPtr<T>::RetainPtr(const RetainPtr<U>& o) > : m_ptr(toStorageType(o.get())) > { >@@ -166,16 +170,34 @@ template<typename T> inline void RetainPtr<T>::clear() > CFRelease(ptr); > } > >-template<typename T> inline typename RetainPtr<T>::PtrType RetainPtr<T>::leakRef() >+template<typename T> inline auto RetainPtr<T>::leakRef() -> PtrType > { > return fromStorageType(std::exchange(m_ptr, nullptr)); > } > >+template<typename T> inline auto RetainPtr<T>::autoreleaseCF() -> PtrType >+{ >+#ifdef __OBJC__ >+ static_assert((!std::is_convertible<PtrType, id>::value), "Don't use autoreleaseCF for Objective-C pointer types."); >+#endif >+ return (PtrType)CFAutorelease(leakRef()); >+} >+ > #ifdef __OBJC__ >+ > template<typename T> inline auto RetainPtr<T>::autorelease() -> PtrType > { >- return (__bridge PtrType)CFBridgingRelease(leakRef()); >+ static_assert((std::is_convertible<PtrType, id>::value), "Don't use autorelease for non-Objective-C pointer types."); >+ return CFBridgingRelease(std::exchange(m_ptr, nullptr)); > } >+ >+// FIXME: It would be nice if we could base the return type on the type that is toll-free bridged with T rather than using id. >+template<typename T> inline id RetainPtr<T>::bridgingAutorelease() >+{ >+ static_assert((!std::is_convertible<PtrType, id>::value), "Don't use bridgingAutorelease for Objective-C pointer types."); >+ return CFBridgingRelease(leakRef()); >+} >+ > #endif > > template<typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr& o) >diff --git a/Source/WTF/wtf/text/mac/StringImplMac.mm b/Source/WTF/wtf/text/mac/StringImplMac.mm >index a00ec0d120ba102e374fe1e23bba74ad4b8a0a61..7e1e4ff418720d17600bc6b74575ac0dad81051e 100644 >--- a/Source/WTF/wtf/text/mac/StringImplMac.mm >+++ b/Source/WTF/wtf/text/mac/StringImplMac.mm >@@ -28,7 +28,7 @@ namespace WTF { > > StringImpl::operator NSString *() > { >- return (NSString *)createCFString().autorelease(); >+ return createCFString().bridgingAutorelease(); > } > > } >diff --git a/Source/WebCore/platform/mac/URLMac.mm b/Source/WebCore/platform/mac/URLMac.mm >index bbbf9a2f7869a02f80f65280d2f11f057e7af9a6..025c1de7b0283cd0dbdba56ca16fafc5f39c58b6 100644 >--- a/Source/WebCore/platform/mac/URLMac.mm >+++ b/Source/WebCore/platform/mac/URLMac.mm >@@ -56,7 +56,7 @@ URL::operator NSURL *() const > { > // Creating a toll-free bridged CFURL because creation with NSURL methods would not preserve the original string. > // We'll need fidelity when round-tripping via CFURLGetBytes(). >- return (NSURL *)createCFURL().autorelease(); >+ return createCFURL().bridgingAutorelease(); > } > > RetainPtr<CFURLRef> URL::createCFURL() const >diff --git a/Source/WebKit/Platform/cf/ModuleCF.cpp b/Source/WebKit/Platform/cf/ModuleCF.cpp >index 78dbfb74bd15c961b1223a0325a8e5b012647668..058bcfd43c49ecdbf455f168afee5e64084f1a7c 100644 >--- a/Source/WebKit/Platform/cf/ModuleCF.cpp >+++ b/Source/WebKit/Platform/cf/ModuleCF.cpp >@@ -41,7 +41,7 @@ bool Module::load() > if (!CFBundleLoadExecutable(bundle.get())) > return false; > >- m_bundle = adoptCF(bundle.leakRef()); >+ m_bundle = WTFMove(bundle); > return true; > } > >diff --git a/Source/WebKit/Shared/Cocoa/WKNSURLExtras.mm b/Source/WebKit/Shared/Cocoa/WKNSURLExtras.mm >index 1a8363e8f8848bd5df3e3425f1b1db7b237266bf..0cbad69d07c0a7bcd1ae848afeaeed2927a22d6a 100644 >--- a/Source/WebKit/Shared/Cocoa/WKNSURLExtras.mm >+++ b/Source/WebKit/Shared/Cocoa/WKNSURLExtras.mm >@@ -38,13 +38,13 @@ @implementation NSURL (WKExtras) > + (instancetype)_web_URLWithWTFString:(const String&)string > { > URL url { URL { }, string }; >- return (__bridge NSURL*) url.createCFURL().autorelease(); >+ return url.createCFURL().bridgingAutorelease(); > } > > + (instancetype)_web_URLWithWTFString:(const String&)string relativeToURL:(NSURL *)baseURL > { > URL url { URL { baseURL }, string }; >- return (__bridge NSURL*) url.createCFURL().autorelease(); >+ return url.createCFURL().bridgingAutorelease(); > } > > - (String)_web_originalDataAsWTFString >diff --git a/Source/WebKitLegacy/mac/DOM/DOM.mm b/Source/WebKitLegacy/mac/DOM/DOM.mm >index 83d56d0448655f76a8c76b9b93ceeefb8a7dd81a..182b2c32a52bc7c57d953e006b829006acc01b86 100644 >--- a/Source/WebKitLegacy/mac/DOM/DOM.mm >+++ b/Source/WebKitLegacy/mac/DOM/DOM.mm >@@ -557,7 +557,7 @@ - (void)getPreviewSnapshotImage:(CGImageRef*)cgImage andRects:(NSArray **)rects > > if (textIndicator) { > if (Image* image = textIndicator->contentImage()) >- *cgImage = image->nativeImage().autorelease(); >+ *cgImage = image->nativeImage().autoreleaseCF(); > } > > RetainPtr<NSMutableArray> rectArray = adoptNS([[NSMutableArray alloc] init]); >diff --git a/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm b/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm >index d328862a6c2204289aa9698bf20adc74584c8b67..703c5462c8ef22a37b1dd86048e3ba161ab5f5b2 100644 >--- a/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm >+++ b/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm >@@ -121,8 +121,7 @@ static NSString *preferredBundleLocalizationName() > if (!success) > return @"en_US"; > >- auto code = adoptCF(CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(0, languageCode, regionCode)); >- return (NSString *)code.autorelease(); >+ return adoptCF(CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(0, languageCode, regionCode)).bridgingAutorelease(); > } > > bool NetscapePluginHostManager::spawnPluginHost(const String& pluginPath, cpu_type_t pluginArchitecture, mach_port_t clientPort, mach_port_t& pluginHostPort, ProcessSerialNumber& pluginHostPSN) >diff --git a/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm b/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm >index 9f12122cc07a619ca45c4fb574ffedfe0e14849f..f3e04b4f558061191c86fd6775515914863d1194 100644 >--- a/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm >+++ b/Source/WebKitLegacy/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm >@@ -189,7 +189,7 @@ - (void)createPluginLayer > // FIXME: This code can be shared between WebHostedNetscapePluginView and WebNetscapePluginView. > // Since this layer isn't going to be inserted into a view, we need to create another layer and flip its geometry > // in order to get the coordinate system right. >- RetainPtr<CALayer> realPluginLayer = adoptNS(_pluginLayer.leakRef()); >+ RetainPtr<CALayer> realPluginLayer = WTFMove(_pluginLayer); > > _pluginLayer = adoptNS([[CALayer alloc] init]); > _pluginLayer.get().bounds = realPluginLayer.get().bounds; >diff --git a/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm b/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm >index 4b14b6dcbe8350982112c1c234fba70c2f7fa9cd..b2b11d34cff57ec00406acff7c0e258ffb0357c8 100644 >--- a/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm >+++ b/Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm >@@ -1098,7 +1098,7 @@ - (BOOL)createPlugin > // FIXME: This code can be shared between WebHostedNetscapePluginView and WebNetscapePluginView. > // Since this layer isn't going to be inserted into a view, we need to create another layer and flip its geometry > // in order to get the coordinate system right. >- RetainPtr<CALayer> realPluginLayer = adoptNS(_pluginLayer.leakRef()); >+ RetainPtr<CALayer> realPluginLayer = WTFMove(_pluginLayer); > > _pluginLayer = adoptNS([[CALayer alloc] init]); > _pluginLayer.get().bounds = realPluginLayer.get().bounds; >diff --git a/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm b/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm >index cbd6679baff28e62e9e30575ebc34d780ae67c14..79db38a6660bad06b8825bb53cb04d2df6f56408 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebPDFRepresentation.mm >@@ -106,7 +106,7 @@ - (NSData *)convertPostScriptDataSourceToPDF:(NSData *)data > // Error handled by detecting zero-length 'result' in caller > CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0); > >- return (NSData *)result.autorelease(); >+ return result.bridgingAutorelease(); > } > > - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 1ad6b83000ce08bfe8d1fe6481ebc1a48f301efe..aab07089f3c2961d57ba4409b2f126e6005b7fcd 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2018-06-11 Darin Adler <darin@apple.com> >+ >+ [Cocoa] Make some RetainPtr refinements to get more ready for ARC >+ https://bugs.webkit.org/show_bug.cgi?id=186526 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DumpRenderTree/mac/LayoutTestHelper.m: >+ (colorProfileURLForDisplay): Use CFBridingRelease instead of using >+ CFAutorelease for a bridging use case. >+ > 2018-06-11 Philippe Normand <pnormand@igalia.com> > > [webkitpy] PHP7.2 support on Debian platforms >diff --git a/Tools/DumpRenderTree/mac/LayoutTestHelper.m b/Tools/DumpRenderTree/mac/LayoutTestHelper.m >index 330f27ef0beb497a493872afa38c7aaaf7b36d4e..1b5750403fd0ae72ead2d52019e3d083bc89573a 100644 >--- a/Tools/DumpRenderTree/mac/LayoutTestHelper.m >+++ b/Tools/DumpRenderTree/mac/LayoutTestHelper.m >@@ -95,7 +95,7 @@ > return nil; > } > >- NSURL *url = (NSURL *)CFAutorelease(CFRetain(profileURL)); >+ NSURL *url = CFBridgingRelease(CFRetain(profileURL)); > CFRelease(deviceInfo); > return url; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186526
:
342440
|
342548
|
342550
|
342579
|
342632
|
342720