Prefer RetainPtr<NSObject> to RetainPtr<NSObject *>
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2019 00:03:09 +0000 (00:03 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2019 00:03:09 +0000 (00:03 +0000)
<https://webkit.org/b/193056>

Reviewed by Alex Christensen.

Source/WebCore:

* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]):
(-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]):
* platform/network/cf/AuthenticationChallenge.h:
- Remove '*' from RetainPtr<> type.

* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::cookiesForURL):
- Once retainPtr() was changed to return RetainPtr<NSArray>
  instead of RetainPtr<NSArray *> here, that forced the type of
  `cookiesPtr` to change as well since
  Optional<RetainPtr<NSArray>> is not assignable to
  Optional<RetainPtr<NSArray *>> without further template
  specialization, which didn't seem useful since
  Optional<RetainPtr<>> variable types are rarely used.

Source/WebKit:

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceMain):
* UIProcess/API/Cocoa/_WKThumbnailView.mm:
* UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
* UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* UIProcess/Plugins/PluginProcessProxy.h:
* UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::createEmbeddedView):
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:
(WebKit::PlatformCALayerRemoteCustom::clone const):
- Remove '*' from RetainPtr<> type.

Source/WebKitLegacy/mac:

* Plugins/Hosted/NetscapePluginHostProxy.h:
* Plugins/Hosted/NetscapePluginInstanceProxy.h:
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::enumerate):
(WebKit::NetscapePluginInstanceProxy::marshalValue):
(WebKit::NetscapePluginInstanceProxy::marshalValues):
(WebKit::NetscapePluginInstanceProxy::demarshalValue):
(WebKit::NetscapePluginInstanceProxy::demarshalValues):
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::invoke):
* WebCoreSupport/WebGeolocationClient.mm:
* WebView/WebDataSource.mm:
(-[WebDataSource _receivedData:]):
* WebView/WebView.mm:
(-[WebView _cachedResponseForURL:]):
- Remove '*' from RetainPtr<> type.

Source/WTF:

* wtf/RetainPtr.h:
(WTF::RetainPtr<T>::HelperPtrType):
- Use C++ template metaprogramming to define a shared return
  type for adoptNS() and retainPtr() that uses
  RetainPtr<NSObject> instead of RetainPtr<NSObject *>.  The
  non-Objective-C typedef is used with retainPtr() for CFTypeRef
  objects.
(WTF::adoptNS):
- Only make declarations available when compilng with
  Objective-C.  The inline implementation is only available for
  Objective-C, so this makes the declarations consistent.
- Change return type to remove '*' from NS types using
  RetainPtr<T>::HelperPtrType.
(WTF::retainPtr):
- Change return type to remove '*' from NS types using
  RetainPtr<T>::HelperPtrType.

* wtf/SchedulePair.h:
- Remove '*' from RetainPtr<> type.

Tools:

* Scripts/webkitpy/style/checker.py:
- Ignore use of new runtime/retainptr check in
  Tools/TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm since it
  contains tests to ensure RetainPtr<NSObject *> is compatible
  with RetainPtr<NSObject>.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_language):
(CppChecker):
- Add checker for use of '*' in RetainPtr<> type.  A for loop
  was used instead of a single regex so that angle brackets
  could be matched up when checking the type contained within
  the RetainPtr<> type.

* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest):
- Add unit test for new runtime/retainptr check.

* TestRunnerShared/EventSerialization/mac/EventSerializerMac.h:
* TestWebKitAPI/EditingTestHarness.h:
- Remove '*' from RetainPtr<> type.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
- Add cf/RetainPtr.cpp back to TestWTFLibrary target!  This
  regressed in r201938.

* TestWebKitAPI/Tests/WTF/cf/RetainPtr.cpp:
(TestWebKitAPI::TEST):
- Update tests to match RetainPtr.mm tests (except for the
  `*SimilarNSType` tests since there is no CF equivalent of
  RetainPtr<NSString> and RetainPtr<NSString *>).

* TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm:
(TestWebKitAPI::TEST):
- Update tests to:
  - Not conflict by name with equivalent CF tests in
    RetainPtr.cpp.
  - Add test cases for RetainPtr<NSObject>,
    RetainPtr<NSObject *> and RetainPtr<id> were appropriate.
  - Add `*SimilarNSType` tests for converting between
    RetainPtr<NSObject> and RetainPtr<NSObject *>.
  - Change `0` to `nil` as appropriate.
  - Re-alphabetize the tests by name.
  - Add Optional<RetainPtr<>> tests.
  - Add retainPtr() tests.

* TestWebKitAPI/Tests/WebKitCocoa/DownloadProgress.mm:
(-[DownloadProgressTestRunner _download:decideDestinationWithSuggestedFilename:completionHandler:]):
* TestWebKitAPI/Tests/WebKitCocoa/IconLoadingDelegate.mm:
(TEST):
- Remove '*' from RetainPtr<> type.

* TestWebKitAPI/Tests/WebKitCocoa/JITEnabled.mm:
(TEST(WebKit, JITEnabled)):
- Add missing WTFMove().  Apparently a temporary was being
  created before in the argument list due to mismatched
  RetainPtr<> types.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
* TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm:
(TestWebKitAPI::setUpWebViewForTestingVideoControlsManager):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
* TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
* WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
(WTR::resourcesDirectoryURL):
* WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm:
(WTR::InjectedBundle::platformInitialize):
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
- Remove '*' from RetainPtr<> type.

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

42 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/RetainPtr.h
Source/WTF/wtf/SchedulePair.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/network/cf/AuthenticationChallenge.h
Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm
Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm
Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h
Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h
Source/WebKit/UIProcess/Plugins/PluginProcessProxy.h
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.h
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKitLegacy/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebGeolocationClient.mm
Source/WebKitLegacy/mac/WebView/WebDataSource.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/Scripts/webkitpy/style/checker.py
Tools/Scripts/webkitpy/style/checkers/cpp.py
Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
Tools/TestRunnerShared/EventSerialization/mac/EventSerializerMac.h
Tools/TestWebKitAPI/EditingTestHarness.h
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/cf/RetainPtr.cpp
Tools/TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/DownloadProgress.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IconLoadingDelegate.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/JITEnabled.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm
Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm
Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm
Tools/WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm
Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm

index 48cfa46..f8a87b0 100644 (file)
@@ -1,3 +1,30 @@
+2019-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Prefer RetainPtr<NSObject> to RetainPtr<NSObject *>
+        <https://webkit.org/b/193056>
+
+        Reviewed by Alex Christensen.
+
+        * wtf/RetainPtr.h:
+        (WTF::RetainPtr<T>::HelperPtrType):
+        - Use C++ template metaprogramming to define a shared return
+          type for adoptNS() and retainPtr() that uses
+          RetainPtr<NSObject> instead of RetainPtr<NSObject *>.  The
+          non-Objective-C typedef is used with retainPtr() for CFTypeRef
+          objects.
+        (WTF::adoptNS):
+        - Only make declarations available when compilng with
+          Objective-C.  The inline implementation is only available for
+          Objective-C, so this makes the declarations consistent.
+        - Change return type to remove '*' from NS types using
+          RetainPtr<T>::HelperPtrType.
+        (WTF::retainPtr):
+        - Change return type to remove '*' from NS types using
+          RetainPtr<T>::HelperPtrType.
+
+        * wtf/SchedulePair.h:
+        - Remove '*' from RetainPtr<> type.
+
 2019-01-07  Eric Carlson  <eric.carlson@apple.com>
 
         A MediaTime timescale must never be zero
