Chromium Code Reviews| 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 { |
| 11 | 11 |
| 12 class WebGestureEvent; | 12 class WebGestureEvent; |
| 13 | 13 |
| 14 // See WebInputEvent.h for details why this pack is here. | 14 // See WebInputEvent.h for details why this pack is here. |
| 15 #pragma pack(push, 4) | 15 #pragma pack(push, 4) |
| 16 | 16 |
| 17 // WebMouseEvent -------------------------------------------------------------- | 17 // WebMouseEvent -------------------------------------------------------------- |
| 18 | 18 |
| 19 // TODO(mustaq): We are truncating |float|s to integers whenever setting | 19 // TODO(mustaq): We are truncating |float|s to integers whenever setting |
| 20 // coordinate values, to avoid regressions for now. Will be fixed later | 20 // coordinate values, to avoid regressions for now. Will be fixed later |
| 21 // on. crbug.com/456625 | 21 // on. crbug.com/456625 |
| 22 class WebMouseEvent : public WebInputEvent, public WebPointerProperties { | 22 class WebMouseEvent : public WebInputEvent, public WebPointerProperties { |
| 23 public: | 23 public: |
| 24 static constexpr int kMousePointerId = std::numeric_limits<int>::max(); | |
|
haraken
2017/05/02 00:27:23
kMousePointerId => kUndefinedMousePointerID or som
| |
| 25 | |
| 24 int click_count; | 26 int click_count; |
| 25 | 27 |
| 26 WebMouseEvent(Type type_param, | 28 WebMouseEvent(Type type_param, |
| 27 int x_param, | 29 int x_param, |
| 28 int y_param, | 30 int y_param, |
| 29 int global_x_param, | 31 int global_x_param, |
| 30 int global_y_param, | 32 int global_y_param, |
| 31 int modifiers_param, | 33 int modifiers_param, |
| 32 double time_stamp_seconds_param) | 34 double time_stamp_seconds_param, |
| 35 int id_param = kMousePointerId) | |
| 33 : WebInputEvent(sizeof(WebMouseEvent), | 36 : WebInputEvent(sizeof(WebMouseEvent), |
| 34 type_param, | 37 type_param, |
| 35 modifiers_param, | 38 modifiers_param, |
| 36 time_stamp_seconds_param), | 39 time_stamp_seconds_param), |
| 37 WebPointerProperties(), | 40 WebPointerProperties(id_param), |
| 38 position_in_widget_(x_param, y_param), | 41 position_in_widget_(x_param, y_param), |
| 39 position_in_screen_(global_x_param, global_y_param) {} | 42 position_in_screen_(global_x_param, global_y_param) {} |
| 40 | 43 |
| 41 WebMouseEvent(Type type_param, | 44 WebMouseEvent(Type type_param, |
| 42 WebFloatPoint position, | 45 WebFloatPoint position, |
| 43 WebFloatPoint global_position, | 46 WebFloatPoint global_position, |
| 44 Button button_param, | 47 Button button_param, |
| 45 int click_count_param, | 48 int click_count_param, |
| 46 int modifiers_param, | 49 int modifiers_param, |
| 47 double time_stamp_seconds_param) | 50 double time_stamp_seconds_param, |
| 51 int id_param = kMousePointerId) | |
| 48 : WebInputEvent(sizeof(WebMouseEvent), | 52 : WebInputEvent(sizeof(WebMouseEvent), |
| 49 type_param, | 53 type_param, |
| 50 modifiers_param, | 54 modifiers_param, |
| 51 time_stamp_seconds_param), | 55 time_stamp_seconds_param), |
| 52 WebPointerProperties(button_param, PointerType::kMouse), | 56 WebPointerProperties(id_param, button_param, PointerType::kMouse), |
| 53 click_count(click_count_param), | 57 click_count(click_count_param), |
| 54 position_in_widget_(floor(position.x), floor(position.y)), | 58 position_in_widget_(floor(position.x), floor(position.y)), |
| 55 position_in_screen_(floor(global_position.x), | 59 position_in_screen_(floor(global_position.x), |
| 56 floor(global_position.y)) {} | 60 floor(global_position.y)) {} |
| 57 | 61 |
| 58 WebMouseEvent(Type type_param, | 62 WebMouseEvent(Type type_param, |
| 59 int modifiers_param, | 63 int modifiers_param, |
| 60 double time_stamp_seconds_param) | 64 double time_stamp_seconds_param, |
| 65 int id_param = kMousePointerId) | |
| 61 : WebMouseEvent(sizeof(WebMouseEvent), | 66 : WebMouseEvent(sizeof(WebMouseEvent), |
| 62 type_param, | 67 type_param, |
| 63 modifiers_param, | 68 modifiers_param, |
| 64 time_stamp_seconds_param) {} | 69 time_stamp_seconds_param, |
| 70 id_param) {} | |
| 65 | 71 |
| 66 WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent)) {} | 72 WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent), kMousePointerId) {} |
| 67 | 73 |
| 68 bool FromTouch() const { | 74 bool FromTouch() const { |
| 69 return (GetModifiers() & kIsCompatibilityEventForTouch) != 0; | 75 return (GetModifiers() & kIsCompatibilityEventForTouch) != 0; |
| 70 } | 76 } |
| 71 | 77 |
| 72 #if INSIDE_BLINK | 78 #if INSIDE_BLINK |
| 73 BLINK_PLATFORM_EXPORT WebMouseEvent(Type type_param, | 79 BLINK_PLATFORM_EXPORT WebMouseEvent(Type type_param, |
| 74 const WebGestureEvent&, | 80 const WebGestureEvent&, |
| 75 Button button_param, | 81 Button button_param, |
| 76 int click_count_param, | 82 int click_count_param, |
| 77 int modifiers_param, | 83 int modifiers_param, |
| 78 double time_stamp_seconds_param); | 84 double time_stamp_seconds_param, |
| 85 int id_param = kMousePointerId); | |
| 79 | 86 |
| 80 BLINK_PLATFORM_EXPORT WebFloatPoint MovementInRootFrame() const; | 87 BLINK_PLATFORM_EXPORT WebFloatPoint MovementInRootFrame() const; |
| 81 BLINK_PLATFORM_EXPORT WebFloatPoint PositionInRootFrame() const; | 88 BLINK_PLATFORM_EXPORT WebFloatPoint PositionInRootFrame() const; |
| 82 | 89 |
| 83 // Sets any scaled values to be their computed values and sets |frameScale| | 90 // Sets any scaled values to be their computed values and sets |frameScale| |
| 84 // back to 1 and |translateX|, |translateY| back to 0. | 91 // back to 1 and |translateX|, |translateY| back to 0. |
| 85 BLINK_PLATFORM_EXPORT WebMouseEvent FlattenTransform() const; | 92 BLINK_PLATFORM_EXPORT WebMouseEvent FlattenTransform() const; |
| 86 #endif | 93 #endif |
| 87 | 94 |
| 88 WebFloatPoint PositionInWidget() const { return position_in_widget_; } | 95 WebFloatPoint PositionInWidget() const { return position_in_widget_; } |
| 89 void SetPositionInWidget(float x, float y) { | 96 void SetPositionInWidget(float x, float y) { |
| 90 position_in_widget_ = WebFloatPoint(floor(x), floor(y)); | 97 position_in_widget_ = WebFloatPoint(floor(x), floor(y)); |
| 91 } | 98 } |
| 92 | 99 |
| 93 WebFloatPoint PositionInScreen() const { return position_in_screen_; } | 100 WebFloatPoint PositionInScreen() const { return position_in_screen_; } |
| 94 void SetPositionInScreen(float x, float y) { | 101 void SetPositionInScreen(float x, float y) { |
| 95 position_in_screen_ = WebFloatPoint(floor(x), floor(y)); | 102 position_in_screen_ = WebFloatPoint(floor(x), floor(y)); |
| 96 } | 103 } |
| 97 | 104 |
| 98 protected: | 105 protected: |
| 99 explicit WebMouseEvent(unsigned size_param) | 106 WebMouseEvent(unsigned size_param, int id) |
| 100 : WebInputEvent(size_param), WebPointerProperties() {} | 107 : WebInputEvent(size_param), WebPointerProperties(id) {} |
| 101 | 108 |
| 102 WebMouseEvent(unsigned size_param, | 109 WebMouseEvent(unsigned size_param, |
| 103 Type type, | 110 Type type, |
| 104 int modifiers, | 111 int modifiers, |
| 105 double time_stamp_seconds) | 112 double time_stamp_seconds, |
| 113 int id) | |
| 106 : WebInputEvent(size_param, type, modifiers, time_stamp_seconds), | 114 : WebInputEvent(size_param, type, modifiers, time_stamp_seconds), |
| 107 WebPointerProperties() {} | 115 WebPointerProperties(id) {} |
| 108 | 116 |
| 109 void FlattenTransformSelf(); | 117 void FlattenTransformSelf(); |
| 110 | 118 |
| 111 private: | 119 private: |
| 112 // Widget coordinate, which is relative to the bound of current RenderWidget | 120 // Widget coordinate, which is relative to the bound of current RenderWidget |
| 113 // (e.g. a plugin or OOPIF inside a RenderView). Similar to viewport | 121 // (e.g. a plugin or OOPIF inside a RenderView). Similar to viewport |
| 114 // coordinates but without DevTools emulation transform or overscroll applied. | 122 // coordinates but without DevTools emulation transform or overscroll applied. |
| 115 WebFloatPoint position_in_widget_; | 123 WebFloatPoint position_in_widget_; |
| 116 | 124 |
| 117 // Screen coordinate | 125 // Screen coordinate |
| 118 WebFloatPoint position_in_screen_; | 126 WebFloatPoint position_in_screen_; |
| 119 }; | 127 }; |
| 120 | 128 |
| 121 #pragma pack(pop) | 129 #pragma pack(pop) |
| 122 | 130 |
| 123 } // namespace blink | 131 } // namespace blink |
| 124 | 132 |
| 125 #endif // WebMouseEvent_h | 133 #endif // WebMouseEvent_h |
| OLD | NEW |