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

Unified Diff: webkit/glue/webpreferences.cc

Issue 7606028: Pass per-script fonts to WebKit settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch to commit Created 9 years, 4 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
« chrome/common/pref_names.h ('K') | « webkit/glue/webpreferences.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webpreferences.cc
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index 615b68c9859dc120cc7ef560d6001a5c7d0141c0..cacfd4beb8aa3bae1389ffbdf5b247ff6d8df19e 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -4,6 +4,8 @@
#include "webkit/glue/webpreferences.h"
+#include <unicode/uchar.h>
+
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
@@ -92,6 +94,60 @@ WebPreferences::WebPreferences()
WebPreferences::~WebPreferences() {
}
+namespace {
+
+void setStandardFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setStandardFontFamily(font, script);
+}
+
+void setFixedFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setFixedFontFamily(font, script);
+}
+
+void setSerifFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setSerifFontFamily(font, script);
+}
+
+void setSansSerifFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setSansSerifFontFamily(font, script);
+}
+
+void setCursiveFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setCursiveFontFamily(font, script);
+}
+
+void setFantasyFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setFantasyFontFamily(font, script);
+}
+
+typedef void (*SetFontFamilyWrapper)(
+ WebKit::WebSettings*, const string16&, UScriptCode);
+
+void ApplyFontsFromMap(const WebPreferences::ScriptFontFamilyMap& map,
+ SetFontFamilyWrapper setter,
+ WebSettings* settings) {
+ for (WebPreferences::ScriptFontFamilyMap::const_iterator it = map.begin();
+ it != map.end(); ++it) {
+ int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
+ if (script >= 0 && script < USCRIPT_CODE_LIMIT)
+ (*setter)(settings, it->second, (UScriptCode) script);
+ }
+}
+
+} // namespace
+
void WebPreferences::Apply(WebView* web_view) const {
WebSettings* settings = web_view->settings();
settings->setStandardFontFamily(standard_font_family);
@@ -100,6 +156,16 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setSansSerifFontFamily(sans_serif_font_family);
settings->setCursiveFontFamily(cursive_font_family);
settings->setFantasyFontFamily(fantasy_font_family);
+ ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
+ settings);
+ ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
+ ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
+ ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
+ settings);
+ ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
+ settings);
+ ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
+ settings);
settings->setDefaultFontSize(default_font_size);
settings->setDefaultFixedFontSize(default_fixed_font_size);
settings->setMinimumFontSize(minimum_font_size);
« chrome/common/pref_names.h ('K') | « webkit/glue/webpreferences.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698