Commit bffd0a00 authored by timav's avatar timav Committed by Commit bot

Reland: Move DIP scale away from AwContents

This small refactoring removes device scale factor from AwContents
cache and uses the value from ContentViewCore.
The device scale factor in ContentViewCore is defined after
ContentViewCore native initialization, therefore this CL also
moves the device scale propagation until after that.

This is a prerequisite for https://codereview.chromium.org/2300463002

BUG=620929

> Committed: https://crrev.com/8d849fd2d39c9db747f4e8d89dcedfebb0273a97
> Cr-Commit-Position: refs/heads/master@{#415546}

Reland after fix related to PopupTouchHandleDrawable.

Review-Url: https://codereview.chromium.org/2288273003
Cr-Commit-Position: refs/heads/master@{#415690}
parent 47d02c08
...@@ -75,7 +75,6 @@ import org.chromium.ui.base.ActivityWindowAndroid; ...@@ -75,7 +75,6 @@ import org.chromium.ui.base.ActivityWindowAndroid;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.ViewAndroidDelegate; import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.gfx.DeviceDisplayInfo;
import java.io.File; import java.io.File;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
...@@ -302,8 +301,6 @@ public class AwContents implements SmartClipProvider, ...@@ -302,8 +301,6 @@ public class AwContents implements SmartClipProvider,
private Bitmap mFavicon; private Bitmap mFavicon;
private boolean mHasRequestedVisitedHistoryFromClient; 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. // Whether this WebView is a popup.
private boolean mIsPopupWindow = false; private boolean mIsPopupWindow = false;
...@@ -772,9 +769,7 @@ public class AwContents implements SmartClipProvider, ...@@ -772,9 +769,7 @@ public class AwContents implements SmartClipProvider,
mContentViewClient = new AwContentViewClient(contentsClient, settings, this, mContext); mContentViewClient = new AwContentViewClient(contentsClient, settings, this, mContext);
mLayoutSizer = dependencyFactory.createLayoutSizer(); mLayoutSizer = dependencyFactory.createLayoutSizer();
mSettings = settings; mSettings = settings;
mDIPScale = DeviceDisplayInfo.create(mContext).getDIPScale();
mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); mLayoutSizer.setDelegate(new AwLayoutSizerDelegate());
mLayoutSizer.setDIPScale(mDIPScale);
mWebContentsDelegate = new AwWebContentsDelegateAdapter( mWebContentsDelegate = new AwWebContentsDelegateAdapter(
this, contentsClient, mContentViewClient, mContext, mContainerView); this, contentsClient, mContentViewClient, mContext, mContainerView);
mContentsClientBridge = new AwContentsClientBridge(mContext, contentsClient, mContentsClientBridge = new AwContentsClientBridge(mContext, contentsClient,
...@@ -805,7 +800,6 @@ public class AwContents implements SmartClipProvider, ...@@ -805,7 +800,6 @@ public class AwContents implements SmartClipProvider,
mDefaultVideoPosterRequestHandler = new DefaultVideoPosterRequestHandler(mContentsClient); mDefaultVideoPosterRequestHandler = new DefaultVideoPosterRequestHandler(mContentsClient);
mSettings.setDefaultVideoPosterURL( mSettings.setDefaultVideoPosterURL(
mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL()); mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL());
mSettings.setDIPScale(mDIPScale);
mScrollOffsetManager = mScrollOffsetManager =
dependencyFactory.createScrollOffsetManager(new AwScrollOffsetManagerDelegate()); dependencyFactory.createScrollOffsetManager(new AwScrollOffsetManagerDelegate());
mScrollAccessibilityHelper = new ScrollAccessibilityHelper(mContainerView); mScrollAccessibilityHelper = new ScrollAccessibilityHelper(mContainerView);
...@@ -1066,7 +1060,12 @@ public class AwContents implements SmartClipProvider, ...@@ -1066,7 +1060,12 @@ public class AwContents implements SmartClipProvider,
mNavigationController = mWebContents.getNavigationController(); mNavigationController = mWebContents.getNavigationController();
installWebContentsObserver(); installWebContentsObserver();
mSettings.setWebContents(webContents); mSettings.setWebContents(webContents);
nativeSetDipScale(mNativeAwContents, (float) mDIPScale);
float dipScale = mContentViewCore.getDeviceScaleFactor();
nativeSetDipScale(mNativeAwContents, dipScale);
mLayoutSizer.setDIPScale(dipScale);
mSettings.setDIPScale(dipScale);
updateContentViewCoreVisibility(); updateContentViewCoreVisibility();
// The native side object has been bound to this java instance, so now is the time to // 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, ...@@ -2101,7 +2100,7 @@ public class AwContents implements SmartClipProvider,
*/ */
public float getScale() { public float getScale() {
if (isDestroyed(WARN)) return 1; if (isDestroyed(WARN)) return 1;
return (float) (mPageScaleFactor * mDIPScale); return (float) (mPageScaleFactor * mContentViewCore.getDeviceScaleFactor());
} }
/** /**
...@@ -2684,8 +2683,8 @@ public class AwContents implements SmartClipProvider, ...@@ -2684,8 +2683,8 @@ public class AwContents implements SmartClipProvider,
@CalledByNative @CalledByNative
private long onCreateTouchHandle() { private long onCreateTouchHandle() {
PopupTouchHandleDrawable drawable = PopupTouchHandleDrawable drawable = PopupTouchHandleDrawable.create(
PopupTouchHandleDrawable.create(mTouchHandleDrawables, mContentViewCore, mDIPScale); mTouchHandleDrawables, mContentViewCore, mContentViewCore.getDeviceScaleFactor());
return drawable.getNativeDrawable(); return drawable.getNativeDrawable();
} }
...@@ -2879,9 +2878,9 @@ public class AwContents implements SmartClipProvider, ...@@ -2879,9 +2878,9 @@ public class AwContents implements SmartClipProvider,
if (mPageScaleFactor != pageScaleFactor) { if (mPageScaleFactor != pageScaleFactor) {
float oldPageScaleFactor = mPageScaleFactor; float oldPageScaleFactor = mPageScaleFactor;
mPageScaleFactor = pageScaleFactor; mPageScaleFactor = pageScaleFactor;
float dipScale = mContentViewCore.getDeviceScaleFactor();
mContentsClient.getCallbackHelper().postOnScaleChangedScaled( mContentsClient.getCallbackHelper().postOnScaleChangedScaled(
(float) (oldPageScaleFactor * mDIPScale), oldPageScaleFactor * dipScale, mPageScaleFactor * dipScale);
(float) (mPageScaleFactor * mDIPScale));
} }
} }
...@@ -3107,10 +3106,10 @@ public class AwContents implements SmartClipProvider, ...@@ -3107,10 +3106,10 @@ public class AwContents implements SmartClipProvider,
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
// Note this will trigger IPC back to browser even if nothing is // Note this will trigger IPC back to browser even if nothing is
// hit. // hit.
float dipScale = mContentViewCore.getDeviceScaleFactor();
nativeRequestNewHitTestDataAt(mNativeAwContents, nativeRequestNewHitTestDataAt(mNativeAwContents,
event.getX() / (float) mDIPScale, event.getX() / dipScale, event.getY() / dipScale,
event.getY() / (float) mDIPScale, Math.max(event.getTouchMajor(), event.getTouchMinor()) / dipScale);
Math.max(event.getTouchMajor(), event.getTouchMinor()) / (float) mDIPScale);
} }
if (mOverScrollGlow != null) { if (mOverScrollGlow != null) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment