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

Side by Side Diff: ui/events/blink/blink_event_util.cc

Issue 2036873002: Making EventSender talk to the right WebWidget (for OOPIF support). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback from oshima@. Created 4 years, 2 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/events/blink/blink_event_util.h" 8 #include "ui/events/blink/blink_event_util.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const GestureEventData& data) { 355 const GestureEventData& data) {
356 return CreateWebGestureEvent(data.details, data.time, 356 return CreateWebGestureEvent(data.details, data.time,
357 gfx::PointF(data.x, data.y), 357 gfx::PointF(data.x, data.y),
358 gfx::PointF(data.raw_x, data.raw_y), data.flags, 358 gfx::PointF(data.raw_x, data.raw_y), data.flags,
359 data.unique_touch_event_id); 359 data.unique_touch_event_id);
360 } 360 }
361 361
362 std::unique_ptr<blink::WebInputEvent> ScaleWebInputEvent( 362 std::unique_ptr<blink::WebInputEvent> ScaleWebInputEvent(
363 const blink::WebInputEvent& event, 363 const blink::WebInputEvent& event,
364 float scale) { 364 float scale) {
365 return TranslateAndScaleWebInputEvent(event, 0, 0, scale);
366 }
367
368 std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
369 const blink::WebInputEvent& event,
370 int delta_x,
371 int delta_y,
372 float scale) {
365 std::unique_ptr<blink::WebInputEvent> scaled_event; 373 std::unique_ptr<blink::WebInputEvent> scaled_event;
366 if (scale == 1.f) 374 if (scale == 1.f && delta_x == 0 && delta_y == 0)
367 return scaled_event; 375 return scaled_event;
368 if (event.type == blink::WebMouseEvent::MouseWheel) { 376 if (event.type == blink::WebMouseEvent::MouseWheel) {
369 blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent; 377 blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent;
370 scaled_event.reset(wheel_event); 378 scaled_event.reset(wheel_event);
371 *wheel_event = static_cast<const blink::WebMouseWheelEvent&>(event); 379 *wheel_event = static_cast<const blink::WebMouseWheelEvent&>(event);
380 wheel_event->x += delta_x;
381 wheel_event->y += delta_y;
372 wheel_event->x *= scale; 382 wheel_event->x *= scale;
373 wheel_event->y *= scale; 383 wheel_event->y *= scale;
374 wheel_event->deltaX *= scale; 384 wheel_event->deltaX *= scale;
375 wheel_event->deltaY *= scale; 385 wheel_event->deltaY *= scale;
376 wheel_event->wheelTicksX *= scale; 386 wheel_event->wheelTicksX *= scale;
377 wheel_event->wheelTicksY *= scale; 387 wheel_event->wheelTicksY *= scale;
378 } else if (blink::WebInputEvent::isMouseEventType(event.type)) { 388 } else if (blink::WebInputEvent::isMouseEventType(event.type)) {
379 blink::WebMouseEvent* mouse_event = new blink::WebMouseEvent; 389 blink::WebMouseEvent* mouse_event = new blink::WebMouseEvent;
380 scaled_event.reset(mouse_event); 390 scaled_event.reset(mouse_event);
381 *mouse_event = static_cast<const blink::WebMouseEvent&>(event); 391 *mouse_event = static_cast<const blink::WebMouseEvent&>(event);
392 mouse_event->x += delta_x;
393 mouse_event->y += delta_y;
382 mouse_event->x *= scale; 394 mouse_event->x *= scale;
383 mouse_event->y *= scale; 395 mouse_event->y *= scale;
384 mouse_event->windowX = mouse_event->x; 396 mouse_event->windowX = mouse_event->x;
385 mouse_event->windowY = mouse_event->y; 397 mouse_event->windowY = mouse_event->y;
386 mouse_event->movementX *= scale; 398 mouse_event->movementX *= scale;
387 mouse_event->movementY *= scale; 399 mouse_event->movementY *= scale;
388 } else if (blink::WebInputEvent::isTouchEventType(event.type)) { 400 } else if (blink::WebInputEvent::isTouchEventType(event.type)) {
389 blink::WebTouchEvent* touch_event = new blink::WebTouchEvent; 401 blink::WebTouchEvent* touch_event = new blink::WebTouchEvent;
390 scaled_event.reset(touch_event); 402 scaled_event.reset(touch_event);
391 *touch_event = static_cast<const blink::WebTouchEvent&>(event); 403 *touch_event = static_cast<const blink::WebTouchEvent&>(event);
392 for (unsigned i = 0; i < touch_event->touchesLength; i++) { 404 for (unsigned i = 0; i < touch_event->touchesLength; i++) {
405 touch_event->touches[i].position.x += delta_x;
406 touch_event->touches[i].position.y += delta_y;
393 touch_event->touches[i].position.x *= scale; 407 touch_event->touches[i].position.x *= scale;
394 touch_event->touches[i].position.y *= scale; 408 touch_event->touches[i].position.y *= scale;
395 touch_event->touches[i].radiusX *= scale; 409 touch_event->touches[i].radiusX *= scale;
396 touch_event->touches[i].radiusY *= scale; 410 touch_event->touches[i].radiusY *= scale;
397 } 411 }
398 } else if (blink::WebInputEvent::isGestureEventType(event.type)) { 412 } else if (blink::WebInputEvent::isGestureEventType(event.type)) {
399 blink::WebGestureEvent* gesture_event = new blink::WebGestureEvent; 413 blink::WebGestureEvent* gesture_event = new blink::WebGestureEvent;
400 scaled_event.reset(gesture_event); 414 scaled_event.reset(gesture_event);
401 *gesture_event = static_cast<const blink::WebGestureEvent&>(event); 415 *gesture_event = static_cast<const blink::WebGestureEvent&>(event);
416 gesture_event->x += delta_x;
417 gesture_event->y += delta_y;
402 gesture_event->x *= scale; 418 gesture_event->x *= scale;
403 gesture_event->y *= scale; 419 gesture_event->y *= scale;
404 switch (gesture_event->type) { 420 switch (gesture_event->type) {
405 case blink::WebInputEvent::GestureScrollUpdate: 421 case blink::WebInputEvent::GestureScrollUpdate:
406 gesture_event->data.scrollUpdate.deltaX *= scale; 422 gesture_event->data.scrollUpdate.deltaX *= scale;
407 gesture_event->data.scrollUpdate.deltaY *= scale; 423 gesture_event->data.scrollUpdate.deltaY *= scale;
408 break; 424 break;
409 case blink::WebInputEvent::GestureScrollBegin: 425 case blink::WebInputEvent::GestureScrollBegin:
410 gesture_event->data.scrollBegin.deltaXHint *= scale; 426 gesture_event->data.scrollBegin.deltaXHint *= scale;
411 gesture_event->data.scrollBegin.deltaYHint *= scale; 427 gesture_event->data.scrollBegin.deltaYHint *= scale;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return blink::WebInputEvent::IsRight; 535 return blink::WebInputEvent::IsRight;
520 case DomKeyLocation::NUMPAD: 536 case DomKeyLocation::NUMPAD:
521 return blink::WebInputEvent::IsKeyPad; 537 return blink::WebInputEvent::IsKeyPad;
522 case DomKeyLocation::STANDARD: 538 case DomKeyLocation::STANDARD:
523 break; 539 break;
524 } 540 }
525 return static_cast<blink::WebInputEvent::Modifiers>(0); 541 return static_cast<blink::WebInputEvent::Modifiers>(0);
526 } 542 }
527 543
528 } // namespace ui 544 } // namespace ui
OLDNEW
« ui/events/blink/blink_event_util.h ('K') | « ui/events/blink/blink_event_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698