Bug 1449311 - [1.0] Add GeckoRuntime web fonts control setting. r=droeh,snorp
authorEugen Sawin <esawin@mozilla.com>
Tue, 10 Apr 2018 23:16:40 +0200
changeset 466850 475889d2f86964df75fe76e16e9caa8e18e723f8
parent 466849 c84e830f2c9f426b7a3a5bfc44045c86cee58915
child 466851 fd3a8b247d77fea632ef5deeb95d64a3cb541278
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh, snorp
bugs1449311
milestone61.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 1449311 - [1.0] Add GeckoRuntime web fonts control setting. r=droeh,snorp
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
@@ -70,16 +70,26 @@ public final class GeckoRuntimeSettings 
          * Set whether JavaScript support should be enabled.
          *
          * @param flag A flag determining whether JavaScript should be enabled.
          */
         public @NonNull Builder javaScriptEnabled(final boolean flag) {
             mSettings.mJavaScript.set(flag);
             return this;
         }
+
+        /**
+         * Set whether support for web fonts should be enabled.
+         *
+         * @param flag A flag determining whether web fonts should be enabled.
+         */
+        public @NonNull Builder webFontsEnabled(final boolean flag) {
+            mSettings.mWebFonts.set(flag);
+            return this;
+        }
     }
 
     /* package */ GeckoRuntime runtime;
     /* package */ boolean mUseContentProcess;
     /* package */ String[] mArgs;
     /* package */ Bundle mExtras;
     /* package */ int prefCount;
 
@@ -109,19 +119,21 @@ public final class GeckoRuntimeSettings 
             if (GeckoRuntimeSettings.this.runtime != null) {
                 GeckoRuntimeSettings.this.runtime.setPref(name, value);
             }
         }
     }
 
     /* package */ Pref<Boolean> mJavaScript = new Pref<Boolean>(
         "javascript.enabled", true);
+    /* package */ Pref<Boolean> mWebFonts = new Pref<Boolean>(
+        "browser.display.use_document_fonts", true);
 
     private final Pref<?>[] mPrefs = new Pref<?>[] {
-        mJavaScript
+        mJavaScript, mWebFonts
     };
 
     /* package */ GeckoRuntimeSettings() {
         this(null);
     }
 
     /* package */ GeckoRuntimeSettings(final @Nullable GeckoRuntimeSettings settings) {
         if (BuildConfig.DEBUG && prefCount != mPrefs.length) {
@@ -131,16 +143,17 @@ public final class GeckoRuntimeSettings 
         if (settings == null) {
             mArgs = new String[0];
             mExtras = new Bundle();
         } else {
             mUseContentProcess = settings.getUseContentProcessHint();
             mArgs = settings.getArguments().clone();
             mExtras = new Bundle(settings.getExtras());
             mJavaScript.set(settings.mJavaScript.get());
+            mWebFonts.set(settings.mWebFonts.get());
         }
     }
 
     /* package */ void flush() {
         for (final Pref<?> pref: mPrefs) {
             pref.flush();
         }
     }
@@ -186,35 +199,56 @@ public final class GeckoRuntimeSettings 
      *
      * @param flag A flag determining whether JavaScript should be enabled.
      */
     public @NonNull GeckoRuntimeSettings setJavaScriptEnabled(final boolean flag) {
         mJavaScript.set(flag);
         return this;
     }
 
+    /**
+     * Get whether web fonts support is enabled.
+     *
+     * @return Whether web fonts support is enabled.
+     */
+    public boolean getWebFontsEnabled() {
+        return mWebFonts.get();
+    }
+
+    /**
+     * Set whether support for web fonts should be enabled.
+     *
+     * @param flag A flag determining whether web fonts should be enabled.
+     */
+    public @NonNull GeckoRuntimeSettings setWebFontsEnabled(final boolean flag) {
+        mWebFonts.set(flag);
+        return this;
+    }
+
     @Override // Parcelable
     public int describeContents() {
         return 0;
     }
 
     @Override // Parcelable
     public void writeToParcel(Parcel out, int flags) {
         out.writeByte((byte) (mUseContentProcess ? 1 : 0));
         out.writeStringArray(mArgs);
         mExtras.writeToParcel(out, flags);
         out.writeByte((byte) (mJavaScript.get() ? 1 : 0));
+        out.writeByte((byte) (mWebFonts.get() ? 1 : 0));
     }
 
     // AIDL code may call readFromParcel even though it's not part of Parcelable.
     public void readFromParcel(final Parcel source) {
         mUseContentProcess = source.readByte() == 1;
         mArgs = source.createStringArray();
         mExtras.readFromParcel(source);
         mJavaScript.set(source.readByte() == 1);
+        mWebFonts.set(source.readByte() == 1);
     }
 
     public static final Parcelable.Creator<GeckoRuntimeSettings> CREATOR
         = new Parcelable.Creator<GeckoRuntimeSettings>() {
         @Override
         public GeckoRuntimeSettings createFromParcel(final Parcel in) {
             final GeckoRuntimeSettings settings = new GeckoRuntimeSettings();
             settings.readFromParcel(in);