OLD | NEW |
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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Bundle; | 8 import android.os.Bundle; |
9 import android.os.Handler; | 9 import android.os.Handler; |
10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
11 import android.util.Log; | 11 import android.util.Log; |
12 import android.view.InputDevice; | 12 import android.view.InputDevice; |
13 import android.view.MotionEvent; | 13 import android.view.MotionEvent; |
14 import android.view.ViewConfiguration; | 14 import android.view.ViewConfiguration; |
15 | 15 |
| 16 import org.chromium.base.CommandLine; |
16 import org.chromium.content.browser.LongPressDetector.LongPressDelegate; | 17 import org.chromium.content.browser.LongPressDetector.LongPressDelegate; |
17 import org.chromium.content.browser.third_party.GestureDetector; | 18 import org.chromium.content.browser.third_party.GestureDetector; |
18 import org.chromium.content.browser.third_party.GestureDetector.OnDoubleTapListe
ner; | 19 import org.chromium.content.browser.third_party.GestureDetector.OnDoubleTapListe
ner; |
19 import org.chromium.content.browser.third_party.GestureDetector.OnGestureListene
r; | 20 import org.chromium.content.browser.third_party.GestureDetector.OnGestureListene
r; |
20 import org.chromium.content.common.CommandLine; | 21 import org.chromium.content.common.ContentSwitches; |
21 import org.chromium.content.common.TraceEvent; | 22 import org.chromium.content.common.TraceEvent; |
22 | 23 |
23 import java.util.ArrayDeque; | 24 import java.util.ArrayDeque; |
24 import java.util.Deque; | 25 import java.util.Deque; |
25 | 26 |
26 /** | 27 /** |
27 * This class handles all MotionEvent handling done in ContentViewCore including
the gesture | 28 * This class handles all MotionEvent handling done in ContentViewCore including
the gesture |
28 * recognition. It sends all related native calls through the interface MotionEv
entDelegate. | 29 * recognition. It sends all related native calls through the interface MotionEv
entDelegate. |
29 */ | 30 */ |
30 class ContentViewGestureHandler implements LongPressDelegate { | 31 class ContentViewGestureHandler implements LongPressDelegate { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 380 |
380 mLongPressDetector = new LongPressDetector(context, this); | 381 mLongPressDetector = new LongPressDetector(context, this); |
381 mMotionEventDelegate = delegate; | 382 mMotionEventDelegate = delegate; |
382 mZoomManager = zoomManager; | 383 mZoomManager = zoomManager; |
383 mSnapScrollController = new SnapScrollController(context, mZoomManager); | 384 mSnapScrollController = new SnapScrollController(context, mZoomManager); |
384 mInputEventsDeliveredAtVSync = | 385 mInputEventsDeliveredAtVSync = |
385 inputEventDeliveryMode == ContentViewCore.INPUT_EVENTS_DELIVERED
_AT_VSYNC; | 386 inputEventDeliveryMode == ContentViewCore.INPUT_EVENTS_DELIVERED
_AT_VSYNC; |
386 mPxToDp = 1.0f / context.getResources().getDisplayMetrics().density; | 387 mPxToDp = 1.0f / context.getResources().getDisplayMetrics().density; |
387 | 388 |
388 mDisableClickDelay = CommandLine.isInitialized() && | 389 mDisableClickDelay = CommandLine.isInitialized() && |
389 CommandLine.getInstance().hasSwitch(CommandLine.DISABLE_CLICK_DE
LAY); | 390 CommandLine.getInstance().hasSwitch(ContentSwitches.DISABLE_CLIC
K_DELAY); |
390 | 391 |
391 initGestureDetectors(context); | 392 initGestureDetectors(context); |
392 } | 393 } |
393 | 394 |
394 /** | 395 /** |
395 * Used to override the default long press detector, gesture detector and li
stener. | 396 * Used to override the default long press detector, gesture detector and li
stener. |
396 * This is used for testing only. | 397 * This is used for testing only. |
397 * @param longPressDetector The new LongPressDetector to be assigned. | 398 * @param longPressDetector The new LongPressDetector to be assigned. |
398 * @param gestureDetector The new GestureDetector to be assigned. | 399 * @param gestureDetector The new GestureDetector to be assigned. |
399 * @param listener The new onGestureListener to be assigned. | 400 * @param listener The new onGestureListener to be assigned. |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 | 1366 |
1366 long nowMs = SystemClock.uptimeMillis(); | 1367 long nowMs = SystemClock.uptimeMillis(); |
1367 if ((nowMs - mLastDoubleTapTimeMs) >= ACTION_AFTER_DOUBLE_TAP_WINDOW_MS)
{ | 1368 if ((nowMs - mLastDoubleTapTimeMs) >= ACTION_AFTER_DOUBLE_TAP_WINDOW_MS)
{ |
1368 // Time expired, user took no action (that we care about). | 1369 // Time expired, user took no action (that we care about). |
1369 mMotionEventDelegate.sendActionAfterDoubleTapUMA( | 1370 mMotionEventDelegate.sendActionAfterDoubleTapUMA( |
1370 ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION, !mDisable
ClickDelay); | 1371 ContentViewCore.UMAActionAfterDoubleTap.NO_ACTION, !mDisable
ClickDelay); |
1371 mLastDoubleTapTimeMs = 0; | 1372 mLastDoubleTapTimeMs = 0; |
1372 } | 1373 } |
1373 } | 1374 } |
1374 } | 1375 } |
OLD | NEW |