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 a01472a628829a5f6f15019651d132f1338f8d2b..5c23b8d1895647a752388364f5e024d1f813a260 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 |
@@ -523,6 +523,7 @@ public class ContentViewCore |
// Cached copy of all positions and scales as reported by the renderer. |
private final RenderCoordinates mRenderCoordinates; |
+ private final JoystickScrollProvider mJoystickScrollProvider; |
private boolean mIsMobileOptimizedHint; |
@@ -618,6 +619,8 @@ public class ContentViewCore |
// screen orientation. |
private boolean mFullscreenRequiredForOrientationLock = true; |
+ private boolean mShowingSoftKeyboard; |
+ |
// A ViewAndroidDelegate that delegates to the current container view. |
private ContentViewAndroidDelegate mViewAndroidDelegate; |
@@ -649,6 +652,7 @@ public class ContentViewCore |
mInputMethodManagerWrapper = new InputMethodManagerWrapper(mContext); |
mRenderCoordinates = new RenderCoordinates(); |
+ mJoystickScrollProvider = new JoystickScrollProvider(this); |
float deviceScaleFactor = getContext().getResources().getDisplayMetrics().density; |
String forceScaleFactor = CommandLine.getInstance().getSwitchValue( |
ContentSwitches.FORCE_DEVICE_SCALE_FACTOR); |
@@ -682,6 +686,9 @@ public class ContentViewCore |
return mContainerView; |
} |
+ public boolean getSoftKeyboardShowFlag() { |
+ return mShowingSoftKeyboard; |
+ } |
/** |
* @return The WebContents currently being rendered. |
*/ |
@@ -762,6 +769,7 @@ public class ContentViewCore |
@Override |
public void onDismissInput() { |
getContentViewClient().onImeStateChangeRequested(false); |
+ mShowingSoftKeyboard = false; |
} |
@Override |
@@ -780,9 +788,11 @@ public class ContentViewCore |
return new ResultReceiver(new Handler()) { |
@Override |
public void onReceiveResult(int resultCode, Bundle resultData) { |
+ mShowingSoftKeyboard = resultCode == InputMethodManager.RESULT_SHOWN |
+ || resultCode == InputMethodManager.RESULT_UNCHANGED_SHOWN; |
getContentViewClient().onImeStateChangeRequested( |
- resultCode == InputMethodManager.RESULT_SHOWN |
- || resultCode == InputMethodManager.RESULT_UNCHANGED_SHOWN); |
+ mShowingSoftKeyboard); |
+ |
if (resultCode == InputMethodManager.RESULT_SHOWN) { |
// If OSK is newly shown, delay the form focus until |
// the onSizeChanged (in order to adjust relative to the |
@@ -1795,6 +1805,16 @@ public class ContentViewCore |
mContainerView.postDelayed(mFakeMouseMoveRunnable, 250); |
return true; |
} |
+ } else if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { |
+ // Handle left stick event |
+ mJoystickScrollProvider.onMotion(event); |
+ /** |
+ * Android framework generates secondary DPAD_[DIRECTION] events from unhandled |
+ * (LS,RS)joystick events. These events cause webview focus to change to next |
+ * focus-able item or force default scroll action. Setting the location to 0,0 |
+ *effectively disable these DPAD events. |
+ */ |
+ event.setLocation(0, 0); |
} |
return mContainerViewInternals.super_onGenericMotionEvent(event); |
} |
@@ -1823,11 +1843,9 @@ public class ContentViewCore |
* 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(int xPix, int yPix) { |
- if (mNativeContentViewCore != 0) { |
- nativeScrollBy(mNativeContentViewCore, |
- SystemClock.uptimeMillis(), 0, 0, xPix, yPix); |
- } |
+ public void scrollBy(int dxPix, int dyPix) { |
+ if (mNativeContentViewCore == 0) return; |
+ scrollByImpl(dxPix, dyPix); |
} |
/** |
@@ -1839,18 +1857,20 @@ public class ContentViewCore |
final float yCurrentPix = mRenderCoordinates.getScrollYPix(); |
final float dxPix = xPix - xCurrentPix; |
final float dyPix = yPix - yCurrentPix; |
- if (dxPix != 0 || dyPix != 0) { |
- long time = SystemClock.uptimeMillis(); |
- // It's a very real (and valid) possibility that a fling may still |
- // be active when programatically scrolling. Cancelling the fling in |
- // such cases ensures a consistent gesture event stream. |
- if (mPotentiallyActiveFlingCount > 0) nativeFlingCancel(mNativeContentViewCore, time); |
- nativeScrollBegin(mNativeContentViewCore, time, |
- xCurrentPix, yCurrentPix, -dxPix, -dyPix); |
- nativeScrollBy(mNativeContentViewCore, |
- time, xCurrentPix, yCurrentPix, dxPix, dyPix); |
- nativeScrollEnd(mNativeContentViewCore, time); |
- } |
+ scrollByImpl(dxPix, dyPix); |
+ } |
+ |
+ private void scrollByImpl(float dxPix, float dyPix) { |
sshelke
2015/05/12 12:09:05
Implementation for ScrollBy and ScrollTo looks sam
jdduke (slow)
2015/05/12 15:13:11
The difference is that |ScrollTo| computes the del
|
+ if (mNativeContentViewCore == 0) return; |
+ if (dxPix == 0 && dyPix == 0) return; |
+ long time = SystemClock.uptimeMillis(); |
+ // It's a very real (and valid) possibility that a fling may still |
+ // be active when programatically scrolling. Cancelling the fling in |
+ // such cases ensures a consistent gesture event stream. |
+ if (mPotentiallyActiveFlingCount > 0) nativeFlingCancel(mNativeContentViewCore, time); |
+ nativeScrollBegin(mNativeContentViewCore, time, 0, 0, -dxPix, -dyPix); |
+ nativeScrollBy(mNativeContentViewCore, time, 0, 0, dxPix, dyPix); |
+ nativeScrollEnd(mNativeContentViewCore, time); |
} |
// NOTE: this can go away once ContentView.getScrollX() reports correct values. |
@@ -2309,6 +2329,7 @@ public class ContentViewCore |
// We cannot trust ContentViewClient#onImeStateChangeRequested to |
// hide the input window because it has an empty default implementation. |
// So we need to explicitly hide the input method window here. |
+ mShowingSoftKeyboard = false; |
if (mInputMethodManagerWrapper.isActive(mContainerView)) { |
mInputMethodManagerWrapper.hideSoftInputFromWindow( |
mContainerView.getWindowToken(), 0, null); |