[Cocoa] Adapt more WebKit code to be ARC-compatible
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 15:51:24 +0000 (15:51 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 15:51:24 +0000 (15:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188955

Reviewed by Anders Carlsson.

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h: Use __strong for an in/out argument.
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded):
Use __strong for a in/out argument.
(WebKit::NetworkDataTaskCocoa::applyCookieBlockingPolicy): Call a NSURLSessionTask
method using an explicit category declaration rather than by using performSelector:
since ARC is unable to correctly compile a call when it doesn't know argument and
result types.

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::initializeCocoaOverrides): Add some __bridge casts.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm: Use HashSet<CFTypeRef> instead of
HashSet<Class> since Class ia an ARC-managed type and WTF hash tables can't
currently handle those as key types.
(-[WKRemoteObjectDecoder decodeValueOfObjCType:at:]): Changed types and added casts
to adapt to the above.
(decodeObjectFromObjectStream): Ditto.
(checkIfClassIsAllowed): Ditto.
(decodeInvocationArguments): Ditto.
(decodeObject): Ditto.
(-[WKRemoteObjectDecoder decodeObjectOfClasses:forKey:]): Ditto.
(-[WKRemoteObjectDecoder allowedClasses]): Ditto.
* Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
(propertyListClasses): Ditto.
(initializeMethod): Ditto.
(-[_WKRemoteObjectInterface debugDescription]): Ditto.
(classesForSelectorArgument): Ditto.
(-[_WKRemoteObjectInterface classesForSelector:argumentIndex:ofReply:]): Ditto.
(-[_WKRemoteObjectInterface setClasses:forSelector:argumentIndex:ofReply:]): Ditto.
(-[_WKRemoteObjectInterface _allowedArgumentClassesForSelector:]): Ditto.
(-[_WKRemoteObjectInterface _allowedArgumentClassesForReplyBlockOfSelector:]): Ditto.
* Shared/API/Cocoa/_WKRemoteObjectInterfaceInternal.h: Ditto.

* Shared/API/c/cf/WKStringCF.mm:
(WKStringCreateWithCFString): Use CFRetain instead of -[NSObject retain]. Also use
a __bridge cast.
* Shared/API/c/cf/WKURLCF.mm:
(WKURLCreateWithCFURL): Ditto.

* Shared/Cocoa/APIObject.mm:
(API::Object::ref): Added a __bridge cast.
(API::Object::deref): Ditto.
(API::allocateWKObject): Use class_createInstance instead of NSAllocateObject.
(API::Object::wrap): Use a __bridge cast.
(API::Object::unwrap): Ditto.

* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h: Use CFTypeRef for layers
or views in the RelatedLayerMap since we don't want the items retained, and can't
use __unsafe_uretained because the header is used in non-Objective-C contexts.
* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::RemoteLayerTreePropertyApplier::applyProperties): Added __bridge casts,
needed because of the above change.

* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(WebKit::browsingContextControllerMap): Use __unsafe_unretained.

* UIProcess/API/Cocoa/WKConnection.mm:
(didReceiveMessage): Use a __bridge cast.

* UIProcess/API/Cocoa/WKContentRuleListStore.mm:
(-[WKContentRuleListStore compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]):
Use a retain here so we don't have to have a "releasesArgument:" boolean. The cost of a single
retain/release pair should be infinitesmal compared to the entire process of compiling.
(-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]):
Moved the code for the "releases argument" version here since the private method is now the
actual method that does the work. The public method now simply calls this private one after
doing a retain. The optimization of releasing the argument at the correct moment should be intact.

* UIProcess/API/Cocoa/WKHTTPCookieStore.mm: Use CFTypeRef for the key to the _observers
HashMap since the WTF collections can't yet handle ARC types for keys.
(-[WKHTTPCookieStore addObserver:]): Added __bridge cast for compatibility with the above.
(-[WKHTTPCookieStore removeObserver:]): Ditto.

* UIProcess/API/Cocoa/WKProcessGroup.mm:
(setUpConnectionClient): Added a __bridge cast.
(setUpHistoryClient): Ditto.

* UIProcess/API/Cocoa/WKViewPrivate.h: Added a declaration of the
-[WKView _shouldLoadIconWithParameters:completionHandler:] method. This peculiar idiom
should be removed, but I didn't bother doing that since the entire WKView class is already
deprecated and so will eventually be removed.

* UIProcess/API/Cocoa/WKWebView.mm: Use __unsafe_unretained for the keys in the page to
view map.
(accessibilityEventsEnabledChangedCallback): Use a __bridge cast.
(-[WKWebView _certificateChain]): Ditto.
(-[WKWebView certificateChain]): Ditto.

* UIProcess/API/mac/WKView.mm:
(-[WKView maybeInstallIconLoadingClient]): Call the method
_shouldLoadIconWithParameters:completionHandler: in a normal way rather than using
performSelector:withObject:withObject: since ARC is unable to correctly compile a call
when it doesn't know argument and result types.

* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::webCryptoMasterKey): Use the overload
of API::Data::createWithoutCopying that knows how to work with an NSData rather than
re-implementing it here.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess): Ditto. Also removed unneeded
use of RetainPtr.

* UIProcess/Cocoa/WebViewImpl.h: Use NSObject * as the result type of
immediateActionAnimationControllerForHitTestResult. Our techniques for defining such
functions in headers while remaining compatible with non-Objective-C will still work
fine given how we use this, and converting to and from void* rather than NSObject *
would be difficult to do correctly under ARC.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::acceptsFirstMouse): Use CFRetain/CFAutorelease instead of
retain/autorelease.
(WebKit::WebViewImpl::shouldDelayWindowOrderingForEvent): Ditto.
(WebKit::WebViewImpl::immediateActionAnimationControllerForHitTestResult):
Updated return type to NSObject *.
(WebKit::WebViewImpl::performKeyEquivalent): Use CFRetain/CFAutorelease.

* UIProcess/PageClient.h: Use NSObject * as the result type, as above.

* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree): Use __bridge casts to be compatible
with the changes to the RelatedLayerMap types.
(WebKit::recursivelyMapIOSurfaceBackingStore): Use __bridge cast.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::immediateActionAnimationControllerForHitTestResult):
Use NSObject * as the result type, as above.
* Source/WebKit/UIProcess/WebPageProxy.h: Ditto.

* UIProcess/mac/PageClientImplMac.h: Use NSObject * as the result type, as above.
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::immediateActionAnimationControllerForHitTestResult):
Ditto.
(WebKit::PageClientImpl::refView): Use __bridge cast.
(WebKit::PageClientImpl::derefView): Ditto.

* UIProcess/mac/ServicesController.mm:
(WebKit::ServicesController::refreshExistingServices): Removed unnecessary use
of NeverDestroyed for Objective-C object pointers. Simpler and more efficient
both with and without ARC.

* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _updateImmediateActionItem]): Removed unneeded
cast now that immediateActionAnimationControllerForHitTestResult has a more
accurate return type.

* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView dealloc]): Use a more direct approach to making sure we do the
non-thread-safe actions on the main thread with a call to callOnMainThread.
The old solution, WebCoreObjCScheduleDeallocateOnMainThread, may not be possible
in an ARC-compatible way, but this one should work fine.
(linkDestinationName): Changed to return an NSString * to make sure we get the
object lifetimes correct under ARC.
(-[WKPrintingView _drawPDFDocument:page:atPoint:]): Added __bridge casts.

* WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Use __unsafe_unretained
for the value types in DOM caches.
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm:
(WebKit::toWKDOMNode): Updated for the above.
(WebKit::toWKDOMRange): Ditto.

* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformPreInitialize): Rewrote the class_replaceMethod
call to sidestep the rules about not using @selector(release) under ARC.
(WebKit::NetscapePlugin::updatePluginLayer): Use __bridge casts.

* WebProcess/Plugins/PDF/PDFPlugin.mm: Added an include of
WebAccessibilityObjectWrapperMac.h, without which this code doesn't compile
under ARC.

* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::changeWordCase): Use a function rather than a selector, since ARC is unable
to correctly compile a method call when it doesn't know argument and result types.
(WebKit::WebEditorClient::uppercaseWord): Updated to use a function rather than a selector.
(WebKit::WebEditorClient::lowercaseWord): Ditto.
(WebKit::WebEditorClient::capitalizeWord): Ditto.

* WebProcess/cocoa/WebProcessCocoa.mm: Added an include of
WebAccessibilityObjectWrapperIOS/Mac.h, without which this code doesn't compile
under ARC.

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

39 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
Source/WebKit/PluginProcess/mac/PluginProcessMac.mm
Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm
Source/WebKit/Shared/API/Cocoa/_WKRemoteObjectInterface.mm
Source/WebKit/Shared/API/Cocoa/_WKRemoteObjectInterfaceInternal.h
Source/WebKit/Shared/API/c/cf/WKStringCF.mm
Source/WebKit/Shared/API/c/cf/WKURLCF.mm
Source/WebKit/Shared/Cocoa/APIObject.mm
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm
Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm
Source/WebKit/UIProcess/API/Cocoa/WKConnection.mm
Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKHTTPCookieStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessGroup.mm
Source/WebKit/UIProcess/API/Cocoa/WKViewPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/mac/WKView.mm
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/mac/PageClientImplMac.h
Source/WebKit/UIProcess/mac/PageClientImplMac.mm
Source/WebKit/UIProcess/mac/ServicesController.mm
Source/WebKit/UIProcess/mac/WKImmediateActionController.mm
Source/WebKit/UIProcess/mac/WKPrintingView.mm
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMInternals.h
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm
Source/WebKit/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

