11
11
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
12
12
#import " flutter/shell/platform/darwin/ios/ios_surface.h"
13
13
14
+ FLUTTER_ASSERT_ARC
15
+
14
16
@implementation UIView (FirstResponder)
15
17
- (BOOL )flt_hasFirstResponderInViewHierarchySubtree {
16
18
if (self.isFirstResponder ) {
@@ -91,7 +93,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
91
93
overlay_view.reset ([[FlutterOverlayView alloc ] init ]);
92
94
overlay_view_wrapper.reset ([[FlutterOverlayView alloc ] init ]);
93
95
94
- auto ca_layer = fml::scoped_nsobject<CALayer >{[[ overlay_view.get () layer ] retain ]};
96
+ auto ca_layer = fml::scoped_nsobject<CALayer >{[overlay_view.get () layer ]};
95
97
std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create (ios_context, ca_layer);
96
98
std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface ();
97
99
@@ -105,7 +107,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
105
107
overlay_view_wrapper.reset ([[FlutterOverlayView alloc ] initWithContentsScale: screenScale
106
108
pixelFormat: pixel_format]);
107
109
108
- auto ca_layer = fml::scoped_nsobject<CALayer >{[[ overlay_view.get () layer ] retain ]};
110
+ auto ca_layer = fml::scoped_nsobject<CALayer >{[overlay_view.get () layer ]};
109
111
std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create (ios_context, ca_layer);
110
112
std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface (gr_context);
111
113
@@ -159,12 +161,12 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
159
161
}
160
162
161
163
void FlutterPlatformViewsController::SetFlutterView (UIView* flutter_view) {
162
- flutter_view_.reset ([ flutter_view retain ] );
164
+ flutter_view_.reset (flutter_view);
163
165
}
164
166
165
167
void FlutterPlatformViewsController::SetFlutterViewController (
166
168
UIViewController<FlutterViewResponder>* flutter_view_controller) {
167
- flutter_view_controller_.reset ([ flutter_view_controller retain ] );
169
+ flutter_view_controller_.reset (flutter_view_controller);
168
170
}
169
171
170
172
UIViewController<FlutterViewResponder>* FlutterPlatformViewsController::getFlutterViewController () {
@@ -231,21 +233,19 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
231
233
// Set a unique view identifier, so the platform view can be identified in unit tests.
232
234
platform_view.accessibilityIdentifier =
233
235
[NSString stringWithFormat: @" platform_view[%lld ]" , viewId];
234
- views_[viewId] = fml::scoped_nsobject<NSObject <FlutterPlatformView>>([ embedded_view retain ] );
236
+ views_[viewId] = fml::scoped_nsobject<NSObject <FlutterPlatformView>>(embedded_view);
235
237
236
- FlutterTouchInterceptingView* touch_interceptor = [[[ FlutterTouchInterceptingView alloc ]
238
+ FlutterTouchInterceptingView* touch_interceptor = [[FlutterTouchInterceptingView alloc ]
237
239
initWithEmbeddedView: platform_view
238
240
platformViewsController: GetWeakPtr ()
239
- gestureRecognizersBlockingPolicy: gesture_recognizers_blocking_policies_[viewType]]
240
- autorelease ];
241
+ gestureRecognizersBlockingPolicy: gesture_recognizers_blocking_policies_[viewType]];
241
242
242
243
touch_interceptors_[viewId] =
243
- fml::scoped_nsobject<FlutterTouchInterceptingView>([ touch_interceptor retain ] );
244
+ fml::scoped_nsobject<FlutterTouchInterceptingView>(touch_interceptor);
244
245
245
- ChildClippingView* clipping_view =
246
- [[[ChildClippingView alloc ] initWithFrame: CGRectZero ] autorelease ];
246
+ ChildClippingView* clipping_view = [[ChildClippingView alloc ] initWithFrame: CGRectZero ];
247
247
[clipping_view addSubview: touch_interceptor];
248
- root_views_[viewId] = fml::scoped_nsobject<UIView>([ clipping_view retain ] );
248
+ root_views_[viewId] = fml::scoped_nsobject<UIView>(clipping_view);
249
249
250
250
result (nil );
251
251
}
@@ -307,8 +307,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
307
307
FlutterPlatformViewGestureRecognizersBlockingPolicy gestureRecognizerBlockingPolicy) {
308
308
std::string idString ([factoryId UTF8String ]);
309
309
FML_CHECK (factories_.count (idString) == 0 );
310
- factories_[idString] =
311
- fml::scoped_nsobject<NSObject <FlutterPlatformViewFactory>>([factory retain ]);
310
+ factories_[idString] = fml::scoped_nsobject<NSObject <FlutterPlatformViewFactory>>(factory);
312
311
gesture_recognizers_blocking_policies_[idString] = gestureRecognizerBlockingPolicy;
313
312
}
314
313
@@ -417,7 +416,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
417
416
418
417
long FlutterPlatformViewsController::FindFirstResponderPlatformViewId () {
419
418
for (auto const & [id , root_view] : root_views_) {
420
- if ((UIView*)( root_view.get ()).flt_hasFirstResponderInViewHierarchySubtree ) {
419
+ if ((( UIView*)root_view.get ()).flt_hasFirstResponderInViewHierarchySubtree ) {
421
420
return id ;
422
421
}
423
422
}
@@ -460,7 +459,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
460
459
ChildClippingView* clipView = (ChildClippingView*)embedded_view.superview ;
461
460
462
461
SkMatrix transformMatrix;
463
- NSMutableArray * blurFilters = [[[ NSMutableArray alloc ] init ] autorelease ];
462
+ NSMutableArray * blurFilters = [[NSMutableArray alloc ] init ];
464
463
FML_DCHECK (!clipView.maskView ||
465
464
[clipView.maskView isKindOfClass: [FlutterClippingMaskView class ]]);
466
465
if (clipView.maskView ) {
@@ -530,12 +529,11 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
530
529
// is not supported in Quartz's gaussianBlur CAFilter, so it is not used
531
530
// to blur the PlatformView.
532
531
CGFloat blurRadius = (*iter)->GetFilterMutation ().GetFilter ().asBlur ()->sigma_x ();
533
- UIVisualEffectView* visualEffectView = [[[UIVisualEffectView alloc ]
534
- initWithEffect: [UIBlurEffect effectWithStyle: UIBlurEffectStyleLight]] autorelease ];
535
- PlatformViewFilter* filter =
536
- [[[PlatformViewFilter alloc ] initWithFrame: frameInClipView
537
- blurRadius: blurRadius
538
- visualEffectView: visualEffectView] autorelease ];
532
+ UIVisualEffectView* visualEffectView = [[UIVisualEffectView alloc ]
533
+ initWithEffect: [UIBlurEffect effectWithStyle: UIBlurEffectStyleLight]];
534
+ PlatformViewFilter* filter = [[PlatformViewFilter alloc ] initWithFrame: frameInClipView
535
+ blurRadius: blurRadius
536
+ visualEffectView: visualEffectView];
539
537
if (!filter) {
540
538
canApplyBlurBackdrop = NO ;
541
539
} else {
@@ -950,11 +948,13 @@ @interface DelayingGestureRecognizer : UIGestureRecognizer <UIGestureRecognizerD
950
948
951
949
// Indicates that if the `DelayingGestureRecognizer`'s state should be set to
952
950
// `UIGestureRecognizerStateEnded` during next `touchesEnded` call.
953
- @property (nonatomic ) bool shouldEndInNextTouchesEnded;
951
+ @property (nonatomic ) BOOL shouldEndInNextTouchesEnded;
954
952
955
953
// Indicates that the `DelayingGestureRecognizer`'s `touchesEnded` has been invoked without
956
954
// setting the state to `UIGestureRecognizerStateEnded`.
957
- @property (nonatomic ) bool touchedEndedWithoutBlocking;
955
+ @property (nonatomic ) BOOL touchedEndedWithoutBlocking;
956
+
957
+ @property (nonatomic , readonly ) UIGestureRecognizer* forwardingRecognizer;
958
958
959
959
- (instancetype )initWithTarget : (id )target
960
960
action : (SEL )action
@@ -977,11 +977,13 @@ - (instancetype)initWithTarget:(id)target
977
977
(fml::WeakPtr<flutter::FlutterPlatformViewsController>)platformViewsController ;
978
978
@end
979
979
980
- @implementation FlutterTouchInterceptingView {
981
- fml::scoped_nsobject<DelayingGestureRecognizer> _delayingRecognizer;
982
- FlutterPlatformViewGestureRecognizersBlockingPolicy _blockingPolicy;
983
- UIView* _embeddedView;
984
- }
980
+ @interface FlutterTouchInterceptingView ()
981
+ @property (nonatomic , weak , readonly ) UIView* embeddedView;
982
+ @property (nonatomic , readonly ) DelayingGestureRecognizer* delayingRecognizer;
983
+ @property (nonatomic , readonly ) FlutterPlatformViewGestureRecognizersBlockingPolicy blockingPolicy;
984
+ @end
985
+
986
+ @implementation FlutterTouchInterceptingView
985
987
- (instancetype )initWithEmbeddedView : (UIView*)embeddedView
986
988
platformViewsController :
987
989
(fml::WeakPtr<flutter::FlutterPlatformViewsController>)platformViewsController
@@ -996,47 +998,42 @@ - (instancetype)initWithEmbeddedView:(UIView*)embeddedView
996
998
997
999
[self addSubview: embeddedView];
998
1000
999
- ForwardingGestureRecognizer* forwardingRecognizer = [[[ForwardingGestureRecognizer alloc ]
1000
- initWithTarget: self
1001
- platformViewsController:std: : move ( platformViewsController)] autorelease ];
1001
+ ForwardingGestureRecognizer* forwardingRecognizer =
1002
+ [[ForwardingGestureRecognizer alloc ] initWithTarget: self
1003
+ platformViewsController: platformViewsController];
1002
1004
1003
- _delayingRecognizer.reset ([[DelayingGestureRecognizer alloc ]
1004
- initWithTarget: self
1005
- action: nil
1006
- forwardingRecognizer: forwardingRecognizer]);
1005
+ _delayingRecognizer = [[DelayingGestureRecognizer alloc ] initWithTarget: self
1006
+ action: nil
1007
+ forwardingRecognizer: forwardingRecognizer];
1007
1008
_blockingPolicy = blockingPolicy;
1008
1009
1009
- [self addGestureRecognizer: _delayingRecognizer. get () ];
1010
+ [self addGestureRecognizer: _delayingRecognizer];
1010
1011
[self addGestureRecognizer: forwardingRecognizer];
1011
1012
}
1012
1013
return self;
1013
1014
}
1014
1015
1015
- - (UIView*)embeddedView {
1016
- return [[_embeddedView retain ] autorelease ];
1017
- }
1018
-
1019
1016
- (void )releaseGesture {
1020
- _delayingRecognizer. get () .state = UIGestureRecognizerStateFailed;
1017
+ self. delayingRecognizer .state = UIGestureRecognizerStateFailed;
1021
1018
}
1022
1019
1023
1020
- (void )blockGesture {
1024
1021
switch (_blockingPolicy) {
1025
1022
case FlutterPlatformViewGestureRecognizersBlockingPolicyEager:
1026
1023
// We block all other gesture recognizers immediately in this policy.
1027
- _delayingRecognizer. get () .state = UIGestureRecognizerStateEnded;
1024
+ self. delayingRecognizer .state = UIGestureRecognizerStateEnded;
1028
1025
break ;
1029
1026
case FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded:
1030
- if (_delayingRecognizer. get () .touchedEndedWithoutBlocking ) {
1027
+ if (self. delayingRecognizer .touchedEndedWithoutBlocking ) {
1031
1028
// If touchesEnded of the `DelayingGesureRecognizer` has been already invoked,
1032
1029
// we want to set the state of the `DelayingGesureRecognizer` to
1033
1030
// `UIGestureRecognizerStateEnded` as soon as possible.
1034
- _delayingRecognizer. get () .state = UIGestureRecognizerStateEnded;
1031
+ self. delayingRecognizer .state = UIGestureRecognizerStateEnded;
1035
1032
} else {
1036
1033
// If touchesEnded of the `DelayingGesureRecognizer` has not been invoked,
1037
1034
// We will set a flag to notify the `DelayingGesureRecognizer` to set the state to
1038
1035
// `UIGestureRecognizerStateEnded` when touchesEnded is called.
1039
- _delayingRecognizer. get () .shouldEndInNextTouchesEnded = YES ;
1036
+ self. delayingRecognizer .shouldEndInNextTouchesEnded = YES ;
1040
1037
}
1041
1038
break ;
1042
1039
default :
@@ -1060,19 +1057,12 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
1060
1057
}
1061
1058
1062
1059
- (id )accessibilityContainer {
1063
- return _flutterAccessibilityContainer;
1064
- }
1065
-
1066
- - (void )dealloc {
1067
- [_flutterAccessibilityContainer release ];
1068
- [super dealloc ];
1060
+ return self.flutterAccessibilityContainer ;
1069
1061
}
1070
1062
1071
1063
@end
1072
1064
1073
- @implementation DelayingGestureRecognizer {
1074
- fml::scoped_nsobject<UIGestureRecognizer> _forwardingRecognizer;
1075
- }
1065
+ @implementation DelayingGestureRecognizer
1076
1066
1077
1067
- (instancetype )initWithTarget : (id )target
1078
1068
action : (SEL )action
@@ -1082,9 +1072,9 @@ - (instancetype)initWithTarget:(id)target
1082
1072
self.delaysTouchesBegan = YES ;
1083
1073
self.delaysTouchesEnded = YES ;
1084
1074
self.delegate = self;
1085
- self. shouldEndInNextTouchesEnded = NO ;
1086
- self. touchedEndedWithoutBlocking = NO ;
1087
- _forwardingRecognizer. reset ([forwardingRecognizer retain ]) ;
1075
+ _shouldEndInNextTouchesEnded = NO ;
1076
+ _touchedEndedWithoutBlocking = NO ;
1077
+ _forwardingRecognizer = forwardingRecognizer ;
1088
1078
}
1089
1079
return self;
1090
1080
}
@@ -1093,7 +1083,7 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
1093
1083
shouldBeRequiredToFailByGestureRecognizer : (UIGestureRecognizer*)otherGestureRecognizer {
1094
1084
// The forwarding gesture recognizer should always get all touch events, so it should not be
1095
1085
// required to fail by any other gesture recognizer.
1096
- return otherGestureRecognizer != _forwardingRecognizer. get () && otherGestureRecognizer != self;
1086
+ return otherGestureRecognizer != _forwardingRecognizer && otherGestureRecognizer != self;
1097
1087
}
1098
1088
1099
1089
- (BOOL )gestureRecognizer : (UIGestureRecognizer*)gestureRecognizer
@@ -1158,7 +1148,7 @@ - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
1158
1148
// At the start of each gesture sequence, we reset the `_flutterViewController`,
1159
1149
// so that all the touch events in the same sequence are forwarded to the same
1160
1150
// `_flutterViewController`.
1161
- _flutterViewController.reset ([ _platformViewsController->getFlutterViewController () retain ] );
1151
+ _flutterViewController.reset (_platformViewsController->getFlutterViewController ());
1162
1152
}
1163
1153
[_flutterViewController.get () touchesBegan: touches withEvent: event];
1164
1154
_currentTouchPointersCount += touches.count ;
0 commit comments