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

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

Issue 23533051: [android_webview] Use a fraction to calculate scroll offset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert changes from previous patch set as they break AwSettings tests Created 7 years, 3 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/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 2805af26f729bf2fdf0bbfd2bafbe0f17055a99c..f0f286ffb8adcaf325ccd72bb5cb971b6c1d55ae 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -185,6 +185,12 @@ public class AwContents {
private boolean mClearViewActive;
private boolean mPictureListenerEnabled;
+ // These come from the compositor and are updated immediately (in contrast to the values in
+ // ContentViewCore, which are updated at end of every frame).
+ private float mPageScaleFactor = 1.0f;
+ private float mContentWidthDip;
+ private float mContentHeightDip;
+
private AwAutofillManagerDelegate mAwAutofillManagerDelegate;
private static final class DestroyRunnable implements Runnable {
@@ -355,22 +361,6 @@ public class AwContents {
}
//--------------------------------------------------------------------------------------------
- // NOTE: This content size change notification comes from the compositor and reflects the size
- // of the content on screen (but not neccessarily in the renderer main thread).
- private class AwContentUpdateFrameInfoListener
- implements ContentViewCore.UpdateFrameInfoListener {
- @Override
- public void onFrameInfoUpdated(float widthCss, float heightCss, float pageScaleFactor) {
- if (mNativeAwContents == 0) return;
- int widthPix = (int) Math.floor(widthCss * mDIPScale * pageScaleFactor);
- int heightPix = (int) Math.floor(heightCss * mDIPScale * pageScaleFactor);
- mScrollOffsetManager.setContentSize(widthPix, heightPix);
-
- nativeSetDisplayedPageScaleFactor(mNativeAwContents, pageScaleFactor);
- }
- }
-
- //--------------------------------------------------------------------------------------------
private class AwScrollOffsetManagerDelegate implements AwScrollOffsetManager.Delegate {
@Override
public void overScrollContainerViewBy(int deltaX, int deltaY, int scrollX, int scrollY,
@@ -567,7 +557,6 @@ public class AwContents {
nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
mIoThreadClient, mInterceptNavigationDelegate);
mContentsClient.installWebContentsObserver(mContentViewCore);
- mContentViewCore.setUpdateFrameInfoListener(new AwContentUpdateFrameInfoListener());
mSettings.setWebContents(nativeWebContents);
nativeSetDipScale(mNativeAwContents, (float) mDIPScale);
updateGlobalVisibleRect();
@@ -756,11 +745,11 @@ public class AwContents {
}
public int getContentHeightCss() {
- return (int) Math.ceil(mContentViewCore.getContentHeightCss());
+ return (int) Math.ceil(mContentHeightDip);
}
public int getContentWidthCss() {
- return (int) Math.ceil(mContentViewCore.getContentWidthCss());
+ return (int) Math.ceil(mContentWidthDip);
}
public Picture capturePicture() {
@@ -1345,7 +1334,7 @@ public class AwContents {
* the screen density factor. See CTS WebViewTest.testSetInitialScale.
*/
public float getScale() {
- return (float)(mContentViewCore.getScale() * mDIPScale);
+ return (float)(mPageScaleFactor * mDIPScale);
}
/**
@@ -1823,11 +1812,27 @@ public class AwContents {
}
@CalledByNative
+ private void setMaxContainerViewScrollOffset(int maxX, int maxY) {
+ mScrollOffsetManager.setMaxScrollOffset(maxX, maxY);
+ }
+
+ @CalledByNative
private void scrollContainerViewTo(int x, int y) {
mScrollOffsetManager.scrollContainerViewTo(x, y);
}
@CalledByNative
+ private void setContentsSize(int widthDip, int heightDip) {
+ mContentWidthDip = widthDip;
+ mContentHeightDip = heightDip;
+ }
+
+ @CalledByNative
+ private void setPageScaleFactor(float pageScaleFactor) {
+ mPageScaleFactor = pageScaleFactor;
+ }
+
+ @CalledByNative
private void setAwAutofillManagerDelegate(AwAutofillManagerDelegate delegate) {
mAwAutofillManagerDelegate = delegate;
delegate.init(mContentViewCore);
@@ -1942,8 +1947,6 @@ public class AwContents {
private native void nativeOnAttachedToWindow(int nativeAwContents, int w, int h);
private static native void nativeOnDetachedFromWindow(int nativeAwContents);
private native void nativeSetDipScale(int nativeAwContents, float dipScale);
- private native void nativeSetDisplayedPageScaleFactor(int nativeAwContents,
- float pageScaleFactor);
private native void nativeSetFixedLayoutSize(int nativeAwContents, int widthDip, int heightDip);
// Returns null if save state fails.

Powered by Google App Engine
This is Rietveld 408576698