Diff
Modified: trunk/Source/WebCore/ChangeLog (275764 => 275765)
--- trunk/Source/WebCore/ChangeLog 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebCore/ChangeLog 2021-04-09 16:43:03 UTC (rev 275765)
@@ -1,3 +1,19 @@
+2021-04-08 Darin Adler <da...@apple.com>
+
+ [Cocoa] Reduce usage of autorelease, fix mistakes noticed nearby code using autorelease
+ https://bugs.webkit.org/show_bug.cgi?id=224340
+
+ Reviewed by Anders Carlsson.
+
+ * bridge/objc/objc_instance.h: Added a static member function isInStringValue to
+ help factor the _web_description method better.
+
+ * bridge/objc/objc_instance.mm:
+ (JSC::Bindings::ObjcInstance::stringValue const): Removed unneeded WTF prefixes.
+ (JSC::Bindings::ObjcInstance::isInStringValue): Added.
+ (-[NSObject _web_description]): Moved this out of the C++ namespace since it's an
+ Objective-C class implementation. Refactored for simplicity.
+
2021-04-08 Antoine Quint <grao...@webkit.org>
calc() values resulting from blending mixed type lengths should be simplified
Modified: trunk/Source/WebCore/bridge/objc/objc_instance.h (275764 => 275765)
--- trunk/Source/WebCore/bridge/objc/objc_instance.h 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebCore/bridge/objc/objc_instance.h 2021-04-09 16:43:03 UTC (rev 275765)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -59,6 +59,8 @@
JSValue numberValue(JSGlobalObject*) const;
JSValue booleanValue() const;
+ static bool isInStringValue();
+
protected:
virtual void virtualBegin();
virtual void virtualEnd();
Modified: trunk/Source/WebCore/bridge/objc/objc_instance.mm (275764 => 275765)
--- trunk/Source/WebCore/bridge/objc/objc_instance.mm 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebCore/bridge/objc/objc_instance.mm 2021-04-09 16:43:03 UTC (rev 275765)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -52,16 +52,23 @@
}
#endif
-using namespace JSC::Bindings;
-using namespace JSC;
+@interface NSObject (WebDescriptionCategory)
+- (NSString *)_web_description;
+@end
+namespace JSC {
+namespace Bindings {
+
static RetainPtr<NSString>& globalException()
{
static NeverDestroyed<RetainPtr<NSString>> exception;
return exception;
}
-static JSGlobalObject* s_exceptionEnvironment; // No need to protect this value, since we just use it for a pointer comparison.
+// No need to protect this value, since we just use it for a pointer comparison.
+// FIXME: A new object can happen to be equal to the old one, so even pointer comparison is not safe. Maybe we can use NeverDestroyed<JSC::Weak>?
+static JSGlobalObject* s_exceptionEnvironment;
+
static HashMap<CFTypeRef, ObjcInstance*>& wrapperCache()
{
static NeverDestroyed<HashMap<CFTypeRef, ObjcInstance*>> map;
@@ -74,10 +81,9 @@
return ObjCRuntimeObject::create(lexicalGlobalObject->vm(), WebCore::deprecatedGetDOMStructure<ObjCRuntimeObject>(lexicalGlobalObject), this);
}
-void ObjcInstance::setGlobalException(NSString* exception, JSGlobalObject* exceptionEnvironment)
+void ObjcInstance::setGlobalException(NSString *exception, JSGlobalObject* exceptionEnvironment)
{
globalException() = adoptNS([exception copy]);
-
s_exceptionEnvironment = exceptionEnvironment;
}
@@ -468,32 +474,13 @@
return valueOf(lexicalGlobalObject);
}
-static WTF::ThreadSpecific<uint32_t>* s_descriptionDepth;
+static ThreadSpecific<uint32_t>* s_descriptionDepth;
-@interface NSObject (WebDescriptionCategory)
-- (NSString *)_web_description;
-@end
-
-@implementation NSObject (WebDescriptionCategory)
-
-- (NSString *)_web_description
-{
- ASSERT(s_descriptionDepth);
- if (s_descriptionDepth->isSet() && **s_descriptionDepth)
- return [NSString stringWithFormat:@"<%@>", NSStringFromClass([self class])];
- // We call _web_description here since this method should only be called
- // once we have already swizzled this method with the one on NSObject.
- // Thus, _web_description is actually the original description method.
- return [self _web_description];
-}
-
-@end
-
JSC::JSValue ObjcInstance::stringValue(JSGlobalObject* lexicalGlobalObject) const
{
static std::once_flag initializeDescriptionDepthOnceFlag;
std::call_once(initializeDescriptionDepthOnceFlag, [] {
- s_descriptionDepth = new WTF::ThreadSpecific<uint32_t>();
+ s_descriptionDepth = new ThreadSpecific<uint32_t>();
**s_descriptionDepth = 0;
auto descriptionMethod = class_getInstanceMethod([NSObject class], @selector(description));
@@ -507,6 +494,11 @@
return result;
}
+bool ObjcInstance::isInStringValue()
+{
+ return s_descriptionDepth && s_descriptionDepth->isSet() && **s_descriptionDepth;
+}
+
JSC::JSValue ObjcInstance::numberValue(JSGlobalObject*) const
{
return jsNumber(0);
@@ -521,3 +513,20 @@
{
return stringValue(lexicalGlobalObject);
}
+
+}
+}
+
+@implementation NSObject (WebDescriptionCategory)
+
+- (NSString *)_web_description
+{
+ if (JSC::Bindings::ObjcInstance::isInStringValue())
+ return [NSString stringWithFormat:@"<%@>", NSStringFromClass([self class])];
+
+ // Calling _web_description here invokes the implementation of the original description
+ // method from NSObject, because we have already swapped implementations.
+ return [self _web_description];
+}
+
+@end
Modified: trunk/Source/WebKit/ChangeLog (275764 => 275765)
--- trunk/Source/WebKit/ChangeLog 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebKit/ChangeLog 2021-04-09 16:43:03 UTC (rev 275765)
@@ -1,3 +1,48 @@
+2021-04-08 Darin Adler <da...@apple.com>
+
+ [Cocoa] Reduce usage of autorelease, fix mistakes noticed nearby code using autorelease
+ https://bugs.webkit.org/show_bug.cgi?id=224340
+
+ Reviewed by Anders Carlsson.
+
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: Use RetainPtr<NSURLRequest> instead of
+ __strong NSURLRequest*& for the in/out argument of the
+ applySniffingPoliciesAndBindRequestToInferfaceIfNeeded function.
+
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+ (WebKit::NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded):
+ Updated to use RetainPtr instead of __strong. Also fixed some incorrect uses of %llu
+ to log NSUInteger and uint64_t, switching to "%lu" (and casting to unsigned long to
+ retain 32-bit compatibility) and "%" PRIu64 respectively.
+ (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): Ditto.
+ (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): Ditto.
+
+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+ (setIgnoreHSTS): Added. Helper function so the code that makes a mutableCopy is isolated
+ in a helper function for clarity. A good counterpart to the existing ignoreHSTS function.
+ (updateIgnoreStrictTransportSecuritySetting): Changed to use a RetainPtr<NSURLRequest>
+ in/out argument instead of an argument plus a return value, obviating the need to use
+ autorelease and making this easier to read. Used setIgnoreHSTS for brevity in implementation.
+ (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+ Update for change to updateIgnoreStrictTransportSecuritySetting.
+ (-[WKNetworkSessionDelegate URLSession:task:_schemeUpgraded:completionHandler:]): Ditto.
+ (WebKit::proxyDictionary): Return a RetainPtr instead of something autoreleased.
+ (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): Call get() on the result of the
+ proxyDictionary function.
+
+ * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+ (makePolicyDecisionBlock): Return a BlockPtr instead of an autoreleased block.
+ Also use a lambda and retainWK for better clarity on capture semantics rather than
+ doing a WKRetain in the caller and a WKRelease in the block.
+ (setUpPagePolicyClient): Call get() on the result of the
+ makePolicyDecisionBlock function.
+
+ * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
+ (WebKit::animationValueFromKeyframeValue): Return a RetainPtr instead of an
+ autoreleased object.
+ (WebKit::createAnimation): Call get() on the result of the
+ animationValueFromKeyframeValue function.
+
2021-04-09 Brent Fulgham <bfulg...@apple.com>
[Cocoa] Silence a CFNetwork preference file access warning
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (275764 => 275765)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h 2021-04-09 16:43:03 UTC (rev 275765)
@@ -88,7 +88,7 @@
NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebPageProxyIdentifier, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker>, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried>);
bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&);
- void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
+ void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(RetainPtr<NSURLRequest>&, bool shouldContentSniff, bool shouldContentEncodingSniff);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
static NSHTTPCookieStorage *statelessCookieStorage();
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (275764 => 275765)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2021-04-09 16:43:03 UTC (rev 275765)
@@ -89,7 +89,7 @@
return NSURLSessionTaskPriorityDefault;
}
-void NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest *& nsRequest, bool shouldContentSniff, bool shouldContentEncodingSniff)
+void NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(RetainPtr<NSURLRequest>& nsRequest, bool shouldContentSniff, bool shouldContentEncodingSniff)
{
#if !USE(CFNETWORK_CONTENT_ENCODING_SNIFFING_OVERRIDE)
UNUSED_PARAM(shouldContentEncodingSniff);
@@ -337,21 +337,23 @@
#endif
restrictRequestReferrerToOriginIfNeeded(request);
+ // FIXME: Once we are done with NETWORK_DATA_TASK_COCOA_ADDITIONS, make nsRequest a RetainPtr and get rid of protectedNSRequest.
NSURLRequest *nsRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody);
NETWORK_DATA_TASK_COCOA_ADDITIONS
- m_session->appBoundNavigationTestingData().updateAppBoundNavigationTestingData(request, contextString(nsRequest));
+ auto protectedNSRequest = retainPtr(nsRequest);
+ m_session->appBoundNavigationTestingData().updateAppBoundNavigationTestingData(request, contextString(protectedNSRequest.get()));
- applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(nsRequest, shouldContentSniff == WebCore::ContentSniffingPolicy::SniffContent && !url.isLocalFile(), shouldContentEncodingSniff == WebCore::ContentEncodingSniffingPolicy::Sniff);
+ applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(protectedNSRequest, shouldContentSniff == WebCore::ContentSniffingPolicy::SniffContent && !url.isLocalFile(), shouldContentEncodingSniff == WebCore::ContentEncodingSniffingPolicy::Sniff);
- m_task = [m_sessionWrapper->session dataTaskWithRequest:nsRequest];
+ m_task = [m_sessionWrapper->session dataTaskWithRequest:protectedNSRequest.get()];
WTFBeginSignpost(m_task.get(), "DataTask", "%{public}s pri: %.2f preconnect: %d", url.string().ascii().data(), toNSURLSessionTaskPriority(request.priority()), shouldPreconnectOnly == PreconnectOnly::Yes);
RELEASE_ASSERT(!m_sessionWrapper->dataTaskMap.contains([m_task taskIdentifier]));
m_sessionWrapper->dataTaskMap.add([m_task taskIdentifier], this);
- LOG(NetworkSession, "%llu Creating NetworkDataTask with URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
+ LOG(NetworkSession, "%lu Creating NetworkDataTask with URL %s", (unsigned long)[m_task taskIdentifier], [protectedNSRequest URL].absoluteString.UTF8String);
if (shouldPreconnectOnly == PreconnectOnly::Yes) {
#if ENABLE(SERVER_PRECONNECT)
@@ -368,9 +370,9 @@
if (shouldBlockCookies) {
#if !RELEASE_LOG_DISABLED
if (m_session->shouldLogCookieInformation())
- RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::logCookieInformation: pageID=%llu, frameID=%llu, taskID=%lu: Blocking cookies for URL %s", this, pageID.toUInt64(), frameID.toUInt64(), (unsigned long)[m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
+ RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::logCookieInformation: pageID=%" PRIu64 ", frameID=%" PRIu64 ", taskID=%lu: Blocking cookies for URL %s", this, pageID.toUInt64(), frameID.toUInt64(), (unsigned long)[m_task taskIdentifier], [protectedNSRequest URL].absoluteString.UTF8String);
#else
- LOG(NetworkSession, "%llu Blocking cookies for URL %s", [m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
+ LOG(NetworkSession, "%lu Blocking cookies for URL %s", (unsigned long)[m_task taskIdentifier], [protectedNSRequest URL].absoluteString.UTF8String);
#endif
blockCookies();
}
@@ -516,9 +518,9 @@
unblockCookies();
#if !RELEASE_LOG_DISABLED
if (m_session->shouldLogCookieInformation())
- RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::willPerformHTTPRedirection::logCookieInformation: pageID=%llu, frameID=%llu, taskID=%lu: %s cookies for redirect URL %s", this, m_pageID.toUInt64(), m_frameID.toUInt64(), (unsigned long)[m_task taskIdentifier], (m_hasBeenSetToUseStatelessCookieStorage ? "Blocking" : "Not blocking"), request.url().string().utf8().data());
+ RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::willPerformHTTPRedirection::logCookieInformation: pageID=%" PRIu64 ", frameID=%" PRIu64 ", taskID=%lu: %s cookies for redirect URL %s", this, m_pageID.toUInt64(), m_frameID.toUInt64(), (unsigned long)[m_task taskIdentifier], (m_hasBeenSetToUseStatelessCookieStorage ? "Blocking" : "Not blocking"), request.url().string().utf8().data());
#else
- LOG(NetworkSession, "%llu %s cookies for redirect URL %s", [m_task taskIdentifier], (m_hasBeenSetToUseStatelessCookieStorage ? "Blocking" : "Not blocking"), request.url().string().utf8().data());
+ LOG(NetworkSession, "%lu %s cookies for redirect URL %s", (unsigned long)[m_task taskIdentifier], (m_hasBeenSetToUseStatelessCookieStorage ? "Blocking" : "Not blocking"), request.url().string().utf8().data());
#endif
#endif
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (275764 => 275765)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2021-04-09 16:43:03 UTC (rev 275765)
@@ -504,6 +504,13 @@
[request _setIgnoreHSTS:ignoreHSTS];
}
+static void setIgnoreHSTS(RetainPtr<NSURLRequest>& request, bool shouldIgnoreHSTS)
+{
+ auto mutableRequest = adoptNS([request mutableCopy]);
+ setIgnoreHSTS(mutableRequest.get(), false);
+ request = mutableRequest;
+}
+
static bool ignoreHSTS(NSURLRequest *request)
{
return [request respondsToSelector:@selector(_ignoreHSTS)]
@@ -510,23 +517,19 @@
&& [request _ignoreHSTS];
}
-static NSURLRequest* updateIgnoreStrictTransportSecuritySettingIfNecessary(NSURLRequest *request, bool shouldIgnoreHSTS)
+static void updateIgnoreStrictTransportSecuritySetting(RetainPtr<NSURLRequest>& request, bool shouldIgnoreHSTS)
{
- if ([request.URL.scheme isEqualToString:@"https"] && shouldIgnoreHSTS && ignoreHSTS(request)) {
- // The request was upgraded for some other reason than HSTS.
- // Don't ignore HSTS to avoid the risk of another downgrade.
- auto nsMutableRequest = adoptNS([request mutableCopy]);
- setIgnoreHSTS(nsMutableRequest.get(), false);
- return nsMutableRequest.autorelease();
+ auto scheme = request.get().URL.scheme;
+ if ([scheme isEqualToString:@"https"]) {
+ if (shouldIgnoreHSTS && ignoreHSTS(request.get())) {
+ // The request was upgraded for some other reason than HSTS.
+ // Don't ignore HSTS to avoid the risk of another downgrade.
+ setIgnoreHSTS(request, false);
+ }
+ } else if ([scheme isEqualToString:@"http"]) {
+ if (ignoreHSTS(request.get()) != shouldIgnoreHSTS)
+ setIgnoreHSTS(request, shouldIgnoreHSTS);
}
-
- if ([request.URL.scheme isEqualToString:@"http"] && ignoreHSTS(request) != shouldIgnoreHSTS) {
- auto nsMutableRequest = adoptNS([request mutableCopy]);
- setIgnoreHSTS(nsMutableRequest.get(), shouldIgnoreHSTS);
- return nsMutableRequest.autorelease();
- }
-
- return request;
}
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task willPerformHTTPRedirection:(NSHTTPURLResponse *)response newRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLRequest *))completionHandler
@@ -555,9 +558,9 @@
#else
UNUSED_PARAM(taskIdentifier);
#endif
- auto nsRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody);
- nsRequest = updateIgnoreStrictTransportSecuritySettingIfNecessary(nsRequest, shouldIgnoreHSTS);
- completionHandler(nsRequest);
+ auto nsRequest = retainPtr(request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody));
+ updateIgnoreStrictTransportSecuritySetting(nsRequest, shouldIgnoreHSTS);
+ completionHandler(nsRequest.get());
});
} else {
LOG(NetworkSession, "%llu willPerformHTTPRedirection completionHandler (nil)", taskIdentifier);
@@ -590,9 +593,9 @@
#else
UNUSED_PARAM(taskIdentifier);
#endif
- auto nsRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody);
- nsRequest = updateIgnoreStrictTransportSecuritySettingIfNecessary(nsRequest, shouldIgnoreHSTS);
- completionHandler(nsRequest);
+ auto nsRequest = retainPtr(request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody));
+ updateIgnoreStrictTransportSecuritySetting(nsRequest, shouldIgnoreHSTS);
+ completionHandler(nsRequest.get());
});
} else {
LOG(NetworkSession, "%llu _schemeUpgraded completionHandler (nil)", taskIdentifier);
@@ -1107,7 +1110,7 @@
return makeUnique<NetworkSessionCocoa>(networkProcess, WTFMove(parameters));
}
-static NSDictionary *proxyDictionary(const URL& httpProxy, const URL& httpsProxy)
+static RetainPtr<NSDictionary> proxyDictionary(const URL& httpProxy, const URL& httpsProxy)
{
if (!httpProxy.isValid() && !httpsProxy.isValid())
return nil;
@@ -1125,7 +1128,7 @@
if (auto port = httpsProxy.port())
[dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPSProxyPort];
}
- return dictionary.autorelease();
+ return dictionary;
ALLOW_DEPRECATED_DECLARATIONS_END
}
@@ -1237,7 +1240,7 @@
configuration._preventsSystemHTTPProxyAuthentication = parameters.preventsSystemHTTPProxyAuthentication;
configuration._requiresSecureHTTPSProxyConnection = parameters.requiresSecureHTTPSProxyConnection;
- configuration.connectionProxyDictionary = (NSDictionary *)parameters.proxyConfiguration.get() ?: proxyDictionary(parameters.httpProxy, parameters.httpsProxy);
+ configuration.connectionProxyDictionary = (NSDictionary *)parameters.proxyConfiguration.get() ?: proxyDictionary(parameters.httpProxy, parameters.httpsProxy).get();
#if PLATFORM(IOS_FAMILY)
if (!m_dataConnectionServiceType.isEmpty())
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm (275764 => 275765)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm 2021-04-09 16:43:03 UTC (rev 275765)
@@ -459,27 +459,21 @@
WKPageSetPageNavigationClient(toAPI(&page), &loaderClient.base);
}
-static WKPolicyDecisionHandler makePolicyDecisionBlock(WKFramePolicyListenerRef listener)
+static BlockPtr<void(WKPolicyDecision)> makePolicyDecisionBlock(WKFramePolicyListenerRef listener)
{
- WKRetain(listener); // Released in the decision handler below.
-
- return adoptNS([^(WKPolicyDecision decision) {
+ return makeBlockPtr([listener = retainWK(listener)](WKPolicyDecision decision) {
switch (decision) {
case WKPolicyDecisionCancel:
- WKFramePolicyListenerIgnore(listener);
+ WKFramePolicyListenerIgnore(listener.get());
break;
-
case WKPolicyDecisionAllow:
- WKFramePolicyListenerUse(listener);
+ WKFramePolicyListenerUse(listener.get());
break;
-
case WKPolicyDecisionBecomeDownload:
- WKFramePolicyListenerDownload(listener);
+ WKFramePolicyListenerDownload(listener.get());
break;
};
-
- WKRelease(listener); // Retained in the context above.
- } copy]).autorelease();
+ });
}
static void setUpPagePolicyClient(WKBrowsingContextController *browsingContext, WebKit::WebPageProxy& page)
@@ -512,7 +506,7 @@
[(NSMutableDictionary *)actionDictionary.get() setObject:[NSURL _web_URLWithWTFString:WebKit::toImpl(originatingFrame)->url().string()] forKey:WKActionOriginatingFrameURLKey];
}
- [policyDelegate browsingContextController:browsingContext decidePolicyForNavigationAction:actionDictionary.get() decisionHandler:makePolicyDecisionBlock(listener)];
+ [policyDelegate browsingContextController:browsingContext decidePolicyForNavigationAction:actionDictionary.get() decisionHandler:makePolicyDecisionBlock(listener).get()];
} else
WKFramePolicyListenerUse(listener);
};
@@ -534,7 +528,7 @@
WKActionFrameNameKey: WebKit::toImpl(frameName)->wrapper()
};
- [policyDelegate browsingContextController:browsingContext decidePolicyForNewWindowAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
+ [policyDelegate browsingContextController:browsingContext decidePolicyForNewWindowAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener).get()];
} else
WKFramePolicyListenerUse(listener);
};
@@ -554,7 +548,7 @@
WKActionCanShowMIMETypeKey: @(canShowMIMEType),
};
- [policyDelegate browsingContextController:browsingContext decidePolicyForResponseAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
+ [policyDelegate browsingContextController:browsingContext decidePolicyForResponseAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener).get()];
} else
WKFramePolicyListenerUse(listener);
};
Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm (275764 => 275765)
--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm 2021-04-09 16:38:44 UTC (rev 275764)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm 2021-04-09 16:43:03 UTC (rev 275765)
@@ -731,7 +731,7 @@
m_properties.animations = other.m_properties.animations;
}
-static NSObject* animationValueFromKeyframeValue(const PlatformCAAnimationRemote::KeyframeValue& keyframeValue)
+static RetainPtr<NSObject> animationValueFromKeyframeValue(const PlatformCAAnimationRemote::KeyframeValue& keyframeValue)
{
switch (keyframeValue.keyframeType()) {
case PlatformCAAnimationRemote::KeyframeValue::NumberKeyType:
@@ -750,7 +750,7 @@
return [NSValue valueWithCATransform3D:keyframeValue.transformValue()];
case PlatformCAAnimationRemote::KeyframeValue::FilterKeyType:
- return PlatformCAFilters::filterValueForOperation(keyframeValue.filterValue(), 0 /* unused */).autorelease();
+ return PlatformCAFilters::filterValueForOperation(keyframeValue.filterValue(), 0 /* unused */);
}
}
@@ -762,8 +762,8 @@
auto basicAnimation = [CABasicAnimation animationWithKeyPath:properties.keyPath];
if (properties.keyValues.size() > 1) {
- [basicAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0])];
- [basicAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1])];
+ [basicAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0]).get()];
+ [basicAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1]).get()];
}
if (properties.timingFunctions.size())
@@ -815,8 +815,8 @@
auto springAnimation = [CASpringAnimation animationWithKeyPath:properties.keyPath];
if (properties.keyValues.size() > 1) {
- [springAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0])];
- [springAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1])];
+ [springAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0]).get()];
+ [springAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1]).get()];
}
if (properties.timingFunctions.size()) {