Commit 3d959153 authored by benm@chromium.org's avatar benm@chromium.org

[Android WebView] Reflect system font scale in WebView text rendering.

We should take into account the font scale factor the user has chosen
when drawing text in the WebView.

(Also fixes presubmit warnings in AwSettings.java)

BUG=335343

Review URL: https://codereview.chromium.org/140913003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245582 0039d316-1c4b-4281-b951-d872f2087c98
parent e9ccf415
...@@ -10,6 +10,7 @@ import android.os.Handler; ...@@ -10,6 +10,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.Process; import android.os.Process;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.PluginState;
...@@ -87,6 +88,9 @@ public class AwSettings { ...@@ -87,6 +88,9 @@ public class AwSettings {
private final boolean mPasswordEchoEnabled; private final boolean mPasswordEchoEnabled;
// Font scale factor determined by Android system setting.
private final float mFontScale;
// Not accessed by the native side. // Not accessed by the native side.
private boolean mBlockNetworkLoads; // Default depends on permission of embedding APK. private boolean mBlockNetworkLoads; // Default depends on permission of embedding APK.
private boolean mAllowContentUrlAccess = true; private boolean mAllowContentUrlAccess = true;
...@@ -181,7 +185,9 @@ public class AwSettings { ...@@ -181,7 +185,9 @@ public class AwSettings {
while (mIsUpdateWebkitPrefsMessagePending) { while (mIsUpdateWebkitPrefsMessagePending) {
mAwSettingsLock.wait(); mAwSettingsLock.wait();
} }
} catch (InterruptedException e) {} } catch (InterruptedException e) {
Log.e(TAG, "Interrupted waiting to sync settings to native", e);
}
} }
} }
} }
...@@ -215,6 +221,8 @@ public class AwSettings { ...@@ -215,6 +221,8 @@ public class AwSettings {
// Respect the system setting for password echoing. // Respect the system setting for password echoing.
mPasswordEchoEnabled = Settings.System.getInt(context.getContentResolver(), mPasswordEchoEnabled = Settings.System.getInt(context.getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; Settings.System.TEXT_SHOW_PASSWORD, 1) == 1;
mFontScale = context.getResources().getConfiguration().fontScale;
mTextSizePercent *= mFontScale;
mSupportLegacyQuirks = supportsLegacyQuirks; mSupportLegacyQuirks = supportsLegacyQuirks;
} }
...@@ -537,8 +545,9 @@ public class AwSettings { ...@@ -537,8 +545,9 @@ public class AwSettings {
*/ */
public void setTextZoom(final int textZoom) { public void setTextZoom(final int textZoom) {
synchronized (mAwSettingsLock) { synchronized (mAwSettingsLock) {
if (mTextSizePercent != textZoom) { int scaledTextZoomPercent = (int)(textZoom * mFontScale);
mTextSizePercent = textZoom; if (mTextSizePercent != scaledTextZoomPercent) {
mTextSizePercent = scaledTextZoomPercent;
mEventHandler.updateWebkitPreferencesLocked(); mEventHandler.updateWebkitPreferencesLocked();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment