Bug 1460874 - Part 6: Move GeckoFontScaleListener into GeckoView. r=snorp
☠☠ backed out by cd616c3e3eea ☠ ☠
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 13 Feb 2019 20:10:29 +0000
changeset 458948 78f59df737fc
parent 458947 81c4e88003a5
child 458949 1026b786e779
push id35552
push usershindli@mozilla.com
push dateThu, 14 Feb 2019 04:39:44 +0000
treeherdermozilla-central@c6829642e2d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1460874
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1460874 - Part 6: Move GeckoFontScaleListener into GeckoView. r=snorp With the dependencies on Fennec's GeckoPreferences and GeckoSharedPrefs gone, we can now move the class into GeckoView in preparation for hooking it up to the GeckoViewRuntimeSettings. Differential Revision: https://phabricator.services.mozilla.com/D18506
mobile/android/base/java/org/mozilla/gecko/GeckoFontScaleListener.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoFontScaleListener.java
rename from mobile/android/base/java/org/mozilla/gecko/GeckoFontScaleListener.java
rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoFontScaleListener.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoFontScaleListener.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoFontScaleListener.java
@@ -11,17 +11,23 @@ import android.annotation.SuppressLint;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.database.ContentObserver;
 import android.net.Uri;
 import android.provider.Settings;
 import android.support.annotation.UiThread;
 import android.util.Log;
 
-class GeckoFontScaleListener
+/**
+ * A class that automatically adjusts font size and font inflation settings for web content in Gecko
+ * in accordance with the device's OS font scale setting.
+ *
+ * @see android.provider.Settings.System#FONT_SCALE
+ */
+/* package */ final class GeckoFontScaleListener
         extends ContentObserver {
     private static final String LOGTAG = "GeckoFontScaleListener";
 
     private static final String PREF_SYSTEM_FONT_SCALE = "font.size.systemFontScale";
     private static final String PREF_FONT_INFLATION = "font.size.inflation.minTwips";
     private static final int FONT_INFLATION_OFF = 0;
     private static final int FONT_INFLATION_ON_DEFAULT_VALUE = 120;
     private static final float DEFAULT_FONT_SCALE = 1.0f;
@@ -39,48 +45,69 @@ class GeckoFontScaleListener
         return sInstance;
     }
 
     private GeckoFontScaleListener() {
         // Ensure the ContentObserver callback runs on the UI thread.
         super(ThreadUtils.getUiHandler());
     }
 
+    /**
+     * Prepare the GeckoFontScaleListener for usage. If it has been previously enabled, it will
+     * now start actively working.
+     */
     public void attachToContext(final Context context) {
         ThreadUtils.assertOnUiThread();
 
         if (mAttached) {
             Log.w(LOGTAG, "Already attached!");
             return;
         }
 
         mAttached = true;
         mApplicationContext = context.getApplicationContext();
         onEnabledChange();
     }
 
+    /**
+     * Detaches the context and also stops the GeckoFontScaleListener if it was previously enabled.
+     */
     public void detachFromContext() {
         ThreadUtils.assertOnUiThread();
 
         if (!mAttached) {
             Log.w(LOGTAG, "Already detached!");
             return;
         }
 
         stop();
         mApplicationContext = null;
         mAttached = false;
     }
 
+    /**
+     * Controls whether the GeckoFontScaleListener should automatically adjust font sizes for web
+     * content in Gecko.
+     *
+     * <p>This method can be called at any time, but the GeckoFontScaleListener won't start actively
+     * adjusting font sizes until it has been attached to a context.
+     *
+     * @param enabled True if automatic font size setting should be enabled.
+     */
     public void setEnabled(boolean enabled) {
         ThreadUtils.assertOnUiThread();
         mEnabled = enabled;
         onEnabledChange();
     }
 
+    /**
+     * Get whether the GeckoFontScaleListener is currently enabled.
+     *
+     * @return True if the GeckoFontScaleListener is currently enabled.
+     */
     public boolean getEnabled() {
         return mEnabled;
     }
 
     private void onEnabledChange() {
         if (!mAttached) {
             return;
         }