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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java

Issue 16255010: Hookup android_webview scroll offset delegation to Java side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 7 years, 6 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
Index: android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java b/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..c23b37bb4b5ed4b0b5892c692d354029a41f5bb4
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java
@@ -0,0 +1,54 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview;
+
+import org.chromium.base.CalledByNative;
+
+class AwScrollOffsetManager {
+ public interface Delegate {
+ // Returns whether the update succeeded
+ boolean scrollContainerViewTo(int xPix, int yPix);
+ void scrollNativeTo(int xCss, int yCss);
+ int getContainerViewScrollXPix();
+ int getContainerViewScrollYPix();
+ }
+
+ final Delegate mDelegate;
+ final double mDIPScale;
+ boolean mIgnoreContainerViewScrollChanges;
+ int mNativeScrollXPix;
+ int mNativeScrollYPix;
+
+ public AwScrollOffsetManager(Delegate delegate, double dipScale) {
+ mDelegate = delegate;
+ mDIPScale = dipScale;
+ }
+
+ public void scrollContainerViewTo(int xCss, int yCss) {
joth 2013/06/18 03:19:50 don't CSS pixels normally travel in a float?
mkosiba (inactive) 2013/06/18 18:09:25 yes, they should.
+ mNativeScrollXPix = (int) (xCss * mDIPScale);
+ mNativeScrollYPix = (int) (yCss * mDIPScale);
joth 2013/06/18 03:19:50 maybe it's not difference either way, but I was ho
mkosiba (inactive) 2013/06/18 18:09:25 I don't think there is a really compelling reason.
joth 2013/06/19 05:34:45 I think in_process_view_renderer.cc will need to k
+
+ if (!mDelegate.scrollContainerViewTo(mNativeScrollXPix, mNativeScrollYPix)) {
+ scrollNativeTo(mDelegate.getContainerViewScrollXPix(),
+ mDelegate.getContainerViewScrollYPix());
joth 2013/06/18 03:19:50 the logic in this class is verging on so simple it
mkosiba (inactive) 2013/06/18 18:09:25 the main reason I opted to make this a separate cl
+ }
+ }
+
+ public void onContainerViewScrollChanged(int xPix, int yPix) {
+ scrollNativeTo(xPix, yPix);
+ }
+
+ private void scrollNativeTo(int xPix, int yPix) {
+ if (xPix == mNativeScrollXPix && yPix == mNativeScrollYPix)
+ return;
+
+ mNativeScrollXPix = xPix;
+ mNativeScrollYPix = yPix;
+
+ int xCss = (int) (xPix / mDIPScale);
+ int yCss = (int) (yPix / mDIPScale);
+ mDelegate.scrollNativeTo(xCss, yCss);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698