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

Side by Side Diff: Source/WebKit/chromium/src/WebInputEventConversion.cpp

Issue 12319074: Merge 142571 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 10 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "WebInputEvent.h" 47 #include "WebInputEvent.h"
48 #include "WheelEvent.h" 48 #include "WheelEvent.h"
49 #include "Widget.h" 49 #include "Widget.h"
50 50
51 using namespace WebCore; 51 using namespace WebCore;
52 52
53 namespace WebKit { 53 namespace WebKit {
54 54
55 static const double millisPerSecond = 1000.0; 55 static const double millisPerSecond = 1000.0;
56 56
57 static float widgetScaleFactor(const Widget* widget)
58 {
59 if (!widget)
60 return 1;
61
62 ScrollView* rootView = widget->root();
63 if (!rootView)
64 return 1;
65
66 return rootView->visibleContentScaleFactor();
67 }
68
57 // MakePlatformMouseEvent ----------------------------------------------------- 69 // MakePlatformMouseEvent -----------------------------------------------------
58 70
59 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo useEvent& e) 71 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo useEvent& e)
60 { 72 {
73 float scale = widgetScaleFactor(widget);
61 // FIXME: widget is always toplevel, unless it's a popup. We may be able 74 // FIXME: widget is always toplevel, unless it's a popup. We may be able
62 // to get rid of this once we abstract popups into a WebKit API. 75 // to get rid of this once we abstract popups into a WebKit API.
63 m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); 76 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
64 m_globalPosition = IntPoint(e.globalX, e.globalY); 77 m_globalPosition = IntPoint(e.globalX, e.globalY);
65 #if ENABLE(POINTER_LOCK) 78 #if ENABLE(POINTER_LOCK)
66 m_movementDelta = IntPoint(e.movementX, e.movementY); 79 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale);
67 #endif 80 #endif
68 m_button = static_cast<MouseButton>(e.button); 81 m_button = static_cast<MouseButton>(e.button);
69 82
70 m_modifiers = 0; 83 m_modifiers = 0;
71 if (e.modifiers & WebInputEvent::ShiftKey) 84 if (e.modifiers & WebInputEvent::ShiftKey)
72 m_modifiers |= PlatformEvent::ShiftKey; 85 m_modifiers |= PlatformEvent::ShiftKey;
73 if (e.modifiers & WebInputEvent::ControlKey) 86 if (e.modifiers & WebInputEvent::ControlKey)
74 m_modifiers |= PlatformEvent::CtrlKey; 87 m_modifiers |= PlatformEvent::CtrlKey;
75 if (e.modifiers & WebInputEvent::AltKey) 88 if (e.modifiers & WebInputEvent::AltKey)
76 m_modifiers |= PlatformEvent::AltKey; 89 m_modifiers |= PlatformEvent::AltKey;
(...skipping 20 matching lines...) Expand all
97 110
98 default: 111 default:
99 ASSERT_NOT_REACHED(); 112 ASSERT_NOT_REACHED();
100 } 113 }
101 } 114 }
102 115
103 // PlatformWheelEventBuilder -------------------------------------------------- 116 // PlatformWheelEventBuilder --------------------------------------------------
104 117
105 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo useWheelEvent& e) 118 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo useWheelEvent& e)
106 { 119 {
107 m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); 120 float scale = widgetScaleFactor(widget);
121 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
108 m_globalPosition = IntPoint(e.globalX, e.globalY); 122 m_globalPosition = IntPoint(e.globalX, e.globalY);
109 m_deltaX = e.deltaX; 123 m_deltaX = e.deltaX;
110 m_deltaY = e.deltaY; 124 m_deltaY = e.deltaY;
111 m_wheelTicksX = e.wheelTicksX; 125 m_wheelTicksX = e.wheelTicksX;
112 m_wheelTicksY = e.wheelTicksY; 126 m_wheelTicksY = e.wheelTicksY;
113 m_granularity = e.scrollByPage ? 127 m_granularity = e.scrollByPage ?
114 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; 128 ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
115 129
116 m_type = PlatformEvent::Wheel; 130 m_type = PlatformEvent::Wheel;
117 131
(...skipping 16 matching lines...) Expand all
134 m_unacceleratedScrollingDeltaX = e.deltaX; 148 m_unacceleratedScrollingDeltaX = e.deltaX;
135 m_unacceleratedScrollingDeltaY = e.deltaY; 149 m_unacceleratedScrollingDeltaY = e.deltaY;
136 #endif 150 #endif
137 } 151 }
138 152
139 // PlatformGestureEventBuilder ------------------------------------------------- - 153 // PlatformGestureEventBuilder ------------------------------------------------- -
140 154
141 #if ENABLE(GESTURE_EVENTS) 155 #if ENABLE(GESTURE_EVENTS)
142 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W ebGestureEvent& e) 156 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W ebGestureEvent& e)
143 { 157 {
158 float scale = widgetScaleFactor(widget);
144 switch (e.type) { 159 switch (e.type) {
145 case WebInputEvent::GestureScrollBegin: 160 case WebInputEvent::GestureScrollBegin:
146 m_type = PlatformEvent::GestureScrollBegin; 161 m_type = PlatformEvent::GestureScrollBegin;
147 break; 162 break;
148 case WebInputEvent::GestureScrollEnd: 163 case WebInputEvent::GestureScrollEnd:
149 m_type = PlatformEvent::GestureScrollEnd; 164 m_type = PlatformEvent::GestureScrollEnd;
150 break; 165 break;
151 case WebInputEvent::GestureScrollUpdate: 166 case WebInputEvent::GestureScrollUpdate:
152 m_type = PlatformEvent::GestureScrollUpdate; 167 m_type = PlatformEvent::GestureScrollUpdate;
153 m_deltaX = e.data.scrollUpdate.deltaX; 168 m_deltaX = e.data.scrollUpdate.deltaX / scale;
154 m_deltaY = e.data.scrollUpdate.deltaY; 169 m_deltaY = e.data.scrollUpdate.deltaY / scale;
155 break; 170 break;
156 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 171 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
157 m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation; 172 m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation;
158 m_deltaX = e.data.scrollUpdate.deltaX; 173 m_deltaX = e.data.scrollUpdate.deltaX / scale;
159 m_deltaY = e.data.scrollUpdate.deltaY; 174 m_deltaY = e.data.scrollUpdate.deltaY / scale;
160 break; 175 break;
161 case WebInputEvent::GestureTap: 176 case WebInputEvent::GestureTap:
162 m_type = PlatformEvent::GestureTap; 177 m_type = PlatformEvent::GestureTap;
163 m_area = IntSize(e.data.tap.width, e.data.tap.height); 178 m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap. height / scale));
164 // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123 179 // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
165 m_deltaX = static_cast<int>(e.data.tap.tapCount); 180 m_deltaX = static_cast<int>(e.data.tap.tapCount);
166 break; 181 break;
167 case WebInputEvent::GestureTapDown: 182 case WebInputEvent::GestureTapDown:
168 m_type = PlatformEvent::GestureTapDown; 183 m_type = PlatformEvent::GestureTapDown;
169 m_area = IntSize(e.data.tapDown.width, e.data.tapDown.height); 184 m_area = expandedIntSize(FloatSize(e.data.tapDown.width / scale, e.data. tapDown.height / scale));
170 break; 185 break;
171 case WebInputEvent::GestureTapCancel: 186 case WebInputEvent::GestureTapCancel:
172 m_type = PlatformEvent::GestureTapDownCancel; 187 m_type = PlatformEvent::GestureTapDownCancel;
173 break; 188 break;
174 case WebInputEvent::GestureDoubleTap: 189 case WebInputEvent::GestureDoubleTap:
175 m_type = PlatformEvent::GestureDoubleTap; 190 m_type = PlatformEvent::GestureDoubleTap;
176 break; 191 break;
177 case WebInputEvent::GestureTwoFingerTap: 192 case WebInputEvent::GestureTwoFingerTap:
178 m_type = PlatformEvent::GestureTwoFingerTap; 193 m_type = PlatformEvent::GestureTwoFingerTap;
179 m_area = IntSize(e.data.twoFingerTap.firstFingerWidth, e.data.twoFingerT ap.firstFingerHeight); 194 m_area = expandedIntSize(FloatSize(e.data.twoFingerTap.firstFingerWidth / scale, e.data.twoFingerTap.firstFingerHeight / scale));
180 break; 195 break;
181 case WebInputEvent::GestureLongPress: 196 case WebInputEvent::GestureLongPress:
182 m_type = PlatformEvent::GestureLongPress; 197 m_type = PlatformEvent::GestureLongPress;
183 m_area = IntSize(e.data.longPress.width, e.data.longPress.height); 198 m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.dat a.longPress.height / scale));
184 break; 199 break;
185 case WebInputEvent::GestureLongTap: 200 case WebInputEvent::GestureLongTap:
186 m_type = PlatformEvent::GestureLongTap; 201 m_type = PlatformEvent::GestureLongTap;
187 m_area = IntSize(e.data.longPress.width, e.data.longPress.height); 202 m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.dat a.longPress.height / scale));
188 break; 203 break;
189 case WebInputEvent::GesturePinchBegin: 204 case WebInputEvent::GesturePinchBegin:
190 m_type = PlatformEvent::GesturePinchBegin; 205 m_type = PlatformEvent::GesturePinchBegin;
191 break; 206 break;
192 case WebInputEvent::GesturePinchEnd: 207 case WebInputEvent::GesturePinchEnd:
193 m_type = PlatformEvent::GesturePinchEnd; 208 m_type = PlatformEvent::GesturePinchEnd;
194 break; 209 break;
195 case WebInputEvent::GesturePinchUpdate: 210 case WebInputEvent::GesturePinchUpdate:
196 m_type = PlatformEvent::GesturePinchUpdate; 211 m_type = PlatformEvent::GesturePinchUpdate;
197 // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123 212 // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
198 m_deltaX = e.data.pinchUpdate.scale; 213 m_deltaX = e.data.pinchUpdate.scale;
199 break; 214 break;
200 default: 215 default:
201 ASSERT_NOT_REACHED(); 216 ASSERT_NOT_REACHED();
202 } 217 }
203 m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); 218 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
204 m_globalPosition = IntPoint(e.globalX, e.globalY); 219 m_globalPosition = IntPoint(e.globalX, e.globalY);
205 m_timestamp = e.timeStampSeconds; 220 m_timestamp = e.timeStampSeconds;
206 221
207 m_modifiers = 0; 222 m_modifiers = 0;
208 if (e.modifiers & WebInputEvent::ShiftKey) 223 if (e.modifiers & WebInputEvent::ShiftKey)
209 m_modifiers |= PlatformEvent::ShiftKey; 224 m_modifiers |= PlatformEvent::ShiftKey;
210 if (e.modifiers & WebInputEvent::ControlKey) 225 if (e.modifiers & WebInputEvent::ControlKey)
211 m_modifiers |= PlatformEvent::CtrlKey; 226 m_modifiers |= PlatformEvent::CtrlKey;
212 if (e.modifiers & WebInputEvent::AltKey) 227 if (e.modifiers & WebInputEvent::AltKey)
213 m_modifiers |= PlatformEvent::AltKey; 228 m_modifiers |= PlatformEvent::AltKey;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return WebTouchPoint::StateCancelled; 370 return WebTouchPoint::StateCancelled;
356 if (type == eventNames().touchstartEvent) 371 if (type == eventNames().touchstartEvent)
357 return WebTouchPoint::StatePressed; 372 return WebTouchPoint::StatePressed;
358 if (type == eventNames().touchmoveEvent) 373 if (type == eventNames().touchmoveEvent)
359 return WebTouchPoint::StateMoved; 374 return WebTouchPoint::StateMoved;
360 return WebTouchPoint::StateUndefined; 375 return WebTouchPoint::StateUndefined;
361 } 376 }
362 377
363 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo uchPoint& point) 378 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo uchPoint& point)
364 { 379 {
380 float scale = widgetScaleFactor(widget);
365 m_id = point.id; 381 m_id = point.id;
366 m_state = toPlatformTouchPointState(point.state); 382 m_state = toPlatformTouchPointState(point.state);
367 m_pos = widget->convertFromContainingWindow(point.position); 383 m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scal e, point.position.y / scale));
368 m_screenPos = point.screenPosition; 384 m_screenPos = point.screenPosition;
369 m_radiusY = point.radiusY; 385 m_radiusY = point.radiusY / scale;
370 m_radiusX = point.radiusX; 386 m_radiusX = point.radiusX / scale;
371 m_rotationAngle = point.rotationAngle; 387 m_rotationAngle = point.rotationAngle;
372 m_force = point.force; 388 m_force = point.force;
373 } 389 }
374 390
375 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo uchEvent& event) 391 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo uchEvent& event)
376 { 392 {
377 m_type = toPlatformTouchEventType(event.type); 393 m_type = toPlatformTouchEventType(event.type);
378 394
379 m_modifiers = 0; 395 m_modifiers = 0;
380 if (event.modifiers & WebInputEvent::ShiftKey) 396 if (event.modifiers & WebInputEvent::ShiftKey)
(...skipping 26 matching lines...) Expand all
407 return modifiers; 423 return modifiers;
408 } 424 }
409 425
410 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati on, const WebCore::RenderObject& renderObject) 426 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati on, const WebCore::RenderObject& renderObject)
411 { 427 {
412 return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms) ); 428 return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms) );
413 } 429 }
414 430
415 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev ent, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEv ent& webEvent) 431 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& ev ent, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEv ent& webEvent)
416 { 432 {
433 float scale = widgetScaleFactor(&widget);
417 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; 434 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond;
418 webEvent.modifiers = getWebInputModifiers(event); 435 webEvent.modifiers = getWebInputModifiers(event);
419 436
420 ScrollView* view = widget.parent(); 437 ScrollView* view = widget.root();
421 IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocatio n().x(), event.absoluteLocation().y())); 438 IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocatio n().x(), event.absoluteLocation().y()));
422 webEvent.globalX = event.screenX(); 439 webEvent.globalX = event.screenX();
423 webEvent.globalY = event.screenY(); 440 webEvent.globalY = event.screenY();
424 webEvent.windowX = windowPoint.x(); 441 webEvent.windowX = windowPoint.x() * scale;
425 webEvent.windowY = windowPoint.y(); 442 webEvent.windowY = windowPoint.y() * scale;
426 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), renderObject); 443 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), renderObject);
427 webEvent.x = localPoint.x(); 444 webEvent.x = localPoint.x() * scale;
428 webEvent.y = localPoint.y(); 445 webEvent.y = localPoint.y() * scale;
429 } 446 }
430 447
431 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore:: RenderObject* renderObject, const MouseEvent& event) 448 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore:: RenderObject* renderObject, const MouseEvent& event)
432 { 449 {
433 if (event.type() == eventNames().mousemoveEvent) 450 if (event.type() == eventNames().mousemoveEvent)
434 type = WebInputEvent::MouseMove; 451 type = WebInputEvent::MouseMove;
435 else if (event.type() == eventNames().mouseoutEvent) 452 else if (event.type() == eventNames().mouseoutEvent)
436 type = WebInputEvent::MouseLeave; 453 type = WebInputEvent::MouseLeave;
437 else if (event.type() == eventNames().mouseoverEvent) 454 else if (event.type() == eventNames().mouseoverEvent)
438 type = WebInputEvent::MouseEnter; 455 type = WebInputEvent::MouseEnter;
(...skipping 26 matching lines...) Expand all
465 break; 482 break;
466 case MiddleButton: 483 case MiddleButton:
467 modifiers |= WebInputEvent::MiddleButtonDown; 484 modifiers |= WebInputEvent::MiddleButtonDown;
468 break; 485 break;
469 case RightButton: 486 case RightButton:
470 modifiers |= WebInputEvent::RightButtonDown; 487 modifiers |= WebInputEvent::RightButtonDown;
471 break; 488 break;
472 } 489 }
473 } 490 }
474 #if ENABLE(POINTER_LOCK) 491 #if ENABLE(POINTER_LOCK)
475 movementX = event.webkitMovementX(); 492 float scale = widgetScaleFactor(widget);
476 movementY = event.webkitMovementY(); 493 movementX = event.webkitMovementX() * scale;
494 movementY = event.webkitMovementY() * scale;
477 #endif 495 #endif
478 clickCount = event.detail(); 496 clickCount = event.detail();
479 } 497 }
480 498
481 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore:: RenderObject* renderObject, const TouchEvent& event) 499 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore:: RenderObject* renderObject, const TouchEvent& event)
482 { 500 {
501 float scale = widgetScaleFactor(widget);
483 if (!event.touches()) 502 if (!event.touches())
484 return; 503 return;
485 if (event.touches()->length() != 1) { 504 if (event.touches()->length() != 1) {
486 if (event.touches()->length() || event.type() != eventNames().touchendEv ent || !event.changedTouches() || event.changedTouches()->length() != 1) 505 if (event.touches()->length() || event.type() != eventNames().touchendEv ent || !event.changedTouches() || event.changedTouches()->length() != 1)
487 return; 506 return;
488 } 507 }
489 508
490 const Touch* touch = event.touches()->length() == 1 ? event.touches()->item( 0) : event.changedTouches()->item(0); 509 const Touch* touch = event.touches()->length() == 1 ? event.touches()->item( 0) : event.changedTouches()->item(0);
491 if (touch->identifier()) 510 if (touch->identifier())
492 return; 511 return;
493 512
494 if (event.type() == eventNames().touchstartEvent) 513 if (event.type() == eventNames().touchstartEvent)
495 type = MouseDown; 514 type = MouseDown;
496 else if (event.type() == eventNames().touchmoveEvent) 515 else if (event.type() == eventNames().touchmoveEvent)
497 type = MouseMove; 516 type = MouseMove;
498 else if (event.type() == eventNames().touchendEvent) 517 else if (event.type() == eventNames().touchendEvent)
499 type = MouseUp; 518 type = MouseUp;
500 else 519 else
501 return; 520 return;
502 521
503 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi s); 522 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi s);
504 523
505 button = WebMouseEvent::ButtonLeft; 524 button = WebMouseEvent::ButtonLeft;
506 modifiers |= WebInputEvent::LeftButtonDown; 525 modifiers |= WebInputEvent::LeftButtonDown;
507 clickCount = (type == MouseDown || type == MouseUp); 526 clickCount = (type == MouseDown || type == MouseUp);
508 527
509 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absolute Location(), *renderObject); 528 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absolute Location(), *renderObject);
510 x = localPoint.x(); 529 x = localPoint.x() * scale;
511 y = localPoint.y(); 530 y = localPoint.y() * scale;
512 } 531 }
513 532
514 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const WheelEvent& event) 533 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const WheelEvent& event)
515 { 534 {
516 if (event.type() != eventNames().mousewheelEvent) 535 if (event.type() != eventNames().mousewheelEvent)
517 return; 536 return;
518 type = WebInputEvent::MouseWheel; 537 type = WebInputEvent::MouseWheel;
519 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi s); 538 updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *thi s);
520 deltaX = static_cast<float>(event.rawDeltaX()); 539 deltaX = static_cast<float>(event.rawDeltaX());
521 deltaY = static_cast<float>(event.rawDeltaY()); 540 deltaY = static_cast<float>(event.rawDeltaY());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap)); 574 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap));
556 for (unsigned i = 0; i < numberOfCharacters; ++i) { 575 for (unsigned i = 0; i < numberOfCharacters; ++i) {
557 text[i] = event.keyEvent()->text()[i]; 576 text[i] = event.keyEvent()->text()[i];
558 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; 577 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
559 } 578 }
560 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length()); 579 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length());
561 } 580 }
562 581
563 #if ENABLE(TOUCH_EVENTS) 582 #if ENABLE(TOUCH_EVENTS)
564 583
565 static void addTouchPoints(const AtomicString& touchType, TouchList* touches, We bTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObje ct* renderObject) 584 static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con st WebCore::RenderObject* renderObject)
566 { 585 {
586 float scale = widgetScaleFactor(widget);
567 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned> (WebTouchEvent::touchesLengthCap)); 587 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned> (WebTouchEvent::touchesLengthCap));
568 for (unsigned i = 0; i < numberOfTouches; ++i) { 588 for (unsigned i = 0; i < numberOfTouches; ++i) {
569 const Touch* touch = touches->item(i); 589 const Touch* touch = touches->item(i);
570 590
571 WebTouchPoint point; 591 WebTouchPoint point;
572 point.id = touch->identifier(); 592 point.id = touch->identifier();
573 point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); 593 point.screenPosition = WebPoint(touch->screenX(), touch->screenY());
574 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL ocation(), *renderObject); 594 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteL ocation(), *renderObject);
575 point.radiusX = touch->webkitRadiusX(); 595 point.position.x *= scale;
576 point.radiusY = touch->webkitRadiusY(); 596 point.position.y *= scale;
597 point.radiusX = touch->webkitRadiusX() * scale;
598 point.radiusY = touch->webkitRadiusY() * scale;
577 point.rotationAngle = touch->webkitRotationAngle(); 599 point.rotationAngle = touch->webkitRotationAngle();
578 point.force = touch->webkitForce(); 600 point.force = touch->webkitForce();
579 point.state = toWebTouchPointState(touchType); 601 point.state = toWebTouchPointState(touchType);
580 602
581 touchPoints[i] = point; 603 touchPoints[i] = point;
582 } 604 }
583 *touchPointsLength = numberOfTouches; 605 *touchPointsLength = numberOfTouches;
584 } 606 }
585 607
586 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore:: RenderObject* renderObject, const TouchEvent& event) 608 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore:: RenderObject* renderObject, const TouchEvent& event)
587 { 609 {
588 if (event.type() == eventNames().touchstartEvent) 610 if (event.type() == eventNames().touchstartEvent)
589 type = TouchStart; 611 type = TouchStart;
590 else if (event.type() == eventNames().touchmoveEvent) 612 else if (event.type() == eventNames().touchmoveEvent)
591 type = TouchMove; 613 type = TouchMove;
592 else if (event.type() == eventNames().touchendEvent) 614 else if (event.type() == eventNames().touchendEvent)
593 type = TouchEnd; 615 type = TouchEnd;
594 else if (event.type() == eventNames().touchcancelEvent) 616 else if (event.type() == eventNames().touchcancelEvent)
595 type = TouchCancel; 617 type = TouchCancel;
596 else { 618 else {
597 ASSERT_NOT_REACHED(); 619 ASSERT_NOT_REACHED();
598 type = Undefined; 620 type = Undefined;
599 return; 621 return;
600 } 622 }
601 623
602 modifiers = getWebInputModifiers(event); 624 modifiers = getWebInputModifiers(event);
603 timeStampSeconds = event.timeStamp() / millisPerSecond; 625 timeStampSeconds = event.timeStamp() / millisPerSecond;
604 626
605 addTouchPoints(event.type(), event.touches(), touches, &touchesLength, rende rObject); 627 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt h, renderObject);
606 addTouchPoints(event.type(), event.changedTouches(), changedTouches, &change dTouchesLength, renderObject); 628 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
607 addTouchPoints(event.type(), event.targetTouches(), targetTouches, &targetTo uchesLength, renderObject); 629 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, & targetTouchesLength, renderObject);
608 } 630 }
609 631
610 #endif // ENABLE(TOUCH_EVENTS) 632 #endif // ENABLE(TOUCH_EVENTS)
611 633
612 #if ENABLE(GESTURE_EVENTS) 634 #if ENABLE(GESTURE_EVENTS)
613 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCo re::RenderObject* renderObject, const GestureEvent& event) 635 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCo re::RenderObject* renderObject, const GestureEvent& event)
614 { 636 {
637 float scale = widgetScaleFactor(widget);
615 if (event.type() == eventNames().gesturetapEvent) 638 if (event.type() == eventNames().gesturetapEvent)
616 type = GestureTap; 639 type = GestureTap;
617 else if (event.type() == eventNames().gesturetapdownEvent) 640 else if (event.type() == eventNames().gesturetapdownEvent)
618 type = GestureTapDown; 641 type = GestureTapDown;
619 else if (event.type() == eventNames().gesturescrollstartEvent) 642 else if (event.type() == eventNames().gesturescrollstartEvent)
620 type = GestureScrollBegin; 643 type = GestureScrollBegin;
621 else if (event.type() == eventNames().gesturescrollendEvent) 644 else if (event.type() == eventNames().gesturescrollendEvent)
622 type = GestureScrollEnd; 645 type = GestureScrollEnd;
623 else if (event.type() == eventNames().gesturescrollupdateEvent) { 646 else if (event.type() == eventNames().gesturescrollupdateEvent) {
624 type = GestureScrollUpdate; 647 type = GestureScrollUpdate;
625 data.scrollUpdate.deltaX = event.deltaX(); 648 data.scrollUpdate.deltaX = event.deltaX() * scale;
626 data.scrollUpdate.deltaY = event.deltaY(); 649 data.scrollUpdate.deltaY = event.deltaY() * scale;
627 } 650 }
628 651
629 timeStampSeconds = event.timeStamp() / millisPerSecond; 652 timeStampSeconds = event.timeStamp() / millisPerSecond;
630 modifiers = getWebInputModifiers(event); 653 modifiers = getWebInputModifiers(event);
631 654
632 globalX = event.screenX(); 655 globalX = event.screenX();
633 globalY = event.screenY(); 656 globalY = event.screenY();
634 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject); 657 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject);
635 x = localPoint.x(); 658 x = localPoint.x() * scale;
636 y = localPoint.y(); 659 y = localPoint.y() * scale;
637 } 660 }
638 #endif // ENABLE(GESTURE_EVENTS) 661 #endif // ENABLE(GESTURE_EVENTS)
639 662
640 } // namespace WebKit 663 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/public/WebInputEvent.h ('k') | Source/WebKit/chromium/src/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698