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

Side by Side Diff: third_party/WebKit/Source/core/events/GestureEvent.cpp

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Rebase and fix comments 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
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "core/events/GestureEvent.h" 26 #include "core/events/GestureEvent.h"
27 27
28 #include "core/dom/Element.h" 28 #include "core/dom/Element.h"
29 #include "wtf/text/AtomicString.h" 29 #include "wtf/text/AtomicString.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 GestureEvent* GestureEvent::create(AbstractView* view, 33 GestureEvent* GestureEvent::create(AbstractView* view,
34 const PlatformGestureEvent& event) { 34 const WebGestureEvent& event) {
35 AtomicString eventType; 35 AtomicString eventType;
36 float deltaX = 0;
37 float deltaY = 0;
38 float velocityX = 0;
39 float velocityY = 0;
40 ScrollInertialPhase inertialPhase =
41 ScrollInertialPhase::ScrollInertialPhaseUnknown;
42 bool synthetic = false;
43 ScrollGranularity deltaUnits = ScrollGranularity::ScrollByPrecisePixel;
44 36
45 GestureSource source = GestureSourceUninitialized; 37 switch (event.type) {
46 switch (event.source()) { 38 case WebInputEvent::GestureScrollBegin:
47 case PlatformGestureSourceTouchpad: 39 eventType = EventTypeNames::gesturescrollstart;
48 source = GestureSourceTouchpad;
49 break; 40 break;
50 case PlatformGestureSourceTouchscreen: 41 case WebInputEvent::GestureScrollEnd:
51 source = GestureSourceTouchscreen; 42 eventType = EventTypeNames::gesturescrollend;
52 break; 43 break;
53 default: 44 case WebInputEvent::GestureScrollUpdate:
54 NOTREACHED(); 45 eventType = EventTypeNames::gesturescrollupdate;
55 }
56
57 switch (event.type()) {
58 case PlatformEvent::GestureScrollBegin:
59 eventType = EventTypeNames::gesturescrollstart;
60 synthetic = event.synthetic();
61 deltaUnits = event.deltaUnits();
62 inertialPhase = event.inertialPhase();
63 break; 46 break;
64 case PlatformEvent::GestureScrollEnd: 47 case WebInputEvent::GestureTap:
65 eventType = EventTypeNames::gesturescrollend;
66 synthetic = event.synthetic();
67 deltaUnits = event.deltaUnits();
68 inertialPhase = event.inertialPhase();
69 break;
70 case PlatformEvent::GestureScrollUpdate:
71 // Only deltaX/Y are used when converting this
72 // back to a PlatformGestureEvent.
73 eventType = EventTypeNames::gesturescrollupdate;
74 deltaX = event.deltaX();
75 deltaY = event.deltaY();
76 inertialPhase = event.inertialPhase();
77 deltaUnits = event.deltaUnits();
78 break;
79 case PlatformEvent::GestureTap:
80 eventType = EventTypeNames::gesturetap; 48 eventType = EventTypeNames::gesturetap;
81 break; 49 break;
82 case PlatformEvent::GestureTapUnconfirmed: 50 case WebInputEvent::GestureTapUnconfirmed:
83 eventType = EventTypeNames::gesturetapunconfirmed; 51 eventType = EventTypeNames::gesturetapunconfirmed;
84 break; 52 break;
85 case PlatformEvent::GestureTapDown: 53 case WebInputEvent::GestureTapDown:
86 eventType = EventTypeNames::gesturetapdown; 54 eventType = EventTypeNames::gesturetapdown;
87 break; 55 break;
88 case PlatformEvent::GestureShowPress: 56 case WebInputEvent::GestureShowPress:
89 eventType = EventTypeNames::gestureshowpress; 57 eventType = EventTypeNames::gestureshowpress;
90 break; 58 break;
91 case PlatformEvent::GestureLongPress: 59 case WebInputEvent::GestureLongPress:
92 eventType = EventTypeNames::gesturelongpress; 60 eventType = EventTypeNames::gesturelongpress;
93 break; 61 break;
94 case PlatformEvent::GestureFlingStart: 62 case WebInputEvent::GestureFlingStart:
95 eventType = EventTypeNames::gestureflingstart; 63 eventType = EventTypeNames::gestureflingstart;
96 velocityX = event.velocityX();
97 velocityY = event.velocityY();
98 break; 64 break;
99 case PlatformEvent::GestureTwoFingerTap: 65 case WebInputEvent::GestureTwoFingerTap:
100 case PlatformEvent::GesturePinchBegin: 66 case WebInputEvent::GesturePinchBegin:
101 case PlatformEvent::GesturePinchEnd: 67 case WebInputEvent::GesturePinchEnd:
102 case PlatformEvent::GesturePinchUpdate: 68 case WebInputEvent::GesturePinchUpdate:
103 case PlatformEvent::GestureTapDownCancel: 69 case WebInputEvent::GestureTapCancel:
104 default: 70 default:
105 return nullptr; 71 return nullptr;
106 } 72 }
107 return new GestureEvent( 73 return new GestureEvent(eventType, view, event);
108 eventType, view, event.globalPosition().x(), event.globalPosition().y(),
109 event.position().x(), event.position().y(), event.getModifiers(), deltaX,
110 deltaY, velocityX, velocityY, inertialPhase, synthetic, deltaUnits,
111 event.timestamp(), event.resendingPluginId(), source);
112 } 74 }
113 75
76 GestureEvent::GestureEvent(const AtomicString& eventType,
77 AbstractView* view,
78 const WebGestureEvent& event)
79 : UIEventWithKeyState(
80 eventType,
81 true,
82 true,
83 view,
84 0,
85 static_cast<PlatformEvent::Modifiers>(event.modifiers),
86 TimeTicks::FromSeconds(event.timeStampSeconds),
87 nullptr),
mustaq 2016/12/15 19:25:46 Curious: shouldn't we have sourceCapabilities=fire
dtapuska 2016/12/15 21:29:38 This event isn't actually ever exposed to the web
88 m_nativeEvent(event) {}
89
114 const AtomicString& GestureEvent::interfaceName() const { 90 const AtomicString& GestureEvent::interfaceName() const {
115 // FIXME: when a GestureEvent.idl interface is defined, return the string 91 // FIXME: when a GestureEvent.idl interface is defined, return the string
116 // "GestureEvent". Until that happens, do not advertise an interface that 92 // "GestureEvent". Until that happens, do not advertise an interface that
117 // does not exist, since it will trip up the bindings integrity checks. 93 // does not exist, since it will trip up the bindings integrity checks.
118 return UIEvent::interfaceName(); 94 return UIEvent::interfaceName();
119 } 95 }
120 96
121 bool GestureEvent::isGestureEvent() const { 97 bool GestureEvent::isGestureEvent() const {
122 return true; 98 return true;
123 } 99 }
124 100
125 GestureEvent::GestureEvent(const AtomicString& type,
126 AbstractView* view,
127 int screenX,
128 int screenY,
129 int clientX,
130 int clientY,
131 PlatformEvent::Modifiers modifiers,
132 float deltaX,
133 float deltaY,
134 float velocityX,
135 float velocityY,
136 ScrollInertialPhase inertialPhase,
137 bool synthetic,
138 ScrollGranularity deltaUnits,
139 TimeTicks platformTimeStamp,
140 int resendingPluginId,
141 GestureSource source)
142 : MouseRelatedEvent(type,
143 true,
144 true,
145 view,
146 0,
147 IntPoint(screenX, screenY),
148 IntPoint(clientX, clientY),
149 IntPoint(0, 0),
150 modifiers,
151 platformTimeStamp,
152 PositionType::Position),
153 m_deltaX(deltaX),
154 m_deltaY(deltaY),
155 m_velocityX(velocityX),
156 m_velocityY(velocityY),
157 m_inertialPhase(inertialPhase),
158 m_synthetic(synthetic),
159 m_deltaUnits(deltaUnits),
160 m_source(source),
161 m_resendingPluginId(resendingPluginId) {}
162
163 DEFINE_TRACE(GestureEvent) { 101 DEFINE_TRACE(GestureEvent) {
164 MouseRelatedEvent::trace(visitor); 102 UIEvent::trace(visitor);
165 } 103 }
166 104
167 } // namespace blink 105 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698