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

Side by Side Diff: ui/events/blink/input_handler_proxy.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
« no previous file with comments | « ui/events/blink/blink_event_util.cc ('k') | ui/events/blink/input_handler_proxy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 input_handler_->MouseUp(); 507 input_handler_->MouseUp();
508 } 508 }
509 return DID_NOT_HANDLE; 509 return DID_NOT_HANDLE;
510 } 510 }
511 case WebInputEvent::MouseMove: { 511 case WebInputEvent::MouseMove: {
512 const WebMouseEvent& mouse_event = 512 const WebMouseEvent& mouse_event =
513 static_cast<const WebMouseEvent&>(event); 513 static_cast<const WebMouseEvent&>(event);
514 // TODO(davemoore): This should never happen, but bug #326635 showed some 514 // TODO(davemoore): This should never happen, but bug #326635 showed some
515 // surprising crashes. 515 // surprising crashes.
516 CHECK(input_handler_); 516 CHECK(input_handler_);
517 input_handler_->MouseMoveAt(gfx::Point(mouse_event.x, mouse_event.y)); 517 input_handler_->MouseMoveAt(gfx::Point(mouse_event.positionInWidget().x,
518 mouse_event.positionInWidget().y));
518 return DID_NOT_HANDLE; 519 return DID_NOT_HANDLE;
519 } 520 }
520 case WebInputEvent::MouseLeave: { 521 case WebInputEvent::MouseLeave: {
521 CHECK(input_handler_); 522 CHECK(input_handler_);
522 input_handler_->MouseLeave(); 523 input_handler_->MouseLeave();
523 return DID_NOT_HANDLE; 524 return DID_NOT_HANDLE;
524 } 525 }
525 526
526 default: 527 default:
527 if (WebInputEvent::isKeyboardEventType(event.type())) { 528 if (WebInputEvent::isKeyboardEventType(event.type())) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 if (touchpad_and_wheel_scroll_latching_enabled_) { 700 if (touchpad_and_wheel_scroll_latching_enabled_) {
700 if (gesture_scroll_on_impl_thread_) { 701 if (gesture_scroll_on_impl_thread_) {
701 TRACE_EVENT_INSTANT2("input", 702 TRACE_EVENT_INSTANT2("input",
702 "InputHandlerProxy::handle_input wheel scroll", 703 "InputHandlerProxy::handle_input wheel scroll",
703 TRACE_EVENT_SCOPE_THREAD, "deltaX", scroll_delta.x(), 704 TRACE_EVENT_SCOPE_THREAD, "deltaX", scroll_delta.x(),
704 "deltaY", scroll_delta.y()); 705 "deltaY", scroll_delta.y());
705 706
706 cc::ScrollStateData scroll_state_update_data; 707 cc::ScrollStateData scroll_state_update_data;
707 scroll_state_update_data.delta_x = scroll_delta.x(); 708 scroll_state_update_data.delta_x = scroll_delta.x();
708 scroll_state_update_data.delta_y = scroll_delta.y(); 709 scroll_state_update_data.delta_y = scroll_delta.y();
709 scroll_state_update_data.position_x = wheel_event.x; 710 scroll_state_update_data.position_x = wheel_event.positionInWidget().x;
710 scroll_state_update_data.position_y = wheel_event.y; 711 scroll_state_update_data.position_y = wheel_event.positionInWidget().y;
711 cc::ScrollState scroll_state_update(scroll_state_update_data); 712 cc::ScrollState scroll_state_update(scroll_state_update_data);
712 713
713 cc::InputHandlerScrollResult scroll_result = 714 cc::InputHandlerScrollResult scroll_result =
714 input_handler_->ScrollBy(&scroll_state_update); 715 input_handler_->ScrollBy(&scroll_state_update);
715 716
716 if (!scroll_result.did_scroll && 717 if (!scroll_result.did_scroll &&
717 input_handler_->ScrollingShouldSwitchtoMainThread()) { 718 input_handler_->ScrollingShouldSwitchtoMainThread()) {
718 gesture_scroll_on_impl_thread_ = false; 719 gesture_scroll_on_impl_thread_ = false;
719 return DID_NOT_HANDLE; 720 return DID_NOT_HANDLE;
720 } 721 }
721 722
722 HandleOverscroll(gfx::Point(wheel_event.x, wheel_event.y), scroll_result, 723 HandleOverscroll(gfx::Point(wheel_event.positionInWidget().x,
723 false); 724 wheel_event.positionInWidget().y),
725 scroll_result, false);
724 if (scroll_result.did_scroll) { 726 if (scroll_result.did_scroll) {
725 return listener_properties == cc::EventListenerProperties::kPassive 727 return listener_properties == cc::EventListenerProperties::kPassive
726 ? DID_HANDLE_NON_BLOCKING 728 ? DID_HANDLE_NON_BLOCKING
727 : DID_HANDLE; 729 : DID_HANDLE;
728 } 730 }
729 731
730 return DROP_EVENT; 732 return DROP_EVENT;
731 } else { 733 } else {
732 return DID_NOT_HANDLE; 734 return DID_NOT_HANDLE;
733 } 735 }
734 } else { // !touchpad_and_wheel_scroll_latching_enabled_ 736 } else { // !touchpad_and_wheel_scroll_latching_enabled_
735 cc::ScrollStateData scroll_state_begin_data; 737 cc::ScrollStateData scroll_state_begin_data;
736 scroll_state_begin_data.position_x = wheel_event.x; 738 scroll_state_begin_data.position_x = wheel_event.positionInWidget().x;
737 scroll_state_begin_data.position_y = wheel_event.y; 739 scroll_state_begin_data.position_y = wheel_event.positionInWidget().y;
738 scroll_state_begin_data.is_beginning = true; 740 scroll_state_begin_data.is_beginning = true;
739 cc::ScrollState scroll_state_begin(scroll_state_begin_data); 741 cc::ScrollState scroll_state_begin(scroll_state_begin_data);
740 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( 742 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
741 &scroll_state_begin, cc::InputHandler::WHEEL); 743 &scroll_state_begin, cc::InputHandler::WHEEL);
742 744
743 RecordMainThreadScrollingReasons( 745 RecordMainThreadScrollingReasons(
744 blink::WebGestureDeviceTouchpad, 746 blink::WebGestureDeviceTouchpad,
745 scroll_status.main_thread_scrolling_reasons); 747 scroll_status.main_thread_scrolling_reasons);
746 748
747 mouse_wheel_result_ = 749 mouse_wheel_result_ =
748 (listener_properties == cc::EventListenerProperties::kPassive) 750 (listener_properties == cc::EventListenerProperties::kPassive)
749 ? DID_HANDLE_NON_BLOCKING 751 ? DID_HANDLE_NON_BLOCKING
750 : DROP_EVENT; 752 : DROP_EVENT;
751 RecordScrollingThreadStatus(blink::WebGestureDeviceTouchpad, 753 RecordScrollingThreadStatus(blink::WebGestureDeviceTouchpad,
752 scroll_status.main_thread_scrolling_reasons); 754 scroll_status.main_thread_scrolling_reasons);
753 755
754 switch (scroll_status.thread) { 756 switch (scroll_status.thread) {
755 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: { 757 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: {
756 TRACE_EVENT_INSTANT2("input", 758 TRACE_EVENT_INSTANT2("input",
757 "InputHandlerProxy::handle_input wheel scroll", 759 "InputHandlerProxy::handle_input wheel scroll",
758 TRACE_EVENT_SCOPE_THREAD, "deltaX", 760 TRACE_EVENT_SCOPE_THREAD, "deltaX",
759 scroll_delta.x(), "deltaY", scroll_delta.y()); 761 scroll_delta.x(), "deltaY", scroll_delta.y());
760 762
761 cc::ScrollStateData scroll_state_update_data; 763 cc::ScrollStateData scroll_state_update_data;
762 scroll_state_update_data.delta_x = scroll_delta.x(); 764 scroll_state_update_data.delta_x = scroll_delta.x();
763 scroll_state_update_data.delta_y = scroll_delta.y(); 765 scroll_state_update_data.delta_y = scroll_delta.y();
764 scroll_state_update_data.position_x = wheel_event.x; 766 scroll_state_update_data.position_x = wheel_event.positionInWidget().x;
765 scroll_state_update_data.position_y = wheel_event.y; 767 scroll_state_update_data.position_y = wheel_event.positionInWidget().y;
766 cc::ScrollState scroll_state_update(scroll_state_update_data); 768 cc::ScrollState scroll_state_update(scroll_state_update_data);
767 769
768 cc::InputHandlerScrollResult scroll_result = 770 cc::InputHandlerScrollResult scroll_result =
769 input_handler_->ScrollBy(&scroll_state_update); 771 input_handler_->ScrollBy(&scroll_state_update);
770 HandleOverscroll(gfx::Point(wheel_event.x, wheel_event.y), 772 HandleOverscroll(gfx::Point(wheel_event.positionInWidget().x,
773 wheel_event.positionInWidget().y),
771 scroll_result, false); 774 scroll_result, false);
772 775
773 cc::ScrollStateData scroll_state_end_data; 776 cc::ScrollStateData scroll_state_end_data;
774 scroll_state_end_data.is_ending = true; 777 scroll_state_end_data.is_ending = true;
775 cc::ScrollState scroll_state_end(scroll_state_end_data); 778 cc::ScrollState scroll_state_end(scroll_state_end_data);
776 input_handler_->ScrollEnd(&scroll_state_end); 779 input_handler_->ScrollEnd(&scroll_state_end);
777 780
778 if (scroll_result.did_scroll) { 781 if (scroll_result.did_scroll) {
779 return listener_properties == cc::EventListenerProperties::kPassive 782 return listener_properties == cc::EventListenerProperties::kPassive
780 ? DID_HANDLE_NON_BLOCKING 783 ? DID_HANDLE_NON_BLOCKING
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 disposition = DID_NOT_HANDLE; 1502 disposition = DID_NOT_HANDLE;
1500 break; 1503 break;
1501 case cc::EventListenerProperties::kPassive: 1504 case cc::EventListenerProperties::kPassive:
1502 case cc::EventListenerProperties::kNone: { 1505 case cc::EventListenerProperties::kNone: {
1503 WebMouseWheelEvent synthetic_wheel(WebInputEvent::MouseWheel, 1506 WebMouseWheelEvent synthetic_wheel(WebInputEvent::MouseWheel,
1504 fling_parameters_.modifiers, 1507 fling_parameters_.modifiers,
1505 InSecondsF(base::TimeTicks::Now())); 1508 InSecondsF(base::TimeTicks::Now()));
1506 synthetic_wheel.deltaX = increment.width; 1509 synthetic_wheel.deltaX = increment.width;
1507 synthetic_wheel.deltaY = increment.height; 1510 synthetic_wheel.deltaY = increment.height;
1508 synthetic_wheel.hasPreciseScrollingDeltas = true; 1511 synthetic_wheel.hasPreciseScrollingDeltas = true;
1509 synthetic_wheel.x = fling_parameters_.point.x; 1512 synthetic_wheel.setPositionInWidget(fling_parameters_.point.x,
1510 synthetic_wheel.y = fling_parameters_.point.y; 1513 fling_parameters_.point.y);
1511 synthetic_wheel.globalX = fling_parameters_.globalPoint.x; 1514 synthetic_wheel.setPositionInScreen(fling_parameters_.globalPoint.x,
1512 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; 1515 fling_parameters_.globalPoint.y);
1513 1516
1514 disposition = FlingScrollByMouseWheel(synthetic_wheel, properties); 1517 disposition = FlingScrollByMouseWheel(synthetic_wheel, properties);
1515 1518
1516 // Send the event over to the main thread. 1519 // Send the event over to the main thread.
1517 if (disposition == DID_HANDLE_NON_BLOCKING) { 1520 if (disposition == DID_HANDLE_NON_BLOCKING) {
1518 client_->DispatchNonBlockingEventToMainThread( 1521 client_->DispatchNonBlockingEventToMainThread(
1519 ui::WebInputEventTraits::Clone(synthetic_wheel), ui::LatencyInfo()); 1522 ui::WebInputEventTraits::Clone(synthetic_wheel), ui::LatencyInfo());
1520 } 1523 }
1521 break; 1524 break;
1522 } 1525 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, 1637 scroll_elasticity_controller_->GetWeakPtr(), gesture_event,
1635 scroll_result)); 1638 scroll_result));
1636 } 1639 }
1637 1640
1638 void InputHandlerProxy::SetTickClockForTesting( 1641 void InputHandlerProxy::SetTickClockForTesting(
1639 std::unique_ptr<base::TickClock> tick_clock) { 1642 std::unique_ptr<base::TickClock> tick_clock) {
1640 tick_clock_ = std::move(tick_clock); 1643 tick_clock_ = std::move(tick_clock);
1641 } 1644 }
1642 1645
1643 } // namespace ui 1646 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/blink_event_util.cc ('k') | ui/events/blink/input_handler_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698