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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: Addressed comments Created 4 years, 2 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: 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..543c62b7c1c80c6c6f260116ab2969fcaf9ed1f8 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;
@@ -659,7 +660,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
setContainerViewInternals(internalDispatcher);
mRenderCoordinates.reset();
- mRenderCoordinates.updateDeviceScaleFactorFromWindow(windowAndroid);
+
+ final float dipScale = windowAndroid.getDisplay().getDIPScale();
+ mRenderCoordinates.setDeviceScaleFactor(dipScale, windowAndroid.getContext());
+ nativeSetDIPScale(mNativeContentViewCore, dipScale, false /* do not force layout */);
boliu 2016/10/19 04:19:19 dipScale should just be part of nativeInit. Then y
Tima Vaisburd 2016/10/19 20:25:11 Done.
initPopupZoomer(mContext);
mImeAdapter = createImeAdapter();
@@ -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) {
+ if (getWindowAndroid() == null) return;
boliu 2016/10/19 04:19:18 avoid calling getWindowAndroid twice. it involves
Tima Vaisburd 2016/10/19 20:25:11 Done.
+ mRenderCoordinates.setDeviceScaleFactor(dipScale, getWindowAndroid().getContext());
+
+ if (mNativeContentViewCore == 0) return;
boliu 2016/10/19 04:19:18 move this check up as well?
Tima Vaisburd 2016/10/19 20:25:11 Done.
+ nativeSetDIPScale(mNativeContentViewCore, dipScale, true /* force layout */);
+ }
+
/**
* Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock
* the screen orientation.
@@ -3330,6 +3346,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused);
+ private native void nativeSetDIPScale(
+ long nativeContentViewCoreImpl, float dipScale, boolean forceLayout);
+
private native void nativeSendOrientationChangeEvent(
long nativeContentViewCoreImpl, int orientation);

Powered by Google App Engine
This is Rietveld 408576698