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

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

Issue 11415293: Refactor access to scroll deltas in GesturePoint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « ui/base/gestures/gesture_point.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0), 726 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0),
727 location, 727 location,
728 flags_, 728 flags_,
729 base::Time::FromDoubleT(point.last_touch_time()), 729 base::Time::FromDoubleT(point.last_touch_time()),
730 1 << point.touch_id())); 730 1 << point.touch_id()));
731 } 731 }
732 } 732 }
733 733
734 void GestureSequence::AppendScrollGestureUpdate(GesturePoint& point, 734 void GestureSequence::AppendScrollGestureUpdate(GesturePoint& point,
735 Gestures* gestures) { 735 Gestures* gestures) {
736 float dx, dy; 736 gfx::Vector2d d;
737 gfx::Point location; 737 gfx::Point location;
738 if (point_count_ == 1) { 738 if (point_count_ == 1) {
739 dx = point.x_delta(); 739 d = point.ScrollDelta();
740 dy = point.y_delta();
741 location = point.last_touch_position(); 740 location = point.last_touch_position();
742 } else { 741 } else {
743 location = bounding_box_.CenterPoint(); 742 location = bounding_box_.CenterPoint();
744 dx = location.x() - latest_multi_scroll_update_location_.x(); 743 d = location - latest_multi_scroll_update_location_;
745 dy = location.y() - latest_multi_scroll_update_location_.y();
746 latest_multi_scroll_update_location_ = location; 744 latest_multi_scroll_update_location_ = location;
747 } 745 }
748 if (scroll_type_ == ST_HORIZONTAL) 746 if (scroll_type_ == ST_HORIZONTAL)
749 dy = 0; 747 d.set_y(0);
750 else if (scroll_type_ == ST_VERTICAL) 748 else if (scroll_type_ == ST_VERTICAL)
751 dx = 0; 749 d.set_x(0);
752 if (dx == 0 && dy == 0) 750 if (d == gfx::Vector2d())
sadrul 2012/12/04 21:27:44 d.IsZero()?
rjkroege 2012/12/04 21:53:34 Done.
753 return; 751 return;
754 752
755 GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE, dx, dy); 753 GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE, d.x(), d.y());
756 details.SetScrollVelocity( 754 details.SetScrollVelocity(
757 scroll_type_ == ST_VERTICAL ? 0 : point.XVelocity(), 755 scroll_type_ == ST_VERTICAL ? 0 : point.XVelocity(),
758 scroll_type_ == ST_HORIZONTAL ? 0 : point.YVelocity()); 756 scroll_type_ == ST_HORIZONTAL ? 0 : point.YVelocity());
759 gestures->push_back(CreateGestureEvent( 757 gestures->push_back(CreateGestureEvent(
760 details, 758 details,
761 location, 759 location,
762 flags_, 760 flags_,
763 base::Time::FromDoubleT(point.last_touch_time()), 761 base::Time::FromDoubleT(point.last_touch_time()),
764 ComputeTouchBitmask(points_))); 762 ComputeTouchBitmask(points_)));
765 } 763 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 return; 1123 return;
1126 1124
1127 // Since long press timer has been started, there should be a non-NULL point. 1125 // Since long press timer has been started, there should be a non-NULL point.
1128 const GesturePoint* point = GetPointByPointId(0); 1126 const GesturePoint* point = GetPointByPointId(0);
1129 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), 1127 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(),
1130 event.location())) 1128 event.location()))
1131 GetLongPressTimer()->Stop(); 1129 GetLongPressTimer()->Stop();
1132 } 1130 }
1133 1131
1134 } // namespace ui 1132 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/gestures/gesture_point.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698