OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" | 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" |
6 | 6 |
7 #include "base/mac/scoped_nsautorelease_pool.h" | 7 #include "base/mac/scoped_nsautorelease_pool.h" |
8 #include "content/browser/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
9 | 9 |
10 // Unlike some event APIs, Apple does not provide a way to programmatically | 10 // Unlike some event APIs, Apple does not provide a way to programmatically |
11 // build a zoom event. To work around this, we leverage ObjectiveC's flexible | 11 // build a zoom event. To work around this, we leverage ObjectiveC's flexible |
12 // typing and build up an object with the right interface to provide a zoom | 12 // typing and build up an object with the right interface to provide a zoom |
13 // event. | 13 // event. |
14 @interface SyntheticPinchEvent : NSObject | 14 @interface SyntheticPinchEvent : NSObject |
15 | 15 |
16 // Populated based on desired zoom level. | 16 // Populated based on desired zoom level. |
17 @property CGFloat magnification; | 17 @property CGFloat magnification; |
18 @property NSPoint locationInWindow; | 18 @property NSPoint locationInWindow; |
19 @property NSEventType type; | 19 @property NSEventType type; |
20 | 20 |
21 // Filled with default values. | 21 // Filled with default values. |
22 @property(readonly) CGFloat deltaX; | 22 @property(readonly) CGFloat deltaX; |
23 @property(readonly) CGFloat deltaY; | 23 @property(readonly) CGFloat deltaY; |
24 @property(readonly) NSEventModifierFlags modifierFlags; | 24 //@property(readonly) NSEventModifierFlags modifierFlags; |
25 @property(readonly) NSTimeInterval timestamp; | 25 @property(readonly) NSTimeInterval timestamp; |
26 | 26 |
27 @end | 27 @end |
28 | 28 |
29 @implementation SyntheticPinchEvent | 29 @implementation SyntheticPinchEvent |
30 | 30 |
31 @synthesize magnification = magnification_; | 31 @synthesize magnification = magnification_; |
32 @synthesize locationInWindow = locationInWindow_; | 32 @synthesize locationInWindow = locationInWindow_; |
33 @synthesize type = type_; | 33 @synthesize type = type_; |
34 @synthesize deltaX = deltaX_; | 34 @synthesize deltaX = deltaX_; |
35 @synthesize deltaY = deltaY_; | 35 @synthesize deltaY = deltaY_; |
36 @synthesize modifierFlags = modifierFlags_; | 36 //@synthesize modifierFlags = modifierFlags_; |
37 @synthesize timestamp = timestamp_; | 37 @synthesize timestamp = timestamp_; |
38 | 38 |
39 - (id)initWithMagnification:(float)magnification | 39 - (id)initWithMagnification:(float)magnification |
40 locationInWindow:(NSPoint)location { | 40 locationInWindow:(NSPoint)location { |
41 self = [super init]; | 41 self = [super init]; |
42 if (self) { | 42 if (self) { |
43 type_ = NSEventTypeMagnify; | 43 type_ = NSEventTypeMagnify; |
44 magnification_ = magnification; | 44 magnification_ = magnification; |
45 locationInWindow_ = location; | 45 locationInWindow_ = location; |
46 | 46 |
47 deltaX_ = 0; | 47 deltaX_ = 0; |
48 deltaY_ = 0; | 48 deltaY_ = 0; |
49 modifierFlags_ = 0; | 49 // modifierFlags_ = 0; |
50 | 50 |
51 // Default timestamp to current time. | 51 // Default timestamp to current time. |
52 timestamp_ = [[NSDate date] timeIntervalSince1970]; | 52 timestamp_ = [[NSDate date] timeIntervalSince1970]; |
53 } | 53 } |
54 | 54 |
55 return self; | 55 return self; |
56 } | 56 } |
57 | 57 |
58 + (id)eventWithMagnification:(float)magnification | 58 + (id)eventWithMagnification:(float)magnification |
59 locationInWindow:(NSPoint)location { | 59 locationInWindow:(NSPoint)location { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 default: | 113 default: |
114 break; | 114 break; |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 // This event wasn't handled yet, forward to the base class. | 118 // This event wasn't handled yet, forward to the base class. |
119 SyntheticGestureTargetBase::DispatchInputEventToPlatform(event); | 119 SyntheticGestureTargetBase::DispatchInputEventToPlatform(event); |
120 } | 120 } |
121 | 121 |
122 } // namespace content | 122 } // namespace content |
OLD | NEW |