index aa96dea..e0eba2d 100644 (file)
@@ -56,7 +56,9 @@ namespace WTF {
 template<typename T> class RetainPtr;
 
 template<typename T> RetainPtr<T> adoptCF(T CF_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
-template<typename T> RetainPtr<T> adoptNS(T NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
+#ifdef __OBJC__
+template<typename T> RetainPtr<typename RetainPtr<T>::HelperPtrType> adoptNS(T NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
+#endif
 
 template<typename T> class RetainPtr {
 public:
@@ -64,6 +66,12 @@ public:
     typedef ValueType* PtrType;
     typedef CFTypeRef StorageType;
 
+#ifdef __OBJC__
+    typedef typename std::conditional<std::is_convertible<T, id>::value && !std::is_same<T, id>::value, typename std::remove_pointer<T>::type, T>::type HelperPtrType;
+#else
+    typedef T HelperPtrType;
+#endif
+
     RetainPtr() : m_ptr(nullptr) { }
     RetainPtr(PtrType ptr) : m_ptr(toStorageType(ptr)) { if (m_ptr) CFRetain(m_ptr); }
 
@@ -109,7 +117,9 @@ public:
     void swap(RetainPtr&);
 
     template<typename U> friend RetainPtr<U> adoptCF(U CF_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
-    template<typename U> friend RetainPtr<U> adoptNS(U NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
+#ifdef __OBJC__
+    template<typename U> friend RetainPtr<typename RetainPtr<U>::HelperPtrType> adoptNS(U NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
+#endif
 
 private:
     enum AdoptTag { Adopt };
@@ -152,7 +162,7 @@ private:
 };
 
 // Helper function for creating a RetainPtr using template argument deduction.
-template<typename T> RetainPtr<T> retainPtr(T) WARN_UNUSED_RETURN;
+template<typename T> RetainPtr<typename RetainPtr<T>::HelperPtrType> retainPtr(T) WARN_UNUSED_RETURN;
 
 template<typename T> inline RetainPtr<T>::~RetainPtr()
 {
@@ -306,21 +316,21 @@ template<typename T> inline RetainPtr<T> adoptCF(T CF_RELEASES_ARGUMENT ptr)
 }
 
 #ifdef __OBJC__
-template<typename T> inline RetainPtr<T> adoptNS(T NS_RELEASES_ARGUMENT ptr)
+template<typename T> inline RetainPtr<typename RetainPtr<T>::HelperPtrType> adoptNS(T NS_RELEASES_ARGUMENT ptr)
 {
 #if __has_feature(objc_arc)
     return ptr;
 #elif defined(OBJC_NO_GC)
-    return RetainPtr<T>(ptr, RetainPtr<T>::Adopt);
+    return RetainPtr<typename RetainPtr<T>::HelperPtrType>(ptr, RetainPtr<typename RetainPtr<T>::HelperPtrType>::Adopt);
 #else
-    RetainPtr<T> result = ptr;
+    RetainPtr<typename RetainPtr<T>::HelperPtrType> result = ptr;
     [ptr release];
     return result;
 #endif
 }
 #endif
 
-template<typename T> inline RetainPtr<T> retainPtr(T ptr)
+template<typename T> inline RetainPtr<typename RetainPtr<T>::HelperPtrType> retainPtr(T ptr)
 {
     return ptr;
 }
@@ -373,10 +383,10 @@ template<typename T> T* dynamic_objc_cast(id object)
 
 using WTF::RetainPtr;
 using WTF::adoptCF;
-using WTF::adoptNS;
 using WTF::retainPtr;
 
 #ifdef __OBJC__
+using WTF::adoptNS;
 using WTF::dynamic_objc_cast;
 #endif
 
index c41bcbb..a36e00c 100644 (file)
@@ -63,7 +63,7 @@ private:
 
 #if PLATFORM(COCOA)
     WTF_EXPORT_PRIVATE SchedulePair(NSRunLoop*, CFStringRef);
-    RetainPtr<NSRunLoop*> m_nsRunLoop;
+    RetainPtr<NSRunLoop> m_nsRunLoop;
 #endif
 
     RetainPtr<CFRunLoopRef> m_runLoop;
index 84a2f88..8ef6637 100644 (file)
@@ -1,3 +1,26 @@
+2019-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Prefer RetainPtr<NSObject> to RetainPtr<NSObject *>
+        <https://webkit.org/b/193056>
+
+        Reviewed by Alex Christensen.
+
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]):
+        (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]):
+        * platform/network/cf/AuthenticationChallenge.h:
+        - Remove '*' from RetainPtr<> type.
+
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::cookiesForURL):
+        - Once retainPtr() was changed to return RetainPtr<NSArray>
+          instead of RetainPtr<NSArray *> here, that forced the type of
+          `cookiesPtr` to change as well since
+          Optional<RetainPtr<NSArray>> is not assignable to
+          Optional<RetainPtr<NSArray *>> without further template
+          specialization, which didn't seem useful since
+          Optional<RetainPtr<>> variable types are rarely used.
+
 2019-01-07  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: extend XHR breakpoints to work with fetch
index 0ecf755..c4717ce 100644 (file)
@@ -143,7 +143,7 @@ SOFT_LINK_CONSTANT(AVFoundation, AVSampleBufferDisplayLayerFailedToDecodeNotific
 {
     ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
 
-    RetainPtr<AVAsset*> protectedAsset = asset;
+    RetainPtr<AVAsset> protectedAsset = asset;
     callOnMainThread([parent = _parent, protectedAsset = WTFMove(protectedAsset)] {
         if (parent)
             parent->didParseStreamDataAsAsset(protectedAsset.get());
@@ -155,7 +155,7 @@ SOFT_LINK_CONSTANT(AVFoundation, AVSampleBufferDisplayLayerFailedToDecodeNotific
     UNUSED_PARAM(discontinuity);
     ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
 
-    RetainPtr<AVAsset*> protectedAsset = asset;
+    RetainPtr<AVAsset> protectedAsset = asset;
     callOnMainThread([parent = _parent, protectedAsset = WTFMove(protectedAsset)] {
         if (parent)
             parent->didParseStreamDataAsAsset(protectedAsset.get());
index 157b852..3f648e0 100644 (file)
@@ -73,7 +73,7 @@ private:
     RetainPtr<CFURLAuthChallengeRef> m_cfChallenge;
 #else
     RetainPtr<id> m_sender;
-    RetainPtr<NSURLAuthenticationChallenge *> m_nsChallenge;
+    RetainPtr<NSURLAuthenticationChallenge> m_nsChallenge;
 #endif
 };
 
index b579973..465f161 100644 (file)
@@ -202,7 +202,7 @@ static RetainPtr<NSDictionary> policyProperties(const SameSiteInfo& sameSiteInfo
 static NSArray *cookiesForURL(NSHTTPCookieStorage *storage, NSURL *url, NSURL *mainDocumentURL, const Optional<SameSiteInfo>& sameSiteInfo, NSString *partition = nullptr)
 {
     // The _getCookiesForURL: method calls the completionHandler synchronously. We use Optional<> to ensure this invariant.
-    Optional<RetainPtr<NSArray *>> cookiesPtr;
+    Optional<RetainPtr<NSArray>> cookiesPtr;
     auto completionHandler = [&cookiesPtr] (NSArray *cookies) {
         cookiesPtr = retainPtr(cookies);
     };
index 1319dde..a14ba53 100644 (file)
@@ -1,3 +1,22 @@
+2019-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Prefer RetainPtr<NSObject> to RetainPtr<NSObject *>
+        <https://webkit.org/b/193056>
+
+        Reviewed by Alex Christensen.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
+        (WebKit::XPCServiceMain):
+        * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+        * UIProcess/Plugins/PluginProcessProxy.h:
+        * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
+        (WebKit::RemoteLayerTreeHost::createEmbeddedView):
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:
+        (WebKit::PlatformCALayerRemoteCustom::clone const):
+        - Remove '*' from RetainPtr<> type.
+
 2019-01-07  Dean Jackson  <dino@apple.com>
 
         Turn on Pointer Events by default for iOS
index 9fa05fc..a43fd90 100644 (file)
@@ -130,7 +130,7 @@ int XPCServiceMain(int, const char**)
             @autoreleasepool {
                 NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain];
                 NSMutableDictionary *newArguments = [existingArguments mutableCopy];
-                RetainPtr<NSMutableArray *> newLanguages = adoptNS([[NSMutableArray alloc] init]);
+                RetainPtr<NSMutableArray> newLanguages = adoptNS([[NSMutableArray alloc] init]);
                 xpc_array_apply(languages, ^(size_t index, xpc_object_t value) {
                     [newLanguages addObject:[NSString stringWithCString:xpc_string_get_string_ptr(value) encoding:NSUTF8StringEncoding]];
                     return true;
index c9bb1b5..d685db9 100644 (file)
@@ -57,7 +57,7 @@
     CGFloat _lastSnapshotScale;
     CGSize _lastSnapshotMaximumSize;
 
-    RetainPtr<NSColor *> _overrideBackgroundColor;
+    RetainPtr<NSColor> _overrideBackgroundColor;
 }
 
 @synthesize snapshotSize=_snapshotSize;
index 1b16e9f..745c8eb 100644 (file)
@@ -151,7 +151,7 @@ private:
 #if PLATFORM(MAC)
     uint64_t m_showPaymentUIRequestSeed { 0 };
     RetainPtr<NSWindow> m_sheetWindow;
-    RetainPtr<NSObject *> m_sheetWindowWillCloseObserver;
+    RetainPtr<NSObject> m_sheetWindowWillCloseObserver;
 #endif
     
 #if defined(WEBPAYMENTCOORDINATORPROXY_ADDITIONS)
index 297f968..3e268ce 100644 (file)
@@ -111,7 +111,7 @@ private:
     VideoFullscreenManagerProxy* m_manager;
     Ref<PlaybackSessionModelContext> m_playbackSessionModel;
     uint64_t m_contextId;
-    RetainPtr<PlatformView *> m_layerHostView;
+    RetainPtr<PlatformView> m_layerHostView;
     HashSet<WebCore::VideoFullscreenModelClient*> m_clients;
     WebCore::FloatSize m_videoDimensions;
     bool m_hasVideo { false };
index c7e94a8..6099967 100644 (file)
@@ -173,7 +173,7 @@ private:
 
 #if PLATFORM(COCOA)
     RetainPtr<NSObject> m_activationObserver;
-    RetainPtr<WKPlaceholderModalWindow *> m_placeholderWindow;
+    RetainPtr<WKPlaceholderModalWindow> m_placeholderWindow;
     bool m_modalWindowIsShowing;
     bool m_fullscreenWindowIsShowing;
     unsigned m_preFullscreenAppPresentationOptions;
index 3d58acf..c1fca2b 100644 (file)
@@ -128,7 +128,7 @@ RetainPtr<WKEmbeddedView> RemoteLayerTreeHost::createEmbeddedView(const RemoteLa
     if (m_isDebugLayerTreeHost)
         return adoptNS([[UIView alloc] init]);
 
-    auto result = m_embeddedViews.ensure(properties.embeddedViewID, [&]() -> RetainPtr<UIView *> {
+    auto result = m_embeddedViews.ensure(properties.embeddedViewID, [&]() -> RetainPtr<UIView> {
         switch (properties.type) {
 #if HAVE(PENCILKIT)
         case PlatformCALayer::LayerTypeEditableImageLayer: {
index 4ce2070..583614a 100644 (file)
@@ -100,7 +100,7 @@ uint32_t PlatformCALayerRemoteCustom::hostingContextID()
 
 Ref<WebCore::PlatformCALayer> PlatformCALayerRemoteCustom::clone(PlatformCALayerClient* owner) const
 {
-    RetainPtr<CALayer *> clonedLayer;
+    RetainPtr<CALayer> clonedLayer;
     bool copyContents = true;
 
     if (layerType() == LayerTypeAVPlayerLayer) {
index f3933e0..08e88f1 100644 (file)
@@ -1,3 +1,27 @@
+2019-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Prefer RetainPtr<NSObject> to RetainPtr<NSObject *>
+        <https://webkit.org/b/193056>
+
+        Reviewed by Alex Christensen.
+
+        * Plugins/Hosted/NetscapePluginHostProxy.h:
+        * Plugins/Hosted/NetscapePluginInstanceProxy.h:
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::enumerate):
+        (WebKit::NetscapePluginInstanceProxy::marshalValue):
+        (WebKit::NetscapePluginInstanceProxy::marshalValues):
+        (WebKit::NetscapePluginInstanceProxy::demarshalValue):
+        (WebKit::NetscapePluginInstanceProxy::demarshalValues):
+        * Plugins/Hosted/ProxyInstance.mm:
+        (WebKit::ProxyInstance::invoke):
+        * WebCoreSupport/WebGeolocationClient.mm:
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource _receivedData:]):
+        * WebView/WebView.mm:
+        (-[WebView _cachedResponseForURL:]):
+        - Remove '*' from RetainPtr<> type.
+
 2019-01-04  Alex Christensen  <achristensen@webkit.org>
 
         Progress towards fixing Mac CMake build
index 742d4c4..8d0ba6f 100644 (file)
@@ -92,7 +92,7 @@ private:
     RetainPtr<CFMachPortRef> m_deadNameNotificationPort;
     
     RetainPtr<id> m_activationObserver;
-    RetainPtr<WebPlaceholderModalWindow *> m_placeholderWindow;
+    RetainPtr<WebPlaceholderModalWindow> m_placeholderWindow;
     unsigned m_isModal;
     bool m_menuBarIsVisible;
     bool m_fullscreenWindowIsShowing;
index 65205fc..10a08e9 100644 (file)
@@ -143,7 +143,7 @@ public:
                       double& destX, double& destY, NPCoordinateSpace destSpace);
 
     RefPtr<JSC::Bindings::Instance> createBindingsInstance(Ref<JSC::Bindings::RootObject>&&);
-    RetainPtr<NSData *> marshalValues(JSC::ExecState*, const JSC::ArgList& args);
+    RetainPtr<NSData> marshalValues(JSC::ExecState*, const JSC::ArgList& args);
     void marshalValue(JSC::ExecState*, JSC::JSValue, data_t& resultData, mach_msg_type_number_t& resultLength);
     JSC::JSValue demarshalValue(JSC::ExecState*, const char* valueData, mach_msg_type_number_t valueLength);
 
index c692841..91c605e 100644 (file)
@@ -101,8 +101,8 @@ private:
     }
     
     uint32_t m_requestID;
-    RetainPtr<NSURLRequest*> m_request;
-    RetainPtr<NSString*> m_frameName;
+    RetainPtr<NSURLRequest> m_request;
+    RetainPtr<NSString> m_frameName;
     bool m_allowPopups;
 };
 
@@ -1277,7 +1277,7 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat
     PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
     object->methodTable(vm)->getPropertyNames(object, exec, propertyNames, EnumerationMode());
 
-    RetainPtr<NSMutableArray*> array = adoptNS([[NSMutableArray alloc] init]);
+    RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] init]);
     for (unsigned i = 0; i < propertyNames.size(); i++) {
         uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(propertyNames[i].string().utf8().data()));
 
@@ -1346,7 +1346,7 @@ void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecSta
 
 void NetscapePluginInstanceProxy::marshalValue(ExecState* exec, JSValue value, data_t& resultData, mach_msg_type_number_t& resultLength)
 {
-    RetainPtr<NSMutableArray*> array = adoptNS([[NSMutableArray alloc] init]);
+    RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] init]);
     
     addValueToArray(array.get(), exec, value);
 
@@ -1359,9 +1359,9 @@ void NetscapePluginInstanceProxy::marshalValue(ExecState* exec, JSValue value, d
     memcpy(resultData, data.bytes, resultLength);
 }
 
-RetainPtr<NSData *> NetscapePluginInstanceProxy::marshalValues(ExecState* exec, const ArgList& args)
+RetainPtr<NSData> NetscapePluginInstanceProxy::marshalValues(ExecState* exec, const ArgList& args)
 {
-    RetainPtr<NSMutableArray*> array = adoptNS([[NSMutableArray alloc] init]);
+    RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] init]);
 
     for (unsigned i = 0; i < args.size(); i++)
         addValueToArray(array.get(), exec, args.at(i));
@@ -1426,7 +1426,7 @@ bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArr
 
 JSValue NetscapePluginInstanceProxy::demarshalValue(ExecState* exec, const char* valueData, mach_msg_type_number_t valueLength)
 {
-    RetainPtr<NSData*> data = adoptNS([[NSData alloc] initWithBytesNoCopy:(void*)valueData length:valueLength freeWhenDone:NO]);
+    RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytesNoCopy:(void*)valueData length:valueLength freeWhenDone:NO]);
 
     NSArray *array = [NSPropertyListSerialization propertyListWithData:data.get() options:NSPropertyListImmutable format:nullptr error:nullptr];
 
@@ -1440,7 +1440,7 @@ JSValue NetscapePluginInstanceProxy::demarshalValue(ExecState* exec, const char*
 
 void NetscapePluginInstanceProxy::demarshalValues(ExecState* exec, data_t valuesData, mach_msg_type_number_t valuesLength, MarkedArgumentBuffer& result)
 {
-    RetainPtr<NSData*> data = adoptNS([[NSData alloc] initWithBytesNoCopy:valuesData length:valuesLength freeWhenDone:NO]);
+    RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytesNoCopy:valuesData length:valuesLength freeWhenDone:NO]);
 
     NSArray *array = [NSPropertyListSerialization propertyListWithData:data.get() options:NSPropertyListImmutable format:nullptr error:nullptr];
 
index fe50886..202c6de 100644 (file)
@@ -146,7 +146,7 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id
     if (!m_instanceProxy)
         return jsUndefined();
 
-    RetainPtr<NSData*> arguments(m_instanceProxy->marshalValues(exec, args));
+    RetainPtr<NSData> arguments(m_instanceProxy->marshalValues(exec, args));
 
     uint32_t requestID = m_instanceProxy->nextRequestID();
 
index cb083bf..2cf715e 100644 (file)
@@ -56,7 +56,7 @@ using namespace WebCore;
 @interface WebGeolocationPolicyListener : NSObject <WebAllowDenyPolicyListener>
 {
     RefPtr<Geolocation> _geolocation;
-    RetainPtr<WebView *> _webView;
+    RetainPtr<WebView> _webView;
 }
 - (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView;
 @end
index 645b1b2..51802cc 100644 (file)
@@ -246,7 +246,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 - (void)_receivedData:(NSData *)data
 {
     // protect self temporarily, as the bridge receivedData call could remove our last ref
-    RetainPtr<WebDataSource*> protect(self);
+    RetainPtr<WebDataSource> protect(self);
     
     [[self representation] receivedData:data withDataSource:self];
     [[[[self webFrame] frameView] documentView] dataSourceUpdated:self];
index 4b66127..f247b03 100644 (file)
@@ -3661,7 +3661,7 @@ IGNORE_WARNINGS_END
 
 - (NSCachedURLResponse *)_cachedResponseForURL:(NSURL *)URL
 {
-    RetainPtr<NSMutableURLRequest *> request = adoptNS([[NSMutableURLRequest alloc] initWithURL:URL]);
+    RetainPtr<NSMutableURLRequest> request = adoptNS([[NSMutableURLRequest alloc] initWithURL:URL]);
     [request _web_setHTTPUserAgent:[self userAgentForURL:URL]];
     NSCachedURLResponse *cachedResponse;
 
index d5fb0a3..fa6b300 100644 (file)
@@ -1,3 +1,81 @@
+2019-01-07  David Kilzer  <ddkilzer@apple.com>
+
+        Prefer RetainPtr<NSObject> to RetainPtr<NSObject *>
+        <https://webkit.org/b/193056>
+
+        Reviewed by Alex Christensen.
+
+        * Scripts/webkitpy/style/checker.py:
+        - Ignore use of new runtime/retainptr check in
+          Tools/TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm since it
+          contains tests to ensure RetainPtr<NSObject *> is compatible
+          with RetainPtr<NSObject>.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_language):
+        (CppChecker):
+        - Add checker for use of '*' in RetainPtr<> type.  A for loop
+          was used instead of a single regex so that angle brackets
+          could be matched up when checking the type contained within
+          the RetainPtr<> type.
+
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (CppStyleTest):
+        - Add unit test for new runtime/retainptr check.
+
+        * TestRunnerShared/EventSerialization/mac/EventSerializerMac.h:
+        * TestWebKitAPI/EditingTestHarness.h:
+        - Remove '*' from RetainPtr<> type.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        - Add cf/RetainPtr.cpp back to TestWTFLibrary target!  This
+          regressed in r201938.
+
+        * TestWebKitAPI/Tests/WTF/cf/RetainPtr.cpp:
+        (TestWebKitAPI::TEST):
+        - Update tests to match RetainPtr.mm tests (except for the
+          `*SimilarNSType` tests since there is no CF equivalent of
+          RetainPtr<NSString> and RetainPtr<NSString *>).
+
+        * TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm:
+        (TestWebKitAPI::TEST):
+        - Update tests to:
+          - Not conflict by name with equivalent CF tests in
+            RetainPtr.cpp.
+          - Add test cases for RetainPtr<NSObject>,
+            RetainPtr<NSObject *> and RetainPtr<id> were appropriate.
+          - Add `*SimilarNSType` tests for converting between
+            RetainPtr<NSObject> and RetainPtr<NSObject *>.
+          - Change `0` to `nil` as appropriate.
+          - Re-alphabetize the tests by name.
+          - Add Optional<RetainPtr<>> tests.
+          - Add retainPtr() tests.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/DownloadProgress.mm:
+        (-[DownloadProgressTestRunner _download:decideDestinationWithSuggestedFilename:completionHandler:]):
+        * TestWebKitAPI/Tests/WebKitCocoa/IconLoadingDelegate.mm:
+        (TEST):
+        - Remove '*' from RetainPtr<> type.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/JITEnabled.mm:
+        (TEST(WebKit, JITEnabled)):
+        - Add missing WTFMove().  Apparently a temporary was being
+          created before in the argument list due to mismatched
+          RetainPtr<> types.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm:
+        (TestWebKitAPI::setUpWebViewForTestingVideoControlsManager):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+        * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
+        * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
+        (WTR::resourcesDirectoryURL):
+        * WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm:
+        (WTR::InjectedBundle::platformInitialize):
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        - Remove '*' from RetainPtr<> type.
+
 2019-01-07  Eric Carlson  <eric.carlson@apple.com>
 
         A MediaTime timescale must never be zero
index 1742493..f307650 100644 (file)
@@ -142,6 +142,9 @@ _PATH_RULES_SPECIFIER = [
       os.path.join('Tools', 'DumpRenderTree', 'TestNetscapePlugIn')],
      ["-build/include",
       "-readability/naming"]),
+    ([  # Ignore use of RetainPtr<NSObject *> for tests that ensure its compatibility with ReteainPtr<NSObject>.
+      os.path.join('Tools', 'TestWebKitAPI', 'Tests', 'WTF', 'ns', 'RetainPtr.mm')],
+     ["-runtime/retainptr"]),
     ([  # There is no clean way to avoid "yy_*" names used by flex.
       os.path.join('Source', 'WebCore', 'css', 'CSSParser.cpp'),
       # TestWebKitAPI uses funny macros like EXPECT_WK_STREQ.
index 8cd2c05..ced973f 100644 (file)
@@ -3313,6 +3313,25 @@ def check_language(filename, clean_lines, line_number, file_extension, include_s
         error(line_number, 'runtime/dispatch_set_target_queue', 5,
               'Never use dispatch_set_target_queue.  Use dispatch_queue_create_with_target instead.')
 
+    matched = search(r'\b(RetainPtr<.*)', line)
+    if matched:
+        match_line = matched.group(1)
+        nested_angle_bracket_count = 1
+        previous_closing_angle_bracket_index = -1
+        closing_angle_bracket_index = 9 # Used if only one pair of angle brackets.
+        for i in xrange(10, len(match_line) - 1):
+            if match_line[i] == '<':
+                nested_angle_bracket_count += 1
+            if match_line[i] == '>':
+                nested_angle_bracket_count -= 1
+                previous_closing_angle_bracket_index = closing_angle_bracket_index
+                closing_angle_bracket_index = i
+            if nested_angle_bracket_count == 0:
+                if "*" in match_line[previous_closing_angle_bracket_index:closing_angle_bracket_index]:
+                    error(line_number, 'runtime/retainptr', 5,
+                          'RetainPtr<> should never contain a type with \'*\'. Correct: RetainPtr<NSString>, RetainPtr<CFStringRef>.')
+                break
+
     # Check for suspicious usage of "if" like
     # } if (a == b) {
     if search(r'\}\s*if\s*\(', line):
@@ -4052,6 +4071,7 @@ class CppChecker(object):
         'runtime/printf',
         'runtime/printf_format',
         'runtime/references',
+        'runtime/retainptr',
         'runtime/rtti',
         'runtime/sizeof',
         'runtime/soft-linked-alloc',
index 318d1c3..d6ad3b2 100644 (file)
@@ -1667,6 +1667,27 @@ class CppStyleTest(CppStyleTestBase):
             '  [runtime/dispatch_set_target_queue] [5]')
         self.assert_lint('globalQueue = dispatch_queue_create_with_target("My Serial Queue", DISPATCH_QUEUE_SERIAL, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));', '')
 
+    def test_retainptr_pointer(self):
+        self.assert_lint(
+            '''RetainPtr<CFRunLoopRef*> m_cfRunLoop;''',
+            'RetainPtr<> should never contain a type with \'*\'. Correct: RetainPtr<NSString>, RetainPtr<CFStringRef>.'
+            '  [runtime/retainptr] [5]')
+        self.assert_lint('RetainPtr<CFRunLoopRef> m_cfRunLoop;', '')
+        self.assert_lint(
+            '''RetainPtr<NSRunLoop*> m_nsRunLoop;''',
+            'RetainPtr<> should never contain a type with \'*\'. Correct: RetainPtr<NSString>, RetainPtr<CFStringRef>.'
+            '  [runtime/retainptr] [5]')
+        self.assert_lint('RetainPtr<NSRunLoop> m_nsRunLoop;', '')
+        self.assert_lint(
+            '''RetainPtr<NSMutableArray<NSDictionary *> *> m_editorStateHistory;''',
+            'RetainPtr<> should never contain a type with \'*\'. Correct: RetainPtr<NSString>, RetainPtr<CFStringRef>.'
+            '  [runtime/retainptr] [5]')
+        self.assert_lint(
+            '''RetainPtr<NSDictionary<NSString *, NSArray<NSString *>> *> dictionary;''',
+            'RetainPtr<> should never contain a type with \'*\'. Correct: RetainPtr<NSString>, RetainPtr<CFStringRef>.'
+            '  [runtime/retainptr] [5]')
+        self.assert_lint('''RetainPtr<NSDictionary<NSString *, NSArray<NSString *>>> dictionary;''', '')
+
     # Variable-length arrays are not permitted.
     def test_variable_length_array_detection(self):
         errmsg = ('Do not use variable-length arrays.  Use an appropriately named '
index 2cd2d55..9028f00 100644 (file)
@@ -38,8 +38,8 @@
 @end
 
 @interface EventStreamPlayer : NSObject {
-    RetainPtr<NSMutableArray *> _remainingEventDictionaries;
-    RetainPtr<NSWindow *> _window;
+    RetainPtr<NSMutableArray> _remainingEventDictionaries;
+    RetainPtr<NSWindow> _window;
     BlockPtr<void ()> _completionHandler;
     uint64_t _startTime;
 }
index 33e26c3..29af321 100644 (file)
@@ -31,8 +31,8 @@
 #import <WebKit/WKUIDelegatePrivate.h>
 
 @interface EditingTestHarness : NSObject<WKUIDelegatePrivate> {
-    RetainPtr<NSMutableArray<NSDictionary *> *> _editorStateHistory;
-    RetainPtr<TestWKWebView *> _webView;
+    RetainPtr<NSMutableArray<NSDictionary *>> _editorStateHistory;
+    RetainPtr<TestWKWebView> _webView;
 }
 
 - (instancetype)initWithWebView:(TestWKWebView *)webView;
index b6984b7..5c33785 100644 (file)
                4433A396208044140091ED57 /* SynchronousTimeoutTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */; };
                44817A2F1F0486BF00003810 /* WKRequestActivatedElementInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44817A2E1F0486BF00003810 /* WKRequestActivatedElementInfo.mm */; };
                448D7E471EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448D7E451EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp */; };
+               44AC8BC621D0245A00CAFB34 /* RetainPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC029B161486AD6400817DA9 /* RetainPtr.cpp */; };
                4612C2B9210A6ACE00B788A6 /* LoadFileThenReload.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4612C2B8210A6ABF00B788A6 /* LoadFileThenReload.mm */; };
                46397B951DC2C850009A78AE /* DOMNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46397B941DC2C850009A78AE /* DOMNode.mm */; };
                4647B1261EBA3B850041D7EF /* ProcessDidTerminate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4647B1251EBA3B730041D7EF /* ProcessDidTerminate.cpp */; };
                                7C83DF151D0A590C00FEBCF3 /* RefCounter.cpp in Sources */,
                                7C83DED71D0A590C00FEBCF3 /* RefLogger.cpp in Sources */,
                                7C83DF161D0A590C00FEBCF3 /* RefPtr.cpp in Sources */,
+                               44AC8BC621D0245A00CAFB34 /* RetainPtr.cpp in Sources */,
                                7C83DF241D0A590C00FEBCF3 /* RetainPtr.mm in Sources */,
                                7C83DF051D0A590C00FEBCF3 /* RunLoop.cpp in Sources */,
                                7C83DF261D0A590C00FEBCF3 /* SaturatedArithmeticOperations.cpp in Sources */,
index 0033f3b..c9cfef1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 
 #include <wtf/RetainPtr.h>
+#include <wtf/cf/TypeCastsCF.h>
 
 namespace TestWebKitAPI {
 
 TEST(RetainPtr, AdoptCF)
 {
-    RetainPtr<CFArrayRef> foo = adoptCF(CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr));
+    RetainPtr<CFArrayRef> array1 = adoptCF(CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr));
+    EXPECT_EQ(1, CFGetRetainCount(array1.get()));
+    EXPECT_EQ(0, CFArrayGetCount(array1.get()));
 
-    EXPECT_EQ(1, CFGetRetainCount(foo.get()));
+    RetainPtr<CFTypeRef> array2 = adoptCF(CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr));
+    EXPECT_EQ(1, CFGetRetainCount(array2.get()));
+    EXPECT_EQ(0, CFArrayGetCount(checked_cf_cast<CFArrayRef>(array2.get())));
+}
+
+TEST(RetainPtr, ConstructionFromMutableCFType)
+{
+    CFMutableStringRef string = CFStringCreateMutableCopy(kCFAllocatorDefault, 4, CFSTR("foo"));
+
+    // This should invoke RetainPtr's move constructor.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // CFTypeRef that logs -retain and -release calls.
+    RetainPtr<CFStringRef> ptr = RetainPtr<CFMutableStringRef>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    RetainPtr<CFMutableStringRef> temp = string;
+
+    // This should invoke RetainPtr's move constructor.
+    RetainPtr<CFStringRef> ptr2(WTFMove(temp));
+
+    EXPECT_EQ(string, ptr2);
+    EXPECT_EQ((CFStringRef)nullptr, temp);
+}
+
+TEST(RetainPtr, ConstructionFromSameCFType)
+{
+    CFStringRef string = CFSTR("foo");
+
+    // This should invoke RetainPtr's move constructor.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // CFTypeRef that logs -retain and -release calls.
+    RetainPtr<CFStringRef> ptr = RetainPtr<CFStringRef>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    RetainPtr<CFStringRef> temp = string;
+
+    // This should invoke RetainPtr's move constructor.
+    RetainPtr<CFStringRef> ptr2(WTFMove(temp));
+
+    EXPECT_EQ(string, ptr2);
+    EXPECT_EQ((CFStringRef)nullptr, temp);
+}
+
+TEST(RetainPtr, MoveAssignmentFromMutableCFType)
+{
+    CFMutableStringRef string = CFStringCreateMutableCopy(kCFAllocatorDefault, 4, CFSTR("foo"));
+    RetainPtr<CFStringRef> ptr;
+
+    // This should invoke RetainPtr's move assignment operator.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // CFTypeRef that logs -retain and -release calls.
+    ptr = RetainPtr<CFMutableStringRef>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    ptr = nullptr;
+    RetainPtr<CFMutableStringRef> temp = string;
+
+    // This should invoke RetainPtr's move assignment operator.
+    ptr = WTFMove(temp);
+
+    EXPECT_EQ(string, ptr);
+    EXPECT_EQ((CFStringRef)nullptr, temp);
+}
+
+TEST(RetainPtr, MoveAssignmentFromSameCFType)
+{
+    CFStringRef string = CFSTR("foo");
+    RetainPtr<CFStringRef> ptr;
+
+    // This should invoke RetainPtr's move assignment operator.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // CFTypeRef that logs -retain and -release calls.
+    ptr = RetainPtr<CFStringRef>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    ptr = nullptr;
+    RetainPtr<CFStringRef> temp = string;
+
+    // This should invoke RetainPtr's move assignment operator.
+    ptr = WTFMove(temp);
+
+    EXPECT_EQ(string, ptr);
+    EXPECT_EQ((CFStringRef)nullptr, temp);
+}
+
+TEST(RetainPtr, OptionalRetainPtrCF)
+{
+    // Test assignment from adoptCF().
+    float value = 3.1415926535;
+    Optional<RetainPtr<CFNumberRef>> optionalObject1 = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));
+    EXPECT_EQ(1, CFGetRetainCount(optionalObject1.value().get()));
+    RetainPtr<CFNumberRef> object1 = optionalObject1.value();
+    EXPECT_EQ(optionalObject1.value(), object1);
+
+    // Test assignment from retainPtr().
+    Optional<RetainPtr<CFNumberRef>> optionalObject2 = retainPtr(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));
+    CFRelease(optionalObject2.value().get());
+    EXPECT_EQ(1, CFGetRetainCount(optionalObject2.value().get()));
+    RetainPtr<CFNumberRef> object2 = optionalObject2.value();
+    EXPECT_EQ(optionalObject2.value(), object2);
+
+    EXPECT_NE(object1, object2);
+
+    // Test assignment from Optional<RetainPtr<CFNumberRef>>.
+    optionalObject1 = optionalObject2;
+    EXPECT_TRUE(optionalObject1.value());
+    EXPECT_TRUE(optionalObject1.value().get());
+    EXPECT_EQ(optionalObject1.value(), object2);
+    EXPECT_TRUE(optionalObject2.value());
+    EXPECT_TRUE(optionalObject2.value().get());
+    EXPECT_EQ(optionalObject2.value(), object2);
+
+    // Reset after assignment test.
+    optionalObject1 = object1;
+    EXPECT_EQ(optionalObject1.value(), object1);
+    EXPECT_EQ(optionalObject2.value(), object2);
+
+    // Test move from Optional<RetainPtr<CFNumberRef>>.
+    optionalObject1 = WTFMove(optionalObject2);
+    EXPECT_TRUE(optionalObject1.value());
+    EXPECT_TRUE(optionalObject1.value().get());
+    EXPECT_EQ(optionalObject1.value(), object2);
+    EXPECT_FALSE(optionalObject2);
+}
+
+TEST(RetainPtr, RetainPtrCF)
+{
+    float value = 3.1415926535;
+    RetainPtr<CFNumberRef> object1 = retainPtr(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));
+    CFRelease(object1.get());
+    EXPECT_EQ(1, CFGetRetainCount(object1.get()));
+
+    RetainPtr<CFTypeRef> object2 = retainPtr(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));
+    CFRelease(object2.get());
+    EXPECT_EQ(1, CFGetRetainCount(object2.get()));
 }
 
 } // namespace TestWebKitAPI
