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

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: fix compile break 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..2e3955cab43d4a9d118bbd4e1f6c349455ff9f52
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java
@@ -0,0 +1,50 @@
+// 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 {
+ // The unit of all the values in this delegate are physical pixels
+ public interface Delegate {
+ // Returns whether the update succeeded
+ boolean scrollContainerViewTo(int x, int y);
+ void scrollNativeTo(int x, int y);
+ int getContainerViewScrollX();
+ int getContainerViewScrollY();
+ }
+
+ final Delegate mDelegate;
+ int mNativeScrollX;
+ int mNativeScrollY;
+
+ public AwScrollOffsetManager(Delegate delegate) {
+ mDelegate = delegate;
+ }
+
+ public void scrollContainerViewTo(int x, int y) {
+ mNativeScrollX = x;
+ mNativeScrollY = y;
+
+ if (!mDelegate.scrollContainerViewTo(x, y)) {
+ scrollNativeTo(mDelegate.getContainerViewScrollX(),
+ mDelegate.getContainerViewScrollY());
+ }
+ }
+
+ public void onContainerViewScrollChanged(int x, int y) {
+ scrollNativeTo(x, y);
+ }
+
+ private void scrollNativeTo(int x, int y) {
+ if (x == mNativeScrollX && y == mNativeScrollY)
+ return;
+
+ mNativeScrollX = x;
+ mNativeScrollY = y;
+
+ mDelegate.scrollNativeTo(x, y);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698