index bec1e4c..f68913b 100644 (file)
@@ -1,3 +1,191 @@
+2018-08-26  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Adapt more WebKit code to be ARC-compatible
+        https://bugs.webkit.org/show_bug.cgi?id=188955
+
+        Reviewed by Anders Carlsson.
+
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: Use __strong for an in/out argument.
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded):
+        Use __strong for a in/out argument.
+        (WebKit::NetworkDataTaskCocoa::applyCookieBlockingPolicy): Call a NSURLSessionTask
+        method using an explicit category declaration rather than by using performSelector:
+        since ARC is unable to correctly compile a call when it doesn't know argument and
+        result types.
+
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::initializeCocoaOverrides): Add some __bridge casts.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm: Use HashSet<CFTypeRef> instead of
+        HashSet<Class> since Class ia an ARC-managed type and WTF hash tables can't
+        currently handle those as key types.
+        (-[WKRemoteObjectDecoder decodeValueOfObjCType:at:]): Changed types and added casts
+        to adapt to the above.
+        (decodeObjectFromObjectStream): Ditto.
+        (checkIfClassIsAllowed): Ditto.
+        (decodeInvocationArguments): Ditto.
+        (decodeObject): Ditto.
+        (-[WKRemoteObjectDecoder decodeObjectOfClasses:forKey:]): Ditto.
+        (-[WKRemoteObjectDecoder allowedClasses]): Ditto.
+        * Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
+        (propertyListClasses): Ditto.
+        (initializeMethod): Ditto.
+        (-[_WKRemoteObjectInterface debugDescription]): Ditto.
+        (classesForSelectorArgument): Ditto.
+        (-[_WKRemoteObjectInterface classesForSelector:argumentIndex:ofReply:]): Ditto.
+        (-[_WKRemoteObjectInterface setClasses:forSelector:argumentIndex:ofReply:]): Ditto.
+        (-[_WKRemoteObjectInterface _allowedArgumentClassesForSelector:]): Ditto.
+        (-[_WKRemoteObjectInterface _allowedArgumentClassesForReplyBlockOfSelector:]): Ditto.
+        * Shared/API/Cocoa/_WKRemoteObjectInterfaceInternal.h: Ditto.
+
+        * Shared/API/c/cf/WKStringCF.mm:
+        (WKStringCreateWithCFString): Use CFRetain instead of -[NSObject retain]. Also use
+        a __bridge cast.
+        * Shared/API/c/cf/WKURLCF.mm:
+        (WKURLCreateWithCFURL): Ditto.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::ref): Added a __bridge cast.
+        (API::Object::deref): Ditto.
+        (API::allocateWKObject): Use class_createInstance instead of NSAllocateObject.
+        (API::Object::wrap): Use a __bridge cast.
+        (API::Object::unwrap): Ditto.
+
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h: Use CFTypeRef for layers
+        or views in the RelatedLayerMap since we don't want the items retained, and can't
+        use __unsafe_uretained because the header is used in non-Objective-C contexts.
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties): Added __bridge casts,
+        needed because of the above change.
+
+        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+        (WebKit::browsingContextControllerMap): Use __unsafe_unretained.
+
+        * UIProcess/API/Cocoa/WKConnection.mm:
+        (didReceiveMessage): Use a __bridge cast.
+
+        * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
+        (-[WKContentRuleListStore compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]):
+        Use a retain here so we don't have to have a "releasesArgument:" boolean. The cost of a single
+        retain/release pair should be infinitesmal compared to the entire process of compiling.
+        (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]):
+        Moved the code for the "releases argument" version here since the private method is now the
+        actual method that does the work. The public method now simply calls this private one after
+        doing a retain. The optimization of releasing the argument at the correct moment should be intact.
+
+        * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: Use CFTypeRef for the key to the _observers
+        HashMap since the WTF collections can't yet handle ARC types for keys.
+        (-[WKHTTPCookieStore addObserver:]): Added __bridge cast for compatibility with the above.
+        (-[WKHTTPCookieStore removeObserver:]): Ditto.
+
+        * UIProcess/API/Cocoa/WKProcessGroup.mm:
+        (setUpConnectionClient): Added a __bridge cast.
+        (setUpHistoryClient): Ditto.
+
+        * UIProcess/API/Cocoa/WKViewPrivate.h: Added a declaration of the
+        -[WKView _shouldLoadIconWithParameters:completionHandler:] method. This peculiar idiom
+        should be removed, but I didn't bother doing that since the entire WKView class is already
+        deprecated and so will eventually be removed.
+
+        * UIProcess/API/Cocoa/WKWebView.mm: Use __unsafe_unretained for the keys in the page to
+        view map.
+        (accessibilityEventsEnabledChangedCallback): Use a __bridge cast.
+        (-[WKWebView _certificateChain]): Ditto.
+        (-[WKWebView certificateChain]): Ditto.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView maybeInstallIconLoadingClient]): Call the method
+        _shouldLoadIconWithParameters:completionHandler: in a normal way rather than using
+        performSelector:withObject:withObject: since ARC is unable to correctly compile a call
+        when it doesn't know argument and result types.
+
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::NavigationClient::webCryptoMasterKey): Use the overload
+        of API::Data::createWithoutCopying that knows how to work with an NSData rather than
+        re-implementing it here.
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess): Ditto. Also removed unneeded
+        use of RetainPtr.
+
+        * UIProcess/Cocoa/WebViewImpl.h: Use NSObject * as the result type of
+        immediateActionAnimationControllerForHitTestResult. Our techniques for defining such
+        functions in headers while remaining compatible with non-Objective-C will still work
+        fine given how we use this, and converting to and from void* rather than NSObject *
+        would be difficult to do correctly under ARC.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::acceptsFirstMouse): Use CFRetain/CFAutorelease instead of
+        retain/autorelease.
+        (WebKit::WebViewImpl::shouldDelayWindowOrderingForEvent): Ditto.
+        (WebKit::WebViewImpl::immediateActionAnimationControllerForHitTestResult):
+        Updated return type to NSObject *.
+        (WebKit::WebViewImpl::performKeyEquivalent): Use CFRetain/CFAutorelease.
+
+        * UIProcess/PageClient.h: Use NSObject * as the result type, as above.
+
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::updateLayerTree): Use __bridge casts to be compatible
+        with the changes to the RelatedLayerMap types.
+        (WebKit::recursivelyMapIOSurfaceBackingStore): Use __bridge cast.
+
+        * Source/WebKit/UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::immediateActionAnimationControllerForHitTestResult):
+        Use NSObject * as the result type, as above.
+        * Source/WebKit/UIProcess/WebPageProxy.h: Ditto.
+
+        * UIProcess/mac/PageClientImplMac.h: Use NSObject * as the result type, as above.
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::immediateActionAnimationControllerForHitTestResult):
+        Ditto.
+        (WebKit::PageClientImpl::refView): Use __bridge cast.
+        (WebKit::PageClientImpl::derefView): Ditto.
+
+        * UIProcess/mac/ServicesController.mm:
+        (WebKit::ServicesController::refreshExistingServices): Removed unnecessary use
+        of NeverDestroyed for Objective-C object pointers. Simpler and more efficient
+        both with and without ARC.
+
+        * UIProcess/mac/WKImmediateActionController.mm:
+        (-[WKImmediateActionController _updateImmediateActionItem]): Removed unneeded
+        cast now that immediateActionAnimationControllerForHitTestResult has a more
+        accurate return type.
+
+        * UIProcess/mac/WKPrintingView.mm:
+        (-[WKPrintingView dealloc]): Use a more direct approach to making sure we do the
+        non-thread-safe actions on the main thread with a call to callOnMainThread.
+        The old solution, WebCoreObjCScheduleDeallocateOnMainThread, may not be possible
+        in an ARC-compatible way, but this one should work fine.
+        (linkDestinationName): Changed to return an NSString * to make sure we get the
+        object lifetimes correct under ARC.
+        (-[WKPrintingView _drawPDFDocument:page:atPoint:]): Added __bridge casts.
+
+        * WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Use __unsafe_unretained
+        for the value types in DOM caches.
+        * WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm:
+        (WebKit::toWKDOMNode): Updated for the above.
+        (WebKit::toWKDOMRange): Ditto.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformPreInitialize): Rewrote the class_replaceMethod
+        call to sidestep the rules about not using @selector(release) under ARC.
+        (WebKit::NetscapePlugin::updatePluginLayer): Use __bridge casts.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.mm: Added an include of
+        WebAccessibilityObjectWrapperMac.h, without which this code doesn't compile
+        under ARC.
+
+        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+        (WebKit::changeWordCase): Use a function rather than a selector, since ARC is unable
+        to correctly compile a method call when it doesn't know argument and result types.
+        (WebKit::WebEditorClient::uppercaseWord): Updated to use a function rather than a selector.
+        (WebKit::WebEditorClient::lowercaseWord): Ditto.
+        (WebKit::WebEditorClient::capitalizeWord): Ditto.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm: Added an include of
+        WebAccessibilityObjectWrapperIOS/Mac.h, without which this code doesn't compile
+        under ARC.
+
 2018-08-27  Alex Christensen  <achristensen@webkit.org>
 
         Fix authentication for clients of WKPageLoaderClient after r234941
