OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.view.GestureDetector; | 8 import android.view.GestureDetector; |
9 import android.view.MotionEvent; | 9 import android.view.MotionEvent; |
10 import android.view.ViewConfiguration; | 10 import android.view.ViewConfiguration; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 /** The Y coordinate of the synthetic ACTION_DOWN MotionEvent. */ | 104 /** The Y coordinate of the synthetic ACTION_DOWN MotionEvent. */ |
105 private float mSyntheticActionDownY; | 105 private float mSyntheticActionDownY; |
106 | 106 |
107 /** The list of recorded events. */ | 107 /** The list of recorded events. */ |
108 private final ArrayList<MotionEvent> mRecordedEvents = new ArrayList<MotionE vent>(); | 108 private final ArrayList<MotionEvent> mRecordedEvents = new ArrayList<MotionE vent>(); |
109 | 109 |
110 /** The initial Y position of the current gesture. */ | 110 /** The initial Y position of the current gesture. */ |
111 private float mInitialEventY; | 111 private float mInitialEventY; |
112 | 112 |
113 /** Whether or not the superclass has seen a down event. */ | |
114 private boolean mFilterHadDownEvent; | |
115 | |
113 private class SwipeRecognizerImpl extends SwipeRecognizer { | 116 private class SwipeRecognizerImpl extends SwipeRecognizer { |
114 public SwipeRecognizerImpl(Context context) { | 117 public SwipeRecognizerImpl(Context context) { |
115 super(context); | 118 super(context); |
116 setSwipeHandler(mPanel); | 119 setSwipeHandler(mPanel); |
117 } | 120 } |
118 | 121 |
119 @Override | 122 @Override |
120 public boolean onSingleTapUp(MotionEvent event) { | 123 public boolean onSingleTapUp(MotionEvent event) { |
121 mPanel.handleClick(event.getEventTime(), event.getX() * mPxToDp, | 124 mPanel.handleClick(event.getEventTime(), event.getX() * mPxToDp, |
122 event.getY() * mPxToDp); | 125 event.getY() * mPxToDp); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 e.recycle(); | 324 e.recycle(); |
322 } | 325 } |
323 | 326 |
324 /** | 327 /** |
325 * Propagates the given {@link MotionEvent} to the given {@link EventTarget} . | 328 * Propagates the given {@link MotionEvent} to the given {@link EventTarget} . |
326 * @param e The {@link MotionEvent} to be propagated. | 329 * @param e The {@link MotionEvent} to be propagated. |
327 * @param target The {@link EventTarget} to propagate events to. | 330 * @param target The {@link EventTarget} to propagate events to. |
328 */ | 331 */ |
329 private void propagateEvent(MotionEvent e, EventTarget target) { | 332 private void propagateEvent(MotionEvent e, EventTarget target) { |
330 if (target == EventTarget.PANEL) { | 333 if (target == EventTarget.PANEL) { |
334 // Make sure the internal gesture detector has seen at least on down event. | |
335 if (e.getActionMasked() == MotionEvent.ACTION_DOWN) mFilterHadDownEv ent = true; | |
336 if (!mFilterHadDownEvent) { | |
337 MotionEvent down = MotionEvent.obtain(e); | |
338 down.setAction(MotionEvent.ACTION_DOWN); | |
339 super.onTouchEventInternal(down); | |
Khushal
2017/04/27 17:18:00
set mFilterHadDownEvent to true in this block as w
mdjones
2017/04/27 17:22:32
Whoops; done.
| |
340 } | |
331 super.onTouchEventInternal(e); | 341 super.onTouchEventInternal(e); |
332 } else if (target == EventTarget.CONTENT_VIEW) { | 342 } else if (target == EventTarget.CONTENT_VIEW) { |
333 propagateEventToContentViewCore(e); | 343 propagateEventToContentViewCore(e); |
334 } | 344 } |
335 } | 345 } |
336 | 346 |
337 /** | 347 /** |
338 * Propagates the given {@link MotionEvent} to the {@link ContentViewCore}. | 348 * Propagates the given {@link MotionEvent} to the {@link ContentViewCore}. |
339 * @param e The {@link MotionEvent} to be propagated. | 349 * @param e The {@link MotionEvent} to be propagated. |
340 */ | 350 */ |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 public boolean onSingleTapUp(MotionEvent e) { | 568 public boolean onSingleTapUp(MotionEvent e) { |
559 return handleSingleTapUp(e); | 569 return handleSingleTapUp(e); |
560 } | 570 } |
561 | 571 |
562 @Override | 572 @Override |
563 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { | 573 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { |
564 return handleScroll(e1, e2, distanceY); | 574 return handleScroll(e1, e2, distanceY); |
565 } | 575 } |
566 } | 576 } |
567 } | 577 } |
OLD | NEW |