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

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

Issue 2586133003: Remove PlatformWheelEvent and use WebMouseWheelEvent instead (Closed)
Patch Set: Adjust function name Created 3 years, 11 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 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
6 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 6 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "core/events/WheelEvent.h" 24 #include "core/events/WheelEvent.h"
25 25
26 #include "core/clipboard/DataTransfer.h" 26 #include "core/clipboard/DataTransfer.h"
27 #include "platform/PlatformMouseEvent.h" 27 #include "platform/PlatformMouseEvent.h"
28 #include "platform/PlatformWheelEvent.h"
29 28
30 namespace blink { 29 namespace blink {
31 30
32 inline static unsigned convertDeltaMode(const PlatformWheelEvent& event) { 31 namespace {
33 return event.granularity() == ScrollByPageWheelEvent 32
34 ? WheelEvent::kDomDeltaPage 33 unsigned convertDeltaMode(const WebMouseWheelEvent& event) {
35 : WheelEvent::kDomDeltaPixel; 34 return event.scrollByPage ? WheelEvent::kDomDeltaPage
35 : WheelEvent::kDomDeltaPixel;
36 } 36 }
37 37
38 // Negate a long value without integer overflow. 38 // Negate a long value without integer overflow.
39 inline static long negateIfPossible(long value) { 39 long negateIfPossible(long value) {
40 if (value == LONG_MIN) 40 if (value == LONG_MIN)
41 return value; 41 return value;
42 return -value; 42 return -value;
43 } 43 }
44 44
45 WheelEvent* WheelEvent::create(const PlatformWheelEvent& event, 45 } // namespace
46
47 WheelEvent* WheelEvent::create(const WebMouseWheelEvent& event,
46 AbstractView* view) { 48 AbstractView* view) {
47 return new WheelEvent( 49 return new WheelEvent(event, view);
48 FloatPoint(event.wheelTicksX(), event.wheelTicksY()),
49 FloatPoint(event.deltaX(), event.deltaY()), convertDeltaMode(event), view,
50 event.globalPosition(), event.position(), event.getModifiers(),
51 MouseEvent::platformModifiersToButtons(event.getModifiers()),
52 event.timestamp(), event.resendingPluginId(),
53 event.hasPreciseScrollingDeltas(),
54 static_cast<Event::RailsMode>(event.getRailsMode()), event.cancelable()
55 #if OS(MACOSX)
56 ,
57 static_cast<WheelEventPhase>(event.phase()),
58 static_cast<WheelEventPhase>(event.momentumPhase())
59 #endif
60 );
61 } 50 }
62 51
63 WheelEvent::WheelEvent() 52 WheelEvent::WheelEvent()
64 : m_deltaX(0), 53 : m_deltaX(0), m_deltaY(0), m_deltaZ(0), m_deltaMode(kDomDeltaPixel) {}
65 m_deltaY(0),
66 m_deltaZ(0),
67 m_deltaMode(kDomDeltaPixel),
68 m_resendingPluginId(-1),
69 m_hasPreciseScrollingDeltas(false),
70 m_railsMode(RailsModeFree) {}
71 54
72 WheelEvent::WheelEvent(const AtomicString& type, 55 WheelEvent::WheelEvent(const AtomicString& type,
73 const WheelEventInit& initializer) 56 const WheelEventInit& initializer)
74 : MouseEvent(type, initializer), 57 : MouseEvent(type, initializer),
75 m_wheelDelta(initializer.wheelDeltaX() ? initializer.wheelDeltaX() 58 m_wheelDelta(initializer.wheelDeltaX() ? initializer.wheelDeltaX()
76 : -initializer.deltaX(), 59 : -initializer.deltaX(),
77 initializer.wheelDeltaY() ? initializer.wheelDeltaY() 60 initializer.wheelDeltaY() ? initializer.wheelDeltaY()
78 : -initializer.deltaY()), 61 : -initializer.deltaY()),
79 m_deltaX(initializer.deltaX() 62 m_deltaX(initializer.deltaX()
80 ? initializer.deltaX() 63 ? initializer.deltaX()
81 : negateIfPossible(initializer.wheelDeltaX())), 64 : negateIfPossible(initializer.wheelDeltaX())),
82 m_deltaY(initializer.deltaY() 65 m_deltaY(initializer.deltaY()
83 ? initializer.deltaY() 66 ? initializer.deltaY()
84 : negateIfPossible(initializer.wheelDeltaY())), 67 : negateIfPossible(initializer.wheelDeltaY())),
85 m_deltaZ(initializer.deltaZ()), 68 m_deltaZ(initializer.deltaZ()),
86 m_deltaMode(initializer.deltaMode()), 69 m_deltaMode(initializer.deltaMode()) {}
87 m_resendingPluginId(-1),
88 m_hasPreciseScrollingDeltas(false),
89 m_railsMode(RailsModeFree)
90 #if OS(MACOSX)
91 ,
92 m_phase(WheelEventPhaseNone),
93 m_momentumPhase(WheelEventPhaseNone)
94 #endif
95 {
96 }
97 70
98 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, 71 WheelEvent::WheelEvent(const WebMouseWheelEvent& event, AbstractView* view)
99 const FloatPoint& rawDelta,
100 unsigned deltaMode,
101 AbstractView* view,
102 const IntPoint& screenLocation,
103 const IntPoint& windowLocation,
104 PlatformEvent::Modifiers modifiers,
105 unsigned short buttons,
106 TimeTicks platformTimeStamp,
107 int resendingPluginId,
108 bool hasPreciseScrollingDeltas,
109 RailsMode railsMode,
110 bool cancelable)
111 : MouseEvent(EventTypeNames::wheel, 72 : MouseEvent(EventTypeNames::wheel,
112 true, 73 true,
113 cancelable, 74 event.isCancelable(),
114 view, 75 view,
115 0,
116 screenLocation.x(),
117 screenLocation.y(),
118 windowLocation.x(),
119 windowLocation.y(),
120 0,
121 0,
122 modifiers,
123 0,
124 buttons,
125 nullptr,
126 platformTimeStamp,
127 PlatformMouseEvent::RealOrIndistinguishable, 76 PlatformMouseEvent::RealOrIndistinguishable,
128 // TODO(zino): Should support canvas hit region because the 77 // TODO(zino): Should support canvas hit region because the
129 // wheel event is a kind of mouse event. Please see 78 // wheel event is a kind of mouse event. Please see
130 // http://crbug.com/594075 79 // http://crbug.com/594075
131 String(), 80 String(),
132 nullptr), 81 event),
133 m_wheelDelta(wheelTicks.x() * TickMultiplier, 82 m_wheelDelta(event.wheelTicksX * TickMultiplier,
134 wheelTicks.y() * TickMultiplier), 83 event.wheelTicksY * TickMultiplier),
135 m_deltaX(-rawDelta.x()), 84 m_deltaX(-event.deltaXInRootFrame()),
136 m_deltaY(-rawDelta.y()), 85 m_deltaY(-event.deltaYInRootFrame()),
137 m_deltaZ(0), 86 m_deltaZ(0),
138 m_deltaMode(deltaMode), 87 m_deltaMode(convertDeltaMode(event)),
139 m_resendingPluginId(resendingPluginId), 88 m_nativeEvent(event) {}
140 m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas),
141 m_railsMode(railsMode)
142 #if OS(MACOSX)
143 ,
144 m_phase(WheelEventPhaseNone),
145 m_momentumPhase(WheelEventPhaseNone)
146 #endif
147 {
148 }
149
150 #if OS(MACOSX)
151 WheelEvent::WheelEvent(const FloatPoint& wheelTicks,
152 const FloatPoint& rawDelta,
153 unsigned deltaMode,
154 AbstractView* view,
155 const IntPoint& screenLocation,
156 const IntPoint& windowLocation,
157 PlatformEvent::Modifiers modifiers,
158 unsigned short buttons,
159 TimeTicks platformTimeStamp,
160 int resendingPluginId,
161 bool hasPreciseScrollingDeltas,
162 RailsMode railsMode,
163 bool cancelable,
164 WheelEventPhase phase,
165 WheelEventPhase momentumPhase)
166 : MouseEvent(EventTypeNames::wheel,
167 true,
168 cancelable,
169 view,
170 0,
171 screenLocation.x(),
172 screenLocation.y(),
173 windowLocation.x(),
174 windowLocation.y(),
175 0,
176 0,
177 modifiers,
178 0,
179 buttons,
180 nullptr,
181 platformTimeStamp,
182 PlatformMouseEvent::RealOrIndistinguishable,
183 // TODO(zino): Should support canvas hit region because the
184 // wheel event is a kind of mouse event. Please see
185 // http://crbug.com/594075
186 String(),
187 nullptr),
188 m_wheelDelta(wheelTicks.x() * TickMultiplier,
189 wheelTicks.y() * TickMultiplier),
190 m_deltaX(-rawDelta.x()),
191 m_deltaY(-rawDelta.y()),
192 m_deltaZ(0),
193 m_deltaMode(deltaMode),
194 m_resendingPluginId(resendingPluginId),
195 m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas),
196 m_railsMode(railsMode),
197 m_phase(phase),
198 m_momentumPhase(momentumPhase) {}
199 #endif
200 89
201 const AtomicString& WheelEvent::interfaceName() const { 90 const AtomicString& WheelEvent::interfaceName() const {
202 return EventNames::WheelEvent; 91 return EventNames::WheelEvent;
203 } 92 }
204 93
205 bool WheelEvent::isMouseEvent() const { 94 bool WheelEvent::isMouseEvent() const {
206 return false; 95 return false;
207 } 96 }
208 97
209 bool WheelEvent::isWheelEvent() const { 98 bool WheelEvent::isWheelEvent() const {
210 return true; 99 return true;
211 } 100 }
212 101
213 EventDispatchMediator* WheelEvent::createMediator() { 102 EventDispatchMediator* WheelEvent::createMediator() {
214 return EventDispatchMediator::create(this); 103 return EventDispatchMediator::create(this);
215 } 104 }
216 105
217 DEFINE_TRACE(WheelEvent) { 106 DEFINE_TRACE(WheelEvent) {
218 MouseEvent::trace(visitor); 107 MouseEvent::trace(visitor);
219 } 108 }
220 109
221 } // namespace blink 110 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/WheelEvent.h ('k') | third_party/WebKit/Source/core/input/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698