index f925ce7..09e03ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,34 +34,97 @@ namespace TestWebKitAPI {
 
 TEST(RetainPtr, AdoptNS)
 {
-    RetainPtr<NSObject> foo = adoptNS([[NSObject alloc] init]);
+    RetainPtr<NSObject> object1 = adoptNS([[NSObject alloc] init]);
+    EXPECT_EQ(1, CFGetRetainCount(object1.get()));
 
-    EXPECT_EQ(1, CFGetRetainCount(foo.get()));
+    RetainPtr<NSObject *> object2 = adoptNS([[NSObject alloc] init]);
+    EXPECT_EQ(1, CFGetRetainCount(object2.get()));
+
+    RetainPtr<id> object3 = adoptNS([[NSObject alloc] init]);
+    EXPECT_EQ(1, CFGetRetainCount(object3.get()));
 }
 
-TEST(RetainPtr, MoveAssignmentFromSameType)
+TEST(RetainPtr, ConstructionFromMutableNSType)
+{
+    NSMutableString *string = [NSMutableString stringWithUTF8String:"foo"];
+
+    // This should invoke RetainPtr's move constructor.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // NSObject that logs -retain and -release calls.
+    RetainPtr<NSString> ptr = RetainPtr<NSMutableString>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    RetainPtr<NSMutableString> temp = string;
+
+    // This should invoke RetainPtr's move constructor.
+    RetainPtr<NSString> ptr2(WTFMove(temp));
+
+    EXPECT_EQ(string, ptr2);
+    EXPECT_EQ((NSString *)nil, temp);
+}
+
+TEST(RetainPtr, ConstructionFromSameNSType)
 {
     NSString *string = @"foo";
-    RetainPtr<NSString> ptr;
 
-    // This should invoke RetainPtr's move assignment operator.
+    // This should invoke RetainPtr's move constructor.
     // FIXME: This doesn't actually test that we moved the value. We should use a mock
     // NSObject that logs -retain and -release calls.
-    ptr = RetainPtr<NSString>(string);
+    RetainPtr<NSString> ptr = RetainPtr<NSString>(string);
 
     EXPECT_EQ(string, ptr);
 
-    ptr = 0;
     RetainPtr<NSString> temp = string;
 
-    // This should invoke RetainPtr's move assignment operator.
-    ptr = WTFMove(temp);
+    // This should invoke RetainPtr's move constructor.
+    RetainPtr<NSString> ptr2(WTFMove(temp));
+
+    EXPECT_EQ(string, ptr2);
+    EXPECT_EQ((NSString *)nil, temp);
+}
+
+TEST(RetainPtr, ConstructionFromSimilarNSType)
+{
+    NSString *string = @"foo";
+
+    // This should invoke RetainPtr's move constructor.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // NSObject that logs -retain and -release calls.
+    RetainPtr<NSString> ptr = RetainPtr<NSString *>(string);
 
     EXPECT_EQ(string, ptr);
-    EXPECT_EQ((NSString *)0, temp);
+
+    RetainPtr<NSString *> temp = string;
+
+    // This should invoke RetainPtr's move constructor.
+    RetainPtr<NSString> ptr2(WTFMove(temp));
+
+    EXPECT_EQ(string, ptr2);
+    EXPECT_EQ((NSString *)nil, temp);
 }
 
-TEST(RetainPtr, MoveAssignmentFromSimilarType)
+TEST(RetainPtr, ConstructionFromSimilarNSTypeReversed)
+{
+    NSString *string = @"foo";
+
+    // This should invoke RetainPtr's move constructor.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // NSObject that logs -retain and -release calls.
+    RetainPtr<NSString *> ptr = RetainPtr<NSString>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    RetainPtr<NSString> temp = string;
+
+    // This should invoke RetainPtr's move constructor.
+    RetainPtr<NSString *> ptr2(WTFMove(temp));
+
+    EXPECT_EQ(string, ptr2);
+    EXPECT_EQ((NSString *)nil, temp);
+}
+
+TEST(RetainPtr, MoveAssignmentFromMutableNSType)
 {
     NSMutableString *string = [NSMutableString stringWithUTF8String:"foo"];
     RetainPtr<NSString> ptr;
@@ -73,54 +136,142 @@ TEST(RetainPtr, MoveAssignmentFromSimilarType)
 
     EXPECT_EQ(string, ptr);
 
-    ptr = 0;
+    ptr = nil;
     RetainPtr<NSMutableString> temp = string;
 
     // This should invoke RetainPtr's move assignment operator.
     ptr = WTFMove(temp);
 
     EXPECT_EQ(string, ptr);
-    EXPECT_EQ((NSString *)0, temp);
+    EXPECT_EQ((NSString *)nil, temp);
 }
 
-TEST(RetainPtr, ConstructionFromSameType)
+TEST(RetainPtr, MoveAssignmentFromSameNSType)
 {
     NSString *string = @"foo";
+    RetainPtr<NSString> ptr;
 
-    // This should invoke RetainPtr's move constructor.
+    // This should invoke RetainPtr's move assignment operator.
     // FIXME: This doesn't actually test that we moved the value. We should use a mock
     // NSObject that logs -retain and -release calls.
-    RetainPtr<NSString> ptr = RetainPtr<NSString>(string);
+    ptr = RetainPtr<NSString>(string);
 
     EXPECT_EQ(string, ptr);
 
+    ptr = nil;
     RetainPtr<NSString> temp = string;
 
-    // This should invoke RetainPtr's move constructor.
-    RetainPtr<NSString> ptr2(WTFMove(temp));
+    // This should invoke RetainPtr's move assignment operator.
+    ptr = WTFMove(temp);
 
-    EXPECT_EQ(string, ptr2);
-    EXPECT_EQ((NSString *)0, temp);
+    EXPECT_EQ(string, ptr);
+    EXPECT_EQ((NSString *)nil, temp);
 }
 
-TEST(RetainPtr, ConstructionFromSimilarType)
+TEST(RetainPtr, MoveAssignmentFromSimilarNSType)
 {
-    NSMutableString *string = [NSMutableString stringWithUTF8String:"foo"];
+    NSString *string = @"foo";
+    RetainPtr<NSString> ptr;
 
-    // This should invoke RetainPtr's move constructor.
+    // This should invoke RetainPtr's move assignment operator.
     // FIXME: This doesn't actually test that we moved the value. We should use a mock
     // NSObject that logs -retain and -release calls.
-    RetainPtr<NSString> ptr = RetainPtr<NSMutableString>(string);
+    ptr = RetainPtr<NSString *>(string);
 
     EXPECT_EQ(string, ptr);
 
-    RetainPtr<NSMutableString> temp = string;
+    ptr = nil;
+    RetainPtr<NSString *> temp = string;
 
-    // This should invoke RetainPtr's move constructor.
-    RetainPtr<NSString> ptr2(WTFMove(temp));
+    // This should invoke RetainPtr's move assignment operator.
+    ptr = WTFMove(temp);
 
-    EXPECT_EQ(string, ptr2);
-    EXPECT_EQ((NSString *)0, temp);
+    EXPECT_EQ(string, ptr);
+    EXPECT_EQ((NSString *)nil, temp);
+}
+
+TEST(RetainPtr, MoveAssignmentFromSimilarNSTypeReversed)
+{
+    NSString *string = @"foo";
+    RetainPtr<NSString *> ptr;
+
+    // This should invoke RetainPtr's move assignment operator.
+    // FIXME: This doesn't actually test that we moved the value. We should use a mock
+    // NSObject that logs -retain and -release calls.
+    ptr = RetainPtr<NSString>(string);
+
+    EXPECT_EQ(string, ptr);
+
+    ptr = nil;
+    RetainPtr<NSString> temp = string;
+
+    // This should invoke RetainPtr's move assignment operator.
+    ptr = WTFMove(temp);
+
+    EXPECT_EQ(string, ptr);
+    EXPECT_EQ((NSString *)nil, temp);
+}
+
+TEST(RetainPtr, OptionalRetainPtrNS)
+{
+    // Test assignment from adoptNS().
+    Optional<RetainPtr<NSObject>> optionalObject1 = adoptNS([NSObject new]);
+    EXPECT_EQ(1, CFGetRetainCount(optionalObject1.value().get()));
+    RetainPtr<NSObject> object1 = optionalObject1.value();
+    EXPECT_EQ(optionalObject1.value(), object1);
+
+    // Test assignment from retainPtr().
+    Optional<RetainPtr<NSObject>> optionalObject2;
+    @autoreleasepool {
+        optionalObject2 = retainPtr([[NSObject new] autorelease]);
+    }
+    EXPECT_EQ(1, CFGetRetainCount(optionalObject2.value().get()));
+    RetainPtr<NSObject> object2 = optionalObject2.value();
+    EXPECT_EQ(optionalObject2.value(), object2);
+
+    EXPECT_NE(object1, object2);
+
+    // Test assignment from Optional<RetainPtr<NSObject>>.
+    optionalObject1 = optionalObject2;
+    EXPECT_TRUE(optionalObject1.value());
+    EXPECT_TRUE(optionalObject1.value().get());
+    EXPECT_EQ(optionalObject1.value(), object2);
+    EXPECT_TRUE(optionalObject2.value());
+    EXPECT_TRUE(optionalObject2.value().get());
+    EXPECT_EQ(optionalObject2.value(), object2);
+
+    // Reset after assignment test.
+    optionalObject1 = object1;
+    EXPECT_EQ(optionalObject1.value(), object1);
+    EXPECT_EQ(optionalObject2.value(), object2);
+
+    // Test move from Optional<RetainPtr<NSObject>>.
+    optionalObject1 = WTFMove(optionalObject2);
+    EXPECT_TRUE(optionalObject1.value());
+    EXPECT_TRUE(optionalObject1.value().get());
+    EXPECT_EQ(optionalObject1.value(), object2);
+    EXPECT_FALSE(optionalObject2);
+}
+
+TEST(RetainPtr, RetainPtrNS)
+{
+    RetainPtr<NSObject> object1;
+    @autoreleasepool {
+        object1 = retainPtr([[NSObject new] autorelease]);
+    }
+    EXPECT_EQ(1, CFGetRetainCount(object1.get()));
+
+    RetainPtr<NSObject *> object2;
+    @autoreleasepool {
+        object2 = retainPtr([[NSObject new] autorelease]);
+    }
+    EXPECT_EQ(1, CFGetRetainCount(object2.get()));
+
+    RetainPtr<id> object3;
+    @autoreleasepool {
+        object3 = retainPtr([[NSObject new] autorelease]);
+    }
+    EXPECT_EQ(1, CFGetRetainCount(object3.get()));
 }
 
 } // namespace TestWebKitAPI
