зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1561135 - Don't automatically enable font inflation when automatic font size adjustment is enabled in GV. r=snorp
Differential Revision: https://phabricator.services.mozilla.com/D35819 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d268240183
Коммит
6e7c55ee7a
|
@ -937,6 +937,7 @@ public class GeckoApplication extends Application
|
|||
if (GeckoPreferences.PREFS_SYSTEM_FONT_SIZE.equals(key)) {
|
||||
final boolean enabled = prefs.getBoolean(GeckoPreferences.PREFS_SYSTEM_FONT_SIZE, false);
|
||||
getRuntime().getSettings().setAutomaticFontSizeAdjustment(enabled);
|
||||
getRuntime().getSettings().setFontInflationEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class RuntimeSettingsTest : BaseSessionTest() {
|
|||
assertThat("Gecko font scale should match system font scale",
|
||||
settings.fontSizeFactor.toDouble(), closeTo(expectedFontSizeFactor.toDouble(), 0.05))
|
||||
assertThat("font inflation enabled",
|
||||
settings.fontInflationEnabled, `is`(true))
|
||||
settings.fontInflationEnabled, `is`(initialFontInflation))
|
||||
|
||||
settings.automaticFontSizeAdjustment = false
|
||||
assertThat("Gecko font scale restored to previous value",
|
||||
|
@ -65,7 +65,7 @@ class RuntimeSettingsTest : BaseSessionTest() {
|
|||
assertThat("Gecko font scale should match system font scale",
|
||||
settings.fontSizeFactor.toDouble(), closeTo(expectedFontSizeFactor.toDouble(), 0.05))
|
||||
assertThat("font inflation enabled",
|
||||
settings.fontInflationEnabled, `is`(true))
|
||||
settings.fontInflationEnabled, `is`(initialFontInflation))
|
||||
|
||||
settings.automaticFontSizeAdjustment = false
|
||||
assertThat("Gecko font scale restored to previous value",
|
||||
|
|
|
@ -18,7 +18,7 @@ import android.support.annotation.UiThread;
|
|||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* A class that automatically adjusts font size and font inflation settings for web content in Gecko
|
||||
* A class that automatically adjusts font size settings for web content in Gecko
|
||||
* in accordance with the device's OS font scale setting.
|
||||
*
|
||||
* @see android.provider.Settings.System#FONT_SCALE
|
||||
|
@ -41,7 +41,6 @@ import android.util.Log;
|
|||
private boolean mRunning;
|
||||
|
||||
private float mPrevGeckoFontScale;
|
||||
private boolean mPrevFontInflationState;
|
||||
|
||||
public static GeckoFontScaleListener getInstance() {
|
||||
return sInstance;
|
||||
|
@ -131,7 +130,6 @@ import android.util.Log;
|
|||
}
|
||||
|
||||
mPrevGeckoFontScale = mSettings.getFontSizeFactor();
|
||||
mPrevFontInflationState = mSettings.getFontInflationEnabled();
|
||||
ContentResolver contentResolver = mApplicationContext.getContentResolver();
|
||||
Uri fontSizeSetting = Settings.System.getUriFor(Settings.System.FONT_SCALE);
|
||||
contentResolver.registerContentObserver(fontSizeSetting, false, this);
|
||||
|
@ -155,17 +153,13 @@ import android.util.Log;
|
|||
private void onSystemFontScaleChange(final ContentResolver contentResolver,
|
||||
final boolean stopping) {
|
||||
float fontScale;
|
||||
boolean fontInflationEnabled;
|
||||
|
||||
if (!stopping) { // Either we were enabled, or else the system font scale changed.
|
||||
fontScale = Settings.System.getFloat(contentResolver, Settings.System.FONT_SCALE, DEFAULT_FONT_SCALE);
|
||||
fontInflationEnabled = true;
|
||||
} else { // We were turned off.
|
||||
fontScale = mPrevGeckoFontScale;
|
||||
fontInflationEnabled = mPrevFontInflationState;
|
||||
}
|
||||
|
||||
mSettings.setFontInflationEnabledInternal(fontInflationEnabled);
|
||||
mSettings.setFontSizeFactorInternal(fontScale);
|
||||
}
|
||||
|
||||
|
|
|
@ -743,10 +743,10 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
|
|||
|
||||
/**
|
||||
* Set whether or not font sizes in web content should be automatically scaled according to
|
||||
* the device's current system font scale setting.
|
||||
* Disabling this setting will restore the previously used values for
|
||||
* {@link GeckoRuntimeSettings#getFontSizeFactor()} and
|
||||
* {@link GeckoRuntimeSettings#getFontInflationEnabled()}.
|
||||
* the device's current system font scale setting. Enabling this will prevent modification of
|
||||
* the {@link GeckoRuntimeSettings#setFontSizeFactor font size factor}.
|
||||
* Disabling this setting will restore the previously used value for the
|
||||
* {@link GeckoRuntimeSettings#getFontSizeFactor font size factor}.
|
||||
*
|
||||
* @param enabled A flag determining whether or not font sizes should be scaled automatically
|
||||
* to match the device's system font scale.
|
||||
|
@ -835,7 +835,7 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
|
|||
}
|
||||
|
||||
final int fontSizePercentage = Math.round(fontSizeFactor * 100);
|
||||
mFontSizeFactor.commit(Math.round(fontSizePercentage));
|
||||
mFontSizeFactor.commit(fontSizePercentage);
|
||||
if (getFontInflationEnabled()) {
|
||||
final int scaledFontInflation = Math.round(FONT_INFLATION_BASE_VALUE * fontSizeFactor);
|
||||
mFontInflationMinTwips.commit(scaledFontInflation);
|
||||
|
@ -866,21 +866,10 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
|
|||
*
|
||||
* <p>Currently, any changes only take effect after a reload of the session.
|
||||
*
|
||||
* <p>This setting cannot be modified while
|
||||
* {@link GeckoRuntimeSettings#setAutomaticFontSizeAdjustment automatic font size adjustment}
|
||||
* is enabled.
|
||||
*
|
||||
* @param enabled A flag determining whether or not font inflation should be enabled.
|
||||
* @return This GeckoRuntimeSettings instance.
|
||||
*/
|
||||
public @NonNull GeckoRuntimeSettings setFontInflationEnabled(final boolean enabled) {
|
||||
if (getAutomaticFontSizeAdjustment()) {
|
||||
throw new IllegalStateException("Not allowed when automatic font size adjustment is enabled");
|
||||
}
|
||||
return setFontInflationEnabledInternal(enabled);
|
||||
}
|
||||
|
||||
/* package */ @NonNull GeckoRuntimeSettings setFontInflationEnabledInternal(final boolean enabled) {
|
||||
final int minTwips =
|
||||
enabled ? Math.round(FONT_INFLATION_BASE_VALUE * getFontSizeFactor()) : 0;
|
||||
mFontInflationMinTwips.commit(minTwips);
|
||||
|
|
|
@ -8,6 +8,13 @@ exclude: true
|
|||
|
||||
<h1> GeckoView API Changelog. </h1>
|
||||
|
||||
## v69
|
||||
- Modified behavior of ['setAutomaticFontSizeAdjustment'][69.1] so that it no
|
||||
longer has any effect on ['setFontInflationEnabled'][69.2]
|
||||
|
||||
[69.1]: ./GeckoRuntimeSettings.html#setAutomaticFontSizeAdjustment-boolean-
|
||||
[69.2]: ./GeckoRuntimeSettings.html#setFontInflationEnabled-boolean-
|
||||
|
||||
## v68
|
||||
- Added [`GeckoRuntime#configurationChanged`][68.1] to notify the device
|
||||
configuration has changed.
|
||||
|
|
Загрузка…
Ссылка в новой задаче