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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/eventfilter/GestureEventFilter.java

Issue 2798733002: Block onScroll if input MotionEvents are null (Closed)
Patch Set: doc Created 3 years, 8 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
« no previous file with comments | « no previous file | 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 package org.chromium.chrome.browser.compositor.layouts.eventfilter; 5 package org.chromium.chrome.browser.compositor.layouts.eventfilter;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Handler; 8 import android.os.Handler;
9 import android.view.GestureDetector; 9 import android.view.GestureDetector;
10 import android.view.MotionEvent; 10 import android.view.MotionEvent;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 context.getResources(); 91 context.getResources();
92 92
93 mDetector = new GestureDetector(context, new GestureDetector.SimpleOnGes tureListener() { 93 mDetector = new GestureDetector(context, new GestureDetector.SimpleOnGes tureListener() {
94 94
95 private float mOnScrollBeginX; 95 private float mOnScrollBeginX;
96 private float mOnScrollBeginY; 96 private float mOnScrollBeginY;
97 97
98 @Override 98 @Override
99 public boolean onScroll(MotionEvent e1, MotionEvent e2, 99 public boolean onScroll(MotionEvent e1, MotionEvent e2,
100 float distanceX, float distanceY) { 100 float distanceX, float distanceY) {
101 // This should ideally never happen but is used as a workaround for a larger
102 // problem. See https://crbug.com/656603
103 if (e1 == null || e2 == null) return false;
104
101 if (!mSeenFirstScrollEvent) { 105 if (!mSeenFirstScrollEvent) {
102 // Remove the touch slop region from the first scroll event to avoid a 106 // Remove the touch slop region from the first scroll event to avoid a
103 // jump. 107 // jump.
104 mSeenFirstScrollEvent = true; 108 mSeenFirstScrollEvent = true;
105 float distance = (float) Math.sqrt( 109 float distance = (float) Math.sqrt(
106 distanceX * distanceX + distanceY * distanceY); 110 distanceX * distanceX + distanceY * distanceY);
107 if (distance > 0.0f) { 111 if (distance > 0.0f) {
108 float ratio = Math.max(0, distance - mScaledTouchSlop) / distance; 112 float ratio = Math.max(0, distance - mScaledTouchSlop) / distance;
109 mOnScrollBeginX = e1.getX() + distanceX * (1.0f - ratio) ; 113 mOnScrollBeginX = e1.getX() + distanceX * (1.0f - ratio) ;
110 mOnScrollBeginY = e1.getY() + distanceY * (1.0f - ratio) ; 114 mOnScrollBeginY = e1.getY() + distanceY * (1.0f - ratio) ;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 243 }
240 mDetector.onTouchEvent(e); 244 mDetector.onTouchEvent(e);
241 245
242 // Propagate the up event after any gesture events. 246 // Propagate the up event after any gesture events.
243 if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANC EL) { 247 if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANC EL) {
244 mHandler.onUpOrCancel(); 248 mHandler.onUpOrCancel();
245 } 249 }
246 return true; 250 return true;
247 } 251 }
248 } 252 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698