Chromium Code Reviews| Index: content/renderer/web_preferences.cc |
| diff --git a/content/renderer/web_preferences.cc b/content/renderer/web_preferences.cc |
| index 17d4a9c2344df2af9ca9bb35f95c9b2e6687083d..033de7301cd54cb288642a986fc96df6ba66983e 100644 |
| --- a/content/renderer/web_preferences.cc |
| +++ b/content/renderer/web_preferences.cc |
| @@ -16,6 +16,10 @@ |
| #include "third_party/icu/source/common/unicode/uscript.h" |
| #include "webkit/common/webpreferences.h" |
| +#if defined(OS_ANDROID) |
| +#include "ui/gfx/android/device_display_info.h" |
| +#endif |
| + |
| using WebKit::WebNetworkStateNotifier; |
| using WebKit::WebRuntimeFeatures; |
| using WebKit::WebSettings; |
| @@ -109,6 +113,32 @@ void ApplyFontsFromMap(const webkit_glue::ScriptFontFamilyMap& map, |
| } |
| } |
| +#if defined(OS_ANDROID) |
| + |
| +const float kMinFSM = 1.05f; |
| +const int kWidthForMinFSM = 320; |
| +const float kMaxFSM = 1.3f; |
| +const int kWidthForMaxFSM = 800; |
| + |
| +float GetFontScaleMultiplier(const WebPreferences& prefs) { |
| + if (prefs.font_scale_factor_quirk) { |
| + // The pref value passed by Clank already includes the multiplier. |
| + return 1.0; |
| + } |
| + gfx::DeviceDisplayInfo info; |
| + int minWidth = info.GetSmallestDIPWidth(); |
| + |
| + if (minWidth <= kWidthForMinFSM) return kMinFSM; |
|
aelias_OOO_until_Jul13
2013/10/19 03:27:43
nit: return should be on another line
aelias_OOO_until_Jul13
2013/10/19 03:27:43
nit: return should be on newline
skobes
2013/10/21 17:49:30
Done.
skobes
2013/10/21 17:49:30
Done.
|
| + if (minWidth >= kWidthForMaxFSM) return kMaxFSM; |
| + |
| + // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. |
| + float ratio = ((float)(minWidth - kWidthForMinFSM)) / |
|
aelias_OOO_until_Jul13
2013/10/19 03:27:43
nit: use static_cast<float>(), and no need for the
skobes
2013/10/21 17:49:30
Done.
|
| + ((float)(kWidthForMaxFSM - kWidthForMinFSM)); |
| + return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
| +} |
| + |
| +#endif // defined(OS_ANDROID) |
| + |
| } // namespace |
| void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) { |
| @@ -324,7 +354,8 @@ void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) { |
| #if defined(OS_ANDROID) |
| settings->setAllowCustomScrollbarInMainFrame(false); |
| settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| - settings->setTextAutosizingFontScaleFactor(prefs.font_scale_factor); |
| + settings->setTextAutosizingFontScaleFactor( |
| + prefs.font_scale_factor * GetFontScaleMultiplier(prefs)); |
| web_view->setIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| settings->setAutoZoomFocusedNodeToLegibleScale(true); |
| settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |