Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| index 0a5293ba55910c06f9f875e7fbe0115e5489ad2b..4f20253677ae54fbee18998c6c8f77a5eb9546cc 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| @@ -86,6 +86,7 @@ import org.chromium.ui.base.DeviceFormFactor; |
| import org.chromium.ui.base.ViewAndroidDelegate; |
| import org.chromium.ui.base.WindowAndroid; |
| import org.chromium.ui.base.ime.TextInputType; |
| +import org.chromium.ui.display.DisplayAndroid; |
| import org.chromium.ui.display.DisplayAndroid.DisplayAndroidObserver; |
| import org.chromium.ui.touch_selection.SelectionEventType; |
| @@ -652,15 +653,18 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| assert windowNativePointer != 0; |
| mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE; |
| + |
| + final float dipScale = windowAndroid.getDisplay().getDIPScale(); |
|
Ted C
2016/10/31 20:02:40
in java, the method name should be getDipScale()
Ted C
2016/11/01 19:04:59
Still need to do this renaming though
Tima Vaisburd
2016/11/01 22:45:33
I started doing this, but in view of https://coder
|
| + |
| + mRenderCoordinates.reset(); |
| + mRenderCoordinates.setDeviceScaleFactor(dipScale, windowAndroid.getContext()); |
| + |
| mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, windowNativePointer, |
| - mRetainedJavaScriptObjects); |
| + dipScale, mRetainedJavaScriptObjects); |
| mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); |
| setContainerViewInternals(internalDispatcher); |
| - mRenderCoordinates.reset(); |
| - mRenderCoordinates.updateDeviceScaleFactorFromWindow(windowAndroid); |
| - |
| initPopupZoomer(mContext); |
| mImeAdapter = createImeAdapter(); |
| attachImeAdapter(); |
| @@ -694,9 +698,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| if (!mAttachedToWindow) return; |
| WindowAndroid windowAndroid = getWindowAndroid(); |
| if (windowAndroid != null) { |
| - mRenderCoordinates.updateDeviceScaleFactorFromWindow(windowAndroid); |
| - windowAndroid.getDisplay().addObserver(this); |
| - onRotationChanged(windowAndroid.getDisplay().getRotation()); |
| + DisplayAndroid display = windowAndroid.getDisplay(); |
| + display.addObserver(this); |
| + onRotationChanged(display.getRotation()); |
| + onDIPScaleChanged(display.getDIPScale()); |
| } |
| } |
| @@ -3234,6 +3239,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| updateGestureStateListener(GestureEventType.FLING_END); |
| } |
| + // DisplayAndroidObserver method. |
| @Override |
| public void onRotationChanged(int rotation) { |
| // ActionMode#invalidate() won't be able to re-layout the floating |
| @@ -3266,6 +3272,16 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| sendOrientationChangeEvent(rotationDegrees); |
| } |
| + // DisplayAndroidObserver method. |
| + @Override |
| + public void onDIPScaleChanged(float dipScale) { |
| + WindowAndroid windowAndroid = getWindowAndroid(); |
| + if (windowAndroid == null || mNativeContentViewCore == 0) return; |
| + |
| + mRenderCoordinates.setDeviceScaleFactor(dipScale, getWindowAndroid().getContext()); |
| + nativeSetDIPScale(mNativeContentViewCore, dipScale); |
| + } |
| + |
| /** |
| * Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock |
| * the screen orientation. |
| @@ -3318,7 +3334,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| } |
| private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate, |
| - long windowAndroidPtr, HashSet<Object> retainedObjectSet); |
| + long windowAndroidPtr, float dipScale, HashSet<Object> retainedObjectSet); |
| private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents); |
| private native void nativeUpdateWindowAndroid( |
| @@ -3330,6 +3346,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
| private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused); |
| + private native void nativeSetDIPScale(long nativeContentViewCoreImpl, float dipScale); |
| + |
| private native void nativeSendOrientationChangeEvent( |
| long nativeContentViewCoreImpl, int orientation); |