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

Side by Side Diff: content/browser/renderer_host/input/input_router_impl.cc

Issue 260123003: Revert of Remove smiluate-touch-screen-with-mouse content flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 "content/browser/renderer_host/input/input_router_impl.h" 5 #include "content/browser/renderer_host/input/input_router_impl.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE; 92 return TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE;
93 if (modeString == switches::kTouchScrollingModeSyncTouchmove) 93 if (modeString == switches::kTouchScrollingModeSyncTouchmove)
94 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE; 94 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE;
95 if (modeString == switches::kTouchScrollingModeTouchcancel) 95 if (modeString == switches::kTouchScrollingModeTouchcancel)
96 return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL; 96 return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL;
97 if (modeString != "") 97 if (modeString != "")
98 LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString; 98 LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString;
99 return TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT; 99 return TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT;
100 } 100 }
101 101
102 GestureEventWithLatencyInfo MakeGestureEvent(WebInputEvent::Type type,
103 double timestamp_seconds,
104 int x,
105 int y,
106 int modifiers,
107 const ui::LatencyInfo& latency) {
108 WebGestureEvent result;
109
110 result.type = type;
111 result.x = x;
112 result.y = y;
113 result.sourceDevice = WebGestureEvent::Touchscreen;
114 result.timeStampSeconds = timestamp_seconds;
115 result.modifiers = modifiers;
116
117 return GestureEventWithLatencyInfo(result, latency);
118 }
119
102 const char* GetEventAckName(InputEventAckState ack_result) { 120 const char* GetEventAckName(InputEventAckState ack_result) {
103 switch(ack_result) { 121 switch(ack_result) {
104 case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN"; 122 case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN";
105 case INPUT_EVENT_ACK_STATE_CONSUMED: return "CONSUMED"; 123 case INPUT_EVENT_ACK_STATE_CONSUMED: return "CONSUMED";
106 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: return "NOT_CONSUMED"; 124 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: return "NOT_CONSUMED";
107 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: return "NO_CONSUMER_EXISTS"; 125 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: return "NO_CONSUMER_EXISTS";
108 case INPUT_EVENT_ACK_STATE_IGNORED: return "IGNORED"; 126 case INPUT_EVENT_ACK_STATE_IGNORED: return "IGNORED";
109 } 127 }
110 DLOG(WARNING) << "Unhandled InputEventAckState in GetEventAckName."; 128 DLOG(WARNING) << "Unhandled InputEventAckState in GetEventAckName.";
111 return ""; 129 return "";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 case InputMsg_HandleInputEvent::ID: 177 case InputMsg_HandleInputEvent::ID:
160 NOTREACHED() << "WebInputEvents should never be sent via SendInput."; 178 NOTREACHED() << "WebInputEvents should never be sent via SendInput.";
161 return false; 179 return false;
162 default: 180 default:
163 return Send(message.release()); 181 return Send(message.release());
164 } 182 }
165 } 183 }
166 184
167 void InputRouterImpl::SendMouseEvent( 185 void InputRouterImpl::SendMouseEvent(
168 const MouseEventWithLatencyInfo& mouse_event) { 186 const MouseEventWithLatencyInfo& mouse_event) {
187 // Order is important here; we need to convert all MouseEvents before they
188 // propagate further, e.g., to the tap suppression controller.
189 if (CommandLine::ForCurrentProcess()->HasSwitch(
190 switches::kSimulateTouchScreenWithMouse)) {
191 SimulateTouchGestureWithMouse(mouse_event);
192 return;
193 }
194
169 if (mouse_event.event.type == WebInputEvent::MouseDown && 195 if (mouse_event.event.type == WebInputEvent::MouseDown &&
170 gesture_event_queue_.GetTouchpadTapSuppressionController()-> 196 gesture_event_queue_.GetTouchpadTapSuppressionController()->
171 ShouldDeferMouseDown(mouse_event)) 197 ShouldDeferMouseDown(mouse_event))
172 return; 198 return;
173 if (mouse_event.event.type == WebInputEvent::MouseUp && 199 if (mouse_event.event.type == WebInputEvent::MouseUp &&
174 gesture_event_queue_.GetTouchpadTapSuppressionController()-> 200 gesture_event_queue_.GetTouchpadTapSuppressionController()->
175 ShouldSuppressMouseUp()) 201 ShouldSuppressMouseUp())
176 return; 202 return;
177 203
178 SendMouseEventImmediately(mouse_event); 204 SendMouseEventImmediately(mouse_event);
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 return; 721 return;
696 722
697 OverscrollController* controller = client_->GetOverscrollController(); 723 OverscrollController* controller = client_->GetOverscrollController();
698 if (!controller) 724 if (!controller)
699 return; 725 return;
700 726
701 controller->ReceivedEventACK( 727 controller->ReceivedEventACK(
702 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 728 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
703 } 729 }
704 730
731 void InputRouterImpl::SimulateTouchGestureWithMouse(
732 const MouseEventWithLatencyInfo& event) {
733 const WebMouseEvent& mouse_event = event.event;
734 int x = mouse_event.x, y = mouse_event.y;
735 float dx = mouse_event.movementX, dy = mouse_event.movementY;
736 static int startX = 0, startY = 0;
737
738 switch (mouse_event.button) {
739 case WebMouseEvent::ButtonLeft:
740 if (mouse_event.type == WebInputEvent::MouseDown) {
741 startX = x;
742 startY = y;
743 SendGestureEvent(MakeGestureEvent(
744 WebInputEvent::GestureScrollBegin, mouse_event.timeStampSeconds,
745 x, y, 0, event.latency));
746 }
747 if (dx != 0 || dy != 0) {
748 GestureEventWithLatencyInfo gesture_event = MakeGestureEvent(
749 WebInputEvent::GestureScrollUpdate, mouse_event.timeStampSeconds,
750 x, y, 0, event.latency);
751 gesture_event.event.data.scrollUpdate.deltaX = dx;
752 gesture_event.event.data.scrollUpdate.deltaY = dy;
753 SendGestureEvent(gesture_event);
754 }
755 if (mouse_event.type == WebInputEvent::MouseUp) {
756 SendGestureEvent(MakeGestureEvent(
757 WebInputEvent::GestureScrollEnd, mouse_event.timeStampSeconds,
758 x, y, 0, event.latency));
759 }
760 break;
761 case WebMouseEvent::ButtonMiddle:
762 if (mouse_event.type == WebInputEvent::MouseDown) {
763 startX = x;
764 startY = y;
765 SendGestureEvent(MakeGestureEvent(
766 WebInputEvent::GestureShowPress, mouse_event.timeStampSeconds,
767 x, y, 0, event.latency));
768 SendGestureEvent(MakeGestureEvent(
769 WebInputEvent::GestureTapDown, mouse_event.timeStampSeconds,
770 x, y, 0, event.latency));
771 }
772 if (mouse_event.type == WebInputEvent::MouseUp) {
773 SendGestureEvent(MakeGestureEvent(
774 WebInputEvent::GestureTap, mouse_event.timeStampSeconds,
775 x, y, 0, event.latency));
776 }
777 break;
778 case WebMouseEvent::ButtonRight:
779 if (mouse_event.type == WebInputEvent::MouseDown) {
780 startX = x;
781 startY = y;
782 SendGestureEvent(MakeGestureEvent(
783 WebInputEvent::GestureScrollBegin, mouse_event.timeStampSeconds,
784 x, y, 0, event.latency));
785 SendGestureEvent(MakeGestureEvent(
786 WebInputEvent::GesturePinchBegin, mouse_event.timeStampSeconds,
787 x, y, 0, event.latency));
788 }
789 if (dx != 0 || dy != 0) {
790 dx = pow(dy < 0 ? 0.998f : 1.002f, fabs(dy));
791 GestureEventWithLatencyInfo gesture_event = MakeGestureEvent(
792 WebInputEvent::GesturePinchUpdate, mouse_event.timeStampSeconds,
793 startX, startY, 0, event.latency);
794 gesture_event.event.data.pinchUpdate.scale = dx;
795 SendGestureEvent(gesture_event);
796 }
797 if (mouse_event.type == WebInputEvent::MouseUp) {
798 SendGestureEvent(MakeGestureEvent(
799 WebInputEvent::GesturePinchEnd, mouse_event.timeStampSeconds,
800 x, y, 0, event.latency));
801 SendGestureEvent(MakeGestureEvent(
802 WebInputEvent::GestureScrollEnd, mouse_event.timeStampSeconds,
803 x, y, 0, event.latency));
804 }
805 break;
806 case WebMouseEvent::ButtonNone:
807 break;
808 }
809 }
810
705 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { 811 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() {
706 if (!touch_ack_timeout_supported_) { 812 if (!touch_ack_timeout_supported_) {
707 touch_event_queue_.SetAckTimeoutEnabled(false, base::TimeDelta()); 813 touch_event_queue_.SetAckTimeoutEnabled(false, base::TimeDelta());
708 return; 814 return;
709 } 815 }
710 816
711 // Mobile sites tend to be well-behaved with respect to touch handling, so 817 // Mobile sites tend to be well-behaved with respect to touch handling, so
712 // they have less need for the touch timeout fallback. 818 // they have less need for the touch timeout fallback.
713 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; 819 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0;
714 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; 820 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 select_range_pending_ || 852 select_range_pending_ ||
747 move_caret_pending_; 853 move_caret_pending_;
748 } 854 }
749 855
750 bool InputRouterImpl::IsInOverscrollGesture() const { 856 bool InputRouterImpl::IsInOverscrollGesture() const {
751 OverscrollController* controller = client_->GetOverscrollController(); 857 OverscrollController* controller = client_->GetOverscrollController();
752 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; 858 return controller && controller->overscroll_mode() != OVERSCROLL_NONE;
753 } 859 }
754 860
755 } // namespace content 861 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/input_router_impl.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698