index f771243..f560df3 100644 (file)
@@ -381,7 +381,7 @@ static void* progressObservingContext = &progressObservingContext;
     EXPECT_EQ(download, m_download.get());
 
     WebCore::FileSystem::PlatformFileHandle fileHandle;
-    RetainPtr<NSString *> path = (NSString *)WebCore::FileSystem::openTemporaryFile("TestWebKitAPI", fileHandle);
+    RetainPtr<NSString> path = (NSString *)WebCore::FileSystem::openTemporaryFile("TestWebKitAPI", fileHandle);
     EXPECT_TRUE(fileHandle != WebCore::FileSystem::invalidPlatformFileHandle);
     WebCore::FileSystem::closeFile(fileHandle);
 
index 1f825bb..71d2810 100644 (file)
@@ -205,7 +205,7 @@ TEST(IconLoading, AlreadyCachedIcon)
     RetainPtr<IconLoadingSchemeHandler> handler = adoptNS([[IconLoadingSchemeHandler alloc] initWithData:mainData]);
 
     NSURL *url = [[NSBundle mainBundle] URLForResource:@"large-red-square-image" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
-    RetainPtr<NSData *> iconDataFromDisk = [NSData dataWithContentsOfURL:url];
+    RetainPtr<NSData> iconDataFromDisk = [NSData dataWithContentsOfURL:url];
     [handler.get() setFaviconData:iconDataFromDisk.get()];
 
     [configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
index 8068719..b3a3b3d 100644 (file)
@@ -53,7 +53,7 @@ TEST(WebKit, JITEnabled)
     auto configuration = adoptNS([WKWebViewConfiguration new]);
     [configuration setProcessPool:[[[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()] autorelease]];
     auto webViewNoJIT = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-    checkJITEnabled(webViewNoJIT, NO);
+    checkJITEnabled(WTFMove(webViewNoJIT), NO);
     checkJITEnabled(adoptNS([WKWebView new]), YES);
 }
 
index 96133a9..5333097 100644 (file)
@@ -188,7 +188,7 @@ static RetainPtr<WKWebView> createdWebView;
 @interface PSONScheme : NSObject <WKURLSchemeHandler> {
     const char* _bytes;
     HashMap<String, String> _redirects;
-    HashMap<String, RetainPtr<NSData *>> _dataMappings;
+    HashMap<String, RetainPtr<NSData>> _dataMappings;
 }
 - (instancetype)initWithBytes:(const char*)bytes;
 - (void)addRedirectFromURLString:(NSString *)sourceURLString toURLString:(NSString *)destinationURLString;
index f489bbe..abf2aa6 100644 (file)
 
 namespace TestWebKitAPI {
 
-RetainPtr<VideoControlsManagerTestWebView*> setUpWebViewForTestingVideoControlsManager(NSRect frame)
+RetainPtr<VideoControlsManagerTestWebView> setUpWebViewForTestingVideoControlsManager(NSRect frame)
 {
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
@@ -126,7 +126,7 @@ RetainPtr<VideoControlsManagerTestWebView*> setUpWebViewForTestingVideoControlsM
 
 TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideo)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     // A large video with audio should have a controls manager even if it is played via script like this video.
     // So the expectation is YES.
@@ -136,7 +136,7 @@ TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideo)
 
 TEST(VideoControlsManager, VideoControlsManagerSingleSmallVideo)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     // A small video will not have a controls manager unless it started playing because of a user gesture. Since this
     // video is started with a script, the expectation is NO.
@@ -146,7 +146,7 @@ TEST(VideoControlsManager, VideoControlsManagerSingleSmallVideo)
 
 TEST(VideoControlsManager, VideoControlsManagerMultipleVideosWithAudio)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     [webView loadTestPageNamed:@"large-videos-with-audio"];
     [webView waitForPageToLoadWithAutoplayingVideos:0];
@@ -157,7 +157,7 @@ TEST(VideoControlsManager, VideoControlsManagerMultipleVideosWithAudio)
 // FIXME: Re-enable this test once <webkit.org/b/175143> is resolved.
 TEST(VideoControlsManager, DISABLED_VideoControlsManagerMultipleVideosWithAudioAndAutoplay)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     [webView loadTestPageNamed:@"large-videos-with-audio-autoplay"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -168,7 +168,7 @@ TEST(VideoControlsManager, DISABLED_VideoControlsManagerMultipleVideosWithAudioA
 
 TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPausedVideoOutOfView)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
 
     [webView loadTestPageNamed:@"large-videos-paused-video-hides-controls"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -179,7 +179,7 @@ TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPausedVideoOu
 
 TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingVideoWithSoundOutOfView)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
 
     [webView loadTestPageNamed:@"large-videos-playing-video-keeps-controls"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -190,7 +190,7 @@ TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingVideoW
 
 TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingMutedVideoOutOfView)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
 
     [webView loadTestPageNamed:@"large-videos-playing-muted-video-hides-controls"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -201,7 +201,7 @@ TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollPlayingMutedV
 
 TEST(VideoControlsManager, VideoControlsManagerMultipleVideosShowControlsForLastInteractedVideo)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
     NSPoint clickPoint = NSMakePoint(400, 300);
 
     [webView loadTestPageNamed:@"large-videos-autoplaying-click-to-pause"];
@@ -228,7 +228,7 @@ TEST(VideoControlsManager, VideoControlsManagerMultipleVideosShowControlsForLast
 // FIXME: Re-enable this test once <webkit.org/b/175909> is resolved.
 TEST(VideoControlsManager, DISABLED_VideoControlsManagerMultipleVideosSwitchControlledVideoWhenScrolling)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
 
     [webView loadTestPageNamed:@"large-videos-autoplaying-scroll-to-video"];
     [webView waitForPageToLoadWithAutoplayingVideos:2];
@@ -241,7 +241,7 @@ TEST(VideoControlsManager, DISABLED_VideoControlsManagerMultipleVideosSwitchCont
 
 TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollOnlyLargeVideoOutOfView)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
 
     [webView loadTestPageNamed:@"large-video-playing-scroll-away"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -251,7 +251,7 @@ TEST(VideoControlsManager, VideoControlsManagerMultipleVideosScrollOnlyLargeVide
 
 TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     [webView loadTestPageNamed:@"autoplaying-video-with-audio"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -262,7 +262,7 @@ TEST(VideoControlsManager, VideoControlsManagerSingleSmallAutoplayingVideo)
 
 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEnding)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     [webView loadTestPageNamed:@"large-video-seek-after-ending"];
 
@@ -275,7 +275,7 @@ TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAfterEn
 
 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlaysAfterEnding)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     // Since the video is still playing, the expectation is YES even if the video has ended once.
     [webView loadTestPageNamed:@"large-video-seek-to-beginning-and-play-after-ending"];
@@ -284,7 +284,7 @@ TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoSeeksAndPlay
 
 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoAfterSeekingToEnd)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     [webView loadTestPageNamed:@"large-video-hides-controls-after-seek-to-end"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -297,7 +297,7 @@ TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoAfterSeeking
 
 TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     // A large video with no audio will not have a controls manager unless it started playing because of a user gesture. Since this
     // video is started with a script, the expectation is NO.
@@ -307,7 +307,7 @@ TEST(VideoControlsManager, VideoControlsManagerSingleLargeVideoWithoutAudio)
 
 TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedWithScript)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     // An audio element MUST be started with a user gesture in order to have a controls manager, so the expectation is NO.
     [webView loadTestPageNamed:@"audio-only"];
@@ -316,7 +316,7 @@ TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedWithScript)
 
 TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedByInteraction)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 400, 400));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 400, 400));
 
     [webView loadTestPageNamed:@"play-audio-on-click"];
     [webView waitForPageToLoadWithAutoplayingVideos:0];
