Chromium Code Reviews| Index: webkit/glue/webpreferences.cc |
| diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc |
| index 615b68c9859dc120cc7ef560d6001a5c7d0141c0..653a28acb681dd47b5814b53d5dbfc94160c4bd2 100644 |
| --- a/webkit/glue/webpreferences.cc |
| +++ b/webkit/glue/webpreferences.cc |
| @@ -92,6 +92,55 @@ WebPreferences::WebPreferences() |
| WebPreferences::~WebPreferences() { |
| } |
| +void setStandardFontFamilyWrapper(WebSettings* settings, |
|
Mattias Nissler (ping if slow)
2011/08/16 09:22:45
declare these helpers static or wrap them in an an
falken
2011/08/16 12:20:33
Done.
|
| + 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); |
| + } |
| +} |
| + |
| void WebPreferences::Apply(WebView* web_view) const { |
| WebSettings* settings = web_view->settings(); |
| settings->setStandardFontFamily(standard_font_family); |
| @@ -100,6 +149,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); |
|
Mattias Nissler (ping if slow)
2011/08/16 09:22:45
missing space after ,
falken
2011/08/16 12:20:33
Done.
|
| + 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); |