index 3e82ee4..62b1c14 100644 (file)
@@ -87,7 +87,7 @@ private:
     NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, uint64_t frameID, uint64_t pageID, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, std::optional<NetworkActivityTracker>);
 
     bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&);
-    void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
+    void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     static NSHTTPCookieStorage *statelessCookieStorage();
index f2cc733..fc209c8 100644 (file)
 #import <CFNetwork/CFNSURLConnection.h>
 #endif
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+
+// FIXME: Move to CFNetworkSPI.h?
+@interface NSURLSessionTask ()
+- (void)_setExplicitCookieStorage:(CFHTTPCookieStorageRef)storage;
+@end
+
+#endif
+
 namespace WebKit {
 
 #if USE(CREDENTIAL_STORAGE_WITH_NETWORK_SESSION)
@@ -85,7 +94,7 @@ static float toNSURLSessionTaskPriority(WebCore::ResourceLoadPriority priority)
     return NSURLSessionTaskPriorityDefault;
 }
 
-void NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(NSURLRequest*& nsRequest, bool shouldContentSniff, bool shouldContentEncodingSniff)
+void NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest *& nsRequest, bool shouldContentSniff, bool shouldContentEncodingSniff)
 {
 #if !PLATFORM(MAC)
     UNUSED_PARAM(shouldContentEncodingSniff);
@@ -119,6 +128,7 @@ void NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeede
 }
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+
 NSHTTPCookieStorage *NetworkDataTaskCocoa::statelessCookieStorage()
 {
     static NeverDestroyed<RetainPtr<NSHTTPCookieStorage>> statelessCookieStorage;
@@ -144,10 +154,11 @@ void NetworkDataTaskCocoa::applyCookieBlockingPolicy(bool shouldBlock)
     if (shouldBlock == m_hasBeenSetToUseStatelessCookieStorage)
         return;
 
-    NSHTTPCookieStorage *storage = shouldBlock ? statelessCookieStorage(): m_session->networkStorageSession().nsCookieStorage();
-    [m_task performSelector:NSSelectorFromString(@"_setExplicitCookieStorage:") withObject:(NSObject*)storage._cookieStorage];
+    NSHTTPCookieStorage *storage = shouldBlock ? statelessCookieStorage() : m_session->networkStorageSession().nsCookieStorage();
+    [m_task _setExplicitCookieStorage:storage._cookieStorage];
     m_hasBeenSetToUseStatelessCookieStorage = shouldBlock;
 }
+
 #endif
 
 bool NetworkDataTaskCocoa::isThirdPartyRequest(const WebCore::ResourceRequest& request)
index 7ec04bc..c3120bb 100644 (file)
@@ -453,8 +453,8 @@ static void initializeCocoaOverrides()
                                                        usingBlock:^(NSNotification *notification) { fullscreenWindowTracker().windowHidden([notification object]); }];
 
     // Leak the two observers so that they observe notifications for the lifetime of the process.
-    CFRetain(orderOnScreenObserver);
-    CFRetain(orderOffScreenObserver);
+    CFRetain((__bridge CFTypeRef)orderOnScreenObserver);
+    CFRetain((__bridge CFTypeRef)orderOffScreenObserver);
 }
 
 void PluginProcess::setModalWindowIsShowing(bool modalWindowIsShowing)
index 6f0b9b2..8d1f1ac 100644 (file)
@@ -385,7 +385,7 @@ static NSString *escapeKey(NSString *key)
     const API::Array* _objectStream;
     size_t _objectStreamPosition;
 
-    const HashSet<Class>* _allowedClasses;
+    const HashSet<CFTypeRef>* _allowedClasses;
 }
 
 - (id)initWithInterface:(_WKRemoteObjectInterface *)interface rootObjectDictionary:(const API::Dictionary*)rootObjectDictionary replyToSelector:(SEL)replyToSelector
@@ -410,7 +410,7 @@ static NSString *escapeKey(NSString *key)
     switch (*type) {
     // int
     case 'i':
-        *static_cast<int*>(data) = [decodeObjectFromObjectStream(self, { [NSNumber class] }) intValue];
+        *static_cast<int*>(data) = [decodeObjectFromObjectStream(self, { (__bridge CFTypeRef)[NSNumber class] }) intValue];
         break;
 
     default:
@@ -433,9 +433,9 @@ static NSString *escapeKey(NSString *key)
     return [self decodeObjectOfClasses:nil forKey:key];
 }
 
-static id decodeObject(WKRemoteObjectDecoder *, const API::Dictionary*, const HashSet<Class>& allowedClasses);
+static id decodeObject(WKRemoteObjectDecoder *, const API::Dictionary*, const HashSet<CFTypeRef>& allowedClasses);
 
-static id decodeObjectFromObjectStream(WKRemoteObjectDecoder *decoder, const HashSet<Class>& allowedClasses)
+static id decodeObjectFromObjectStream(WKRemoteObjectDecoder *decoder, const HashSet<CFTypeRef>& allowedClasses)
 {
     if (!decoder->_objectStream)
         return nil;
@@ -454,11 +454,11 @@ static void checkIfClassIsAllowed(WKRemoteObjectDecoder *decoder, Class objectCl
     if (!allowedClasses)
         return;
 
-    if (allowedClasses->contains(objectClass))
+    if (allowedClasses->contains((__bridge CFTypeRef)objectClass))
         return;
 
     for (Class superclass = class_getSuperclass(objectClass); superclass; superclass = class_getSuperclass(superclass)) {
-        if (allowedClasses->contains(superclass))
+        if (allowedClasses->contains((__bridge CFTypeRef)superclass))
             return;
     }
 
@@ -478,7 +478,7 @@ static void validateClass(WKRemoteObjectDecoder *decoder, Class objectClass)
     [decoder validateClassSupportsSecureCoding:objectClass];
 }
 
-static void decodeInvocationArguments(WKRemoteObjectDecoder *decoder, NSInvocation *invocation, const Vector<HashSet<Class>>& allowedArgumentClasses, NSUInteger firstArgument)
+static void decodeInvocationArguments(WKRemoteObjectDecoder *decoder, NSInvocation *invocation, const Vector<HashSet<CFTypeRef>>& allowedArgumentClasses, NSUInteger firstArgument)
 {
     NSMethodSignature *methodSignature = invocation.methodSignature;
     NSUInteger argumentCount = methodSignature.numberOfArguments;
@@ -491,56 +491,56 @@ static void decodeInvocationArguments(WKRemoteObjectDecoder *decoder, NSInvocati
         switch (*type) {
         // double
         case 'd': {
-            double value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
+            double value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) doubleValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // float
         case 'f': {
-            float value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) floatValue];
+            float value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) floatValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // int
         case 'i': {
-            int value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) intValue];
+            int value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) intValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // unsigned
         case 'I': {
-            unsigned value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) unsignedIntValue];
+            unsigned value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) unsignedIntValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // char
         case 'c': {
-            char value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) charValue];
+            char value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) charValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // bool
         case 'B': {
-            bool value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) boolValue];
+            bool value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) boolValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // long
         case 'q': {
-            long value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) longValue];
+            long value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) longValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
 
         // unsigned long
         case 'Q': {
-            unsigned long value = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) unsignedLongValue];
+            unsigned long value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) unsignedLongValue];
             [invocation setArgument:&value atIndex:i];
             break;
         }
@@ -559,13 +559,13 @@ static void decodeInvocationArguments(WKRemoteObjectDecoder *decoder, NSInvocati
         // struct
         case '{':
             if (!strcmp(type, @encode(NSRange))) {
-                NSRange value = [decodeObjectFromObjectStream(decoder, { [NSValue class] }) rangeValue];
+                NSRange value = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSValue class] }) rangeValue];
                 [invocation setArgument:&value atIndex:i];
                 break;
             } else if (!strcmp(type, @encode(CGSize))) {
                 CGSize value;
-                value.width = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
-                value.height = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
+                value.width = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) doubleValue];
+                value.height = [decodeObjectFromObjectStream(decoder, { (__bridge CFTypeRef)[NSNumber class] }) doubleValue];
                 [invocation setArgument:&value atIndex:i];
                 break;
             }
@@ -675,7 +675,7 @@ static id decodeObject(WKRemoteObjectDecoder *decoder)
     return [result autorelease];
 }
 
