Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / web / web_state / ui / crw_touch_tracking_recognizer.mm
blob48032530eb8e0921325d1a3e3f1db2b91a27aeca
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "ios/web/web_state/ui/crw_touch_tracking_recognizer.h"
7 @interface CRWTouchTrackingRecognizer () <UIGestureRecognizerDelegate> {
8   __weak id<CRWTouchTrackingDelegate> _delegate;
10 @end
12 @implementation CRWTouchTrackingRecognizer
14 @synthesize touchTrackingDelegate = _delegate;
16 - (id)initWithDelegate:(id<CRWTouchTrackingDelegate>)delegate {
17   if ((self = [super init])) {
18     _delegate = delegate;
19     self.delegate = self;
20   }
21   return self;
24 #pragma mark -
25 #pragma mark UIGestureRecognizer Methods
27 - (void)reset {
28   [super reset];
31 - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
32   [super touchesBegan:touches withEvent:event];
33   [_delegate touched:YES];
36 - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
37   [super touchesMoved:touches withEvent:event];
40 - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
41   [super touchesEnded:touches withEvent:event];
42   self.state = UIGestureRecognizerStateFailed;
43   [_delegate touched:NO];
46 - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event {
47   [super touchesCancelled:touches withEvent:event];
48   [_delegate touched:NO];
51 #pragma mark -
52 #pragma mark UIGestureRecognizerDelegate Method
54 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
55     shouldRecognizeSimultaneouslyWithGestureRecognizer:
56         (UIGestureRecognizer*)otherGestureRecognizer {
57   return YES;
60 @end