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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 1131723006: [Android] Implement scrollTo in terms of scrollBy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/android/javatests/src/org/chromium/content/browser/ContentViewScrollingTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2ebfb8e79e70afba5d5de45144274eafaf540c7d..66a26291fe59ce6481d252ebb1abd7797b83fa39 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
@@ -1790,34 +1790,29 @@ 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(float dxPix, float dyPix) {
jdduke (slow) 2015/05/18 21:31:53 We have to convert to float at some point anyway,
hush (inactive) 2015/05/19 00:33:23 Hi Jared, Just making sure I understand it. Neithe
+ 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);
}
/**
* @see View#scrollTo(int, int)
*/
- public void scrollTo(int xPix, int yPix) {
+ public void scrollTo(float xPix, float yPix) {
if (mNativeContentViewCore == 0) return;
final float xCurrentPix = mRenderCoordinates.getScrollXPix();
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);
- }
+ scrollBy(dxPix, dyPix);
}
// NOTE: this can go away once ContentView.getScrollX() reports correct values.
« no previous file with comments | « no previous file | content/public/android/javatests/src/org/chromium/content/browser/ContentViewScrollingTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698