-static id decodeObject(WKRemoteObjectDecoder *decoder, const API::Dictionary* dictionary, const HashSet<Class>& allowedClasses)
+static id decodeObject(WKRemoteObjectDecoder *decoder, const API::Dictionary* dictionary, const HashSet<CFTypeRef>& allowedClasses)
 {
     if (!dictionary)
         return nil;
@@ -686,7 +686,7 @@ static id decodeObject(WKRemoteObjectDecoder *decoder, const API::Dictionary* di
     if (allowedClasses.isEmpty())
         return decodeObject(decoder);
 
-    SetForScope<const HashSet<Class>*> allowedClassesChange(decoder->_allowedClasses, &allowedClasses);
+    SetForScope<const HashSet<CFTypeRef>*> allowedClassesChange(decoder->_allowedClasses, &allowedClasses);
     return decodeObject(decoder);
 }
 
@@ -762,9 +762,9 @@ static id decodeObject(WKRemoteObjectDecoder *decoder, const API::Dictionary* di
 
 - (id)decodeObjectOfClasses:(NSSet *)classes forKey:(NSString *)key
 {
-    HashSet<Class> allowedClasses;
+    HashSet<CFTypeRef> allowedClasses;
     for (Class allowedClass in classes)
-        allowedClasses.add(allowedClass);
+        allowedClasses.add((__bridge CFTypeRef)allowedClass);
 
     return decodeObject(self, _currentDictionary->get<API::Dictionary>(escapeKey(key)), allowedClasses);
 }
@@ -775,8 +775,8 @@ static id decodeObject(WKRemoteObjectDecoder *decoder, const API::Dictionary* di
         return [NSSet set];
 
     auto result = adoptNS([[NSMutableSet alloc] init]);
-    for (Class allowedClass : *_allowedClasses)
-        [result addObject:allowedClass];
+    for (auto allowedClass : *_allowedClasses)
+        [result addObject:(__bridge Class)allowedClass];
 
     return result.autorelease();
 }
index 0c440dd..e7d804f 100644 (file)
@@ -46,12 +46,12 @@ const char *_protocol_getMethodTypeEncoding(Protocol *p, SEL sel, BOOL isRequire
 @end
 
 struct MethodInfo {
-    Vector<HashSet<Class>> allowedArgumentClasses;
+    Vector<HashSet<CFTypeRef>> allowedArgumentClasses;
 
     struct ReplyInfo {
         NSUInteger replyPosition;
         CString replySignature;
-        Vector<HashSet<Class>> allowedReplyClasses;
+        Vector<HashSet<CFTypeRef>> allowedReplyClasses;
     };
     std::optional<ReplyInfo> replyInfo;
 };
@@ -70,12 +70,15 @@ static bool isContainerClass(Class objectClass)
     return objectClass == arrayClass || objectClass == dictionaryClass;
 }
 
-static HashSet<Class>& propertyListClasses()
+static HashSet<CFTypeRef>& propertyListClasses()
 {
-    static LazyNeverDestroyed<HashSet<Class>> propertyListClasses;
+    static LazyNeverDestroyed<HashSet<CFTypeRef>> propertyListClasses;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{
-        propertyListClasses.construct(std::initializer_list<Class> { [NSArray class], [NSDictionary class], [NSNumber class], [NSString class] });
+        propertyListClasses.construct(std::initializer_list<CFTypeRef> {
+            (__bridge CFTypeRef)[NSArray class], (__bridge CFTypeRef)[NSDictionary class],
+            (__bridge CFTypeRef)[NSNumber class], (__bridge CFTypeRef)[NSString class]
+        });
     });
 
     return propertyListClasses;
@@ -83,7 +86,7 @@ static HashSet<Class>& propertyListClasses()
 
 static void initializeMethod(MethodInfo& methodInfo, Protocol *protocol, SEL selector, NSMethodSignature *methodSignature, bool forReplyBlock)
 {
-    Vector<HashSet<Class>> allowedClasses;
+    Vector<HashSet<CFTypeRef>> allowedClasses;
 
     NSUInteger firstArgument = forReplyBlock ? 1 : 2;
     NSUInteger argumentCount = methodSignature.numberOfArguments;
@@ -127,7 +130,7 @@ static void initializeMethod(MethodInfo& methodInfo, Protocol *protocol, SEL sel
             continue;
         }
 
-        allowedClasses.append({ objectClass });
+        allowedClasses.append({ (__bridge CFTypeRef)objectClass });
     }
 
     if (forReplyBlock)
@@ -212,8 +215,8 @@ static void initializeMethods(_WKRemoteObjectInterface *interface, Protocol *pro
             auto result = adoptNS([[NSMutableString alloc] initWithString:@"{"]);
 
             auto orderedArgumentClasses = copyToVector(allowedArgumentClasses);
-            std::sort(orderedArgumentClasses.begin(), orderedArgumentClasses.end(), [](Class a, Class b) {
-                return CString(class_getName(a)) < CString(class_getName(b));
+            std::sort(orderedArgumentClasses.begin(), orderedArgumentClasses.end(), [](CFTypeRef a, CFTypeRef b) {
+                return CString(class_getName((__bridge Class)a)) < CString(class_getName((__bridge Class)b));
             });
 
             bool needsComma = false;
@@ -221,7 +224,7 @@ static void initializeMethods(_WKRemoteObjectInterface *interface, Protocol *pro
                 if (needsComma)
                     [result appendString:@", "];
 
-                [result appendFormat:@"%s", class_getName(argumentClass)];
+                [result appendFormat:@"%s", class_getName((__bridge Class)argumentClass)];
                 needsComma = true;
             }
 
@@ -252,7 +255,7 @@ static void initializeMethods(_WKRemoteObjectInterface *interface, Protocol *pro
     return result.autorelease();
 }
 
-static HashSet<Class>& classesForSelectorArgument(_WKRemoteObjectInterface *interface, SEL selector, NSUInteger argumentIndex, bool replyBlock)
+static HashSet<CFTypeRef>& classesForSelectorArgument(_WKRemoteObjectInterface *interface, SEL selector, NSUInteger argumentIndex, bool replyBlock)
 {
     auto it = interface->_methods.find(selector);
     if (it == interface->_methods.end())
@@ -280,16 +283,16 @@ static HashSet<Class>& classesForSelectorArgument(_WKRemoteObjectInterface *inte
     auto result = adoptNS([[NSMutableSet alloc] init]);
 
     for (auto allowedClass : classesForSelectorArgument(self, selector, argumentIndex, ofReply))
-        [result addObject:allowedClass];
+        [result addObject:(__bridge Class)allowedClass];
 
     return result.autorelease();
 }
 
 - (void)setClasses:(NSSet *)classes forSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex ofReply:(BOOL)ofReply
 {
-    HashSet<Class> allowedClasses;
+    HashSet<CFTypeRef> allowedClasses;
     for (Class allowedClass in classes)
-        allowedClasses.add(allowedClass);
+        allowedClasses.add((__bridge CFTypeRef)allowedClass);
 
     classesForSelectorArgument(self, selector, argumentIndex, ofReply) = WTFMove(allowedClasses);
 }
@@ -344,14 +347,14 @@ static const char* methodArgumentTypeEncodingForSelector(Protocol *protocol, SEL
     return [NSMethodSignature signatureWithObjCTypes:methodInfo.replyInfo->replySignature.data()];
 }
 
-- (const Vector<HashSet<Class>>&)_allowedArgumentClassesForSelector:(SEL)selector
+- (const Vector<HashSet<CFTypeRef>>&)_allowedArgumentClassesForSelector:(SEL)selector
 {
     ASSERT(_methods.contains(selector));
 
     return _methods.find(selector)->value.allowedArgumentClasses;
 }
 
-- (const Vector<HashSet<Class>>&)_allowedArgumentClassesForReplyBlockOfSelector:(SEL)selector
+- (const Vector<HashSet<CFTypeRef>>&)_allowedArgumentClassesForReplyBlockOfSelector:(SEL)selector
 {
     ASSERT(_methods.contains(selector));
 
index 170642c..45ef0a7 100644 (file)
@@ -35,8 +35,8 @@
 
 - (NSMethodSignature *)_methodSignatureForSelector:(SEL)selector;
 - (NSMethodSignature *)_methodSignatureForReplyBlockOfSelector:(SEL)selector;
-- (const Vector<HashSet<Class>>&)_allowedArgumentClassesForSelector:(SEL)selector;
-- (const Vector<HashSet<Class>>&)_allowedArgumentClassesForReplyBlockOfSelector:(SEL)selector;
+- (const Vector<HashSet<CFTypeRef>>&)_allowedArgumentClassesForSelector:(SEL)selector;
+- (const Vector<HashSet<CFTypeRef>>&)_allowedArgumentClassesForReplyBlockOfSelector:(SEL)selector;
 
 @end
 
index 61d1d47..2c43936 100644 (file)
@@ -51,7 +51,7 @@ WKStringRef WKStringCreateWithCFString(CFStringRef cfString)
 #if WK_API_ENABLED
     // Since WKNSString is an internal class with no subclasses, we can do a simple equality check.
     if (object_getClass((__bridge NSString *)cfString) == wkNSStringClass())
-        return toAPI(static_cast<API::String*>(&[(WKNSString *)[(NSString *)cfString retain] _apiObject]));
+        return toAPI(static_cast<API::String*>(&[(WKNSString *)(__bridge NSString *)CFRetain(cfString) _apiObject]));
 #endif
     String string(cfString);
     return toCopiedAPI(string);
index ee627b3..7a1c3b7 100644 (file)
@@ -55,7 +55,7 @@ WKURLRef WKURLCreateWithCFURL(CFURLRef cfURL)
 #if WK_API_ENABLED
     // Since WKNSURL is an internal class with no subclasses, we can do a simple equality check.
     if (object_getClass((__bridge NSURL *)cfURL) == wkNSURLClass())
-        return toAPI(static_cast<API::URL*>(&[(WKNSURL *)[(NSURL *)cfURL retain] _apiObject]));
+        return toAPI(static_cast<API::URL*>(&[(WKNSURL *)(__bridge NSURL *)CFRetain(cfURL) _apiObject]));
 #endif
 
     CString urlBytes;
index 6f3d284..448ffd2 100644 (file)
@@ -95,17 +95,17 @@ namespace API {
 
 void Object::ref()
 {
-    CFRetain(wrapper());
+    CFRetain((__bridge CFTypeRef)wrapper());
 }
 
 void Object::deref()
 {
-    CFRelease(wrapper());
+    CFRelease((__bridge CFTypeRef)wrapper());
 }
 
 static id <WKObject> allocateWKObject(Class cls, size_t size)
 {
-    return NSAllocateObject(cls, size + maximumExtraSpaceForAlignment, nullptr);
+    return class_createInstance(cls, size + maximumExtraSpaceForAlignment);
 }
 
 API::Object& Object::fromWKObjectExtraSpace(id <WKObject> obj)
@@ -372,7 +372,7 @@ void* Object::wrap(API::Object* object)
     if (!object)
         return nullptr;
 
-    return static_cast<void*>(object->wrapper());
+    return (__bridge void*)object->wrapper();
 }
 
 API::Object* Object::unwrap(void* object)
@@ -380,7 +380,7 @@ API::Object* Object::unwrap(void* object)
     if (!object)
         return nullptr;
 
-    return &static_cast<id <WKObject>>(object)._apiObject;
+    return &((__bridge id <WKObject>)object)._apiObject;
 }
 
 } // namespace API
index 301ba91..07b37e9 100644 (file)
@@ -35,7 +35,7 @@ class RemoteLayerTreeHost;
 
 class RemoteLayerTreePropertyApplier {
 public:
-    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerOrView *> RelatedLayerMap;
+    using RelatedLayerMap = HashMap<WebCore::GraphicsLayer::PlatformLayerID, CFTypeRef>;
     static void applyProperties(CALayer *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
 #if PLATFORM(IOS)
     static void applyProperties(UIView *, RemoteLayerTreeHost*, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&, RemoteLayerBackingStore::LayerContentsType);
index 726a5b7..1d55102 100644 (file)
@@ -263,7 +263,7 @@ void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayer
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
         for (auto& child : properties.children) {
             ASSERT(relatedLayers.get(child));
-            [children addObject:relatedLayers.get(child)];
+            [children addObject:(__bridge id)relatedLayers.get(child)];
         }
 
         layer.sublayers = children.get();
@@ -274,13 +274,13 @@ void RemoteLayerTreePropertyApplier::applyProperties(CALayer *layer, RemoteLayer
             layer.mask = nullptr;
         else {
 #if PLATFORM(IOS)
-            UIView *maskView = relatedLayers.get(properties.maskLayerID);
+            UIView *maskView = (__bridge UIView *)relatedLayers.get(properties.maskLayerID);
             // FIXME: need to check that the mask view is kept alive.
             ASSERT(!maskView.layer.superlayer);
             if (!maskView.layer.superlayer)
                 layer.mask = maskView.layer;
 #else
-            CALayer *maskLayer = relatedLayers.get(properties.maskLayerID);
+            CALayer *maskLayer = (__bridge CALayer *)relatedLayers.get(properties.maskLayerID);
             ASSERT(!maskLayer.superlayer);
             if (!maskLayer.superlayer)
                 layer.mask = maskLayer;
@@ -300,7 +300,7 @@ void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTr
         RetainPtr<NSMutableArray> children = adoptNS([[NSMutableArray alloc] initWithCapacity:properties.children.size()]);
         for (auto& child : properties.children) {
             ASSERT(relatedLayers.get(child));
-            [children addObject:relatedLayers.get(child)];
+            [children addObject:(__bridge id)relatedLayers.get(child)];
         }
 
         if (properties.customAppearance == GraphicsLayer::CustomAppearance::LightBackdrop || properties.customAppearance == GraphicsLayer::CustomAppearance::DarkBackdrop) {
@@ -324,7 +324,7 @@ void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTr
         if (!properties.maskLayerID)
             maskOwnerLayer.mask = nullptr;
         else {
-            UIView *maskView = relatedLayers.get(properties.maskLayerID);
+            UIView *maskView = (__bridge UIView *)relatedLayers.get(properties.maskLayerID);
             // FIXME: need to check that the mask view is kept alive.
             ASSERT(!maskView.layer.superlayer);
             if (!maskView.layer.superlayer)
index e6eefcd..d624aa4 100644 (file)
@@ -83,9 +83,9 @@ NSString * const WKActionCanShowMIMETypeKey = @"WKActionCanShowMIMETypeKey";
     WeakObjCPtr<id <WKBrowsingContextPolicyDelegate>> _policyDelegate;
 }
 
-static HashMap<WebPageProxy*, WKBrowsingContextController *>& browsingContextControllerMap()
+static HashMap<WebPageProxy*, __unsafe_unretained WKBrowsingContextController *>& browsingContextControllerMap()
 {
-    static NeverDestroyed<HashMap<WebPageProxy*, WKBrowsingContextController *>> browsingContextControllerMap;
+    static NeverDestroyed<HashMap<WebPageProxy*, __unsafe_unretained WKBrowsingContextController *>> browsingContextControllerMap;
     return browsingContextControllerMap;
 }
 
index ce23d0e..abe4348 100644 (file)
@@ -57,7 +57,7 @@ static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRe
     if ([delegate respondsToSelector:@selector(connection:didReceiveMessageWithName:body:)]) {
         RetainPtr<CFStringRef> nsMessageName = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, messageName));
         RetainPtr<id> nsMessageBody = static_cast<ObjCObjectGraph*>(toImpl(messageBody))->rootObject();
-        [delegate connection:connection didReceiveMessageWithName:(NSString *)nsMessageName.get() body:nsMessageBody.get()];
+        [delegate connection:connection didReceiveMessageWithName:(__bridge NSString *)nsMessageName.get() body:nsMessageBody.get()];
     }
 }
 
index 4b41b43..ba742ae 100644 (file)
@@ -74,27 +74,7 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
 
 - (void)compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler
 {
-    [self _compileContentRuleListForIdentifier:identifier encodedContentRuleList:encodedContentRuleList completionHandler:completionHandler releasesArgument:NO];
-}
-
-- (void)_compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler releasesArgument:(BOOL)releasesArgument
-{
-    String json(encodedContentRuleList);
-    if (releasesArgument) {
-        [encodedContentRuleList release];
-        encodedContentRuleList = nil;
-    }
-
-    _contentRuleListStore->compileContentRuleList(identifier, WTFMove(json), [completionHandler = makeBlockPtr(completionHandler)](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) {
-        if (error) {
-            auto userInfo = @{NSHelpAnchorErrorKey: [NSString stringWithFormat:@"Rule list compilation failed: %s", error.message().c_str()]};
-
-            // error.value() could have a specific compiler error that is not equal to WKErrorContentRuleListStoreCompileFailed.
-            // We want to use error.message, but here we want to only pass on CompileFailed with userInfo from the std::error_code.
-            return completionHandler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorContentRuleListStoreCompileFailed userInfo:userInfo]);
-        }
-        completionHandler(wrapper(*contentRuleList), nil);
-    });
+    [self _compileContentRuleListForIdentifier:identifier encodedContentRuleList:[encodedContentRuleList retain] completionHandler:completionHandler];
 }
 
 - (void)lookUpContentRuleListForIdentifier:(NSString *)identifier completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler
@@ -170,10 +150,22 @@ static WKErrorCode toWKErrorCode(const std::error_code& error)
 }
 
 // NS_RELEASES_ARGUMENT to keep peak memory usage low.
-
-- (void)_compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler
+- (void)_compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *) NS_RELEASES_ARGUMENT encodedContentRuleList completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler
 {
-    [self _compileContentRuleListForIdentifier:identifier encodedContentRuleList:encodedContentRuleList completionHandler:completionHandler releasesArgument:YES];
+    String json(encodedContentRuleList);
+    [encodedContentRuleList release];
+    encodedContentRuleList = nil;
+
+    _contentRuleListStore->compileContentRuleList(identifier, WTFMove(json), [completionHandler = makeBlockPtr(completionHandler)](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) {
+        if (error) {
+            auto userInfo = @{NSHelpAnchorErrorKey: [NSString stringWithFormat:@"Rule list compilation failed: %s", error.message().c_str()]};
+
+            // error.value() could have a specific compiler error that is not equal to WKErrorContentRuleListStoreCompileFailed.
+            // We want to use error.message, but here we want to only pass on CompileFailed with userInfo from the std::error_code.
+            return completionHandler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorContentRuleListStoreCompileFailed userInfo:userInfo]);
+        }
+        completionHandler(wrapper(*contentRuleList), nil);
+    });
 }
 
 + (instancetype)defaultStoreWithLegacyFilename
index 55324a1..a806bde 100644 (file)
@@ -63,7 +63,7 @@ private:
 };
 
 @implementation WKHTTPCookieStore {
-    HashMap<id<WKHTTPCookieStoreObserver>, std::unique_ptr<WKHTTPCookieStoreObserver>> _observers;
+    HashMap<CFTypeRef, std::unique_ptr<WKHTTPCookieStoreObserver>> _observers;
 }
 
 - (void)dealloc
