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

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

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: An attempt to fix tests compilation Created 4 years, 3 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 64f957629819ae073a7fa5a0b1ce869a19640fdb..0f93669bf461375e04fb0c7860db45d9d499ea3b 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -72,6 +72,7 @@ import org.chromium.content_public.common.Referrer;
import org.chromium.net.NetError;
import org.chromium.net.NetworkChangeNotifier;
import org.chromium.ui.base.ActivityWindowAndroid;
+import org.chromium.ui.base.DIPScaleListener;
import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid;
@@ -96,8 +97,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,
+ DIPScaleListener {
private static final String TAG = "AwContents";
private static final boolean TRACE = false;
private static final int NO_WARN = 0;
@@ -1061,12 +1062,7 @@ public class AwContents implements SmartClipProvider,
installWebContentsObserver();
mSettings.setWebContents(webContents);
- float dipScale = mContentViewCore.getDeviceScaleFactor();
- nativeSetDipScale(mNativeAwContents, dipScale);
- mLayoutSizer.setDIPScale(dipScale);
- mSettings.setDIPScale(dipScale);
-
- updateContentViewCoreVisibility();
+ onDIPScaleChanged(mWindowAndroid.getWindowAndroid().getDIPScale());
// The native side object has been bound to this java instance, so now is the time to
// bind all the native->java relationships.
@@ -2284,6 +2280,16 @@ public class AwContents implements SmartClipProvider,
sentPortIds);
}
+ // Implements DIPScaleListener 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.
*/
@@ -2393,6 +2399,7 @@ public class AwContents implements SmartClipProvider,
if (TRACE) Log.i(TAG, "%s onAttachedToWindow", this);
mTemporarilyDetached = false;
mAwViewMethods.onAttachedToWindow();
+ mWindowAndroid.getWindowAndroid().addDIPScaleListener(this);
}
/**
@@ -2401,6 +2408,7 @@ public class AwContents implements SmartClipProvider,
@SuppressLint("MissingSuperCall")
public void onDetachedFromWindow() {
if (TRACE) Log.i(TAG, "%s onDetachedFromWindow", this);
+ mWindowAndroid.getWindowAndroid().removeDIPScaleListener(this);
mAwViewMethods.onDetachedFromWindow();
}
« no previous file with comments | « no previous file | components/external_video_surface/BUILD.gn » ('j') | components/external_video_surface/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698