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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased, fixed a comment in web_input_event_builders_mac.mm Created 3 years, 8 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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 const blink::WebInputEvent& event, 751 const blink::WebInputEvent& event,
752 const gfx::Vector2d& delta, 752 const gfx::Vector2d& delta,
753 float scale) { 753 float scale) {
754 std::unique_ptr<blink::WebInputEvent> scaled_event; 754 std::unique_ptr<blink::WebInputEvent> scaled_event;
755 if (scale == 1.f && delta.IsZero()) 755 if (scale == 1.f && delta.IsZero())
756 return scaled_event; 756 return scaled_event;
757 if (event.type() == blink::WebMouseEvent::MouseWheel) { 757 if (event.type() == blink::WebMouseEvent::MouseWheel) {
758 blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent; 758 blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent;
759 scaled_event.reset(wheel_event); 759 scaled_event.reset(wheel_event);
760 *wheel_event = static_cast<const blink::WebMouseWheelEvent&>(event); 760 *wheel_event = static_cast<const blink::WebMouseWheelEvent&>(event);
761 wheel_event->x += delta.x(); 761 float x = (wheel_event->positionInWidget().x + delta.x()) * scale;
762 wheel_event->y += delta.y(); 762 float y = (wheel_event->positionInWidget().y + delta.y()) * scale;
763 wheel_event->x *= scale; 763 wheel_event->setPositionInWidget(x, y);
764 wheel_event->y *= scale;
765 if (!wheel_event->scrollByPage) { 764 if (!wheel_event->scrollByPage) {
766 wheel_event->deltaX *= scale; 765 wheel_event->deltaX *= scale;
767 wheel_event->deltaY *= scale; 766 wheel_event->deltaY *= scale;
768 wheel_event->wheelTicksX *= scale; 767 wheel_event->wheelTicksX *= scale;
769 wheel_event->wheelTicksY *= scale; 768 wheel_event->wheelTicksY *= scale;
770 } 769 }
771 } else if (blink::WebInputEvent::isMouseEventType(event.type())) { 770 } else if (blink::WebInputEvent::isMouseEventType(event.type())) {
772 blink::WebMouseEvent* mouse_event = new blink::WebMouseEvent; 771 blink::WebMouseEvent* mouse_event = new blink::WebMouseEvent;
773 scaled_event.reset(mouse_event); 772 scaled_event.reset(mouse_event);
774 *mouse_event = static_cast<const blink::WebMouseEvent&>(event); 773 *mouse_event = static_cast<const blink::WebMouseEvent&>(event);
775 mouse_event->x += delta.x(); 774 float x = (mouse_event->positionInWidget().x + delta.x()) * scale;
776 mouse_event->y += delta.y(); 775 float y = (mouse_event->positionInWidget().y + delta.y()) * scale;
777 mouse_event->x *= scale; 776 mouse_event->setPositionInWidget(x, y);
778 mouse_event->y *= scale;
779 mouse_event->movementX *= scale; 777 mouse_event->movementX *= scale;
780 mouse_event->movementY *= scale; 778 mouse_event->movementY *= scale;
781 } else if (blink::WebInputEvent::isTouchEventType(event.type())) { 779 } else if (blink::WebInputEvent::isTouchEventType(event.type())) {
782 blink::WebTouchEvent* touch_event = new blink::WebTouchEvent; 780 blink::WebTouchEvent* touch_event = new blink::WebTouchEvent;
783 scaled_event.reset(touch_event); 781 scaled_event.reset(touch_event);
784 *touch_event = static_cast<const blink::WebTouchEvent&>(event); 782 *touch_event = static_cast<const blink::WebTouchEvent&>(event);
785 for (unsigned i = 0; i < touch_event->touchesLength; i++) { 783 for (unsigned i = 0; i < touch_event->touchesLength; i++) {
786 touch_event->touches[i].position.x += delta.x(); 784 touch_event->touches[i].position.x += delta.x();
787 touch_event->touches[i].position.y += delta.y(); 785 touch_event->touches[i].position.y += delta.y();
788 touch_event->touches[i].position.x *= scale; 786 touch_event->touches[i].position.x *= scale;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 switch (type) { 986 switch (type) {
989 case blink::WebGestureEvent::GestureScrollUpdate: 987 case blink::WebGestureEvent::GestureScrollUpdate:
990 case blink::WebGestureEvent::GesturePinchUpdate: 988 case blink::WebGestureEvent::GesturePinchUpdate:
991 return true; 989 return true;
992 default: 990 default:
993 return false; 991 return false;
994 } 992 }
995 } 993 }
996 994
997 } // namespace ui 995 } // namespace ui
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/WebTouchPoint.h ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698