Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: ios/chrome/browser/ui/stack_view/card_stack_pinch_gesture_recognizer.mm

Issue 2587023002: Upstream Chrome on iOS source code [8/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #import "ios/chrome/browser/ui/stack_view/card_stack_pinch_gesture_recognizer.h"
6
7 #include "base/logging.h"
8
9 @interface CardStackPinchGestureRecognizer ()
10
11 // Returns the number of non-ended, non-cancelled touches in |event|.
12 - (NSUInteger)numberOfActiveTouchesInEvent:(UIEvent*)event;
13
14 @end
15
16 @implementation CardStackPinchGestureRecognizer
17
18 @synthesize numberOfActiveTouches = numberOfActiveTouches_;
19
20 - (NSUInteger)numberOfActiveTouches {
21 // Certain corner cases can cause |numberOfActiveTouches_| to temporarily
22 // grow to be larger than |[self numberOfTouches]| (this seems to occur only
23 // when the user brings two fingers very closely together). As a safeguard,
24 // ensure that the number returned is never greater than
25 // |[self numberOfTouches]|, as the latter number dictates the greatest index
26 // that a client can pass to |locationOfTouch:| without causing an exception.
27 return std::min(numberOfActiveTouches_, [self numberOfTouches]);
28 }
29
30 - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
31 numberOfActiveTouches_ = [self numberOfActiveTouchesInEvent:event];
32 [super touchesBegan:touches withEvent:event];
33 }
34
35 - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
36 numberOfActiveTouches_ = [self numberOfActiveTouchesInEvent:event];
37 [super touchesEnded:touches withEvent:event];
38 }
39
40 - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event {
41 numberOfActiveTouches_ = [self numberOfActiveTouchesInEvent:event];
42 [super touchesCancelled:touches withEvent:event];
43 }
44
45 - (void)reset {
46 numberOfActiveTouches_ = 0;
47 [super reset];
48 }
49
50 - (NSUInteger)numberOfActiveTouchesInEvent:(UIEvent*)event {
51 NSUInteger count = 0;
52 for (UITouch* touch in [event touchesForGestureRecognizer:self]) {
53 if (touch.phase == UITouchPhaseBegan || touch.phase == UITouchPhaseMoved ||
54 touch.phase == UITouchPhaseStationary)
55 count++;
56 }
57 return count;
58 }
59
60 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/stack_view/card_stack_pinch_gesture_recognizer.h ('k') | ios/chrome/browser/ui/stack_view/card_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698