OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WebMouseEvent_h | 5 #ifndef WebMouseEvent_h |
6 #define WebMouseEvent_h | 6 #define WebMouseEvent_h |
7 | 7 |
8 #include "WebInputEvent.h" | 8 #include "WebInputEvent.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 11 matching lines...) Expand all Loading... | |
22 class WebMouseEvent : public WebInputEvent, public WebPointerProperties { | 22 class WebMouseEvent : public WebInputEvent, public WebPointerProperties { |
23 public: | 23 public: |
24 int click_count; | 24 int click_count; |
25 | 25 |
26 WebMouseEvent(Type type_param, | 26 WebMouseEvent(Type type_param, |
27 int x_param, | 27 int x_param, |
28 int y_param, | 28 int y_param, |
29 int global_x_param, | 29 int global_x_param, |
30 int global_y_param, | 30 int global_y_param, |
31 int modifiers_param, | 31 int modifiers_param, |
32 double time_stamp_seconds_param) | 32 double time_stamp_seconds_param, |
33 int id_param = kMousePointerId) | |
dtapuska
2017/05/01 15:49:05
Why do you use an int here and an int32_t for the
lanwei
2017/05/01 23:51:21
Done.
| |
33 : WebInputEvent(sizeof(WebMouseEvent), | 34 : WebInputEvent(sizeof(WebMouseEvent), |
34 type_param, | 35 type_param, |
35 modifiers_param, | 36 modifiers_param, |
36 time_stamp_seconds_param), | 37 time_stamp_seconds_param), |
37 WebPointerProperties(), | 38 WebPointerProperties(id_param), |
38 position_in_widget_(x_param, y_param), | 39 position_in_widget_(x_param, y_param), |
39 position_in_screen_(global_x_param, global_y_param) {} | 40 position_in_screen_(global_x_param, global_y_param) {} |
40 | 41 |
41 WebMouseEvent(Type type_param, | 42 WebMouseEvent(Type type_param, |
42 WebFloatPoint position, | 43 WebFloatPoint position, |
43 WebFloatPoint global_position, | 44 WebFloatPoint global_position, |
44 Button button_param, | 45 Button button_param, |
45 int click_count_param, | 46 int click_count_param, |
46 int modifiers_param, | 47 int modifiers_param, |
47 double time_stamp_seconds_param) | 48 double time_stamp_seconds_param, |
49 int id_param = kMousePointerId) | |
48 : WebInputEvent(sizeof(WebMouseEvent), | 50 : WebInputEvent(sizeof(WebMouseEvent), |
49 type_param, | 51 type_param, |
50 modifiers_param, | 52 modifiers_param, |
51 time_stamp_seconds_param), | 53 time_stamp_seconds_param), |
52 WebPointerProperties(button_param, PointerType::kMouse), | 54 WebPointerProperties(id_param, button_param, PointerType::kMouse), |
53 click_count(click_count_param), | 55 click_count(click_count_param), |
54 position_in_widget_(floor(position.x), floor(position.y)), | 56 position_in_widget_(floor(position.x), floor(position.y)), |
55 position_in_screen_(floor(global_position.x), | 57 position_in_screen_(floor(global_position.x), |
56 floor(global_position.y)) {} | 58 floor(global_position.y)) {} |
57 | 59 |
58 WebMouseEvent(Type type_param, | 60 WebMouseEvent(Type type_param, |
59 int modifiers_param, | 61 int modifiers_param, |
60 double time_stamp_seconds_param) | 62 double time_stamp_seconds_param, |
63 int id_param = kMousePointerId) | |
61 : WebMouseEvent(sizeof(WebMouseEvent), | 64 : WebMouseEvent(sizeof(WebMouseEvent), |
62 type_param, | 65 type_param, |
63 modifiers_param, | 66 modifiers_param, |
64 time_stamp_seconds_param) {} | 67 time_stamp_seconds_param, |
68 id_param) {} | |
65 | 69 |
66 WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent)) {} | 70 WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent), kMousePointerId) {} |
67 | 71 |
68 bool FromTouch() const { | 72 bool FromTouch() const { |
69 return (GetModifiers() & kIsCompatibilityEventForTouch) != 0; | 73 return (GetModifiers() & kIsCompatibilityEventForTouch) != 0; |
70 } | 74 } |
71 | 75 |
72 #if INSIDE_BLINK | 76 #if INSIDE_BLINK |
73 BLINK_PLATFORM_EXPORT WebMouseEvent(Type type_param, | 77 BLINK_PLATFORM_EXPORT WebMouseEvent(Type type_param, |
74 const WebGestureEvent&, | 78 const WebGestureEvent&, |
75 Button button_param, | 79 Button button_param, |
76 int click_count_param, | 80 int click_count_param, |
77 int modifiers_param, | 81 int modifiers_param, |
78 double time_stamp_seconds_param); | 82 double time_stamp_seconds_param, |
83 int id_param = kMousePointerId); | |
79 | 84 |
80 BLINK_PLATFORM_EXPORT WebFloatPoint MovementInRootFrame() const; | 85 BLINK_PLATFORM_EXPORT WebFloatPoint MovementInRootFrame() const; |
81 BLINK_PLATFORM_EXPORT WebFloatPoint PositionInRootFrame() const; | 86 BLINK_PLATFORM_EXPORT WebFloatPoint PositionInRootFrame() const; |
82 | 87 |
83 // Sets any scaled values to be their computed values and sets |frameScale| | 88 // Sets any scaled values to be their computed values and sets |frameScale| |
84 // back to 1 and |translateX|, |translateY| back to 0. | 89 // back to 1 and |translateX|, |translateY| back to 0. |
85 BLINK_PLATFORM_EXPORT WebMouseEvent FlattenTransform() const; | 90 BLINK_PLATFORM_EXPORT WebMouseEvent FlattenTransform() const; |
86 #endif | 91 #endif |
87 | 92 |
88 WebFloatPoint PositionInWidget() const { return position_in_widget_; } | 93 WebFloatPoint PositionInWidget() const { return position_in_widget_; } |
89 void SetPositionInWidget(float x, float y) { | 94 void SetPositionInWidget(float x, float y) { |
90 position_in_widget_ = WebFloatPoint(floor(x), floor(y)); | 95 position_in_widget_ = WebFloatPoint(floor(x), floor(y)); |
91 } | 96 } |
92 | 97 |
93 WebFloatPoint PositionInScreen() const { return position_in_screen_; } | 98 WebFloatPoint PositionInScreen() const { return position_in_screen_; } |
94 void SetPositionInScreen(float x, float y) { | 99 void SetPositionInScreen(float x, float y) { |
95 position_in_screen_ = WebFloatPoint(floor(x), floor(y)); | 100 position_in_screen_ = WebFloatPoint(floor(x), floor(y)); |
96 } | 101 } |
97 | 102 |
98 protected: | 103 protected: |
99 explicit WebMouseEvent(unsigned size_param) | 104 explicit WebMouseEvent(unsigned size_param, int id) |
100 : WebInputEvent(size_param), WebPointerProperties() {} | 105 : WebInputEvent(size_param), WebPointerProperties(id) {} |
101 | 106 |
102 WebMouseEvent(unsigned size_param, | 107 WebMouseEvent(unsigned size_param, |
103 Type type, | 108 Type type, |
104 int modifiers, | 109 int modifiers, |
105 double time_stamp_seconds) | 110 double time_stamp_seconds, |
111 int id) | |
106 : WebInputEvent(size_param, type, modifiers, time_stamp_seconds), | 112 : WebInputEvent(size_param, type, modifiers, time_stamp_seconds), |
107 WebPointerProperties() {} | 113 WebPointerProperties(id) {} |
108 | 114 |
109 void FlattenTransformSelf(); | 115 void FlattenTransformSelf(); |
110 | 116 |
111 private: | 117 private: |
112 // Widget coordinate, which is relative to the bound of current RenderWidget | 118 // Widget coordinate, which is relative to the bound of current RenderWidget |
113 // (e.g. a plugin or OOPIF inside a RenderView). Similar to viewport | 119 // (e.g. a plugin or OOPIF inside a RenderView). Similar to viewport |
114 // coordinates but without DevTools emulation transform or overscroll applied. | 120 // coordinates but without DevTools emulation transform or overscroll applied. |
115 WebFloatPoint position_in_widget_; | 121 WebFloatPoint position_in_widget_; |
116 | 122 |
117 // Screen coordinate | 123 // Screen coordinate |
118 WebFloatPoint position_in_screen_; | 124 WebFloatPoint position_in_screen_; |
119 }; | 125 }; |
120 | 126 |
121 #pragma pack(pop) | 127 #pragma pack(pop) |
122 | 128 |
123 } // namespace blink | 129 } // namespace blink |
124 | 130 |
125 #endif // WebMouseEvent_h | 131 #endif // WebMouseEvent_h |
OLD | NEW |