Commit dcb8bc16 authored by tdresser@chromium.org's avatar tdresser@chromium.org

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
parent e9c3367a
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#if defined(USE_AURA) #if defined(USE_AURA)
#include "ui/events/gestures/gesture_configuration.h" #include "ui/events/gestures/gesture_configuration.h"
#include "ui/events/gestures/unified_gesture_detector_enabled.h"
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
#include "ui/gfx/android/view_configuration.h" #include "ui/gfx/android/view_configuration.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
...@@ -52,8 +53,9 @@ TouchEventQueue::Config GetTouchEventQueueConfig() { ...@@ -52,8 +53,9 @@ TouchEventQueue::Config GetTouchEventQueueConfig() {
config.touchmove_slop_suppression_length_dips = config.touchmove_slop_suppression_length_dips =
ui::GestureConfiguration::max_touch_move_in_pixels_for_click(); ui::GestureConfiguration::max_touch_move_in_pixels_for_click();
// TODO(jdduke): Remove when unified GR enabled, crbug.com/332418.
config.touchmove_slop_suppression_region_includes_boundary = false; config.touchmove_slop_suppression_region_includes_boundary =
ui::IsUnifiedGestureDetectorEnabled();
return config; return config;
} }
......
...@@ -348,6 +348,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -348,6 +348,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
private: private:
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SetCompositionText); FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SetCompositionText);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventState); FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventState);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
TouchEventPositionsArentRounded);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventSyncAsync); FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, TouchEventSyncAsync);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SwapNotifiesWindow); FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, SwapNotifiesWindow);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
......
...@@ -1802,6 +1802,31 @@ TEST_F(RenderWidgetHostViewAuraTest, VisibleViewportTest) { ...@@ -1802,6 +1802,31 @@ TEST_F(RenderWidgetHostViewAuraTest, VisibleViewportTest) {
EXPECT_EQ(60, params.a.visible_viewport_size.height()); EXPECT_EQ(60, params.a.visible_viewport_size.height());
} }
// Ensures that touch event positions are never truncated to integers.
TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) {
const float kX = 30.58f;
const float kY = 50.23f;
view_->InitAsChild(NULL);
view_->Show();
ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
gfx::PointF(kX, kY),
0,
ui::EventTimeForNow());
view_->OnTouchEvent(&press);
EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type);
EXPECT_TRUE(view_->touch_event_.cancelable);
EXPECT_EQ(1U, view_->touch_event_.touchesLength);
EXPECT_EQ(blink::WebTouchPoint::StatePressed,
view_->touch_event_.touches[0].state);
EXPECT_EQ(kX, view_->touch_event_.touches[0].screenPosition.x);
EXPECT_EQ(kX, view_->touch_event_.touches[0].position.x);
EXPECT_EQ(kY, view_->touch_event_.touches[0].screenPosition.y);
EXPECT_EQ(kY, view_->touch_event_.touches[0].position.y);
}
// Tests that scroll ACKs are correctly handled by the overscroll-navigation // Tests that scroll ACKs are correctly handled by the overscroll-navigation
// controller. // controller.
TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) { TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) {
......
...@@ -314,7 +314,7 @@ blink::WebTouchPoint* UpdateWebTouchEventFromUIEvent( ...@@ -314,7 +314,7 @@ blink::WebTouchPoint* UpdateWebTouchEventFromUIEvent(
point->position.x = event.x(); point->position.x = event.x();
point->position.y = event.y(); point->position.y = event.y();
const gfx::Point root_point = event.root_location(); const gfx::PointF& root_point = event.root_location_f();
point->screenPosition.x = root_point.x(); point->screenPosition.x = root_point.x();
point->screenPosition.y = root_point.y(); point->screenPosition.y = root_point.y();
......
...@@ -109,6 +109,8 @@ component("events") { ...@@ -109,6 +109,8 @@ component("events") {
"gestures/gesture_sequence.cc", "gestures/gesture_sequence.cc",
"gestures/gesture_sequence.h", "gestures/gesture_sequence.h",
"gestures/gesture_types.h", "gestures/gesture_types.h",
"gestures/unified_gesture_detector_enabled.cc",
"gestures/unified_gesture_detector_enabled.h",
"gestures/velocity_calculator.cc", "gestures/velocity_calculator.cc",
"gestures/velocity_calculator.h", "gestures/velocity_calculator.h",
"platform/x11/x11_event_source.cc", "platform/x11/x11_event_source.cc",
......
...@@ -248,13 +248,16 @@ class EVENTS_EXPORT LocatedEvent : public Event { ...@@ -248,13 +248,16 @@ class EVENTS_EXPORT LocatedEvent : public Event {
// TODO(tdresser): Always return floating point location. See // TODO(tdresser): Always return floating point location. See
// crbug.com/337824. // crbug.com/337824.
gfx::Point location() const { return gfx::ToFlooredPoint(location_); } 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) { void set_root_location(const gfx::PointF& root_location) {
root_location_ = root_location; root_location_ = root_location;
} }
gfx::Point root_location() const { gfx::Point root_location() const {
return gfx::ToFlooredPoint(root_location_); return gfx::ToFlooredPoint(root_location_);
} }
const gfx::PointF& root_location_f() const {
return root_location_;
}
// Transform the locations using |inverted_root_transform|. // Transform the locations using |inverted_root_transform|.
// This is applied to both |location_| and |root_location_|. // This is applied to both |location_| and |root_location_|.
......
...@@ -123,6 +123,8 @@ ...@@ -123,6 +123,8 @@
'gestures/gesture_types.h', 'gestures/gesture_types.h',
'gestures/motion_event_aura.cc', 'gestures/motion_event_aura.cc',
'gestures/motion_event_aura.h', 'gestures/motion_event_aura.h',
'gestures/unified_gesture_detector_enabled.cc',
'gestures/unified_gesture_detector_enabled.h',
'gestures/velocity_calculator.cc', 'gestures/velocity_calculator.cc',
'gestures/velocity_calculator.h', 'gestures/velocity_calculator.h',
'ozone/events_ozone.cc', 'ozone/events_ozone.cc',
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/events/gestures/gesture_configuration.h" #include "ui/events/gestures/gesture_configuration.h"
#include "ui/events/gestures/gesture_sequence.h" #include "ui/events/gestures/gesture_sequence.h"
#include "ui/events/gestures/gesture_types.h" #include "ui/events/gestures/gesture_types.h"
#include "ui/events/gestures/unified_gesture_detector_enabled.h"
namespace ui { namespace ui {
...@@ -69,28 +70,7 @@ GestureProviderAura* CreateGestureProvider(GestureProviderAuraClient* client) { ...@@ -69,28 +70,7 @@ GestureProviderAura* CreateGestureProvider(GestureProviderAuraClient* client) {
// GestureRecognizerImpl, public: // GestureRecognizerImpl, public:
GestureRecognizerImpl::GestureRecognizerImpl() { GestureRecognizerImpl::GestureRecognizerImpl() {
// Default to using the unified gesture detector. use_unified_gesture_detector_ = IsUnifiedGestureDetectorEnabled();
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;
}
} }
GestureRecognizerImpl::~GestureRecognizerImpl() { GestureRecognizerImpl::~GestureRecognizerImpl() {
......
// 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
// 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_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment