OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/chrome/browser/ui/contextual_search/window_gesture_observer.h" | 5 #include "ios/chrome/browser/ui/contextual_search/window_gesture_observer.h" |
6 | 6 |
| 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 8 #error "This file requires ARC support." |
| 9 #endif |
| 10 |
7 @implementation WindowGestureObserver { | 11 @implementation WindowGestureObserver { |
8 NSObject* _target; | 12 NSObject* _target; |
9 SEL _action; | 13 SEL _action; |
10 BOOL _actionPassesSelf; | 14 BOOL _actionPassesSelf; |
11 } | 15 } |
12 | 16 |
13 @synthesize viewToExclude = _viewToExclude; | 17 @synthesize viewToExclude = _viewToExclude; |
14 @synthesize touchedView = _touchedView; | 18 @synthesize touchedView = _touchedView; |
15 | 19 |
16 - (instancetype)initWithTarget:(id)target action:(SEL)action { | 20 - (instancetype)initWithTarget:(id)target action:(SEL)action { |
(...skipping 18 matching lines...) Expand all Loading... |
35 - (void)addTarget:(id)target action:(SEL)action { | 39 - (void)addTarget:(id)target action:(SEL)action { |
36 // No-op. | 40 // No-op. |
37 } | 41 } |
38 | 42 |
39 - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { | 43 - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { |
40 _touchedView = nil; | 44 _touchedView = nil; |
41 for (UITouch* touch in touches) { | 45 for (UITouch* touch in touches) { |
42 if (![[touch view] isDescendantOfView:_viewToExclude]) { | 46 if (![[touch view] isDescendantOfView:_viewToExclude]) { |
43 _touchedView = [touch view]; | 47 _touchedView = [touch view]; |
44 dispatch_async(dispatch_get_main_queue(), ^{ | 48 dispatch_async(dispatch_get_main_queue(), ^{ |
| 49 |
| 50 #pragma clang diagnostic push |
| 51 #pragma clang diagnostic ignored "-Warc-performSelector-leaks" |
45 if (_actionPassesSelf) { | 52 if (_actionPassesSelf) { |
46 [_target performSelector:_action withObject:self]; | 53 [_target performSelector:_action withObject:self]; |
47 } else { | 54 } else { |
48 [_target performSelector:_action]; | 55 [_target performSelector:_action]; |
49 } | 56 } |
| 57 #pragma clang diagnostic pop |
| 58 |
50 }); | 59 }); |
51 // Only invoke from the first qualifying touch. | 60 // Only invoke from the first qualifying touch. |
52 break; | 61 break; |
53 } | 62 } |
54 } | 63 } |
55 | 64 |
56 // Cancels to forward touch to other handlers. | 65 // Cancels to forward touch to other handlers. |
57 self.state = UIGestureRecognizerStateFailed; | 66 self.state = UIGestureRecognizerStateFailed; |
58 [super touchesBegan:touches withEvent:event]; | 67 [super touchesBegan:touches withEvent:event]; |
59 } | 68 } |
60 | 69 |
61 @end | 70 @end |
OLD | NEW |