summaryrefslogtreecommitdiff
path: root/chromium/ui/events/gesture_detection
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-05-09 14:22:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-05-09 15:11:45 +0000
commit2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch)
treee75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/ui/events/gesture_detection
parenta4f3d46271c57e8155ba912df46a05559d14726e (diff)
downloadqtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion. Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/ui/events/gesture_detection')
-rw-r--r--chromium/ui/events/gesture_detection/filtered_gesture_provider.cc20
-rw-r--r--chromium/ui/events/gesture_detection/filtered_gesture_provider.h9
-rw-r--r--chromium/ui/events/gesture_detection/filtered_gesture_provider_unittest.cc100
-rw-r--r--chromium/ui/events/gesture_detection/gesture_detector.cc2
-rw-r--r--chromium/ui/events/gesture_detection/gesture_detector.h1
-rw-r--r--chromium/ui/events/gesture_detection/gesture_event_data.cc2
-rw-r--r--chromium/ui/events/gesture_detection/gesture_event_data.h1
-rw-r--r--chromium/ui/events/gesture_detection/gesture_provider.cc2
-rw-r--r--chromium/ui/events/gesture_detection/gesture_provider.h1
-rw-r--r--chromium/ui/events/gesture_detection/gesture_provider_config_helper.cc2
-rw-r--r--chromium/ui/events/gesture_detection/motion_event_generic.cc2
-rw-r--r--chromium/ui/events/gesture_detection/motion_event_generic.h1
12 files changed, 112 insertions, 31 deletions
diff --git a/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc b/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc
index e616e7bbd64..be4b197994a 100644
--- a/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc
+++ b/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc
@@ -6,12 +6,13 @@
#include "base/auto_reset.h"
#include "base/logging.h"
+#include "ui/events/blink/blink_event_util.h"
#include "ui/events/gesture_detection/motion_event.h"
namespace ui {
FilteredGestureProvider::TouchHandlingResult::TouchHandlingResult()
- : succeeded(false), did_generate_scroll(false) {
+ : succeeded(false), moved_beyond_slop_region(false) {
}
FilteredGestureProvider::FilteredGestureProvider(
@@ -21,7 +22,7 @@ FilteredGestureProvider::FilteredGestureProvider(
gesture_provider_(config, this),
gesture_filter_(this),
handling_event_(false),
- last_touch_event_did_generate_scroll_(false) {
+ any_touch_moved_beyond_slop_region_(false) {
}
FilteredGestureProvider::TouchHandlingResult
@@ -30,7 +31,10 @@ FilteredGestureProvider::OnTouchEvent(const MotionEvent& event) {
base::AutoReset<bool> handling_event(&handling_event_, true);
pending_gesture_packet_ = GestureEventDataPacket::FromTouch(event);
- last_touch_event_did_generate_scroll_ = false;
+
+ if (event.GetAction() == MotionEvent::ACTION_DOWN)
+ any_touch_moved_beyond_slop_region_ = false;
+
if (!gesture_provider_.OnTouchEvent(event))
return TouchHandlingResult();
@@ -43,7 +47,7 @@ FilteredGestureProvider::OnTouchEvent(const MotionEvent& event) {
TouchHandlingResult result;
result.succeeded = true;
- result.did_generate_scroll = last_touch_event_did_generate_scroll_;
+ result.moved_beyond_slop_region = any_touch_moved_beyond_slop_region_;
return result;
}
@@ -76,11 +80,9 @@ const ui::MotionEvent* FilteredGestureProvider::GetCurrentDownEvent() const {
void FilteredGestureProvider::OnGestureEvent(const GestureEventData& event) {
if (handling_event_) {
- if (event.details.type() == ui::ET_GESTURE_SCROLL_BEGIN ||
- event.details.type() == ui::ET_GESTURE_SCROLL_UPDATE ||
- event.details.type() == ui::ET_SCROLL_FLING_START) {
- last_touch_event_did_generate_scroll_ = true;
- }
+ if (event.details.type() == ui::ET_GESTURE_SCROLL_BEGIN)
+ any_touch_moved_beyond_slop_region_ = true;
+
pending_gesture_packet_.Push(event);
return;
}
diff --git a/chromium/ui/events/gesture_detection/filtered_gesture_provider.h b/chromium/ui/events/gesture_detection/filtered_gesture_provider.h
index d8a8dc0d252..c0af13b111c 100644
--- a/chromium/ui/events/gesture_detection/filtered_gesture_provider.h
+++ b/chromium/ui/events/gesture_detection/filtered_gesture_provider.h
@@ -34,11 +34,8 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider
// |event| and cease further propagation.
bool succeeded;
- // Whether |event| produced scrolling motion, either the start of a scroll,
- // subsequent scroll movement or a fling event.
- // TODO(jdduke): Figure out a way to guarantee that this bit propagates with
- // the processed touch event as it moves downstream.
- bool did_generate_scroll;
+ // Whether |event| occurred beyond the touch slop region.
+ bool moved_beyond_slop_region;
};
TouchHandlingResult OnTouchEvent(const MotionEvent& event) WARN_UNUSED_RESULT;
@@ -66,7 +63,7 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider
ui::TouchDispositionGestureFilter gesture_filter_;
bool handling_event_;
- bool last_touch_event_did_generate_scroll_;
+ bool any_touch_moved_beyond_slop_region_;
ui::GestureEventDataPacket pending_gesture_packet_;
DISALLOW_COPY_AND_ASSIGN(FilteredGestureProvider);
diff --git a/chromium/ui/events/gesture_detection/filtered_gesture_provider_unittest.cc b/chromium/ui/events/gesture_detection/filtered_gesture_provider_unittest.cc
index 4514946ccc7..d3e10f637db 100644
--- a/chromium/ui/events/gesture_detection/filtered_gesture_provider_unittest.cc
+++ b/chromium/ui/events/gesture_detection/filtered_gesture_provider_unittest.cc
@@ -22,63 +22,133 @@ class FilteredGestureProviderTest : public GestureProviderClient,
base::MessageLoopForUI message_loop_;
};
-TEST_F(FilteredGestureProviderTest, TouchDidGenerateScroll) {
+// Single touch drag test: After touch-start, the moved_beyond_slop_region bit
+// should stay unset as long as the touch movement is confined to the slop
+// region. Once the touch moves beyond the slop region, the bit should remain
+// set until (incl) touch-end.
+TEST_F(FilteredGestureProviderTest, TouchMovedBeyondSlopRegion_SingleTouch) {
GestureProvider::Config config;
FilteredGestureProvider provider(config, this);
const float kSlopRegion = config.gesture_detector_config.touch_slop;
test::MockMotionEvent event;
+
event.set_event_time(base::TimeTicks::Now());
event.PressPoint(0, 0);
auto result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_FALSE(result.did_generate_scroll);
+ EXPECT_FALSE(result.moved_beyond_slop_region);
event.MovePoint(0, kSlopRegion / 2.f, 0);
result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_FALSE(result.did_generate_scroll);
+ EXPECT_FALSE(result.moved_beyond_slop_region);
- // Exceeding the slop should triggering scrolling and be reflected in the API.
event.MovePoint(0, kSlopRegion * 2.f, 0);
result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_TRUE(result.did_generate_scroll);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
- // No movement should indicate no scrolling.
event.MovePoint(0, kSlopRegion * 2.f, 0);
result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_FALSE(result.did_generate_scroll);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
- // Nonzero movement should reflect scrolling after exceeding the slop region.
event.MovePoint(0, 0, 0);
result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_TRUE(result.did_generate_scroll);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
- // Ending a touch with no fling should not indicate scrolling.
event.ReleasePoint();
result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_FALSE(result.did_generate_scroll);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
- // Ending a touch with a fling *should* indicate scrolling.
+ // A new touch sequence should reset the bit.
base::TimeTicks time = base::TimeTicks::Now();
event.PressPoint(0, 0);
event.set_event_time(time);
- ASSERT_TRUE(provider.OnTouchEvent(event).succeeded);
+ result = provider.OnTouchEvent(event);
+ ASSERT_TRUE(result.succeeded);
+ EXPECT_FALSE(result.moved_beyond_slop_region);
+ // A fling should set the bit right away.
time += base::TimeDelta::FromMilliseconds(10);
event.MovePoint(0, kSlopRegion * 50, 0);
event.set_event_time(time);
- ASSERT_TRUE(provider.OnTouchEvent(event).succeeded);
+ result = provider.OnTouchEvent(event);
+ ASSERT_TRUE(result.succeeded);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
event.ReleasePoint();
result = provider.OnTouchEvent(event);
EXPECT_TRUE(result.succeeded);
- EXPECT_TRUE(result.did_generate_scroll);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
+}
+
+// Multi-touch: The moved_beyond_slop_region bit should stay unset as long as
+// all touch-points are stationary, and should be set after (including) the
+// first movement in any touch-point.
+TEST_F(FilteredGestureProviderTest, TouchMovedBeyondSlopRegion_MultiTouch) {
+ GestureProvider::Config config;
+ FilteredGestureProvider provider(config, this);
+
+ const float kSlopRegion = config.gesture_detector_config.touch_slop;
+
+ test::MockMotionEvent event;
+
+ float x = 0;
+ const float y0 = 0;
+ const float y1 = kSlopRegion * 10.f;
+ const float y2 = kSlopRegion * 20.f;
+
+ event.set_event_time(base::TimeTicks::Now());
+ event.PressPoint(x, y0);
+ auto result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_FALSE(result.moved_beyond_slop_region);
+
+ event.PressPoint(x, y1);
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_FALSE(result.moved_beyond_slop_region);
+
+ event.PressPoint(x, y2);
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_FALSE(result.moved_beyond_slop_region);
+
+ for (float multiplier = 0.5f; multiplier < 3.f; multiplier += 2.f) {
+ x = kSlopRegion * multiplier;
+
+ event.MovePoint(0, x, y0);
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
+
+ event.MovePoint(0, x, y0);
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
+
+ event.MovePoint(2, x, y2);
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
+
+ event.MovePoint(1, x, y1);
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
+ }
+
+ for(int i = 0; i < 3; i++) {
+ event.ReleasePoint();
+ result = provider.OnTouchEvent(event);
+ EXPECT_TRUE(result.succeeded);
+ EXPECT_TRUE(result.moved_beyond_slop_region);
+ }
}
} // namespace ui
diff --git a/chromium/ui/events/gesture_detection/gesture_detector.cc b/chromium/ui/events/gesture_detection/gesture_detector.cc
index 2996bc70816..6fc39a8e3dd 100644
--- a/chromium/ui/events/gesture_detection/gesture_detector.cc
+++ b/chromium/ui/events/gesture_detection/gesture_detector.cc
@@ -61,6 +61,8 @@ GestureDetector::Config::Config()
single_tap_repeat_interval(1),
velocity_tracker_strategy(VelocityTracker::Strategy::STRATEGY_DEFAULT) {}
+GestureDetector::Config::Config(const Config& other) = default;
+
GestureDetector::Config::~Config() {}
class GestureDetector::TimeoutGestureHandler {
diff --git a/chromium/ui/events/gesture_detection/gesture_detector.h b/chromium/ui/events/gesture_detection/gesture_detector.h
index 49def14b735..9fb699985f2 100644
--- a/chromium/ui/events/gesture_detection/gesture_detector.h
+++ b/chromium/ui/events/gesture_detection/gesture_detector.h
@@ -25,6 +25,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector {
public:
struct GESTURE_DETECTION_EXPORT Config {
Config();
+ Config(const Config& other);
~Config();
base::TimeDelta longpress_timeout;
diff --git a/chromium/ui/events/gesture_detection/gesture_event_data.cc b/chromium/ui/events/gesture_detection/gesture_event_data.cc
index b166ffa0a13..676dadef6f8 100644
--- a/chromium/ui/events/gesture_detection/gesture_event_data.cc
+++ b/chromium/ui/events/gesture_detection/gesture_event_data.cc
@@ -49,6 +49,8 @@ GestureEventData::GestureEventData(EventType type,
details.set_bounding_box(other.details.bounding_box_f());
}
+GestureEventData::GestureEventData(const GestureEventData& other) = default;
+
GestureEventData::GestureEventData()
: motion_event_id(0),
primary_tool_type(MotionEvent::TOOL_TYPE_UNKNOWN),
diff --git a/chromium/ui/events/gesture_detection/gesture_event_data.h b/chromium/ui/events/gesture_detection/gesture_event_data.h
index 8f54355dcf5..541fe125f6b 100644
--- a/chromium/ui/events/gesture_detection/gesture_event_data.h
+++ b/chromium/ui/events/gesture_detection/gesture_event_data.h
@@ -30,6 +30,7 @@ struct GESTURE_DETECTION_EXPORT GestureEventData {
const gfx::RectF& bounding_box,
int flags);
GestureEventData(EventType type, const GestureEventData&);
+ GestureEventData(const GestureEventData& other);
EventType type() const { return details.type(); }
diff --git a/chromium/ui/events/gesture_detection/gesture_provider.cc b/chromium/ui/events/gesture_detection/gesture_provider.cc
index 2ea2b53407f..40944ff8654 100644
--- a/chromium/ui/events/gesture_detection/gesture_provider.cc
+++ b/chromium/ui/events/gesture_detection/gesture_provider.cc
@@ -75,6 +75,8 @@ GestureProvider::Config::Config()
max_gesture_bounds_length(0) {
}
+GestureProvider::Config::Config(const Config& other) = default;
+
GestureProvider::Config::~Config() {
}
diff --git a/chromium/ui/events/gesture_detection/gesture_provider.h b/chromium/ui/events/gesture_detection/gesture_provider.h
index c738f53ab32..0da33163419 100644
--- a/chromium/ui/events/gesture_detection/gesture_provider.h
+++ b/chromium/ui/events/gesture_detection/gesture_provider.h
@@ -28,6 +28,7 @@ class GESTURE_DETECTION_EXPORT GestureProvider {
public:
struct GESTURE_DETECTION_EXPORT Config {
Config();
+ Config(const Config& other);
~Config();
gfx::Display display;
GestureDetector::Config gesture_detector_config;
diff --git a/chromium/ui/events/gesture_detection/gesture_provider_config_helper.cc b/chromium/ui/events/gesture_detection/gesture_provider_config_helper.cc
index 27081026df0..c13636687c9 100644
--- a/chromium/ui/events/gesture_detection/gesture_provider_config_helper.cc
+++ b/chromium/ui/events/gesture_detection/gesture_provider_config_helper.cc
@@ -90,7 +90,7 @@ GestureProvider::Config GetGestureProviderConfig(
break;
}
- gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
+ gfx::Screen* screen = gfx::Screen::GetScreen();
// |screen| is sometimes NULL during tests.
if (screen)
config.display = screen->GetPrimaryDisplay();
diff --git a/chromium/ui/events/gesture_detection/motion_event_generic.cc b/chromium/ui/events/gesture_detection/motion_event_generic.cc
index 041bddda256..935584c4796 100644
--- a/chromium/ui/events/gesture_detection/motion_event_generic.cc
+++ b/chromium/ui/events/gesture_detection/motion_event_generic.cc
@@ -50,6 +50,8 @@ PointerProperties::PointerProperties(const MotionEvent& event,
source_device_id(0) {
}
+PointerProperties::PointerProperties(const PointerProperties& other) = default;
+
void PointerProperties::SetAxesAndOrientation(float radius_x,
float radius_y,
float rotation_angle_degree) {
diff --git a/chromium/ui/events/gesture_detection/motion_event_generic.h b/chromium/ui/events/gesture_detection/motion_event_generic.h
index c5ea1b00f4c..bc9b351381a 100644
--- a/chromium/ui/events/gesture_detection/motion_event_generic.h
+++ b/chromium/ui/events/gesture_detection/motion_event_generic.h
@@ -19,6 +19,7 @@ struct GESTURE_DETECTION_EXPORT PointerProperties {
PointerProperties();
PointerProperties(float x, float y, float touch_major);
PointerProperties(const MotionEvent& event, size_t pointer_index);
+ PointerProperties(const PointerProperties& other);
// Sets |touch_major|, |touch_minor|, and |orientation| from the given radius
// and rotation angle (in degrees).