@@ -329,7 +329,7 @@ TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedByInteraction)
 
 TEST(VideoControlsManager, DISABLED_VideoControlsManagerAudioElementFollowingUserInteraction)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 400, 400));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 400, 400));
 
     [webView loadTestPageNamed:@"play-audio-on-click"];
     [webView waitForPageToLoadWithAutoplayingVideos:0];
@@ -354,7 +354,7 @@ TEST(VideoControlsManager, DISABLED_VideoControlsManagerAudioElementFollowingUse
 
 TEST(VideoControlsManager, VideoControlsManagerTearsDownMediaControlsOnDealloc)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     NSURL *urlOfVideo = [[NSBundle mainBundle] URLForResource:@"video-with-audio" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"];
     [webView loadFileURL:urlOfVideo allowingReadAccessToURL:[urlOfVideo URLByDeletingLastPathComponent]];
@@ -374,7 +374,7 @@ TEST(VideoControlsManager, VideoControlsManagerTearsDownMediaControlsOnDealloc)
 
 TEST(VideoControlsManager, VideoControlsManagerDoesNotShowMediaControlsForOffscreenVideo)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1024, 768));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1024, 768));
 
     [webView loadTestPageNamed:@"large-video-offscreen"];
     [webView waitForMediaControlsToHide];
