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

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

Issue 2288273003: Reland: Move DIP scale away from AwContents (Closed)
Patch Set: Reland with a fix Created 4 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d5ea693e2b8add35cd96fa033a161a6e0a7a53c7..64f957629819ae073a7fa5a0b1ce869a19640fdb 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -75,7 +75,6 @@ import org.chromium.ui.base.ActivityWindowAndroid;
import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid;
-import org.chromium.ui.gfx.DeviceDisplayInfo;
import java.io.File;
import java.lang.annotation.Annotation;
@@ -302,8 +301,6 @@ public class AwContents implements SmartClipProvider,
private Bitmap mFavicon;
private boolean mHasRequestedVisitedHistoryFromClient;
- // TODO(boliu): This should be in a global context, not per webview.
- private final double mDIPScale;
// Whether this WebView is a popup.
private boolean mIsPopupWindow = false;
@@ -772,9 +769,7 @@ public class AwContents implements SmartClipProvider,
mContentViewClient = new AwContentViewClient(contentsClient, settings, this, mContext);
mLayoutSizer = dependencyFactory.createLayoutSizer();
mSettings = settings;
- mDIPScale = DeviceDisplayInfo.create(mContext).getDIPScale();
mLayoutSizer.setDelegate(new AwLayoutSizerDelegate());
- mLayoutSizer.setDIPScale(mDIPScale);
mWebContentsDelegate = new AwWebContentsDelegateAdapter(
this, contentsClient, mContentViewClient, mContext, mContainerView);
mContentsClientBridge = new AwContentsClientBridge(mContext, contentsClient,
@@ -805,7 +800,6 @@ public class AwContents implements SmartClipProvider,
mDefaultVideoPosterRequestHandler = new DefaultVideoPosterRequestHandler(mContentsClient);
mSettings.setDefaultVideoPosterURL(
mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL());
- mSettings.setDIPScale(mDIPScale);
mScrollOffsetManager =
dependencyFactory.createScrollOffsetManager(new AwScrollOffsetManagerDelegate());
mScrollAccessibilityHelper = new ScrollAccessibilityHelper(mContainerView);
@@ -1066,7 +1060,12 @@ public class AwContents implements SmartClipProvider,
mNavigationController = mWebContents.getNavigationController();
installWebContentsObserver();
mSettings.setWebContents(webContents);
- nativeSetDipScale(mNativeAwContents, (float) mDIPScale);
+
+ float dipScale = mContentViewCore.getDeviceScaleFactor();
+ nativeSetDipScale(mNativeAwContents, dipScale);
+ mLayoutSizer.setDIPScale(dipScale);
+ mSettings.setDIPScale(dipScale);
+
updateContentViewCoreVisibility();
// The native side object has been bound to this java instance, so now is the time to
@@ -2101,7 +2100,7 @@ public class AwContents implements SmartClipProvider,
*/
public float getScale() {
if (isDestroyed(WARN)) return 1;
- return (float) (mPageScaleFactor * mDIPScale);
+ return (float) (mPageScaleFactor * mContentViewCore.getDeviceScaleFactor());
}
/**
@@ -2684,8 +2683,8 @@ public class AwContents implements SmartClipProvider,
@CalledByNative
private long onCreateTouchHandle() {
- PopupTouchHandleDrawable drawable =
- PopupTouchHandleDrawable.create(mTouchHandleDrawables, mContentViewCore, mDIPScale);
+ PopupTouchHandleDrawable drawable = PopupTouchHandleDrawable.create(
+ mTouchHandleDrawables, mContentViewCore, mContentViewCore.getDeviceScaleFactor());
return drawable.getNativeDrawable();
}
@@ -2879,9 +2878,9 @@ public class AwContents implements SmartClipProvider,
if (mPageScaleFactor != pageScaleFactor) {
float oldPageScaleFactor = mPageScaleFactor;
mPageScaleFactor = pageScaleFactor;
+ float dipScale = mContentViewCore.getDeviceScaleFactor();
mContentsClient.getCallbackHelper().postOnScaleChangedScaled(
- (float) (oldPageScaleFactor * mDIPScale),
- (float) (mPageScaleFactor * mDIPScale));
+ oldPageScaleFactor * dipScale, mPageScaleFactor * dipScale);
}
}
@@ -3107,10 +3106,10 @@ public class AwContents implements SmartClipProvider,
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
// Note this will trigger IPC back to browser even if nothing is
// hit.
+ float dipScale = mContentViewCore.getDeviceScaleFactor();
nativeRequestNewHitTestDataAt(mNativeAwContents,
- event.getX() / (float) mDIPScale,
- event.getY() / (float) mDIPScale,
- Math.max(event.getTouchMajor(), event.getTouchMinor()) / (float) mDIPScale);
+ event.getX() / dipScale, event.getY() / dipScale,
+ Math.max(event.getTouchMajor(), event.getTouchMinor()) / dipScale);
}
if (mOverScrollGlow != null) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698