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
+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
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();
#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)
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);
}
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+
NSHTTPCookieStorage *NetworkDataTaskCocoa::statelessCookieStorage()
{
static NeverDestroyed<RetainPtr<NSHTTPCookieStorage>> statelessCookieStorage;
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)
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)
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
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:
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;
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;
}
[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;
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;
}
// 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;
}
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;
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);
}
- (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);
}
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();
}
@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;
};
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;
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;
continue;
}
- allowedClasses.append({ objectClass });
+ allowedClasses.append({ (__bridge CFTypeRef)objectClass });
}
if (forReplyBlock)
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;
if (needsComma)
[result appendString:@", "];
- [result appendFormat:@"%s", class_getName(argumentClass)];
+ [result appendFormat:@"%s", class_getName((__bridge Class)argumentClass)];
needsComma = true;
}
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())
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);
}
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));
- (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
#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);
#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;
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)
if (!object)
return nullptr;
- return static_cast<void*>(object->wrapper());
+ return (__bridge void*)object->wrapper();
}
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
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);
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();
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;
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) {
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)
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;
}
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()];
}
}
- (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
}
// 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
};
@implementation WKHTTPCookieStore {
- HashMap<id<WKHTTPCookieStoreObserver>, std::unique_ptr<WKHTTPCookieStoreObserver>> _observers;
+ HashMap<CFTypeRef, std::unique_ptr<WKHTTPCookieStoreObserver>> _observers;
}
- (void)dealloc
- (void)addObserver:(id<WKHTTPCookieStoreObserver>)observer
{
- auto result = _observers.add(observer, nullptr);
+ auto result = _observers.add((__bridge CFTypeRef)observer, nullptr);
if (!result.isNewEntry)
return;
- (void)removeObserver:(id<WKHTTPCookieStoreObserver>)observer
{
- auto result = _observers.take(observer);
+ auto result = _observers.take((__bridge CFTypeRef)observer);
if (!result)
return;
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);
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;
#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
#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;
}
#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];
}
if (!isNullFunctionPointer(_AXSWebAccessibilityEventsEnabled))
_page->updateAccessibilityEventsEnabled(_AXSWebAccessibilityEventsEnabled());
}
+
#endif
#pragma mark OS X-specific methods
- (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;
}
if (!certificateInfo)
return @[ ];
- return (NSArray *)certificateInfo->certificateInfo().certificateChain() ?: @[ ];
+ return (__bridge NSArray *)certificateInfo->certificateInfo().certificateChain() ?: @[ ];
}
@end
static SEL delegateSelector()
{
- return sel_registerName("_shouldLoadIconWithParameters:completionHandler:");
+ return @selector(_shouldLoadIconWithParameters:completionHandler:);
}
private:
{
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) {
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)
}
#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());
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();
// 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;
// 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;
[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];
}
// 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:.
#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() { }
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));
#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;
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);
}
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 ()>&&);
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;
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());
}
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()
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;
}
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;
- (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];
}
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
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]) {
PDFDestination *destination = [linkAnnotation destination];
if (!destination)
continue;
- CGPDFContextSetDestinationForRect(context, linkDestinationName(pdfDocument, destination), transformedRect);
-
+ CGPDFContextSetDestinationForRect(context, (__bridge CFStringRef)linkDestinationName(pdfDocument, destination), transformedRect);
continue;
}
// -- 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. --
// -- 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;
}
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)
WKDOMRange *toWKDOMRange(WebCore::Range* impl)
{
- return toWKDOMType<WebCore::Range*, WKDOMRange *>(impl, WKDOMRangeCache());
+ return toWKDOMType<WebCore::Range*, __unsafe_unretained WKDOMRange *>(impl, WKDOMRangeCache());
}
// -- Helpers --
// 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));
});
}
}
// 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)
#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
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())
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)
#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>