Index: content/renderer/web_preferences.cc |
diff --git a/content/renderer/web_preferences.cc b/content/renderer/web_preferences.cc |
index 17d4a9c2344df2af9ca9bb35f95c9b2e6687083d..89788276616369c48561d3af0cf9af67e5bf032c 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,35 @@ 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 value of font_scale_factor passed by Chrome for Android already |
+ // includes the multiplier. |
+ return 1.0; |
+ } |
+ gfx::DeviceDisplayInfo info; |
+ int minWidth = info.GetSmallestDIPWidth(); |
jamesr
2013/10/21 17:58:33
we shouldn't be doing logic like this here in the
|
+ |
+ if (minWidth <= kWidthForMinFSM) |
+ return kMinFSM; |
+ if (minWidth >= kWidthForMaxFSM) |
+ return kMaxFSM; |
+ |
+ // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. |
+ float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / |
+ (kWidthForMaxFSM - kWidthForMinFSM); |
+ return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
+} |
+ |
+#endif // defined(OS_ANDROID) |
+ |
} // namespace |
void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) { |
@@ -324,7 +357,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); |