| 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 d0c951da7c477f2ad72424b826e488c551975a40..3526498bf02f5304a2e1c34ea77f3ef23ce213e0 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
|
| @@ -82,6 +82,7 @@ import org.chromium.content_public.browser.WebContents;
|
| import org.chromium.content_public.browser.WebContentsObserver;
|
| import org.chromium.device.gamepad.GamepadList;
|
| import org.chromium.ui.base.DeviceFormFactor;
|
| +import org.chromium.ui.base.DisplayObserver;
|
| import org.chromium.ui.base.ViewAndroidDelegate;
|
| import org.chromium.ui.base.WindowAndroid;
|
| import org.chromium.ui.base.ime.TextInputType;
|
| @@ -101,9 +102,9 @@ import java.util.Map;
|
| * being tied to the view system.
|
| */
|
| @JNINamespace("content")
|
| -public class ContentViewCore implements AccessibilityStateChangeListener, ScreenOrientationObserver,
|
| - SystemCaptioningBridge.SystemCaptioningBridgeListener,
|
| - WindowAndroidProvider {
|
| +public class ContentViewCore
|
| + implements AccessibilityStateChangeListener, ScreenOrientationObserver, DisplayObserver,
|
| + SystemCaptioningBridge.SystemCaptioningBridgeListener, WindowAndroidProvider {
|
| private static final String TAG = "cr_ContentViewCore";
|
|
|
| // Used to avoid enabling zooming in / out if resulting zooming will
|
| @@ -659,7 +660,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| setContainerViewInternals(internalDispatcher);
|
|
|
| mRenderCoordinates.reset();
|
| - mRenderCoordinates.setDeviceScaleFactor(getDisplayContext(windowAndroid));
|
| + onDIPScaleChanged(windowAndroid.getDIPScale());
|
|
|
| initPopupZoomer(mContext);
|
| mImeAdapter = createImeAdapter();
|
| @@ -674,6 +675,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| * @param windowAndroid The new {@link WindowAndroid} for this {@link ContentViewCore}.
|
| */
|
| public void updateWindowAndroid(WindowAndroid windowAndroid) {
|
| + WindowAndroid oldWindowAndroid = getWindowAndroid();
|
| + if (oldWindowAndroid != null) oldWindowAndroid.removeDisplayObserver(this);
|
| +
|
| long windowNativePointer = windowAndroid == null ? 0 : windowAndroid.getNativePointer();
|
| nativeUpdateWindowAndroid(mNativeContentViewCore, windowNativePointer);
|
|
|
| @@ -682,7 +686,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| mSelectPopup = null;
|
| mPastePopupMenu = null;
|
|
|
| - mRenderCoordinates.setDeviceScaleFactor(getDisplayContext(windowAndroid));
|
| + if (windowAndroid != null) windowAndroid.addDisplayObserver(this);
|
|
|
| for (WindowAndroidChangedObserver observer : mWindowAndroidChangedObservers) {
|
| observer.onWindowAndroidChanged(windowAndroid);
|
| @@ -1361,6 +1365,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| mAccessibilityManager.addAccessibilityStateChangeListener(this);
|
| mSystemCaptioningBridge.addListener(this);
|
| mImeAdapter.onViewAttachedToWindow();
|
| +
|
| + WindowAndroid windowAndroid = getWindowAndroid();
|
| + if (windowAndroid != null) {
|
| + windowAndroid.addDisplayObserver(this);
|
| + }
|
| }
|
|
|
| /**
|
| @@ -1386,6 +1395,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| @SuppressWarnings("javadoc")
|
| @SuppressLint("MissingSuperCall")
|
| public void onDetachedFromWindow() {
|
| + WindowAndroid windowAndroid = getWindowAndroid();
|
| + if (windowAndroid != null) {
|
| + windowAndroid.removeDisplayObserver(this);
|
| + }
|
| +
|
| mImeAdapter.onViewDetachedFromWindow();
|
| mZoomControlsDelegate.dismissZoomPicker();
|
|
|
| @@ -3246,6 +3260,15 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| sendOrientationChangeEvent(orientation);
|
| }
|
|
|
| + // DisplayObserver method implementation.
|
| + @Override
|
| + public void onDIPScaleChanged(float dipScale) {
|
| + if (mNativeContentViewCore == 0) return;
|
| + nativeSetDIPScale(mNativeContentViewCore, dipScale);
|
| +
|
| + mRenderCoordinates.setDeviceScaleFactor(dipScale, getDisplayContext(getWindowAndroid()));
|
| + }
|
| +
|
| /**
|
| * Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock
|
| * the screen orientation.
|
| @@ -3310,6 +3333,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
|
|
| private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused);
|
|
|
| + private native void nativeSetDIPScale(long nativeContentViewCoreImpl, float dipScale);
|
| +
|
| private native void nativeSendOrientationChangeEvent(
|
| long nativeContentViewCoreImpl, int orientation);
|
|
|
|
|