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

Side by Side Diff: ui/base/gestures/gesture_sequence.cc

Issue 10824158: Pass tap count (1 or 2) with tap gesture events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/gestures/gesture_sequence.h" 5 #include "ui/base/gestures/gesture_sequence.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 Gestures* gestures) { 589 Gestures* gestures) {
590 gestures->push_back(CreateGestureEvent( 590 gestures->push_back(CreateGestureEvent(
591 GestureEventDetails(ui::ET_GESTURE_END, 0, 0), 591 GestureEventDetails(ui::ET_GESTURE_END, 0, 0),
592 point.first_touch_position(), 592 point.first_touch_position(),
593 flags_, 593 flags_,
594 base::Time::FromDoubleT(point.last_touch_time()), 594 base::Time::FromDoubleT(point.last_touch_time()),
595 1 << point.touch_id())); 595 1 << point.touch_id()));
596 } 596 }
597 597
598 void GestureSequence::AppendClickGestureEvent(const GesturePoint& point, 598 void GestureSequence::AppendClickGestureEvent(const GesturePoint& point,
599 int tap_count,
599 Gestures* gestures) { 600 Gestures* gestures) {
600 gfx::Rect er = point.enclosing_rectangle(); 601 gfx::Rect er = point.enclosing_rectangle();
601 gfx::Point center = er.CenterPoint(); 602 gfx::Point center = er.CenterPoint();
602 gestures->push_back(CreateGestureEvent( 603 gestures->push_back(CreateGestureEvent(
603 GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0), 604 GestureEventDetails(ui::ET_GESTURE_TAP, tap_count, 0),
604 center, 605 center,
605 flags_, 606 flags_,
606 base::Time::FromDoubleT(point.last_touch_time()), 607 base::Time::FromDoubleT(point.last_touch_time()),
607 1 << point.touch_id())); 608 1 << point.touch_id()));
608 } 609 }
609 610
610 void GestureSequence::AppendDoubleClickGestureEvent(const GesturePoint& point, 611 void GestureSequence::AppendDoubleClickGestureEvent(const GesturePoint& point,
611 Gestures* gestures) { 612 Gestures* gestures) {
612 gestures->push_back(CreateGestureEvent( 613 gestures->push_back(CreateGestureEvent(
613 GestureEventDetails(ui::ET_GESTURE_DOUBLE_TAP, 0, 0), 614 GestureEventDetails(ui::ET_GESTURE_DOUBLE_TAP, 0, 0),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 point->enclosing_rectangle().CenterPoint(), 747 point->enclosing_rectangle().CenterPoint(),
747 flags_, 748 flags_,
748 base::Time::FromDoubleT(point->last_touch_time()), 749 base::Time::FromDoubleT(point->last_touch_time()),
749 1 << point->touch_id())); 750 1 << point->touch_id()));
750 } 751 }
751 752
752 bool GestureSequence::Click(const TouchEvent& event, 753 bool GestureSequence::Click(const TouchEvent& event,
753 const GesturePoint& point, Gestures* gestures) { 754 const GesturePoint& point, Gestures* gestures) {
754 DCHECK(state_ == GS_PENDING_SYNTHETIC_CLICK); 755 DCHECK(state_ == GS_PENDING_SYNTHETIC_CLICK);
755 if (point.IsInClickWindow(event)) { 756 if (point.IsInClickWindow(event)) {
756 AppendClickGestureEvent(point, gestures); 757 bool double_tap = point.IsInDoubleClickWindow(event);
757 if (point.IsInDoubleClickWindow(event)) 758 AppendClickGestureEvent(point, double_tap ? 2 : 1, gestures);
759 if (double_tap)
758 AppendDoubleClickGestureEvent(point, gestures); 760 AppendDoubleClickGestureEvent(point, gestures);
759 return true; 761 return true;
760 } 762 }
761 return false; 763 return false;
762 } 764 }
763 765
764 bool GestureSequence::ScrollStart(const TouchEvent& event, 766 bool GestureSequence::ScrollStart(const TouchEvent& event,
765 GesturePoint& point, Gestures* gestures) { 767 GesturePoint& point, Gestures* gestures) {
766 DCHECK(state_ == GS_PENDING_SYNTHETIC_CLICK); 768 DCHECK(state_ == GS_PENDING_SYNTHETIC_CLICK);
767 if (point.IsInClickWindow(event) || 769 if (point.IsInClickWindow(event) ||
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 return; 1012 return;
1011 1013
1012 // Since long press timer has been started, there should be a non-NULL point. 1014 // Since long press timer has been started, there should be a non-NULL point.
1013 const GesturePoint* point = GetPointByPointId(0); 1015 const GesturePoint* point = GetPointByPointId(0);
1014 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), 1016 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(),
1015 event.GetLocation())) 1017 event.GetLocation()))
1016 long_press_timer_->Stop(); 1018 long_press_timer_->Stop();
1017 } 1019 }
1018 1020
1019 } // namespace ui 1021 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698