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

Unified Diff: content/browser/renderer_host/input/input_router_impl.cc

Issue 235003005: Consolidate all touch/gesture related constants in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compilation fixes Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/input_router_impl.cc
diff --git a/content/browser/renderer_host/input/input_router_impl.cc b/content/browser/renderer_host/input/input_router_impl.cc
index 337012049b784c52aab2da93c087367612afa4f3..97e68f4b22a7f30a404abed84b5902087206e551 100644
--- a/content/browser/renderer_host/input/input_router_impl.cc
+++ b/content/browser/renderer_host/input/input_router_impl.cc
@@ -31,13 +31,6 @@
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
-#if defined(OS_ANDROID)
-#include "ui/gfx/android/view_configuration.h"
-#include "ui/gfx/screen.h"
-#else
-#include "ui/events/gestures/gesture_configuration.h"
-#endif
-
using base::Time;
using base::TimeDelta;
using base::TimeTicks;
@@ -50,57 +43,6 @@ using blink::WebMouseWheelEvent;
namespace content {
namespace {
-// TODO(jdduke): Instead of relying on command line flags or conditional
-// conditional compilation here, we should instead use an InputRouter::Settings
-// construct, supplied and customized by the RenderWidgetHostView. See
-// crbug.com/343917.
-bool GetTouchAckTimeoutDelay(base::TimeDelta* touch_ack_timeout_delay) {
- CommandLine* parsed_command_line = CommandLine::ForCurrentProcess();
- if (!parsed_command_line->HasSwitch(switches::kTouchAckTimeoutDelayMs))
- return false;
-
- std::string timeout_string = parsed_command_line->GetSwitchValueASCII(
- switches::kTouchAckTimeoutDelayMs);
- size_t timeout_ms;
- if (!base::StringToSizeT(timeout_string, &timeout_ms))
- return false;
-
- *touch_ack_timeout_delay = base::TimeDelta::FromMilliseconds(timeout_ms);
- return true;
-}
-
-#if defined(OS_ANDROID)
-double GetTouchMoveSlopSuppressionLengthDips() {
- const double touch_slop_length_pixels =
- static_cast<double>(gfx::ViewConfiguration::GetTouchSlopInPixels());
- const double device_scale_factor =
- gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor();
- return touch_slop_length_pixels / device_scale_factor;
-}
-#elif defined(USE_AURA)
-double GetTouchMoveSlopSuppressionLengthDips() {
- return ui::GestureConfiguration::max_touch_move_in_pixels_for_click();
-}
-#else
-double GetTouchMoveSlopSuppressionLengthDips() {
- return 0;
-}
-#endif
-
-TouchEventQueue::TouchScrollingMode GetTouchScrollingMode() {
- std::string modeString = CommandLine::ForCurrentProcess()->
- GetSwitchValueASCII(switches::kTouchScrollingMode);
- if (modeString == switches::kTouchScrollingModeAsyncTouchmove)
- return TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE;
- if (modeString == switches::kTouchScrollingModeSyncTouchmove)
- return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE;
- if (modeString == switches::kTouchScrollingModeTouchcancel)
- return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL;
- if (modeString != "")
- LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString;
- return TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT;
-}
-
const char* GetEventAckName(InputEventAckState ack_result) {
switch(ack_result) {
case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN";
@@ -115,10 +57,14 @@ const char* GetEventAckName(InputEventAckState ack_result) {
} // namespace
+InputRouterImpl::Config::Config() {
+}
+
InputRouterImpl::InputRouterImpl(IPC::Sender* sender,
InputRouterClient* client,
InputAckHandler* ack_handler,
- int routing_id)
+ int routing_id,
+ const Config& config)
: sender_(sender),
client_(client),
ack_handler_(ack_handler),
@@ -127,19 +73,14 @@ InputRouterImpl::InputRouterImpl(IPC::Sender* sender,
move_caret_pending_(false),
mouse_move_pending_(false),
mouse_wheel_pending_(false),
- touch_ack_timeout_supported_(false),
current_view_flags_(0),
current_ack_source_(ACK_SOURCE_NONE),
flush_requested_(false),
- touch_event_queue_(this,
- GetTouchScrollingMode(),
- GetTouchMoveSlopSuppressionLengthDips()),
- gesture_event_queue_(this, this) {
+ touch_event_queue_(this, config.touch_config),
+ gesture_event_queue_(this, this, config.gesture_config) {
DCHECK(sender);
DCHECK(client);
DCHECK(ack_handler);
- touch_ack_timeout_supported_ =
- GetTouchAckTimeoutDelay(&touch_ack_timeout_delay_);
UpdateTouchAckTimeoutEnabled();
}
@@ -748,11 +689,6 @@ void InputRouterImpl::ProcessAckForOverscroll(const WebInputEvent& event,
}
void InputRouterImpl::UpdateTouchAckTimeoutEnabled() {
- if (!touch_ack_timeout_supported_) {
- touch_event_queue_.SetAckTimeoutEnabled(false, base::TimeDelta());
- return;
- }
-
// Mobile sites tend to be well-behaved with respect to touch handling, so
// they have less need for the touch timeout fallback.
const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0;
@@ -767,8 +703,7 @@ void InputRouterImpl::UpdateTouchAckTimeoutEnabled() {
const bool touch_ack_timeout_enabled = !fixed_page_scale &&
!mobile_viewport &&
!touch_action_none;
- touch_event_queue_.SetAckTimeoutEnabled(touch_ack_timeout_enabled,
- touch_ack_timeout_delay_);
+ touch_event_queue_.SetAckTimeoutEnabled(touch_ack_timeout_enabled);
}
void InputRouterImpl::SignalFlushedIfNecessary() {

Powered by Google App Engine
This is Rietveld 408576698