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

Side by Side Diff: third_party/WebKit/Source/platform/WebGestureEvent.cpp

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Add missing copyright on new file 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 2016 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 #include "public/platform/WebGestureEvent.h"
6
7 namespace blink {
8
9 float WebGestureEvent::deltaXInRootFrame() const {
10 if (type == WebInputEvent::GestureScrollBegin)
11 return data.scrollBegin.deltaXHint / m_frameScale;
12 DCHECK(type == WebInputEvent::GestureScrollUpdate);
13 return data.scrollUpdate.deltaX / m_frameScale;
14 }
15
16 float WebGestureEvent::deltaYInRootFrame() const {
17 if (type == WebInputEvent::GestureScrollBegin)
18 return data.scrollBegin.deltaYHint / m_frameScale;
19 DCHECK(type == WebInputEvent::GestureScrollUpdate);
20 return data.scrollUpdate.deltaY / m_frameScale;
21 }
22
23 WebGestureEvent::ScrollUnits WebGestureEvent::deltaUnits() const {
24 if (type == WebInputEvent::GestureScrollBegin)
25 return data.scrollBegin.deltaHintUnits;
26 if (type == WebInputEvent::GestureScrollUpdate)
27 return data.scrollUpdate.deltaUnits;
28 DCHECK(type == WebInputEvent::GestureScrollEnd);
29 return data.scrollEnd.deltaUnits;
30 }
31
32 float WebGestureEvent::pinchScale() const {
33 DCHECK(type == WebInputEvent::GesturePinchUpdate);
34 return data.pinchUpdate.scale;
35 }
36
37 WebGestureEvent::InertialPhaseState WebGestureEvent::inertialPhase() const {
38 if (type == WebInputEvent::GestureScrollBegin)
39 return data.scrollBegin.inertialPhase;
40 if (type == WebInputEvent::GestureScrollUpdate)
41 return data.scrollUpdate.inertialPhase;
42 DCHECK(type == WebInputEvent::GestureScrollEnd);
43 return data.scrollEnd.inertialPhase;
44 }
45
46 bool WebGestureEvent::synthetic() const {
47 if (type == WebInputEvent::GestureScrollBegin)
48 return data.scrollBegin.synthetic;
49 DCHECK(type == WebInputEvent::GestureScrollEnd);
50 return data.scrollEnd.synthetic;
51 }
52
53 float WebGestureEvent::velocityX() const {
54 if (type == WebInputEvent::GestureScrollUpdate)
55 return data.scrollUpdate.velocityX;
56 DCHECK(type == WebInputEvent::GestureFlingStart);
57 return data.flingStart.velocityX;
58 }
59
60 float WebGestureEvent::velocityY() const {
61 if (type == WebInputEvent::GestureScrollUpdate)
62 return data.scrollUpdate.velocityY;
63 DCHECK(type == WebInputEvent::GestureFlingStart);
64 return data.flingStart.velocityY;
65 }
66
67 WebFloatSize WebGestureEvent::tapAreaInRootFrame() const {
68 if (type == WebInputEvent::GestureTwoFingerTap) {
69 return WebFloatSize(data.twoFingerTap.firstFingerWidth / m_frameScale,
70 data.twoFingerTap.firstFingerHeight / m_frameScale);
71 } else if (type == WebInputEvent::GestureLongPress ||
72 type == WebInputEvent::GestureLongTap) {
73 return WebFloatSize(data.longPress.width / m_frameScale,
74 data.longPress.height / m_frameScale);
75 } else if (type == WebInputEvent::GestureTap ||
76 type == WebInputEvent::GestureTapUnconfirmed) {
77 return WebFloatSize(data.tap.width / m_frameScale,
78 data.tap.height / m_frameScale);
79 } else if (type == WebInputEvent::GestureTapDown) {
80 return WebFloatSize(data.tapDown.width / m_frameScale,
81 data.tapDown.height / m_frameScale);
82 } else if (type == WebInputEvent::GestureShowPress) {
83 return WebFloatSize(data.showPress.width / m_frameScale,
84 data.showPress.height / m_frameScale);
85 }
86 // This function is called for all gestures and determined if the tap
87 // area is empty or not; so return an empty rect here.
88 return WebFloatSize();
89 }
90
91 WebFloatPoint WebGestureEvent::positionInRootFrame() const {
92 return WebFloatPoint((x / m_frameScale) + m_frameTranslate.x,
93 (y / m_frameScale) + m_frameTranslate.y);
94 }
95
96 int WebGestureEvent::tapCount() const {
97 DCHECK(type == WebInputEvent::GestureTap);
98 return data.tap.tapCount;
99 }
100
101 void WebGestureEvent::applyTouchAdjustment(WebFloatPoint rootFrameCoords) {
102 // Update the window-relative position of the event so that the node that
103 // was ultimately hit is under this point (i.e. elementFromPoint for the
104 // client co-ordinates in a 'click' event should yield the target). The
105 // global position is intentionally left unmodified because it's intended to
106 // reflect raw co-ordinates unrelated to any content.
107 m_frameTranslate.x = rootFrameCoords.x - (x / m_frameScale);
108 m_frameTranslate.y = rootFrameCoords.y - (y / m_frameScale);
109 }
110
111 void WebGestureEvent::flattenTransform() {
112 if (m_frameScale != 1) {
113 switch (type) {
114 case WebInputEvent::GestureScrollBegin:
115 data.scrollBegin.deltaXHint /= m_frameScale;
116 data.scrollBegin.deltaYHint /= m_frameScale;
117 break;
118 case WebInputEvent::GestureScrollUpdate:
119 data.scrollUpdate.deltaX /= m_frameScale;
120 data.scrollUpdate.deltaY /= m_frameScale;
121 break;
122 case WebInputEvent::GestureTwoFingerTap:
123 data.twoFingerTap.firstFingerWidth /= m_frameScale;
124 data.twoFingerTap.firstFingerHeight /= m_frameScale;
125 break;
126 case WebInputEvent::GestureLongPress:
127 case WebInputEvent::GestureLongTap:
128 data.longPress.width /= m_frameScale;
129 data.longPress.height /= m_frameScale;
130 break;
131 case WebInputEvent::GestureTap:
132 case WebInputEvent::GestureTapUnconfirmed:
133 data.tap.width /= m_frameScale;
134 data.tap.height /= m_frameScale;
135 break;
136 case WebInputEvent::GestureTapDown:
137 data.tapDown.width /= m_frameScale;
138 data.tapDown.height /= m_frameScale;
139 break;
140 case WebInputEvent::GestureShowPress:
141 data.showPress.width /= m_frameScale;
142 data.showPress.height /= m_frameScale;
143 break;
144 default:
145 break;
146 }
147 }
148
149 x = (x / m_frameScale) + m_frameTranslate.x;
150 y = (y / m_frameScale) + m_frameTranslate.y;
151 m_frameTranslate.x = 0;
152 m_frameTranslate.y = 0;
153 m_frameScale = 1;
154 }
155
156 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/PlatformMouseEvent.h ('k') | third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698