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

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

Issue 2586133003: Remove PlatformWheelEvent and use WebMouseWheelEvent instead (Closed)
Patch Set: Address comments 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 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 m_button(0), 179 m_button(0),
180 m_buttons(0), 180 m_buttons(0),
181 m_relatedTarget(nullptr), 181 m_relatedTarget(nullptr),
182 m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) {} 182 m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) {}
183 183
184 MouseEvent::MouseEvent( 184 MouseEvent::MouseEvent(
185 const AtomicString& eventType, 185 const AtomicString& eventType,
186 bool canBubble, 186 bool canBubble,
187 bool cancelable, 187 bool cancelable,
188 AbstractView* abstractView, 188 AbstractView* abstractView,
189 PlatformMouseEvent::SyntheticEventType syntheticEventType,
190 const String& region,
191 const WebMouseEvent& event)
192 : UIEventWithKeyState(
193 eventType,
194 canBubble,
195 cancelable,
196 abstractView,
197 0,
198 static_cast<PlatformEvent::Modifiers>(event.modifiers),
199 TimeTicks::FromSeconds(event.timeStampSeconds),
200 syntheticEventType == PlatformMouseEvent::FromTouch
201 ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities()
202 : InputDeviceCapabilities::
203 doesntFireTouchEventsSourceCapabilities()),
204 m_screenLocation(event.globalX, event.globalY),
205 m_movementDelta(flooredIntPoint(event.movementInRootFrame())),
206 m_positionType(syntheticEventType == PlatformMouseEvent::Positionless
207 ? PositionType::Positionless
208 : PositionType::Position),
209 m_button(0),
210 m_buttons(platformModifiersToButtons(event.modifiers)),
211 m_syntheticEventType(syntheticEventType),
212 m_region(region) {
213 IntPoint rootFrameCoordinates = flooredIntPoint(event.positionInRootFrame());
214 initCoordinatesFromRootFrame(rootFrameCoordinates.x(),
215 rootFrameCoordinates.y());
216 }
217
218 MouseEvent::MouseEvent(
219 const AtomicString& eventType,
220 bool canBubble,
221 bool cancelable,
222 AbstractView* abstractView,
189 int detail, 223 int detail,
190 int screenX, 224 int screenX,
191 int screenY, 225 int screenY,
192 int windowX, 226 int windowX,
193 int windowY, 227 int windowY,
194 int movementX, 228 int movementX,
195 int movementY, 229 int movementY,
196 PlatformEvent::Modifiers modifiers, 230 PlatformEvent::Modifiers modifiers,
197 short button, 231 short button,
198 unsigned short buttons, 232 unsigned short buttons,
(...skipping 19 matching lines...) Expand all
218 m_positionType(syntheticEventType == PlatformMouseEvent::Positionless 252 m_positionType(syntheticEventType == PlatformMouseEvent::Positionless
219 ? PositionType::Positionless 253 ? PositionType::Positionless
220 : PositionType::Position), 254 : PositionType::Position),
221 m_button(button), 255 m_button(button),
222 m_buttons(buttons), 256 m_buttons(buttons),
223 m_relatedTarget(relatedTarget), 257 m_relatedTarget(relatedTarget),
224 m_syntheticEventType(syntheticEventType), 258 m_syntheticEventType(syntheticEventType),
225 m_region(region) { 259 m_region(region) {
226 if (mouseEvent) 260 if (mouseEvent)
227 m_mouseEvent.reset(new PlatformMouseEvent(*mouseEvent)); 261 m_mouseEvent.reset(new PlatformMouseEvent(*mouseEvent));
262 initCoordinatesFromRootFrame(windowX, windowY);
263 }
228 264
265 MouseEvent::MouseEvent(const AtomicString& eventType,
266 const MouseEventInit& initializer)
267 : UIEventWithKeyState(eventType, initializer),
268 m_screenLocation(
269 DoublePoint(initializer.screenX(), initializer.screenY())),
270 m_movementDelta(
271 IntPoint(initializer.movementX(), initializer.movementY())),
272 m_positionType(PositionType::Position),
273 m_button(initializer.button()),
274 m_buttons(initializer.buttons()),
275 m_relatedTarget(initializer.relatedTarget()),
276 m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable),
277 m_region(initializer.region()) {
278 initCoordinates(initializer.clientX(), initializer.clientY());
279 }
280
281 void MouseEvent::initCoordinates(const double clientX, const double clientY) {
282 // Set up initial values for coordinates.
283 // Correct values are computed lazily, see computeRelativePosition.
284 m_clientLocation = DoublePoint(clientX, clientY);
285 m_pageLocation = m_clientLocation + DoubleSize(contentsScrollOffset(view()));
286
287 m_layerLocation = m_pageLocation;
288 m_offsetLocation = m_pageLocation;
289
290 computePageLocation();
291 m_hasCachedRelativePosition = false;
292 }
293
294 void MouseEvent::initCoordinatesFromRootFrame(int windowX, int windowY) {
229 DoublePoint adjustedPageLocation; 295 DoublePoint adjustedPageLocation;
230 DoubleSize scrollOffset; 296 DoubleSize scrollOffset;
231 297
232 LocalFrame* frame = view() && view()->isLocalDOMWindow() 298 LocalFrame* frame = view() && view()->isLocalDOMWindow()
233 ? toLocalDOMWindow(view())->frame() 299 ? toLocalDOMWindow(view())->frame()
234 : nullptr; 300 : nullptr;
235 if (frame && hasPosition()) { 301 if (frame && hasPosition()) {
236 if (FrameView* frameView = frame->view()) { 302 if (FrameView* frameView = frame->view()) {
237 adjustedPageLocation = 303 adjustedPageLocation =
238 frameView->rootFrameToContents(IntPoint(windowX, windowY)); 304 frameView->rootFrameToContents(IntPoint(windowX, windowY));
(...skipping 11 matching lines...) Expand all
250 316
251 // Set up initial values for coordinates. 317 // Set up initial values for coordinates.
252 // Correct values are computed lazily, see computeRelativePosition. 318 // Correct values are computed lazily, see computeRelativePosition.
253 m_layerLocation = m_pageLocation; 319 m_layerLocation = m_pageLocation;
254 m_offsetLocation = m_pageLocation; 320 m_offsetLocation = m_pageLocation;
255 321
256 computePageLocation(); 322 computePageLocation();
257 m_hasCachedRelativePosition = false; 323 m_hasCachedRelativePosition = false;
258 } 324 }
259 325
260 MouseEvent::MouseEvent(const AtomicString& eventType,
261 const MouseEventInit& initializer)
262 : UIEventWithKeyState(eventType, initializer),
263 m_screenLocation(
264 DoublePoint(initializer.screenX(), initializer.screenY())),
265 m_movementDelta(
266 IntPoint(initializer.movementX(), initializer.movementY())),
267 m_positionType(PositionType::Position),
268 m_button(initializer.button()),
269 m_buttons(initializer.buttons()),
270 m_relatedTarget(initializer.relatedTarget()),
271 m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable),
272 m_region(initializer.region()) {
273 initCoordinates(initializer.clientX(), initializer.clientY());
274 }
275
276 void MouseEvent::initCoordinates(const double clientX, const double clientY) {
277 // Set up initial values for coordinates.
278 // Correct values are computed lazily, see computeRelativePosition.
279 m_clientLocation = DoublePoint(clientX, clientY);
280 m_pageLocation = m_clientLocation + DoubleSize(contentsScrollOffset(view()));
281
282 m_layerLocation = m_pageLocation;
283 m_offsetLocation = m_pageLocation;
284
285 computePageLocation();
286 m_hasCachedRelativePosition = false;
287 }
288
289 MouseEvent::~MouseEvent() {} 326 MouseEvent::~MouseEvent() {}
290 327
291 unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers) { 328 unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers) {
292 unsigned short buttons = 0; 329 unsigned short buttons = 0;
293 330
294 if (modifiers & PlatformEvent::LeftButtonDown) 331 if (modifiers & PlatformEvent::LeftButtonDown)
295 buttons |= static_cast<unsigned short>(WebPointerProperties::Buttons::Left); 332 buttons |= static_cast<unsigned short>(WebPointerProperties::Buttons::Left);
296 if (modifiers & PlatformEvent::RightButtonDown) 333 if (modifiers & PlatformEvent::RightButtonDown)
297 buttons |= 334 buttons |=
298 static_cast<unsigned short>(WebPointerProperties::Buttons::Right); 335 static_cast<unsigned short>(WebPointerProperties::Buttons::Right);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 599
563 int MouseEvent::offsetY() { 600 int MouseEvent::offsetY() {
564 if (!hasPosition()) 601 if (!hasPosition())
565 return 0; 602 return 0;
566 if (!m_hasCachedRelativePosition) 603 if (!m_hasCachedRelativePosition)
567 computeRelativePosition(); 604 computeRelativePosition();
568 return std::round(m_offsetLocation.y()); 605 return std::round(m_offsetLocation.y());
569 } 606 }
570 607
571 } // namespace blink 608 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698