@@ -105,7 +105,7 @@ private:
 
 - (void)addObserver:(id<WKHTTPCookieStoreObserver>)observer
 {
-    auto result = _observers.add(observer, nullptr);
+    auto result = _observers.add((__bridge CFTypeRef)observer, nullptr);
     if (!result.isNewEntry)
         return;
 
@@ -115,7 +115,7 @@ private:
 
 - (void)removeObserver:(id<WKHTTPCookieStoreObserver>)observer
 {
-    auto result = _observers.take(observer);
+    auto result = _observers.take((__bridge CFTypeRef)observer);
     if (!result)
         return;
 
index 47b7c4c..4d417b5 100644 (file)
@@ -79,7 +79,7 @@ static void setUpConnectionClient(WKProcessGroup *processGroup, WKContextRef con
     memset(&connectionClient, 0, sizeof(connectionClient));
 
     connectionClient.base.version = 0;
-    connectionClient.base.clientInfo = processGroup;
+    connectionClient.base.clientInfo = (__bridge CFTypeRef)processGroup;
     connectionClient.didCreateConnection = didCreateConnection;
 
     WKContextSetConnectionClient(contextRef, &connectionClient.base);
@@ -165,7 +165,7 @@ static void setUpHistoryClient(WKProcessGroup *processGroup, WKContextRef contex
     memset(&historyClient, 0, sizeof(historyClient));
 
     historyClient.base.version = 0;
-    historyClient.base.clientInfo = processGroup;
+    historyClient.base.clientInfo = (__bridge CFTypeRef)processGroup;
     historyClient.didNavigateWithNavigationData = didNavigateWithNavigationData;
     historyClient.didPerformClientRedirect = didPerformClientRedirect;
     historyClient.didPerformServerRedirect = didPerformServerRedirect;
index 3e17c0f..fe896bc 100644 (file)
@@ -30,6 +30,8 @@
 #import <WebKit/WKView.h>
 #import <WebKit/_WKOverlayScrollbarStyle.h>
 
+@class _WKLinkIconParameters;
+
 @interface WKView (Private)
 
 /* C SPI support. */
 
 @end
 
+@interface WKView (PrivateForSubclassToDefine)
+
+// This a method that subclasses can define and WKView itself does not define. WKView will call the method if it is present.
+- (void)_shouldLoadIconWithParameters:(_WKLinkIconParameters *)parameters completionHandler:(void (^)(void (^)(NSData *)))completionHandler;
+
+@end
+
 #endif // !TARGET_OS_IPHONE
index 0f2a4b8..7b6ccbe 100644 (file)
@@ -209,9 +209,9 @@ Boolean _AXSWebAccessibilityEventsEnabled();
 
 #endif
 
-static HashMap<WebKit::WebPageProxy*, WKWebView *>& pageToViewMap()
+static HashMap<WebKit::WebPageProxy*, __unsafe_unretained WKWebView *>& pageToViewMap()
 {
-    static NeverDestroyed<HashMap<WebKit::WebPageProxy*, WKWebView *>> map;
+    static NeverDestroyed<HashMap<WebKit::WebPageProxy*, __unsafe_unretained WKWebView *>> map;
     return map;
 }
 
@@ -3151,10 +3151,11 @@ static int32_t activeOrientation(WKWebView *webView)
 #endif // PLATFORM(IOS)
 
 #if ENABLE(ACCESSIBILITY_EVENTS)
+
 static void accessibilityEventsEnabledChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
 {
     ASSERT(observer);
-    WKWebView* webview = static_cast<WKWebView*>(observer);
+    WKWebView *webview = (__bridge WKWebView *)observer;
     [webview _updateAccessibilityEventsEnabled];
 }
 
@@ -3163,6 +3164,7 @@ static void accessibilityEventsEnabledChangedCallback(CFNotificationCenterRef, v
     if (!isNullFunctionPointer(_AXSWebAccessibilityEventsEnabled))
         _page->updateAccessibilityEventsEnabled(_AXSWebAccessibilityEventsEnabled());
 }
+
 #endif
 
 #pragma mark OS X-specific methods
@@ -4243,7 +4245,7 @@ WEBCORE_COMMAND(yankAndSelect)
 - (NSArray *)_certificateChain
 {
     if (WebKit::WebFrameProxy* mainFrame = _page->mainFrame())
-        return mainFrame->certificateInfo() ? (NSArray *)mainFrame->certificateInfo()->certificateInfo().certificateChain() : nil;
+        return mainFrame->certificateInfo() ? (__bridge NSArray *)mainFrame->certificateInfo()->certificateInfo().certificateChain() : nil;
 
     return nil;
 }
@@ -6619,7 +6621,7 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
     if (!certificateInfo)
         return @[ ];
 
-    return (NSArray *)certificateInfo->certificateInfo().certificateChain() ?: @[ ];
+    return (__bridge NSArray *)certificateInfo->certificateInfo().certificateChain() ?: @[ ];
 }
 
 @end
index e983286..bc5de2b 100644 (file)
@@ -884,7 +884,7 @@ Some other editing-related methods still unimplemented:
 
         static SEL delegateSelector()
         {
-            return sel_registerName("_shouldLoadIconWithParameters:completionHandler:");
+            return @selector(_shouldLoadIconWithParameters:completionHandler:);
         }
 
     private:
@@ -894,7 +894,7 @@ Some other editing-related methods still unimplemented:
         {
             RetainPtr<_WKLinkIconParameters> parameters = adoptNS([[_WKLinkIconParameters alloc] _initWithLinkIcon:linkIcon]);
 
-            [m_wkView performSelector:delegateSelector() withObject:parameters.get() withObject:BlockPtr<void(IconLoadCompletionHandler)>::fromCallable([completionHandler = WTFMove(completionHandler)](IconLoadCompletionHandler loadCompletionHandler) mutable {
+            [m_wkView _shouldLoadIconWithParameters:parameters.get() completionHandler:BlockPtr<void(IconLoadCompletionHandler)>::fromCallable([completionHandler = WTFMove(completionHandler)](IconLoadCompletionHandler loadCompletionHandler) mutable {
                 ASSERT(RunLoop::isMain());
                 if (loadCompletionHandler) {
                     completionHandler([loadCompletionHandler = BlockPtr<void (NSData *)>(loadCompletionHandler)](API::Data* data, WebKit::CallbackBase::Error error) {
index 1230ccb..8487e6e 100644 (file)
@@ -978,11 +978,8 @@ RefPtr<API::Data> NavigationState::NavigationClient::webCryptoMasterKey(WebPageP
     if (!navigationDelegate)
         return nullptr;
 
-    RetainPtr<NSData> data = [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webCryptoMasterKeyForWebView:m_navigationState.m_webView];
-
-    return API::Data::createWithoutCopying((const unsigned char*)[data bytes], [data length], [] (unsigned char*, const void* data) {
-        [(NSData *)data release];
-    }, data.leakRef());
+    NSData *data = [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webCryptoMasterKeyForWebView:m_navigationState.m_webView];
+    return API::Data::createWithoutCopying(data);
 }
 
 RefPtr<API::String> NavigationState::NavigationClient::signedPublicKeyAndChallengeString(WebPageProxy& page, unsigned keySizeIndex, const RefPtr<API::String>& challengeString, const WebCore::URL& url)
index 0498d08..d16f585 100644 (file)
@@ -226,12 +226,10 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters&
         }
 
 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
-        auto data = retainPtr(keyedArchiver.get().encodedData);
+        auto data = keyedArchiver.get().encodedData;
 #endif
 
-        parameters.bundleParameterData = API::Data::createWithoutCopying((const unsigned char*)[data bytes], [data length], [] (unsigned char*, const void* data) {
-            [(NSData *)data release];
-        }, data.leakRef());
+        parameters.bundleParameterData = API::Data::createWithoutCopying(WTFMove(data));
     }
     parameters.networkATSContext = adoptCF(_CFNetworkCopyATSContext());
 
index 63e5f66..e54dd00 100644 (file)
@@ -365,7 +365,7 @@ public:
     void prepareForDictionaryLookup();
     void setAllowsLinkPreview(bool);
     bool allowsLinkPreview() const { return m_allowsLinkPreview; }
-    void* immediateActionAnimationControllerForHitTestResult(API::HitTestResult*, uint32_t type, API::Object* userData);
+    NSObject *immediateActionAnimationControllerForHitTestResult(API::HitTestResult*, uint32_t type, API::Object* userData);
     void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object* userData);
     void prepareForImmediateActionAnimation();
     void cancelImmediateActionAnimation();
index 8ead862..5028700 100644 (file)
@@ -2050,7 +2050,8 @@ bool WebViewImpl::acceptsFirstMouse(NSEvent *event)
     // There's a chance that responding to this event will run a nested event loop, and
     // fetching a new event might release the old one. Retaining and then autoreleasing
     // the current event prevents that from causing a problem inside WebKit or AppKit code.
-    [[event retain] autorelease];
+    CFRetain((__bridge CFTypeRef)event);
+    CFAutorelease((__bridge CFTypeRef)event);
 
     if (![m_view hitTest:event.locationInWindow])
         return false;
@@ -2069,7 +2070,8 @@ bool WebViewImpl::shouldDelayWindowOrderingForEvent(NSEvent *event)
     // There's a chance that responding to this event will run a nested event loop, and
     // fetching a new event might release the old one. Retaining and then autoreleasing
     // the current event prevents that from causing a problem inside WebKit or AppKit code.
-    [[event retain] autorelease];
+    CFRetain((__bridge CFTypeRef)event);
+    CFAutorelease((__bridge CFTypeRef)event);
 
     if (![m_view hitTest:event.locationInWindow])
         return false;
@@ -3319,7 +3321,7 @@ void WebViewImpl::setAllowsLinkPreview(bool allowsLinkPreview)
         [m_view addGestureRecognizer:immediateActionRecognizer];
 }
 
-void* WebViewImpl::immediateActionAnimationControllerForHitTestResult(API::HitTestResult* hitTestResult, uint32_t type, API::Object* userData)
+NSObject *WebViewImpl::immediateActionAnimationControllerForHitTestResult(API::HitTestResult* hitTestResult, uint32_t type, API::Object* userData)
 {
     return [m_view _web_immediateActionAnimationControllerForHitTestResultInternal:hitTestResult withType:type userData:userData];
 }
@@ -4900,7 +4902,8 @@ bool WebViewImpl::performKeyEquivalent(NSEvent *event)
     // There's a chance that responding to this event will run a nested event loop, and
     // fetching a new event might release the old one. Retaining and then autoreleasing
     // the current event prevents that from causing a problem inside WebKit or AppKit code.
-    [[event retain] autorelease];
+    CFRetain((__bridge CFTypeRef)event);
+    CFAutorelease((__bridge CFTypeRef)event);
 
     // We get Esc key here after processing either Esc or Cmd+period. The former starts as a keyDown, and the latter starts as a key equivalent,
     // but both get transformed to a cancelOperation: command, executing which passes an Esc key event to -performKeyEquivalent:.
index 883d4bb..04c8115 100644 (file)
@@ -400,11 +400,10 @@ public:
 
 #if PLATFORM(MAC)
     virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0;
-
-    virtual void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) = 0;
-
+    virtual NSObject *immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) = 0;
     virtual void didHandleAcceptedCandidate() = 0;
 #endif
+
     virtual void didFinishProcessingAllPendingMouseEvents() = 0;
 
     virtual void videoControlsManagerDidChange() { }
index 8ff54b2..4efe080 100644 (file)
@@ -104,11 +104,11 @@ bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& tran
         RemoteLayerTreePropertyApplier::RelatedLayerMap relatedLayers;
         if (properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
             for (auto& child : properties.children)
-                relatedLayers.set(child, getLayer(child));
+                relatedLayers.set(child, (__bridge CFTypeRef)getLayer(child));
         }
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged && properties.maskLayerID)
-            relatedLayers.set(properties.maskLayerID, getLayer(properties.maskLayerID));
+            relatedLayers.set(properties.maskLayerID, (__bridge CFTypeRef)getLayer(properties.maskLayerID));
 
         if (properties.changedProperties & RemoteLayerTreeTransaction::ClonedContentsChanged && properties.clonedLayerID)
             clonesToUpdate.append(LayerIDPair(layerID, properties.clonedLayerID));
@@ -292,7 +292,7 @@ void RemoteLayerTreeHost::detachRootLayer()
 #if HAVE(IOSURFACE)
 static void recursivelyMapIOSurfaceBackingStore(CALayer *layer)
 {
-    if (layer.contents && CFGetTypeID(layer.contents) == CAMachPortGetTypeID()) {
+    if (layer.contents && CFGetTypeID((__bridge CFTypeRef)layer.contents) == CAMachPortGetTypeID()) {
         MachSendRight port = MachSendRight::create(CAMachPortGetPort((__bridge CAMachPortRef)layer.contents));
         auto surface = WebCore::IOSurface::createFromSendRight(WTFMove(port), sRGBColorSpaceRef());
         layer.contents = surface ? surface->asLayerContents() : nil;
index 002becf..bf6cf0f 100644 (file)
@@ -7331,7 +7331,7 @@ void WebPageProxy::didPerformImmediateActionHitTest(const WebHitTestResultData&
     m_pageClient.didPerformImmediateActionHitTest(result, contentPreventsDefault, m_process->transformHandlesToObjects(userData.object()).get());
 }
 
-void* WebPageProxy::immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult> hitTestResult, uint64_t type, RefPtr<API::Object> userData)
+NSObject *WebPageProxy::immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult> hitTestResult, uint64_t type, RefPtr<API::Object> userData)
 {
     return m_pageClient.immediateActionAnimationControllerForHitTestResult(hitTestResult, type, userData);
 }
index 2eb241e..77bd8d7 100644 (file)
@@ -1204,7 +1204,7 @@ public:
     void immediateActionDidCancel();
     void immediateActionDidComplete();
 
-    void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>);
+    NSObject *immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>);
 
     void installActivityStateChangeCompletionHandler(WTF::Function<void ()>&&);
 
index 7e462e8..c538b5b 100644 (file)
@@ -217,7 +217,7 @@ private:
     void handleControlledElementIDResponse(const String&) override;
 
     void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
-    void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
+    NSObject *immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
 
     void didHandleAcceptedCandidate() override;
 
index e15b442..8c23b28 100644 (file)
@@ -827,7 +827,7 @@ void PageClientImpl::didPerformImmediateActionHitTest(const WebHitTestResultData
     m_impl->didPerformImmediateActionHitTest(result, contentPreventsDefault, userData);
 }
 
-void* PageClientImpl::immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult> hitTestResult, uint64_t type, RefPtr<API::Object> userData)
+NSObject *PageClientImpl::immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult> hitTestResult, uint64_t type, RefPtr<API::Object> userData)
 {
     return m_impl->immediateActionAnimationControllerForHitTestResult(hitTestResult.get(), type, userData.get());
 }
@@ -856,12 +856,12 @@ WebCore::WebMediaSessionManager& PageClientImpl::mediaSessionManager()
 
 void PageClientImpl::refView()
 {
-    CFRetain(m_view);
+    CFRetain((__bridge CFTypeRef)m_view);
 }
 
 void PageClientImpl::derefView()
 {
-    CFRelease(m_view);
+    CFRelease((__bridge CFTypeRef)m_view);
 }
 
 void PageClientImpl::startWindowDrag()
index bb6fb75..3c8bc64 100644 (file)
@@ -97,27 +97,27 @@ void ServicesController::refreshExistingServices(bool refreshImmediately)
     dispatch_after(refreshTime, m_refreshQueue, ^{
         auto serviceLookupGroup = adoptOSObject(dispatch_group_create());
 
-        static NeverDestroyed<NSImage *> image([[NSImage alloc] init]);
+        static NSImage *image { [[NSImage alloc] init] };
         hasCompatibleServicesForItems(serviceLookupGroup.get(), @[ image ], [this] (bool hasServices) {
             m_hasImageServices = hasServices;
         });
 
-        static NeverDestroyed<NSAttributedString *> attributedString([[NSAttributedString alloc] initWithString:@"a"]);
+        static NSAttributedString *attributedString { [[NSAttributedString alloc] initWithString:@"a"] };
         hasCompatibleServicesForItems(serviceLookupGroup.get(), @[ attributedString ], [this] (bool hasServices) {
             m_hasSelectionServices = hasServices;
         });
 
-        static NSAttributedString *attributedStringWithRichContent;
-        if (!attributedStringWithRichContent) {
-            dispatch_sync(dispatch_get_main_queue(), ^ {
+        static NSAttributedString *attributedStringWithRichContent = [] {
+            NSMutableAttributedString *richString;
+            dispatch_sync(dispatch_get_main_queue(), [&richString] {
                 auto attachment = adoptNS([[NSTextAttachment alloc] init]);
-                auto cell = adoptNS([[NSTextAttachmentCell alloc] initImageCell:image.get()]);
+                auto cell = adoptNS([[NSTextAttachmentCell alloc] initImageCell:image]);
                 [attachment setAttachmentCell:cell.get()];
-                NSMutableAttributedString *richString = (NSMutableAttributedString *)[NSMutableAttributedString attributedStringWithAttachment:attachment.get()];
+                richString = [[NSAttributedString attributedStringWithAttachment:attachment.get()] mutableCopy];
                 [richString appendAttributedString:attributedString];
-                attributedStringWithRichContent = [richString retain];
             });
-        }
+            return richString;
+        }();
 
         hasCompatibleServicesForItems(serviceLookupGroup.get(), @[ attributedStringWithRichContent ], [this] (bool hasServices) {
             m_hasRichContentServices = hasServices;
index 8ceadc1..f872070 100644 (file)
@@ -328,7 +328,7 @@ SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
     }
 
     RefPtr<API::HitTestResult> hitTestResult = [self _webHitTestResult];
-    id customClientAnimationController = (id)(_page->immediateActionAnimationControllerForHitTestResult(hitTestResult, _type, _userData));
+    id customClientAnimationController = _page->immediateActionAnimationControllerForHitTestResult(hitTestResult, _type, _userData);
     if (customClientAnimationController == [NSNull null]) {
         [self _cancelImmediateAction];
         return;
index 7b0b38b..1fda7db 100644 (file)
@@ -63,8 +63,10 @@ static BOOL isForcingPreviewUpdate;
 
 - (void)dealloc
 {
-    if (WebCoreObjCScheduleDeallocateOnMainThread([WKPrintingView class], self))
-        return;
+    callOnMainThread([frame = WTFMove(_webFrame), previews = WTFMove(_pagePreviews)] {
+        // Deallocate these on the main thread, not the current thread, since the
+        // reference counting and the destructors aren't threadsafe.
+    });
 
     [super dealloc];
 }
@@ -431,9 +433,9 @@ static void prepareDataForPrintingOnSecondaryThread(WKPrintingView *view)
     return 0; // Invalid page number.
 }
 
-static CFStringRef linkDestinationName(PDFDocument *document, PDFDestination *destination)
+static NSString *linkDestinationName(PDFDocument *document, PDFDestination *destination)
 {
-    return (CFStringRef)[NSString stringWithFormat:@"%lu-%f-%f", (unsigned long)[document indexForPage:destination.page], destination.point.x, destination.point.y];
+    return [NSString stringWithFormat:@"%lu-%f-%f", (unsigned long)[document indexForPage:destination.page], destination.point.x, destination.point.y];
 }
 
 - (void)_drawPDFDocument:(PDFDocument *)pdfDocument page:(unsigned)page atPoint:(NSPoint)point
@@ -470,7 +472,7 @@ static CFStringRef linkDestinationName(PDFDocument *document, PDFDestination *de
 
     for (const auto& destination : _linkDestinationsPerPage[page]) {
         CGPoint destinationPoint = CGPointApplyAffineTransform(NSPointToCGPoint([destination point]), transform);
-        CGPDFContextAddDestinationAtPoint(context, linkDestinationName(pdfDocument, destination.get()), destinationPoint);
+        CGPDFContextAddDestinationAtPoint(context, (__bridge CFStringRef)linkDestinationName(pdfDocument, destination.get()), destinationPoint);
     }
 
     for (PDFAnnotation *annotation in [pdfPage annotations]) {
@@ -488,8 +490,7 @@ static CFStringRef linkDestinationName(PDFDocument *document, PDFDestination *de
             PDFDestination *destination = [linkAnnotation destination];
             if (!destination)
                 continue;
-            CGPDFContextSetDestinationForRect(context, linkDestinationName(pdfDocument, destination), transformedRect);
-
+            CGPDFContextSetDestinationForRect(context, (__bridge CFStringRef)linkDestinationName(pdfDocument, destination), transformedRect);
             continue;
         }
 
index 2891318..c9eb05a 100644 (file)
@@ -89,8 +89,8 @@ private:
 
 // -- Caches --
 
-DOMCache<WebCore::Node*, WKDOMNode *>& WKDOMNodeCache();
-DOMCache<WebCore::Range*, WKDOMRange *>& WKDOMRangeCache();
+DOMCache<WebCore::Node*, __unsafe_unretained WKDOMNode *>& WKDOMNodeCache();
+DOMCache<WebCore::Range*, __unsafe_unretained WKDOMRange *>& WKDOMRangeCache();
 
 // -- Node and classes derived from Node. --
 
index 650fd47..af0fe63 100644 (file)
@@ -51,15 +51,15 @@ static WKDOMType toWKDOMType(WebCoreType impl, DOMCache<WebCoreType, WKDOMType>&
 
 // -- Caches -- 
 
-DOMCache<WebCore::Node*, WKDOMNode *>& WKDOMNodeCache()
+DOMCache<WebCore::Node*, __unsafe_unretained WKDOMNode *>& WKDOMNodeCache()
 {
-    static NeverDestroyed<DOMCache<WebCore::Node*, WKDOMNode *>> cache;
+    static NeverDestroyed<DOMCache<WebCore::Node*, __unsafe_unretained WKDOMNode *>> cache;
     return cache;
 }
 
-DOMCache<WebCore::Range*, WKDOMRange *>& WKDOMRangeCache()
+DOMCache<WebCore::Range*, __unsafe_unretained WKDOMRange *>& WKDOMRangeCache()
 {
-    static NeverDestroyed<DOMCache<WebCore::Range*, WKDOMRange *>> cache;
+    static NeverDestroyed<DOMCache<WebCore::Range*, __unsafe_unretained WKDOMRange *>> cache;
     return cache;
 }
 
@@ -98,7 +98,7 @@ WebCore::Node* toWebCoreNode(WKDOMNode *wrapper)
 
 WKDOMNode *toWKDOMNode(WebCore::Node* impl)
 {
-    return toWKDOMType<WebCore::Node*, WKDOMNode *>(impl, WKDOMNodeCache());
+    return toWKDOMType<WebCore::Node*, __unsafe_unretained WKDOMNode *>(impl, WKDOMNodeCache());
 }
 
 WebCore::Element* toWebCoreElement(WKDOMElement *wrapper)
@@ -145,7 +145,7 @@ WebCore::Range* toWebCoreRange(WKDOMRange * wrapper)
 
 WKDOMRange *toWKDOMRange(WebCore::Range* impl)
 {
-    return toWKDOMType<WebCore::Range*, WKDOMRange *>(impl, WKDOMRangeCache());
+    return toWKDOMType<WebCore::Range*, __unsafe_unretained WKDOMRange *>(impl, WKDOMRangeCache());
 }
 
 // -- Helpers --
index 8ec6b82..edcf532 100644 (file)
@@ -204,9 +204,10 @@ void NetscapePlugin::platformPreInitialize()
         // Patch -[NSException release] to not release the object.
         static dispatch_once_t once;
         dispatch_once(&once, ^{
-            Class exceptionClass = [NSException class];
-            Method exceptionReleaseMethod = class_getInstanceMethod(exceptionClass, @selector(release));
-            class_replaceMethod(exceptionClass, @selector(release), reinterpret_cast<IMP>(NSException_release), method_getTypeEncoding(exceptionReleaseMethod));
+            auto exceptionClass = [NSException class];
+            auto releaseSelector = sel_registerName("release");
+            auto exceptionReleaseMethod = class_getInstanceMethod(exceptionClass, releaseSelector);
+            class_replaceMethod(exceptionClass, releaseSelector, reinterpret_cast<IMP>(NSException_release), method_getTypeEncoding(exceptionReleaseMethod));
         });
     }
 }
@@ -1159,9 +1160,9 @@ void NetscapePlugin::updatePluginLayer()
     // be returned by using NPN_GetValue and pass the WKNVExpectsNonretainedLayer parameter.
     // https://bugs.webkit.org/show_bug.cgi?id=58282 describes the bug where WebKit expects retained layers.
     if (m_pluginReturnsNonretainedLayer)
-        m_pluginLayer = reinterpret_cast<CALayer *>(value);
+        m_pluginLayer = (__bridge CALayer *)value;
     else
-        m_pluginLayer = adoptNS(reinterpret_cast<CALayer *>(value));
+        m_pluginLayer = adoptNS((__bridge CALayer *)value);
 
     if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists) &&
         !m_isTransparent)
index 5c2e066..5307e26 100644 (file)
@@ -69,6 +69,7 @@
 #import <WebCore/HTMLFormElement.h>
 #import <WebCore/HTMLPlugInElement.h>
 #import <WebCore/LegacyNSPasteboardTypes.h>
+#import <WebCore/LocalDefaultSystemAppearance.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/MouseEvent.h>
 #import <WebCore/PDFDocumentImage.h>
 #import <WebCore/ScrollAnimator.h>
 #import <WebCore/ScrollbarTheme.h>
 #import <WebCore/Settings.h>
+#import <WebCore/WebAccessibilityObjectWrapperMac.h>
 #import <WebCore/WheelEventTestTrigger.h>
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/mac/NSMenuSPI.h>
 #import <wtf/UUID.h>
 
-#if PLATFORM(MAC)
-#include <WebCore/LocalDefaultSystemAppearance.h>
-#endif
-
 using namespace WebCore;
 
 // Set overflow: hidden on the annotation container so <input> elements scrolled out of view don't show
index bfab60a..1f90c4a 100644 (file)
@@ -63,7 +63,7 @@ void WebEditorClient::setInsertionPasteboard(const String&)
     notImplemented();
 }
 
-static void changeWordCase(WebPage* page, SEL selector)
+static void changeWordCase(WebPage* page, NSString *(*changeCase)(NSString *))
 {
     Frame& frame = page->corePage()->focusController().focusedOrMainFrame();
     if (!frame.editor().canEdit())
@@ -72,22 +72,28 @@ static void changeWordCase(WebPage* page, SEL selector)
     frame.editor().command("selectWord").execute();
 
     NSString *selectedString = frame.displayStringModifiedByEncoding(frame.editor().selectedText());
-    page->replaceSelectionWithText(&frame, [selectedString performSelector:selector]);
+    page->replaceSelectionWithText(&frame, changeCase(selectedString));
 }
 
 void WebEditorClient::uppercaseWord()
 {
-    changeWordCase(m_page, @selector(uppercaseString));
+    changeWordCase(m_page, [] (NSString *string) {
+        return [string uppercaseString];
+    });
 }
 
 void WebEditorClient::lowercaseWord()
 {
-    changeWordCase(m_page, @selector(lowercaseString));
+    changeWordCase(m_page, [] (NSString *string) {
+        return [string lowercaseString];
+    });
 }
 
 void WebEditorClient::capitalizeWord()
 {
-    changeWordCase(m_page, @selector(capitalizedString));
+    changeWordCase(m_page, [] (NSString *string) {
+        return [string capitalizedString];
+    });
 }
 
 #if USE(AUTOMATIC_TEXT_REPLACEMENT)
index e43e29d..17cfb34 100644 (file)
 #import <stdio.h>
 
 #if PLATFORM(IOS)
+#import "WKAccessibilityWebPageObjectIOS.h"
 #import <UIKit/UIAccessibility.h>
 #import <pal/spi/ios/GraphicsServicesSPI.h>
+#endif
 
-#if USE(APPLE_INTERNAL_SDK)
+#if PLATFORM(IOS) && USE(APPLE_INTERNAL_SDK)
 #import <AXRuntime/AXDefines.h>
 #import <AXRuntime/AXNotificationConstants.h>
-#else
-#define kAXPidStatusChangedNotification 0
 #endif
 
+#if PLATFORM(IOS) && !USE(APPLE_INTERNAL_SDK)
+#define kAXPidStatusChangedNotification 0
 #endif
 
 #if PLATFORM(MAC)
+#import "WKAccessibilityWebPageObjectMac.h"
 #import <WebCore/GraphicsContext3DManager.h>
 #import <WebCore/ScrollbarThemeMac.h>
 #import <pal/spi/mac/NSScrollerImpSPI.h>