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

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

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: Do not force layout during initialization. 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: 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 b48eb8790663a13fed6107c24f77967b78887ff4..9196128e0c4cdabd08a8c66c5882e01f9d89207b 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -78,6 +78,7 @@ 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.display.DisplayAndroid.DisplayAndroidObserver;
import java.io.File;
import java.lang.annotation.Annotation;
@@ -99,8 +100,8 @@ import java.util.concurrent.Callable;
* continuous build & test in the open source SDK-based tree).
*/
@JNINamespace("android_webview")
-public class AwContents implements SmartClipProvider,
- PostMessageSender.PostMessageSenderDelegate {
+public class AwContents implements SmartClipProvider, PostMessageSender.PostMessageSenderDelegate,
+ DisplayAndroidObserver {
boliu 2016/10/18 00:26:25 use an inner class
Tima Vaisburd 2016/10/19 01:15:54 Done.
private static final String TAG = "AwContents";
private static final boolean TRACE = false;
private static final int NO_WARN = 0;
@@ -1065,10 +1066,7 @@ public class AwContents implements SmartClipProvider,
installWebContentsObserver();
mSettings.setWebContents(webContents);
- float dipScale = mContentViewCore.getDeviceScaleFactor();
- nativeSetDipScale(mNativeAwContents, dipScale);
- mLayoutSizer.setDIPScale(dipScale);
- mSettings.setDIPScale(dipScale);
+ onDIPScaleChanged(mWindowAndroid.getWindowAndroid().getDisplay().getDIPScale());
updateContentViewCoreVisibility();
@@ -2275,6 +2273,20 @@ public class AwContents implements SmartClipProvider,
sentPortIds);
}
+ // Implements DisplayAndroidObserver interface method.
+ @Override
+ public void onRotationChanged(int rotation) {}
+
+ // Implements DisplayAndroidObserver interface method.
+ @Override
+ public void onDIPScaleChanged(float dipScale) {
+ if (TRACE) Log.i(TAG, "%s onDIPScaleChanged dipScale=%f", this, dipScale);
+
+ nativeSetDipScale(mNativeAwContents, dipScale);
+ mLayoutSizer.setDIPScale(dipScale);
+ mSettings.setDIPScale(dipScale);
+ }
+
/**
* Creates a message channel and returns the ports for each end of the channel.
*/
@@ -2384,6 +2396,7 @@ public class AwContents implements SmartClipProvider,
if (TRACE) Log.i(TAG, "%s onAttachedToWindow", this);
mTemporarilyDetached = false;
mAwViewMethods.onAttachedToWindow();
+ mWindowAndroid.getWindowAndroid().getDisplay().addObserver(this);
}
/**
@@ -2392,6 +2405,7 @@ public class AwContents implements SmartClipProvider,
@SuppressLint("MissingSuperCall")
public void onDetachedFromWindow() {
if (TRACE) Log.i(TAG, "%s onDetachedFromWindow", this);
+ mWindowAndroid.getWindowAndroid().getDisplay().removeObserver(this);
mAwViewMethods.onDetachedFromWindow();
}
« no previous file with comments | « no previous file | content/browser/android/content_view_core_impl.h » ('j') | content/browser/android/content_view_core_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698