Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1026)

Unified Diff: content/renderer/web_preferences.cc

Issue 28053002: Add font_scale_factor_quirk pref. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master.pinned
Patch Set: Address review comments. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « content/public/common/common_param_traits_macros.h ('k') | ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698