Title: [260306] trunk/Source/WebKitLegacy/mac
- Revision
- 260306
- Author
- ddkil...@apple.com
- Date
- 2020-04-17 20:04:46 -0700 (Fri, 17 Apr 2020)
Log Message
[iOS WK1] -[_WebSafeForwarder asyncForwarder] uses non-static dispatch_once_t predicate
<https://webkit.org/b/210625>
Reviewed by Daniel Bates.
Remove use of dispatch_once to initialize
_WebSafeForwarder._asyncForwarder, and modernize both
_WebSafeForwarder and _WebSafeAsyncForwarder classes.
* WebView/WebView.mm:
(@interface _WebSafeAsyncForwarder):
- Make `_forwarder` weak. It can't be strong or a retain cycle
would be created between this object and _WebSafeForwarder.
- Change return type from `id` to `instancetype` for
-[_WebSafeAsyncForwarder initWithForwarder:].
(@interface _WebSafeForwarder):
- Make `_target` weak and rename from `target`.
- Make `_defaultTarget` weak and rename from `defaultTarget`.
- Rename `_asyncForwarder` from `asyncForwarder`.
- Delete unused `asyncForwarderPred`.
- Replace -asyncForwarder method declaration with a @property
definition.
(-[_WebSafeForwarder initWithTarget:defaultTarget:]):
- Update for instance variable renames.
- Iniitalize `_asyncForwarder` here. There are (at most) eight
_WebSafeForwarder objects created per WebView, so creating
this object in the constructor seems reasonable.
(-[_WebSafeForwarder asyncForwarder:]):
- Delete this method (and use of dispatch_once, fixing the bug).
Replace with @synthesize statement.
(-[_WebSafeForwarder dealloc:]):
- Update for instance variable renames, and assign nil to all
instance variables.
(-[_WebSafeForwarder forwardInvocation:]):
(-[_WebSafeForwarder respondsToSelector:]):
(-[_WebSafeForwarder methodSignatureForSelector:]):
- Update for instance variable renames.
(-[_WebSafeForwarder initWithForwarder:]):
- Change return type from `id` to `instancetype`.
Modified Paths
Diff
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (260305 => 260306)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-04-18 01:37:23 UTC (rev 260305)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-04-18 03:04:46 UTC (rev 260306)
@@ -1,3 +1,45 @@
+2020-04-17 David Kilzer <ddkil...@apple.com>
+
+ [iOS WK1] -[_WebSafeForwarder asyncForwarder] uses non-static dispatch_once_t predicate
+ <https://webkit.org/b/210625>
+
+ Reviewed by Daniel Bates.
+
+ Remove use of dispatch_once to initialize
+ _WebSafeForwarder._asyncForwarder, and modernize both
+ _WebSafeForwarder and _WebSafeAsyncForwarder classes.
+
+ * WebView/WebView.mm:
+ (@interface _WebSafeAsyncForwarder):
+ - Make `_forwarder` weak. It can't be strong or a retain cycle
+ would be created between this object and _WebSafeForwarder.
+ - Change return type from `id` to `instancetype` for
+ -[_WebSafeAsyncForwarder initWithForwarder:].
+ (@interface _WebSafeForwarder):
+ - Make `_target` weak and rename from `target`.
+ - Make `_defaultTarget` weak and rename from `defaultTarget`.
+ - Rename `_asyncForwarder` from `asyncForwarder`.
+ - Delete unused `asyncForwarderPred`.
+ - Replace -asyncForwarder method declaration with a @property
+ definition.
+ (-[_WebSafeForwarder initWithTarget:defaultTarget:]):
+ - Update for instance variable renames.
+ - Iniitalize `_asyncForwarder` here. There are (at most) eight
+ _WebSafeForwarder objects created per WebView, so creating
+ this object in the constructor seems reasonable.
+ (-[_WebSafeForwarder asyncForwarder:]):
+ - Delete this method (and use of dispatch_once, fixing the bug).
+ Replace with @synthesize statement.
+ (-[_WebSafeForwarder dealloc:]):
+ - Update for instance variable renames, and assign nil to all
+ instance variables.
+ (-[_WebSafeForwarder forwardInvocation:]):
+ (-[_WebSafeForwarder respondsToSelector:]):
+ (-[_WebSafeForwarder methodSignatureForSelector:]):
+ - Update for instance variable renames.
+ (-[_WebSafeForwarder initWithForwarder:]):
+ - Change return type from `id` to `instancetype`.
+
2020-04-17 Rob Buis <rb...@igalia.com>
Move allowPlugins to FrameLoader
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (260305 => 260306)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-04-18 01:37:23 UTC (rev 260305)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-04-18 03:04:46 UTC (rev 260306)
@@ -549,25 +549,24 @@
@class _WebSafeForwarder;
@interface _WebSafeAsyncForwarder : NSObject {
- _WebSafeForwarder *_forwarder;
+ __weak _WebSafeForwarder *_forwarder;
}
-- (id)initWithForwarder:(_WebSafeForwarder *)forwarder;
+- (instancetype)initWithForwarder:(_WebSafeForwarder *)forwarder;
@end
#endif
@interface _WebSafeForwarder : NSObject
{
- id target; // Non-retained. Don't retain delegates.
- id defaultTarget;
+ __weak id _target;
+ __weak id _defaultTarget;
#if PLATFORM(IOS_FAMILY)
- _WebSafeAsyncForwarder *asyncForwarder;
- dispatch_once_t asyncForwarderPred;
+ _WebSafeAsyncForwarder *_asyncForwarder;
#endif
}
- (instancetype)initWithTarget:(id)target defaultTarget:(id)defaultTarget;
#if PLATFORM(IOS_FAMILY)
+@property (nonatomic, readonly, strong) id asyncForwarder;
- (void)clearTarget;
-- (id)asyncForwarder;
#endif
@end
@@ -5334,34 +5333,34 @@
// Used to send messages to delegates that implement informal protocols.
-- (instancetype)initWithTarget:(id)t defaultTarget:(id)dt
+- (instancetype)initWithTarget:(id)target defaultTarget:(id)defaultTarget
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
- target = t; // Non retained.
- defaultTarget = dt;
+ _target = target;
+ _defaultTarget = defaultTarget;
+#if PLATFORM(IOS_FAMILY)
+ _asyncForwarder = [[_WebSafeAsyncForwarder alloc] initWithForwarder:self];
+#endif
return self;
}
#if PLATFORM(IOS_FAMILY)
-- (id)asyncForwarder
-{
- dispatch_once(&asyncForwarderPred, ^{
- asyncForwarder = [[_WebSafeAsyncForwarder alloc] initWithForwarder:self];
- });
- return asyncForwarder;
-}
+@synthesize asyncForwarder=_asyncForwarder;
- (void)dealloc
{
- [asyncForwarder release];
+ _target = nil;
+ _defaultTarget = nil;
+ [_asyncForwarder release];
+ _asyncForwarder = nil;
+
[super dealloc];
}
- (void)clearTarget
{
- target = nil;
+ _target = nil;
}
#endif
@@ -5374,17 +5373,17 @@
return;
}
#endif
- if ([target respondsToSelector:[invocation selector]]) {
+ if ([_target respondsToSelector:invocation.selector]) {
@try {
- [invocation invokeWithTarget:target];
+ [invocation invokeWithTarget:_target];
} @catch(id exception) {
- ReportDiscardedDelegateException([invocation selector], exception);
+ ReportDiscardedDelegateException(invocation.selector, exception);
}
return;
}
- if ([defaultTarget respondsToSelector:[invocation selector]])
- [invocation invokeWithTarget:defaultTarget];
+ if ([_defaultTarget respondsToSelector:invocation.selector])
+ [invocation invokeWithTarget:_defaultTarget];
// Do nothing quietly if method not implemented.
}
@@ -5392,13 +5391,13 @@
#if PLATFORM(IOS_FAMILY)
- (BOOL)respondsToSelector:(SEL)aSelector
{
- return [defaultTarget respondsToSelector:aSelector];
+ return [_defaultTarget respondsToSelector:aSelector];
}
#endif
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
- return [defaultTarget methodSignatureForSelector:aSelector];
+ return [_defaultTarget methodSignatureForSelector:aSelector];
}
@end
@@ -5406,7 +5405,7 @@
#if PLATFORM(IOS_FAMILY)
@implementation _WebSafeAsyncForwarder
-- (id)initWithForwarder:(_WebSafeForwarder *)forwarder
+- (instancetype)initWithForwarder:(_WebSafeForwarder *)forwarder
{
if (!(self = [super init]))
return nil;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes