diff options
author | tdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 23:47:16 +0000 |
---|---|---|
committer | tdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 23:47:16 +0000 |
commit | dcb8bc16bf2dfcafc0a04c6287845b4743fb9544 (patch) | |
tree | f7cdec383a6032bc6a85d7a1cb6ea37bb66fb5f6 /ui/events | |
parent | e9c3367a46b50d045fdaaa53cf00e1502bd7a1b8 (diff) | |
download | chromium_src-dcb8bc16bf2dfcafc0a04c6287845b4743fb9544.zip chromium_src-dcb8bc16bf2dfcafc0a04c6287845b4743fb9544.tar.gz chromium_src-dcb8bc16bf2dfcafc0a04c6287845b4743fb9544.tar.bz2 |
Reland: Fix slop region boundary handling.
Committed https://src.chromium.org/viewvc/chrome?view=rev&revision=276728.
Broke gn build.
Reverted: https://codereview.chromium.org/330613003
Ensure the screenPosition of touches is never truncated to an integer.
Check if the unified gesture detector is enabled before disabling
the inclusive slop region.
BUG=381174
TEST=RenderWidgetHostViewAuraTest.TouchEventPositionsArentRounded
TBR=sadrul@chromium.org
Review URL: https://codereview.chromium.org/334753003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276852 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/events')
-rw-r--r-- | ui/events/BUILD.gn | 2 | ||||
-rw-r--r-- | ui/events/event.h | 5 | ||||
-rw-r--r-- | ui/events/events.gyp | 2 | ||||
-rw-r--r-- | ui/events/gestures/gesture_recognizer_impl.cc | 24 | ||||
-rw-r--r-- | ui/events/gestures/unified_gesture_detector_enabled.cc | 37 | ||||
-rw-r--r-- | ui/events/gestures/unified_gesture_detector_enabled.h | 17 |
6 files changed, 64 insertions, 23 deletions
diff --git a/ui/events/BUILD.gn b/ui/events/BUILD.gn index e2fe42b..652f9a4 100644 --- a/ui/events/BUILD.gn +++ b/ui/events/BUILD.gn @@ -109,6 +109,8 @@ component("events") { "gestures/gesture_sequence.cc", "gestures/gesture_sequence.h", "gestures/gesture_types.h", + "gestures/unified_gesture_detector_enabled.cc", + "gestures/unified_gesture_detector_enabled.h", "gestures/velocity_calculator.cc", "gestures/velocity_calculator.h", "platform/x11/x11_event_source.cc", diff --git a/ui/events/event.h b/ui/events/event.h index dfd867e..928a2b9 100644 --- a/ui/events/event.h +++ b/ui/events/event.h @@ -248,13 +248,16 @@ class EVENTS_EXPORT LocatedEvent : public Event { // TODO(tdresser): Always return floating point location. See // crbug.com/337824. gfx::Point location() const { return gfx::ToFlooredPoint(location_); } - gfx::PointF location_f() const { return location_; } + const gfx::PointF& location_f() const { return location_; } void set_root_location(const gfx::PointF& root_location) { root_location_ = root_location; } gfx::Point root_location() const { return gfx::ToFlooredPoint(root_location_); } + const gfx::PointF& root_location_f() const { + return root_location_; + } // Transform the locations using |inverted_root_transform|. // This is applied to both |location_| and |root_location_|. diff --git a/ui/events/events.gyp b/ui/events/events.gyp index 111e17c..890708d 100644 --- a/ui/events/events.gyp +++ b/ui/events/events.gyp @@ -123,6 +123,8 @@ 'gestures/gesture_types.h', 'gestures/motion_event_aura.cc', 'gestures/motion_event_aura.h', + 'gestures/unified_gesture_detector_enabled.cc', + 'gestures/unified_gesture_detector_enabled.h', 'gestures/velocity_calculator.cc', 'gestures/velocity_calculator.h', 'ozone/events_ozone.cc', diff --git a/ui/events/gestures/gesture_recognizer_impl.cc b/ui/events/gestures/gesture_recognizer_impl.cc index bf0dd44..e145334 100644 --- a/ui/events/gestures/gesture_recognizer_impl.cc +++ b/ui/events/gestures/gesture_recognizer_impl.cc @@ -18,6 +18,7 @@ #include "ui/events/gestures/gesture_configuration.h" #include "ui/events/gestures/gesture_sequence.h" #include "ui/events/gestures/gesture_types.h" +#include "ui/events/gestures/unified_gesture_detector_enabled.h" namespace ui { @@ -69,28 +70,7 @@ GestureProviderAura* CreateGestureProvider(GestureProviderAuraClient* client) { // GestureRecognizerImpl, public: GestureRecognizerImpl::GestureRecognizerImpl() { - // Default to using the unified gesture detector. - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - const std::string unified_gd_enabled_switch = - command_line.HasSwitch(switches::kUnifiedGestureDetector) ? - command_line.GetSwitchValueASCII(switches::kUnifiedGestureDetector) : - switches::kUnifiedGestureDetectorAuto; - - const bool kUseUnifiedGestureDetectorByDefault = true; - if (unified_gd_enabled_switch.empty() || - unified_gd_enabled_switch == switches::kUnifiedGestureDetectorEnabled) { - use_unified_gesture_detector_ = true; - } else if (unified_gd_enabled_switch == - switches::kUnifiedGestureDetectorDisabled) { - use_unified_gesture_detector_ = false; - } else if (unified_gd_enabled_switch == - switches::kUnifiedGestureDetectorAuto) { - use_unified_gesture_detector_ = kUseUnifiedGestureDetectorByDefault; - } else { - LOG(ERROR) << "Invalid --unified-gesture-detector option: " - << unified_gd_enabled_switch; - use_unified_gesture_detector_ = false; - } + use_unified_gesture_detector_ = IsUnifiedGestureDetectorEnabled(); } GestureRecognizerImpl::~GestureRecognizerImpl() { diff --git a/ui/events/gestures/unified_gesture_detector_enabled.cc b/ui/events/gestures/unified_gesture_detector_enabled.cc new file mode 100644 index 0000000..cf221ff --- /dev/null +++ b/ui/events/gestures/unified_gesture_detector_enabled.cc @@ -0,0 +1,37 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "base/logging.h" +#include "ui/events/event_switches.h" +#include "ui/events/gestures/unified_gesture_detector_enabled.h" + +namespace ui { + +bool IsUnifiedGestureDetectorEnabled() { + const bool kUseUnifiedGestureDetectorByDefault = true; + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + const std::string unified_gd_enabled_switch = + command_line.HasSwitch(switches::kUnifiedGestureDetector) ? + command_line.GetSwitchValueASCII(switches::kUnifiedGestureDetector) : + switches::kUnifiedGestureDetectorAuto; + + if (unified_gd_enabled_switch.empty() || + unified_gd_enabled_switch == switches::kUnifiedGestureDetectorEnabled) { + return true; + } + + if (unified_gd_enabled_switch == switches::kUnifiedGestureDetectorDisabled) + return false; + + if (unified_gd_enabled_switch == switches::kUnifiedGestureDetectorAuto) + return kUseUnifiedGestureDetectorByDefault; + + LOG(ERROR) << "Invalid --unified-gesture-detector option: " + << unified_gd_enabled_switch; + return false; +} + +} // namespace ui diff --git a/ui/events/gestures/unified_gesture_detector_enabled.h b/ui/events/gestures/unified_gesture_detector_enabled.h new file mode 100644 index 0000000..18fdc26 --- /dev/null +++ b/ui/events/gestures/unified_gesture_detector_enabled.h @@ -0,0 +1,17 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_EVENTS_GESTURES_UNIFIED_GESTURE_DETECTOR_ENABLED_H_ +#define UI_EVENTS_GESTURES_UNIFIED_GESTURE_DETECTOR_ENABLED_H_ + +#include "ui/events/events_export.h" + +namespace ui { + +// Returns true iff the unified gesture detector is enabled for Aura. +EVENTS_EXPORT bool IsUnifiedGestureDetectorEnabled(); + +} // namespace ui + +#endif // UI_EVENTS_GESTURES_UNIFIED_GESTURE_DETECTOR_ENABLED_H_ |