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

Unified Diff: ui/events/gesture_detection/scale_gesture_detector.cc

Issue 501503003: Avoid an extra GestureDetector instance for double-tap drag zooming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix spelling Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/gesture_detection/scale_gesture_detector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gesture_detection/scale_gesture_detector.cc
diff --git a/ui/events/gesture_detection/scale_gesture_detector.cc b/ui/events/gesture_detection/scale_gesture_detector.cc
index 13aa1a4b5cc077c10c9a9000cc2dabcf06054165..cf8de59cc065cc634faaba30807a3d1f7519072f 100644
--- a/ui/events/gesture_detection/scale_gesture_detector.cc
+++ b/ui/events/gesture_detection/scale_gesture_detector.cc
@@ -31,9 +31,9 @@ const float kScaleFactor = .5f;
// Note: These constants were taken directly from the default (unscaled)
// versions found in Android's ViewConfiguration.
ScaleGestureDetector::Config::Config()
- : min_scaling_touch_major(48),
+ : span_slop(16),
+ min_scaling_touch_major(48),
min_scaling_span(200),
- quick_scale_enabled(true),
min_pinch_update_span_delta(0) {
}
@@ -55,10 +55,8 @@ void ScaleGestureDetector::SimpleScaleGestureListener::OnScaleEnd(
ScaleGestureDetector::ScaleGestureDetector(const Config& config,
ScaleGestureListener* listener)
: listener_(listener),
- config_(config),
focus_x_(0),
focus_y_(0),
- quick_scale_enabled_(false),
curr_span_(0),
prev_span_(0),
initial_span_(0),
@@ -80,13 +78,12 @@ ScaleGestureDetector::ScaleGestureDetector(const Config& config,
double_tap_mode_(DOUBLE_TAP_MODE_NONE),
event_before_or_above_starting_gesture_event_(false) {
DCHECK(listener_);
- span_slop_ = (config.gesture_detector_config.touch_slop + kSlopEpsilon) * 2;
+ span_slop_ = config.span_slop + kSlopEpsilon;
touch_min_major_ = config.min_scaling_touch_major;
touch_max_major_ = std::min(config.min_scaling_span / std::sqrt(2.f),
2.f * touch_min_major_);
min_span_ = config.min_scaling_span + kSlopEpsilon;
ResetTouchHistory();
- SetQuickScaleEnabled(config.quick_scale_enabled);
}
ScaleGestureDetector::~ScaleGestureDetector() {}
@@ -96,12 +93,6 @@ bool ScaleGestureDetector::OnTouchEvent(const MotionEvent& event) {
const int action = event.GetAction();
- // Forward the event to check for double tap gesture.
- if (quick_scale_enabled_) {
- DCHECK(gesture_detector_);
- gesture_detector_->OnTouchEvent(event);
- }
-
const bool stream_complete =
action == MotionEvent::ACTION_UP ||
action == MotionEvent::ACTION_CANCEL ||
@@ -241,18 +232,6 @@ bool ScaleGestureDetector::OnTouchEvent(const MotionEvent& event) {
return true;
}
-void ScaleGestureDetector::SetQuickScaleEnabled(bool scales) {
- quick_scale_enabled_ = scales;
- if (quick_scale_enabled_ && !gesture_detector_) {
- gesture_detector_.reset(
- new GestureDetector(config_.gesture_detector_config, this, this));
- }
-}
-
-bool ScaleGestureDetector::IsQuickScaleEnabled() const {
- return quick_scale_enabled_;
-}
-
bool ScaleGestureDetector::IsInProgress() const { return in_progress_; }
bool ScaleGestureDetector::InDoubleTapMode() const {
« no previous file with comments | « ui/events/gesture_detection/scale_gesture_detector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698