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

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

Issue 298823006: [Aura] Reduce frequency of PinchUpdate events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Jared's comments. Created 6 years, 7 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
Index: ui/events/gesture_detection/gesture_provider.cc
diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc
index 7607f08d8765a7fbc02a96f7eb471af5f813efcb..740cde6c3a51ed922f2ad69338ddcfcb6345d46a 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -130,7 +130,8 @@ class GestureProvider::ScaleGestureListenerImpl
: scale_gesture_detector_(config, this),
provider_(provider),
ignore_multitouch_events_(false),
- pinch_event_sent_(false) {}
+ pinch_event_sent_(false),
+ min_pinch_update_span_delta_(config.min_pinch_update_span_delta) {}
bool OnTouchEvent(const MotionEvent& event) {
// TODO: Need to deal with multi-touch transition.
@@ -171,6 +172,7 @@ class GestureProvider::ScaleGestureListenerImpl
const MotionEvent& e) OVERRIDE {
if (ignore_multitouch_events_ && !detector.InDoubleTapMode())
return false;
+
if (!pinch_event_sent_) {
pinch_event_sent_ = true;
provider_->Send(CreateGesture(ET_GESTURE_PINCH_BEGIN,
@@ -182,6 +184,13 @@ class GestureProvider::ScaleGestureListenerImpl
GetBoundingBox(e)));
}
+ float span = detector.GetCurrentSpan();
+ bool pinch_occured = std::abs(span - detector.GetPreviousSpan()) >=
+ min_pinch_update_span_delta_;
+
jdduke (slow) 2014/05/22 18:06:35 You might consider merging all of this into: if (
tdresser 2014/05/22 18:25:17 Done.
+ if (!pinch_occured)
+ return false;
+
float scale = detector.GetScaleFactor();
if (scale == 1)
return true;
@@ -247,6 +256,10 @@ class GestureProvider::ScaleGestureListenerImpl
// Whether any pinch zoom event has been sent to native.
bool pinch_event_sent_;
+ // The minimum change in span required before this is considered a pinch. See
+ // crbug.com/373318.
+ float min_pinch_update_span_delta_;
+
DISALLOW_COPY_AND_ASSIGN(ScaleGestureListenerImpl);
};
« no previous file with comments | « ui/events/gesture_detection/gesture_config_helper_aura.cc ('k') | ui/events/gesture_detection/gesture_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698