Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| index 952f300d2e701811e9d720a2d1a3bea586a45b42..236f2ae59621eefb8386a65c13bd0b61d468f6cb 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| @@ -344,7 +344,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| private final RenderCoordinates mRenderCoordinates; |
| // Provides smooth gamepad joystick-driven scrolling. |
| - private final JoystickScrollProvider mJoystickScrollProvider; |
| + private JoystickScrollProvider mJoystickScrollProvider; |
| // Provides smooth gamepad joystick-driven zooming. |
| private JoystickZoomProvider mJoystickZoomProvider; |
| @@ -387,10 +387,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| // because the OSK was just brought up. |
| private final Rect mFocusPreOSKViewportRect = new Rect(); |
| - // Store the x, y coordinates of the last touch or mouse event. |
| - private float mLastFocalEventX; |
| - private float mLastFocalEventY; |
| - |
| // Whether a touch scroll sequence is active, used to hide text selection |
| // handles. Note that a scroll sequence will *always* bound a pinch |
| // sequence, so this will also be true for the duration of a pinch gesture. |
| @@ -453,7 +449,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| mContext = context; |
| mProductVersion = productVersion; |
| mRenderCoordinates = new RenderCoordinates(); |
| - mJoystickScrollProvider = new JoystickScrollProvider(this); |
| mAccessibilityManager = (AccessibilityManager) |
| getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); |
| mSystemCaptioningBridge = CaptioningBridgeFactory.getSystemCaptioningBridge(mContext); |
| @@ -635,6 +630,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| mRenderCoordinates.reset(); |
| mRenderCoordinates.setDeviceScaleFactor(dipScale, windowAndroid.getContext()); |
| + mJoystickScrollProvider = new JoystickScrollProvider(webContents, getContainerView()); |
| + mJoystickScrollProvider.setDeviceScaleFactor(dipScale, windowAndroid.getContext()); |
| + |
| mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, windowNativePointer, |
| dipScale, mRetainedJavaScriptObjects); |
| mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); |
| @@ -1542,7 +1540,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| public void onFocusChanged(boolean gainFocus) { |
| mImeAdapter.onViewFocusChanged(gainFocus); |
| - mJoystickScrollProvider.setEnabled(gainFocus && !isFocusedNodeEditable()); |
| + if (mJoystickScrollProvider != null) { |
| + mJoystickScrollProvider.setEnabled(gainFocus && !isFocusedNodeEditable()); |
| + } |
| if (gainFocus) { |
| restoreSelectionPopupsIfNecessary(); |
| @@ -1643,8 +1643,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| public boolean onGenericMotionEvent(MotionEvent event) { |
| if (GamepadList.onGenericMotionEvent(event)) return true; |
| if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| - mLastFocalEventX = event.getX(); |
| - mLastFocalEventY = event.getY(); |
| switch (event.getActionMasked()) { |
| case MotionEvent.ACTION_SCROLL: |
| if (mNativeContentViewCore == 0) return false; |
| @@ -1678,6 +1676,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| } |
| } |
| } else if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { |
| + if (mJoystickScrollProvider == null) return false; |
| if (mJoystickScrollProvider.onMotion(event)) return true; |
| if (mJoystickZoomProvider == null) { |
| mJoystickZoomProvider = |
| @@ -1713,7 +1712,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| * are overridden, so that View's mScrollX and mScrollY will be unchanged at |
| * (0, 0). This is critical for drawing ContentView correctly. |
| */ |
| - public void scrollBy(float dxPix, float dyPix, boolean useLastFocalEventLocation) { |
|
Tima Vaisburd
2016/12/08 00:35:48
Removed now unused third parameter and variables t
|
| + public void scrollBy(float dxPix, float dyPix) { |
| if (mNativeContentViewCore == 0) return; |
| if (dxPix == 0 && dyPix == 0) return; |
| long time = SystemClock.uptimeMillis(); |
| @@ -1722,11 +1721,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| // such cases ensures a consistent gesture event stream. |
| if (mPotentiallyActiveFlingCount > 0) nativeFlingCancel(mNativeContentViewCore, time); |
| // x/y represents starting location of scroll. |
| - final float x = useLastFocalEventLocation ? mLastFocalEventX : 0f; |
| - final float y = useLastFocalEventLocation ? mLastFocalEventY : 0f; |
| - nativeScrollBegin( |
| - mNativeContentViewCore, time, x, y, -dxPix, -dyPix, !useLastFocalEventLocation); |
| - nativeScrollBy(mNativeContentViewCore, time, x, y, dxPix, dyPix); |
| + nativeScrollBegin(mNativeContentViewCore, time, 0f, 0f, -dxPix, -dyPix, true); |
| + nativeScrollBy(mNativeContentViewCore, time, 0f, 0f, dxPix, dyPix); |
| nativeScrollEnd(mNativeContentViewCore, time); |
| } |
| @@ -1739,7 +1735,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| final float yCurrentPix = mRenderCoordinates.getScrollYPix(); |
| final float dxPix = xPix - xCurrentPix; |
| final float dyPix = yPix - yCurrentPix; |
| - scrollBy(dxPix, dyPix, false); |
| + scrollBy(dxPix, dyPix); |
| } |
| // NOTE: this can go away once ContentView.getScrollX() reports correct values. |
| @@ -1833,8 +1829,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| } |
| if (!mPopupZoomer.isShowing()) mPopupZoomer.setLastTouch(xPix, yPix); |
| - mLastFocalEventX = xPix; |
| - mLastFocalEventY = yPix; |
| } |
| public void setZoomControlsDelegate(ZoomControlsDelegate zoomControlsDelegate) { |
| @@ -2017,7 +2011,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| mSelectionPopupController.updateSelectionState(focusedNodeEditable, |
| focusedNodeIsPassword); |
| if (editableToggled) { |
| - mJoystickScrollProvider.setEnabled(!focusedNodeEditable); |
| + if (mJoystickScrollProvider != null) { |
| + mJoystickScrollProvider.setEnabled(!focusedNodeEditable); |
| + } |
| getContentViewClient().onFocusedNodeEditabilityChanged(focusedNodeEditable); |
| } |
| } finally { |
| @@ -2872,6 +2868,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| if (windowAndroid == null || mNativeContentViewCore == 0) return; |
| mRenderCoordinates.setDeviceScaleFactor(dipScale, getWindowAndroid().getContext()); |
| + if (mJoystickScrollProvider != null) { |
| + mJoystickScrollProvider.setDeviceScaleFactor(dipScale, getWindowAndroid().getContext()); |
| + } |
| nativeSetDIPScale(mNativeContentViewCore, dipScale); |
| } |