summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 17:35:38 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 17:35:38 +0000
commit248ca5bfaf8729ac56b3b2af304797118085a975 (patch)
tree2d2b0b04bd1021be94b7fd2b1a3c0cfdb2d2242e /ui/aura
parent5caab3c6a7de0fc70f6aafccd7c6ffd8dcb672d6 (diff)
downloadchromium_src-248ca5bfaf8729ac56b3b2af304797118085a975.zip
chromium_src-248ca5bfaf8729ac56b3b2af304797118085a975.tar.gz
chromium_src-248ca5bfaf8729ac56b3b2af304797118085a975.tar.bz2
Revert 123989 sicne it broke aura_shell_unittests:
--- Gestures are now possible using touch events with any ids Each gesture point stores a "point_id," which is used for state transitions in the GestureRecognizer. The point_ids are maintained such that the set of point_ids is always contiguous, from 0 to the number of current touches. A lower point_id indicates that a touch occurred first. BUG=113144 TEST=GestureRecognizerTest.* Review URL: http://codereview.chromium.org/9452024 TBR=tdresser@chromium.org Review URL: https://chromiumcodereview.appspot.com/9501004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/gestures/gesture_point.cc4
-rw-r--r--ui/aura/gestures/gesture_point.h14
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc179
-rw-r--r--ui/aura/gestures/gesture_sequence.cc109
-rw-r--r--ui/aura/gestures/gesture_sequence.h6
-rw-r--r--ui/aura/window_unittest.cc3
6 files changed, 114 insertions, 201 deletions
diff --git a/ui/aura/gestures/gesture_point.cc b/ui/aura/gestures/gesture_point.cc
index a531f70..be72be1 100644
--- a/ui/aura/gestures/gesture_point.cc
+++ b/ui/aura/gestures/gesture_point.cc
@@ -27,8 +27,7 @@ GesturePoint::GesturePoint()
: first_touch_time_(0.0),
last_touch_time_(0.0),
last_tap_time_(0.0),
- velocity_calculator_(kBufferedPoints),
- point_id_(-1) {
+ velocity_calculator_(kBufferedPoints) {
}
GesturePoint::~GesturePoint() {}
@@ -36,7 +35,6 @@ GesturePoint::~GesturePoint() {}
void GesturePoint::Reset() {
first_touch_time_ = last_touch_time_ = 0.0;
velocity_calculator_.ClearHistory();
- point_id_ = -1;
}
void GesturePoint::UpdateValues(const TouchEvent& event) {
diff --git a/ui/aura/gestures/gesture_point.h b/ui/aura/gestures/gesture_point.h
index 906ba48..b04ffbd 100644
--- a/ui/aura/gestures/gesture_point.h
+++ b/ui/aura/gestures/gesture_point.h
@@ -53,16 +53,8 @@ class GesturePoint {
double last_touch_time() const { return last_touch_time_; }
const gfx::Point& last_touch_position() const { return last_touch_position_; }
- // point_id_ is used to drive GestureSequence::ProcessTouchEventForGesture.
- // point_ids are maintained such that the set of point_ids is always
- // contiguous, from 0 to the number of current touches.
- // A lower point_id indicates that a touch occurred first.
- // A negative point_id indicates that the GesturePoint is not currently
- // associated with a touch.
- void set_point_id(int point_id) { point_id_ = point_id; }
- const int point_id() const { return point_id_; }
-
- const bool in_use() const { return point_id_ >= 0; }
+ void set_touch_id(unsigned int touch_id) { touch_id_ = touch_id; }
+ unsigned int touch_id() const { return touch_id_; }
double x_delta() const {
return last_touch_position_.x() - first_touch_position_.x();
@@ -95,7 +87,7 @@ class GesturePoint {
VelocityCalculator velocity_calculator_;
- int point_id_;
+ unsigned int touch_id_;
DISALLOW_COPY_AND_ASSIGN(GesturePoint);
};
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index f6765d3..518f3dd 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -75,7 +75,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scroll_x() const { return scroll_x_; }
float scroll_y() const { return scroll_y_; }
- int touch_id() const { return touch_id_; }
+ unsigned int touch_id() const { return touch_id_; }
virtual ui::GestureStatus OnGestureEvent(GestureEvent* gesture) OVERRIDE {
switch (gesture->type()) {
@@ -135,7 +135,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scroll_x_;
float scroll_y_;
- int touch_id_;
+ unsigned int touch_id_;
DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate);
};
@@ -241,7 +241,7 @@ class TestOneShotGestureSequenceTimer
class TimerTestGestureSequence : public GestureSequence {
public:
- explicit TimerTestGestureSequence(RootWindow* root_window)
+ TimerTestGestureSequence(RootWindow* root_window)
: GestureSequence(root_window) {
}
@@ -257,7 +257,7 @@ class TimerTestGestureSequence : public GestureSequence {
class TestGestureRecognizer : public GestureRecognizerAura {
public:
- explicit TestGestureRecognizer(RootWindow* root_window)
+ TestGestureRecognizer(RootWindow* root_window)
: GestureRecognizerAura(root_window) {
}
@@ -276,7 +276,6 @@ void SendScrollEvents(RootWindow* root_window,
base::TimeDelta time_start,
int dx,
int dy,
- int touch_id,
int time_step,
int num_steps,
GestureEventConsumeDelegate* delegate) {
@@ -286,7 +285,7 @@ void SendScrollEvents(RootWindow* root_window,
for (int i = 0; i < num_steps; i++) {
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 0);
Event::TestApi test_move(&move);
test_move.set_time_stamp(time);
root_window->DispatchTouchEvent(&move);
@@ -299,10 +298,9 @@ void SendScrollEvents(RootWindow* root_window,
void SendScrollEvent(RootWindow* root_window,
int x,
int y,
- int touch_id,
GestureEventConsumeDelegate* delegate) {
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 0);
root_window->DispatchTouchEvent(&move);
}
@@ -318,13 +316,12 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
- const int kTouchId = 2;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -337,7 +334,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
// Make sure there is enough delay before the touch is released so that it is
// recognized as a tap.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -356,13 +353,12 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
- const int kTouchId = 5;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -375,7 +371,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
// should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
// The first movement is diagonal, to ensure that we have a free scroll,
// and not a rail scroll.
- SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 130, 230, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
EXPECT_FALSE(delegate->double_tap());
@@ -388,7 +384,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
delegate->scroll_begin_position().ToString());
// Move some more to generate a few more scroll updates.
- SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 110, 211, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
EXPECT_FALSE(delegate->double_tap());
@@ -398,7 +394,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
EXPECT_EQ(-20, delegate->scroll_x());
EXPECT_EQ(-19, delegate->scroll_y());
- SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 140, 215, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
EXPECT_FALSE(delegate->double_tap());
@@ -410,7 +406,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
// Release the touch. This should end the scroll.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -429,7 +425,6 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
- const int kTouchId = 2;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -444,7 +439,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
- TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
+ TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -454,10 +449,10 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
// Wait until the timer runs out
gesture_sequence->ForceTimeout();
EXPECT_TRUE(delegate->long_press());
- EXPECT_EQ(0, delegate->touch_id());
+ EXPECT_EQ(0u, delegate->touch_id());
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->long_press());
}
@@ -468,7 +463,6 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
- const int kTouchId = 6;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -483,7 +477,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
- TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
+ TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -491,13 +485,13 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
EXPECT_FALSE(delegate->long_press());
// Scroll around, to cancel the long press
- SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 130, 230, delegate.get());
// Wait until the timer runs out
gesture_sequence->ForceTimeout();
EXPECT_FALSE(delegate->long_press());
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->long_press());
}
@@ -508,8 +502,6 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 300;
const int kWindowHeight = 400;
- const int kTouchId1 = 8;
- const int kTouchId2 = 2;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -523,7 +515,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press);
EXPECT_TRUE(delegate->tap_down());
@@ -532,7 +524,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
// Pinch, to cancel the long press
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
root_window()->DispatchTouchEvent(&press2);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->pinch_begin());
@@ -544,7 +536,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
EXPECT_FALSE(delegate->long_press());
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->long_press());
}
@@ -554,21 +546,20 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
- const int kTouchId = 7;
gfx::Rect bounds(0, 0, 1000, 1000);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), kTouchId);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0);
root_window()->DispatchTouchEvent(&press);
// Move the touch-point horizontally enough that it is considered a
// horizontal scroll.
- SendScrollEvent(root_window(), 20, 1, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 20, 1, delegate.get());
EXPECT_EQ(0, delegate->scroll_y());
EXPECT_EQ(20, delegate->scroll_x());
- SendScrollEvent(root_window(), 25, 6, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 25, 6, delegate.get());
EXPECT_TRUE(delegate->scroll_update());
EXPECT_EQ(5, delegate->scroll_x());
// y shouldn't change, as we're on a horizontal rail.
@@ -577,10 +568,10 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
// Send enough information that a velocity can be calculated for the gesture,
// and we can break the rail
SendScrollEvents(root_window(), 1, 1, press.time_stamp(),
- 1, 100, kTouchId, 1, kBufferedPoints, delegate.get());
+ 1, 100, 1, kBufferedPoints, delegate.get());
- SendScrollEvent(root_window(), 0, 0, kTouchId, delegate.get());
- SendScrollEvent(root_window(), 5, 5, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 0, 0, delegate.get());
+ SendScrollEvent(root_window(), 5, 5, delegate.get());
// The rail should be broken
EXPECT_TRUE(delegate->scroll_update());
@@ -593,21 +584,20 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
- const int kTouchId = 7;
gfx::Rect bounds(0, 0, 1000, 1000);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), kTouchId);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0);
root_window()->DispatchTouchEvent(&press);
// Move the touch-point vertically enough that it is considered a
// vertical scroll.
- SendScrollEvent(root_window(), 1, 20, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 1, 20, delegate.get());
EXPECT_EQ(0, delegate->scroll_x());
EXPECT_EQ(20, delegate->scroll_y());
- SendScrollEvent(root_window(), 6, 25, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 6, 25, delegate.get());
EXPECT_TRUE(delegate->scroll_update());
EXPECT_EQ(5, delegate->scroll_y());
// x shouldn't change, as we're on a vertical rail.
@@ -616,10 +606,10 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
// Send enough information that a velocity can be calculated for the gesture,
// and we can break the rail
SendScrollEvents(root_window(), 1, 1, press.time_stamp(),
- 100, 1, kTouchId, 1, kBufferedPoints, delegate.get());
+ 100, 1, 1, kBufferedPoints, delegate.get());
- SendScrollEvent(root_window(), 0, 0, kTouchId, delegate.get());
- SendScrollEvent(root_window(), 5, 5, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 0, 0, delegate.get());
+ SendScrollEvent(root_window(), 5, 5, delegate.get());
// The rail should be broken
EXPECT_TRUE(delegate->scroll_update());
@@ -633,13 +623,12 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
- const int kTouchId = 3;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -651,7 +640,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Make sure there is enough delay before the touch is released so that it is
// recognized as a tap.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -666,7 +655,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger
// a double-tap.
delegate->Reset();
- TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
+ TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
Event::TestApi test_release1(&press1);
test_release1.set_time_stamp(release.time_stamp() +
base::TimeDelta::FromMilliseconds(1000));
@@ -683,7 +672,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// The first movement is diagonal, to ensure that we have a free scroll,
// and not a rail scroll.
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), kTouchId);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), 0);
root_window()->DispatchTouchEvent(&move);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -696,7 +685,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Move some more to generate a few more scroll updates.
delegate->Reset();
- TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), kTouchId);
+ TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), 0);
root_window()->DispatchTouchEvent(&move1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -708,7 +697,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
EXPECT_EQ(-19, delegate->scroll_y());
delegate->Reset();
- TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), kTouchId);
+ TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), 0);
root_window()->DispatchTouchEvent(&move2);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -721,7 +710,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Release the touch. This should end the scroll.
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -740,7 +729,7 @@ TEST_F(GestureRecognizerTest, GestureTapSyntheticMouse) {
gfx::Rect(0, 0, 123, 45), NULL));
delegate->Reset();
- GestureEvent tap(ui::ET_GESTURE_TAP, 20, 20, 0, base::Time::Now(), 0, 6);
+ GestureEvent tap(ui::ET_GESTURE_TAP, 20, 20, 0, base::Time::Now(), 0, 0);
root_window()->DispatchGestureEvent(&tap);
EXPECT_TRUE(delegate->mouse_enter());
EXPECT_TRUE(delegate->mouse_press());
@@ -764,8 +753,6 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
new QueueTouchEventDelegate(root_window()));
const int kWindowWidth = 123;
const int kWindowHeight = 45;
- const int kTouchId1 = 6;
- const int kTouchId2 = 4;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate(
queued_delegate.get(), -1234, bounds, NULL));
@@ -774,7 +761,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// Touch down on the window. This should not generate any gesture event.
queued_delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -786,7 +773,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// Introduce some delay before the touch is released so that it is recognized
// as a tap. However, this still should not create any gesture events.
queued_delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -805,7 +792,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), NULL));
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), kTouchId2);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 0);
root_window()->DispatchTouchEvent(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -814,7 +801,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), kTouchId2);
+ TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0);
root_window()->DispatchTouchEvent(&release2);
// Process the first queued event.
@@ -840,7 +827,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// Start all over. Press on the first window, then press again on the second
// window. The second press should still go to the first window.
queued_delegate->Reset();
- TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root_window()->DispatchTouchEvent(&press3);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -851,7 +838,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
queued_delegate->Reset();
delegate->Reset();
- TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), kTouchId2);
+ TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 1);
root_window()->DispatchTouchEvent(&press4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -894,8 +881,6 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 300;
const int kWindowHeight = 400;
- const int kTouchId1 = 5;
- const int kTouchId2 = 3;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -903,7 +888,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
aura::RootWindow* root = root_window();
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -915,7 +900,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Move the touch-point enough so that it is considered as a scroll. This
// should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 201), kTouchId1);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 201), 0);
root->DispatchTouchEvent(&move);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -926,7 +911,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Press the second finger. It should cause both a tap-down and pinch-begin.
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
root->DispatchTouchEvent(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -938,7 +923,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Move the first finger.
delegate->Reset();
- TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), kTouchId1);
+ TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), 0);
root->DispatchTouchEvent(&move3);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -951,7 +936,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Now move the second finger.
delegate->Reset();
- TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), kTouchId2);
+ TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 1);
root->DispatchTouchEvent(&move4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -964,7 +949,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Release the first finger. This should end pinch.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -979,7 +964,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Move the second finger. This should still generate a scroll.
delegate->Reset();
- TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), kTouchId2);
+ TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 1);
root->DispatchTouchEvent(&move5);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -991,53 +976,11 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
EXPECT_FALSE(delegate->pinch_update());
}
-TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
-scoped_ptr<GestureEventConsumeDelegate> delegate(
- new GestureEventConsumeDelegate());
- const int kWindowWidth = 300;
- const int kWindowHeight = 400;
- const int kTouchId1 = 5;
- const int kTouchId2 = 3;
- gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
- scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
- delegate.get(), -1234, bounds, NULL));
-
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
- root_window()->DispatchTouchEvent(&press);
- delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
- root_window()->DispatchTouchEvent(&press2);
- EXPECT_TRUE(delegate->pinch_begin());
-
- SendScrollEvent(root_window(), 130, 230, kTouchId1, delegate.get());
- EXPECT_TRUE(delegate->pinch_update());
-
- // Pinch has started, now release the second finger
- delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
- root_window()->DispatchTouchEvent(&release);
- EXPECT_TRUE(delegate->pinch_end());
-
- SendScrollEvent(root_window(), 130, 230, kTouchId2, delegate.get());
- EXPECT_TRUE(delegate->scroll_update());
-
- // Pinch again
- delegate->Reset();
- TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId1);
- root_window()->DispatchTouchEvent(&press3);
- EXPECT_TRUE(delegate->pinch_begin());
-
- SendScrollEvent(root_window(), 130, 230, kTouchId1, delegate.get());
- EXPECT_TRUE(delegate->pinch_update());
-}
-
TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 300;
const int kWindowHeight = 400;
- const int kTouchId1 = 3;
- const int kTouchId2 = 5;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -1045,7 +988,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
aura::RootWindow* root = root_window();
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
root->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -1057,7 +1000,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Press the second finger. It should cause a tap-down, scroll-begin and
// pinch-begin.
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
root->DispatchTouchEvent(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -1069,7 +1012,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Move the first finger.
delegate->Reset();
- TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), kTouchId1);
+ TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), 0);
root->DispatchTouchEvent(&move3);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1082,7 +1025,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Now move the second finger.
delegate->Reset();
- TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), kTouchId2);
+ TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 1);
root->DispatchTouchEvent(&move4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1095,7 +1038,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Release the first finger. This should end pinch.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -1110,7 +1053,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Move the second finger. This should still generate a scroll.
delegate->Reset();
- TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), kTouchId2);
+ TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 1);
root->DispatchTouchEvent(&move5);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
diff --git a/ui/aura/gestures/gesture_sequence.cc b/ui/aura/gestures/gesture_sequence.cc
index 1c5ff7e..554cf10 100644
--- a/ui/aura/gestures/gesture_sequence.cc
+++ b/ui/aura/gestures/gesture_sequence.cc
@@ -12,6 +12,11 @@
#include "ui/aura/gestures/gesture_configuration.h"
#include "ui/base/events.h"
+// TODO(sad): Pinch gestures currently always assume that the first two
+// touch-points (i.e. at indices 0 and 1) are involved. This may not
+// always be the case. This needs to be fixed eventually.
+// http://crbug.com/113144
+
namespace {
// TODO(girard): Make these configurable in sync with this CL
@@ -94,6 +99,18 @@ enum EdgeStateSignatureType {
GST_SCROLL_FIRST_CANCELLED =
G(GS_SCROLL, 0, TS_CANCELLED, false),
+ GST_SCROLL_FIRST_PRESSED =
+ G(GS_SCROLL, 0, TS_PRESSED, false),
+
+ GST_SCROLL_SECOND_RELEASED =
+ G(GS_SCROLL, 1, TS_RELEASED, false),
+
+ GST_SCROLL_SECOND_MOVED =
+ G(GS_SCROLL, 1, TS_MOVED, false),
+
+ GST_SCROLL_SECOND_CANCELLED =
+ G(GS_SCROLL, 1, TS_CANCELLED, false),
+
GST_SCROLL_SECOND_PRESSED =
G(GS_SCROLL, 1, TS_PRESSED, false),
@@ -147,6 +164,9 @@ GestureSequence::GestureSequence(RootWindow* root_window)
long_press_timer_(CreateTimer()),
point_count_(0),
root_window_(root_window) {
+ for (int i = 0; i < kMaxGesturePoints; ++i) {
+ points_[i].set_touch_id(i);
+ }
}
GestureSequence::~GestureSequence() {
@@ -165,13 +185,7 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
if (event.type() == ui::ET_TOUCH_PRESSED) {
if (point_count_ == kMaxGesturePoints)
return NULL;
- GesturePoint* new_point = &points_[event.touch_id()];
- // We shouldn't be able to get two PRESSED events, without a RELEASE
- DCHECK(!points_[event.touch_id()].in_use());
- new_point->set_point_id(point_count_++);
- } else {
- // Make sure the point we're modifying was PRESSED at some point in the past
- DCHECK(points_[event.touch_id()].in_use());
+ ++point_count_;
}
GestureState last_state = state_;
@@ -181,8 +195,7 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
GesturePoint& point = GesturePointForEvent(event);
point.UpdateValues(event);
flags_ = event.flags();
- const int point_id = points_[event.touch_id()].point_id();
- switch (Signature(state_, point_id, event.type(), false)) {
+ switch (Signature(state_, event.touch_id(), event.type(), false)) {
case GST_NO_GESTURE_FIRST_PRESSED:
TouchDown(event, point, gestures.get());
set_state(GS_PENDING_SYNTHETIC_CLICK);
@@ -204,6 +217,7 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
NoGesture(event, point, gestures.get());
break;
case GST_SCROLL_FIRST_MOVED:
+ case GST_SCROLL_SECOND_MOVED:
if (scroll_type_ == ST_VERTICAL ||
scroll_type_ == ST_HORIZONTAL)
BreakRailScroll(event, point, gestures.get());
@@ -212,9 +226,12 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
break;
case GST_SCROLL_FIRST_RELEASED:
case GST_SCROLL_FIRST_CANCELLED:
+ case GST_SCROLL_SECOND_RELEASED:
+ case GST_SCROLL_SECOND_CANCELLED:
ScrollEnd(event, point, gestures.get());
set_state(GS_NO_GESTURE);
break;
+ case GST_SCROLL_FIRST_PRESSED:
case GST_SCROLL_SECOND_PRESSED:
case GST_PENDING_SYNTHETIC_CLICK_SECOND_PRESSED:
PinchStart(event, point, gestures.get());
@@ -248,27 +265,15 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state)
long_press_timer_->Stop();
- // The set of point_ids must be contiguous and include 0.
- // When a touch point is released, all points with ids greater than the
- // released point must have their ids decremented, or the set of point_ids
- // could end up with gaps.
- if (event.type() == ui::ET_TOUCH_RELEASED) {
- GesturePoint& old_point = points_[event.touch_id()];
- for (int i = 0; i < kMaxGesturePoints; ++i) {
- GesturePoint& point = points_[i];
- if (point.point_id() > old_point.point_id())
- point.set_point_id(point.point_id() - 1);
- }
- old_point.Reset();
+ if (event.type() == ui::ET_TOUCH_RELEASED)
--point_count_;
- }
return gestures.release();
}
void GestureSequence::Reset() {
set_state(GS_NO_GESTURE);
- for (int i = 0; i < kMaxGesturePoints; ++i)
+ for (int i = 0; i < point_count_; ++i)
points_[i].Reset();
}
@@ -287,17 +292,6 @@ GesturePoint& GestureSequence::GesturePointForEvent(
return points_[event.touch_id()];
}
-GesturePoint* GestureSequence::GetPointByPointId(int point_id) {
- DCHECK(0 <= point_id && point_id < kMaxGesturePoints);
- for (int i = 0; i < kMaxGesturePoints; ++i) {
- GesturePoint& point = points_[i];
- if (point.in_use() && point.point_id() == point_id)
- return &point;
- }
- NOTREACHED();
- return NULL;
-}
-
void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point,
Gestures* gestures) {
gestures->push_back(linked_ptr<GestureEvent>(new GestureEvent(
@@ -488,14 +482,16 @@ bool GestureSequence::TouchDown(const TouchEvent& event,
}
void GestureSequence::AppendLongPressGestureEvent() {
- const GesturePoint* point = GetPointByPointId(0);
+ // TODO(tdresser) - this may not always be the first point
+ const GesturePoint& point = points_[0];
GestureEvent* gesture = new GestureEvent(
ui::ET_GESTURE_LONG_PRESS,
- point->first_touch_position().x(),
- point->first_touch_position().y(),
+ point.first_touch_position().x(),
+ point.first_touch_position().y(),
flags_,
- base::Time::FromDoubleT(point->last_touch_time()),
- point->point_id(), 0.f);
+ base::Time::FromDoubleT(point.last_touch_time()),
+ point.touch_id(), 0.f);
+
root_window_->DispatchGestureEvent(gesture);
}
@@ -518,16 +514,13 @@ bool GestureSequence::PinchStart(const TouchEvent& event,
state_ == GS_PENDING_SYNTHETIC_CLICK);
AppendTapDownGestureEvent(point, gestures);
- const GesturePoint* point1 = GetPointByPointId(0);
- const GesturePoint* point2 = GetPointByPointId(1);
-
- pinch_distance_current_ = point1->Distance(*point2);
+ pinch_distance_current_ = points_[0].Distance(points_[1]);
pinch_distance_start_ = pinch_distance_current_;
- AppendPinchGestureBegin(*point1, *point2, gestures);
+ AppendPinchGestureBegin(points_[0], points_[1], gestures);
if (state_ == GS_PENDING_SYNTHETIC_CLICK) {
- gfx::Point center = point1->last_touch_position().Middle(
- point2->last_touch_position());
+ gfx::Point center = points_[0].last_touch_position().Middle(
+ points_[1].last_touch_position());
AppendScrollGestureBegin(point, center, gestures);
}
@@ -537,27 +530,23 @@ bool GestureSequence::PinchStart(const TouchEvent& event,
bool GestureSequence::PinchUpdate(const TouchEvent& event,
const GesturePoint& point, Gestures* gestures) {
DCHECK(state_ == GS_PINCH);
-
- const GesturePoint* point1 = GetPointByPointId(0);
- const GesturePoint* point2 = GetPointByPointId(1);
-
- float distance = point1->Distance(*point2);
+ float distance = points_[0].Distance(points_[1]);
if (abs(distance - pinch_distance_current_) <
GestureConfiguration::minimum_pinch_update_distance_in_pixels()) {
// The fingers didn't move towards each other, or away from each other,
// enough to constitute a pinch. But perhaps they moved enough in the same
// direction to do a two-finger scroll.
- if (!point1->DidScroll(event,
+ if (!points_[0].DidScroll(event,
GestureConfiguration::minimum_distance_for_pinch_scroll_in_pixels()) ||
- !point2->DidScroll(event,
+ !points_[1].DidScroll(event,
GestureConfiguration::minimum_distance_for_pinch_scroll_in_pixels()))
return false;
- gfx::Point center = point1->last_touch_position().Middle(
- point2->last_touch_position());
+ gfx::Point center = points_[0].last_touch_position().Middle(
+ points_[1].last_touch_position());
AppendScrollGestureUpdate(point, center, gestures);
} else {
- AppendPinchGestureUpdate(*point1, *point2,
+ AppendPinchGestureUpdate(points_[0], points_[1],
distance / pinch_distance_current_, gestures);
pinch_distance_current_ = distance;
}
@@ -567,12 +556,8 @@ bool GestureSequence::PinchUpdate(const TouchEvent& event,
bool GestureSequence::PinchEnd(const TouchEvent& event,
const GesturePoint& point, Gestures* gestures) {
DCHECK(state_ == GS_PINCH);
-
- const GesturePoint* point1 = GetPointByPointId(0);
- const GesturePoint* point2 = GetPointByPointId(1);
-
- float distance = point1->Distance(*point2);
- AppendPinchGestureEnd(*point1, *point2,
+ float distance = points_[0].Distance(points_[1]);
+ AppendPinchGestureEnd(points_[0], points_[1],
distance / pinch_distance_start_, gestures);
pinch_distance_start_ = 0;
diff --git a/ui/aura/gestures/gesture_sequence.h b/ui/aura/gestures/gesture_sequence.h
index 709d8a5..95ed63c 100644
--- a/ui/aura/gestures/gesture_sequence.h
+++ b/ui/aura/gestures/gesture_sequence.h
@@ -55,11 +55,7 @@ class AURA_EXPORT GestureSequence {
GesturePoint& GesturePointForEvent(const TouchEvent& event);
- // Do a linear scan through points_ to find the GesturePoint
- // with id |point_id|.
- GesturePoint* GetPointByPointId(int point_id);
-
- // Functions to be called to add GestureEvents, after successful recognition.
+ // Functions to be called to add GestureEvents, after succesful recognition.
// Tap gestures.
void AppendTapDownGestureEvent(const GesturePoint& point, Gestures* gestures);
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index f78ed7c..d3779df 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -518,8 +518,7 @@ TEST_F(WindowTest, CaptureTests) {
generator.PressLeftButton();
EXPECT_EQ(1, delegate.mouse_event_count());
- TouchEvent touchev2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1);
- root_window()->DispatchTouchEvent(&touchev2);
+ root_window()->DispatchTouchEvent(&touchev);
EXPECT_EQ(0, delegate.touch_event_count());
// Removing the capture window from parent should reset the capture window