@@ -382,7 +382,7 @@ TEST(VideoControlsManager, VideoControlsManagerDoesNotShowMediaControlsForOffscr
 
 TEST(VideoControlsManager, VideoControlsManagerKeepsControlsStableDuringSrcChangeOnClick)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
 
     [webView loadTestPageNamed:@"change-video-source-on-click"];
     [webView waitForPageToLoadWithAutoplayingVideos:1];
@@ -393,7 +393,7 @@ TEST(VideoControlsManager, VideoControlsManagerKeepsControlsStableDuringSrcChang
 
 TEST(VideoControlsManager, VideoControlsManagerKeepsControlsStableDuringSrcChangeOnEnd)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
 
     [webView loadTestPageNamed:@"change-video-source-on-end"];
     [webView expectControlsManager:YES afterReceivingMessage:@"changed"];
@@ -401,7 +401,7 @@ TEST(VideoControlsManager, VideoControlsManagerKeepsControlsStableDuringSrcChang
 
 TEST(VideoControlsManager, VideoControlsManagerSmallVideoInMediaDocument)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));
 
     __block bool finishedLoad = false;
     [webView performAfterLoading:^ {
@@ -419,7 +419,7 @@ TEST(VideoControlsManager, VideoControlsManagerSmallVideoInMediaDocument)
     
 TEST(VideoControlsManager, VideoControlsManagerOffscreenIframeMediaDocument)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
     [webView loadTestPageNamed:@"offscreen-iframe-of-media-document"];
     
     // We do not expect a controls manager becuase the media document is in an iframe.
@@ -428,7 +428,7 @@ TEST(VideoControlsManager, VideoControlsManagerOffscreenIframeMediaDocument)
 
 TEST(VideoControlsManager, VideoControlsManagerLongSkinnyVideoInWideMainFrame)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
 
     [webView loadTestPageNamed:@"skinny-autoplaying-video-with-audio"];
     [webView expectControlsManager:NO afterReceivingMessage:@"playing"];
@@ -436,7 +436,7 @@ TEST(VideoControlsManager, VideoControlsManagerLongSkinnyVideoInWideMainFrame)
 
 TEST(VideoControlsManager, VideoControlsManagerWideMediumSizedVideoInWideMainFrame)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
 
     [webView loadTestPageNamed:@"wide-autoplaying-video-with-audio"];
     [webView expectControlsManager:YES afterReceivingMessage:@"playing"];
@@ -444,7 +444,7 @@ TEST(VideoControlsManager, VideoControlsManagerWideMediumSizedVideoInWideMainFra
 
 TEST(VideoControlsManager, VideoControlsManagerFullSizeVideoInWideMainFrame)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
 
     [webView loadTestPageNamed:@"full-size-autoplaying-video-with-audio"];
     [webView expectControlsManager:YES afterReceivingMessage:@"playing"];
@@ -452,7 +452,7 @@ TEST(VideoControlsManager, VideoControlsManagerFullSizeVideoInWideMainFrame)
 
 TEST(VideoControlsManager, VideoControlsManagerVideoMutesOnPlaying)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
 
     [webView loadTestPageNamed:@"large-video-mutes-onplaying"];
     [webView expectControlsManager:NO afterReceivingMessage:@"playing"];
@@ -460,7 +460,7 @@ TEST(VideoControlsManager, VideoControlsManagerVideoMutesOnPlaying)
 
 TEST(VideoControlsManager, VideoControlsManagerPageWithEnormousVideo)
 {
-    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+    RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
 
     [webView loadTestPageNamed:@"enormous-video-with-sound"];
     [webView expectControlsManager:NO afterReceivingMessage:@"playing"];
index be0ed94..7b68f77 100644 (file)
@@ -908,7 +908,7 @@ TEST(WebKit, CustomHeaderFields)
 static unsigned loadCount;
 
 @interface DataMappingSchemeHandler : NSObject <WKURLSchemeHandler> {
-    HashMap<String, RetainPtr<NSData *>> _dataMappings;
+    HashMap<String, RetainPtr<NSData>> _dataMappings;
     Function<void(id <WKURLSchemeTask>)> _taskHandler;
 }
 - (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data;
index 4cb8518..20f32ca 100644 (file)
@@ -297,8 +297,8 @@ static NSArray *dragAndDropEventNames()
     RetainPtr<MockDropSession> _dropSession;
     RetainPtr<NSMutableArray> _observedEventNames;
     RetainPtr<NSArray> _externalItemProviders;
-    RetainPtr<NSArray *> _sourceItemProviders;
-    RetainPtr<NSArray *> _finalSelectionRects;
+    RetainPtr<NSArray> _sourceItemProviders;
+    RetainPtr<NSArray> _finalSelectionRects;
     CGPoint _startLocation;
     CGPoint _endLocation;
     CGRect _lastKnownDragCaretRect;
index ea36a0e..3fef2d5 100644 (file)
@@ -47,7 +47,7 @@ namespace WTR {
 
 static NSURL *resourcesDirectoryURL()
 {
-    static NeverDestroyed<RetainPtr<NSURL *>> resourcesDirectory([[NSBundle bundleForClass:[WKTRFontActivatorDummyClass class]] resourceURL]);
+    static NeverDestroyed<RetainPtr<NSURL>> resourcesDirectory([[NSBundle bundleForClass:[WKTRFontActivatorDummyClass class]] resourceURL]);
     return resourcesDirectory.get().get();
 }
 
index 3f2d76c..42908be 100644 (file)
@@ -37,7 +37,7 @@ void InjectedBundle::platformInitialize(WKTypeRef)
     // Language was set up earlier in main(). Don't clobber it.
     NSArray *languages = [[[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain] valueForKey:@"AppleLanguages"];
 
-    RetainPtr<NSMutableDictionary *> dict = adoptNS([[NSMutableDictionary alloc] init]);
+    RetainPtr<NSMutableDictionary> dict = adoptNS([[NSMutableDictionary alloc] init]);
     if (languages)
         [dict setObject:languages forKey:@"AppleLanguages"];
 
index 6c78037..fbfca09 100644 (file)
@@ -48,7 +48,7 @@
 #if WK_API_ENABLED
 
 @interface TestRunnerWKWebView () <WKUIDelegatePrivate> {
-    RetainPtr<NSNumber *> m_stableStateOverride;
+    RetainPtr<NSNumber> m_stableStateOverride;
     BOOL m_isInteractingWithFormControl;
 }