Chromium Code Reviews| Index: ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_recognizer.mm |
| diff --git a/ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_recognizer.mm b/ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_recognizer.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..efb4dd3303f0b3499c4ae6dcf155d7ff1c4de7dd |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_recognizer.mm |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_recognizer.h" |
| + |
| +#import <UIKit/UIGestureRecognizerSubclass.h> |
| +#include "base/mac/scoped_nsobject.h" |
|
justincohen
2017/04/05 14:22:07
sort?
|
| + |
| +@interface OverscrollActionsGestureRecognizer () { |
| + base::scoped_nsprotocol<id> target_; |
| + SEL action_; |
| +} |
| +@end |
| + |
| +@implementation OverscrollActionsGestureRecognizer |
| + |
| +- (instancetype)initWithTarget:(id)target action:(SEL)action { |
| + self = [super initWithTarget:target action:action]; |
| + if (self) { |
| + target_.reset([target retain]); |
| + action_ = action; |
| + } |
| + return self; |
| +} |
| + |
| +- (void)reset { |
| + [super reset]; |
| + [target_ performSelector:action_ withObject:self]; |
| +} |
| + |
| +- (void)removeTarget:(id)target action:(SEL)action { |
|
justincohen
2017/04/05 14:22:07
This is all voodoo to me. Why is this necessary?
|
| + [super removeTarget:target action:action]; |
| + if (target == target_) { |
| + target_.reset(); |
| + } |
| +} |
| + |
| +@end |