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

Side by Side Diff: third_party/WebKit/public/platform/WebMouseEvent.h

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Truncated to int on input, git cl format Created 3 years, 8 months 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
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 class WebMouseEvent : public WebInputEvent, public WebPointerProperties { 19 class WebMouseEvent : public WebInputEvent, public WebPointerProperties {
20 public: 20 public:
21 // Renderer coordinates. Similar to viewport coordinates but without
22 // DevTools emulation transform or overscroll applied. i.e. the coordinates
23 // in Chromium's RenderView bounds.
24 int x;
25 int y;
26
27 // Screen coordinate
28 int globalX;
29 int globalY;
30
31 int clickCount; 21 int clickCount;
32 22
33 WebMouseEvent(Type typeParam, 23 WebMouseEvent(Type typeParam,
34 int xParam, 24 int xParam,
35 int yParam, 25 int yParam,
36 int globalXParam, 26 int globalXParam,
37 int globalYParam, 27 int globalYParam,
38 int modifiersParam, 28 int modifiersParam,
39 double timeStampSecondsParam) 29 double timeStampSecondsParam)
40 : WebInputEvent(sizeof(WebMouseEvent), 30 : WebInputEvent(sizeof(WebMouseEvent),
41 typeParam, 31 typeParam,
42 modifiersParam, 32 modifiersParam,
43 timeStampSecondsParam), 33 timeStampSecondsParam),
44 WebPointerProperties(), 34 WebPointerProperties(),
45 x(xParam), 35 m_positionInWidget(xParam, yParam),
46 y(yParam), 36 m_positionInScreen(globalXParam, globalYParam) {}
47 globalX(globalXParam),
48 globalY(globalYParam) {}
49 37
50 WebMouseEvent(Type typeParam, 38 WebMouseEvent(Type typeParam,
51 WebFloatPoint position, 39 WebFloatPoint position,
52 WebFloatPoint globalPosition, 40 WebFloatPoint globalPosition,
53 Button buttonParam, 41 Button buttonParam,
54 int clickCountParam, 42 int clickCountParam,
55 int modifiersParam, 43 int modifiersParam,
56 double timeStampSecondsParam) 44 double timeStampSecondsParam)
57 : WebInputEvent(sizeof(WebMouseEvent), 45 : WebInputEvent(sizeof(WebMouseEvent),
58 typeParam, 46 typeParam,
59 modifiersParam, 47 modifiersParam,
60 timeStampSecondsParam), 48 timeStampSecondsParam),
61 WebPointerProperties(buttonParam, PointerType::Mouse), 49 WebPointerProperties(buttonParam, PointerType::Mouse),
62 x(position.x), 50 clickCount(clickCountParam),
63 y(position.y), 51 m_positionInWidget(floor(position.x), floor(position.y)),
dtapuska 2017/03/31 14:04:18 Can we add a comment regarding the floor... refere
mustaq 2017/03/31 15:50:32 Added a class comment above.
64 globalX(globalPosition.x), 52 m_positionInScreen(floor(globalPosition.x), floor(globalPosition.y)) {}
65 globalY(globalPosition.y),
66 clickCount(clickCountParam) {}
67 53
68 WebMouseEvent(Type typeParam, 54 WebMouseEvent(Type typeParam,
69 int modifiersParam, 55 int modifiersParam,
70 double timeStampSecondsParam) 56 double timeStampSecondsParam)
71 : WebMouseEvent(sizeof(WebMouseEvent), 57 : WebMouseEvent(sizeof(WebMouseEvent),
72 typeParam, 58 typeParam,
73 modifiersParam, 59 modifiersParam,
74 timeStampSecondsParam) {} 60 timeStampSecondsParam) {}
75 61
76 WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent)) {} 62 WebMouseEvent() : WebMouseEvent(sizeof(WebMouseEvent)) {}
(...skipping 11 matching lines...) Expand all
88 double timeStampSecondsParam); 74 double timeStampSecondsParam);
89 75
90 BLINK_PLATFORM_EXPORT WebFloatPoint movementInRootFrame() const; 76 BLINK_PLATFORM_EXPORT WebFloatPoint movementInRootFrame() const;
91 BLINK_PLATFORM_EXPORT WebFloatPoint positionInRootFrame() const; 77 BLINK_PLATFORM_EXPORT WebFloatPoint positionInRootFrame() const;
92 78
93 // Sets any scaled values to be their computed values and sets |frameScale| 79 // Sets any scaled values to be their computed values and sets |frameScale|
94 // back to 1 and |translateX|, |translateY| back to 0. 80 // back to 1 and |translateX|, |translateY| back to 0.
95 BLINK_PLATFORM_EXPORT WebMouseEvent flattenTransform() const; 81 BLINK_PLATFORM_EXPORT WebMouseEvent flattenTransform() const;
96 #endif 82 #endif
97 83
84 WebFloatPoint positionInWidget() const { return m_positionInWidget; }
85 void setPositionInWidget(float x, float y) {
86 m_positionInWidget = WebFloatPoint(floor(x), floor(y));
dtapuska 2017/03/31 14:04:18 Same as why we are doing the floor...
mustaq 2017/03/31 15:50:32 Ditto.
87 }
88
89 WebFloatPoint positionInScreen() const { return m_positionInScreen; }
90 void setPositionInScreen(float x, float y) {
91 m_positionInScreen = WebFloatPoint(floor(x), floor(y));
dtapuska 2017/03/31 14:04:18 here too :-)
mustaq 2017/03/31 15:50:32 Ditto too :-)
92 }
93
98 protected: 94 protected:
99 explicit WebMouseEvent(unsigned sizeParam) 95 explicit WebMouseEvent(unsigned sizeParam)
100 : WebInputEvent(sizeParam), WebPointerProperties() {} 96 : WebInputEvent(sizeParam), WebPointerProperties() {}
101 97
102 WebMouseEvent(unsigned sizeParam, 98 WebMouseEvent(unsigned sizeParam,
103 Type type, 99 Type type,
104 int modifiers, 100 int modifiers,
105 double timeStampSeconds) 101 double timeStampSeconds)
106 : WebInputEvent(sizeParam, type, modifiers, timeStampSeconds), 102 : WebInputEvent(sizeParam, type, modifiers, timeStampSeconds),
107 WebPointerProperties() {} 103 WebPointerProperties() {}
108 104
109 void flattenTransformSelf(); 105 void flattenTransformSelf();
106
107 private:
108 // Widget coordinates, i.e., the coordinates in Chromium's RenderView
109 // bounds. Similar to viewport coordinates but without DevTools emulation
110 // transform or overscroll applied.
111 WebFloatPoint m_positionInWidget;
112
113 // Screen coordinate
114 WebFloatPoint m_positionInScreen;
110 }; 115 };
111 116
112 #pragma pack(pop) 117 #pragma pack(pop)
113 118
114 } // namespace blink 119 } // namespace blink
115 120
116 #endif // WebMouseEvent_h 121 #endif // WebMouseEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698