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

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

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: Update the fix 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/RenderCoordinates.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java b/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java
index 5bcebc28c86b732dac67dbb830cd7e9c03ab5c00..ccf8de398471bee13f52ded5dc2676d65cc6cdbb 100644
--- a/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java
+++ b/content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java
@@ -8,7 +8,8 @@ import android.content.Context;
import android.util.TypedValue;
import org.chromium.base.VisibleForTesting;
-import org.chromium.ui.base.WindowAndroid;
+
+import java.lang.ref.WeakReference;
/**
* Cached copy of all positions and scales (CSS-to-DIP-to-physical pixels)
@@ -38,7 +39,7 @@ public class RenderCoordinates {
private float mMaxPageScaleFactor = 1.0f;
// Cached device density.
- private float mDeviceScaleFactor;
+ private float mDeviceScaleFactor = 1.0f;
// Multiplier that determines how many (device) pixels to scroll per mouse
// wheel tick. Defaults to the preferred list item height.
@@ -61,14 +62,14 @@ public class RenderCoordinates {
mContentHeightCss = contentHeightCss;
}
- void updateDeviceScaleFactorFromWindow(WindowAndroid windowAndroid) {
- mDeviceScaleFactor = windowAndroid.getDisplay().getDIPScale();
+ void setDeviceScaleFactor(float dipScale, WeakReference<Context> displayContext) {
Ted C 2016/10/31 20:02:40 any reason changes to this file are needed? I see
Tima Vaisburd 2016/10/31 20:37:59 Strictly speaking, this change it not necessary. I
Ted C 2016/11/01 17:07:16 To continue down this rabbit hole, why does native
boliu 2016/11/01 17:13:02 Reminder WindowAndroid isn't always available, whi
Tima Vaisburd 2016/11/01 18:23:26 My considerations were pretty simple here. Right n
Ted C 2016/11/01 19:04:59 I think it is fine to do in follow ups, but I woul
+ mDeviceScaleFactor = dipScale;
// The wheel scroll factor depends on the theme in the context.
// This code assumes that the theme won't change between this call and
// getWheelScrollFactor().
- Context context = windowAndroid.getContext().get();
+ Context context = displayContext.get();
TypedValue outValue = new TypedValue();
// This is the same attribute used by Android Views to scale wheel
// event motion into scroll deltas.

Powered by Google App Engine
This is Rietveld 408576698