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

Side by Side 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: revised patch to address sky's comment 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 unified diff | Download patch | Annotate | Revision Log
« webkit/glue/webpreferences.h ('K') | « webkit/glue/webpreferences.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/webpreferences.h" 5 #include "webkit/glue/webpreferences.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 allow_displaying_insecure_content(true), 85 allow_displaying_insecure_content(true),
86 allow_running_insecure_content(false), 86 allow_running_insecure_content(false),
87 should_print_backgrounds(false), 87 should_print_backgrounds(false),
88 enable_scroll_animator(false), 88 enable_scroll_animator(false),
89 hixie76_websocket_protocol_enabled(false) { 89 hixie76_websocket_protocol_enabled(false) {
90 } 90 }
91 91
92 WebPreferences::~WebPreferences() { 92 WebPreferences::~WebPreferences() {
93 } 93 }
94 94
95 namespace {
96
97 void setStandardFontFamilyWrapper(WebSettings* settings,
98 const string16& font,
99 UScriptCode script) {
100 settings->setStandardFontFamily(font, script);
101 }
102
103 void setFixedFontFamilyWrapper(WebSettings* settings,
104 const string16& font,
105 UScriptCode script) {
106 settings->setFixedFontFamily(font, script);
107 }
108
109 void setSerifFontFamilyWrapper(WebSettings* settings,
110 const string16& font,
111 UScriptCode script) {
112 settings->setSerifFontFamily(font, script);
113 }
114
115 void setSansSerifFontFamilyWrapper(WebSettings* settings,
116 const string16& font,
117 UScriptCode script) {
118 settings->setSansSerifFontFamily(font, script);
119 }
120
121 void setCursiveFontFamilyWrapper(WebSettings* settings,
122 const string16& font,
123 UScriptCode script) {
124 settings->setCursiveFontFamily(font, script);
125 }
126
127 void setFantasyFontFamilyWrapper(WebSettings* settings,
128 const string16& font,
129 UScriptCode script) {
130 settings->setFantasyFontFamily(font, script);
131 }
132
133 typedef void (*SetFontFamilyWrapper)(
134 WebKit::WebSettings*, const string16&, UScriptCode);
135
136 void ApplyFontsFromMap(const WebPreferences::ScriptFontFamilyMap& map,
137 SetFontFamilyWrapper setter,
138 WebSettings* settings) {
139 for (WebPreferences::ScriptFontFamilyMap::const_iterator it = map.begin();
140 it != map.end(); ++it) {
141 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
142 if (script >= 0 && script < USCRIPT_CODE_LIMIT)
143 (*setter)(settings, it->second, (UScriptCode) script);
144 }
145 }
146
147 } // namespace
148
95 void WebPreferences::Apply(WebView* web_view) const { 149 void WebPreferences::Apply(WebView* web_view) const {
96 WebSettings* settings = web_view->settings(); 150 WebSettings* settings = web_view->settings();
97 settings->setStandardFontFamily(standard_font_family); 151 settings->setStandardFontFamily(standard_font_family);
98 settings->setFixedFontFamily(fixed_font_family); 152 settings->setFixedFontFamily(fixed_font_family);
99 settings->setSerifFontFamily(serif_font_family); 153 settings->setSerifFontFamily(serif_font_family);
100 settings->setSansSerifFontFamily(sans_serif_font_family); 154 settings->setSansSerifFontFamily(sans_serif_font_family);
101 settings->setCursiveFontFamily(cursive_font_family); 155 settings->setCursiveFontFamily(cursive_font_family);
102 settings->setFantasyFontFamily(fantasy_font_family); 156 settings->setFantasyFontFamily(fantasy_font_family);
157 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
158 settings);
159 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
160 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
161 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
162 settings);
163 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
164 settings);
165 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
166 settings);
103 settings->setDefaultFontSize(default_font_size); 167 settings->setDefaultFontSize(default_font_size);
104 settings->setDefaultFixedFontSize(default_fixed_font_size); 168 settings->setDefaultFixedFontSize(default_fixed_font_size);
105 settings->setMinimumFontSize(minimum_font_size); 169 settings->setMinimumFontSize(minimum_font_size);
106 settings->setMinimumLogicalFontSize(minimum_logical_font_size); 170 settings->setMinimumLogicalFontSize(minimum_logical_font_size);
107 settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding)); 171 settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding));
108 settings->setJavaScriptEnabled(javascript_enabled); 172 settings->setJavaScriptEnabled(javascript_enabled);
109 settings->setWebSecurityEnabled(web_security_enabled); 173 settings->setWebSecurityEnabled(web_security_enabled);
110 settings->setJavaScriptCanOpenWindowsAutomatically( 174 settings->setJavaScriptCanOpenWindowsAutomatically(
111 javascript_can_open_windows_automatically); 175 javascript_can_open_windows_automatically);
112 settings->setLoadsImagesAutomatically(loads_images_automatically); 176 settings->setLoadsImagesAutomatically(loads_images_automatically);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 settings->setFullScreenEnabled(fullscreen_enabled); 299 settings->setFullScreenEnabled(fullscreen_enabled);
236 settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content); 300 settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content);
237 settings->setAllowRunningOfInsecureContent(allow_running_insecure_content); 301 settings->setAllowRunningOfInsecureContent(allow_running_insecure_content);
238 settings->setShouldPrintBackgrounds(should_print_backgrounds); 302 settings->setShouldPrintBackgrounds(should_print_backgrounds);
239 settings->setEnableScrollAnimator(enable_scroll_animator); 303 settings->setEnableScrollAnimator(enable_scroll_animator);
240 settings->setHixie76WebSocketProtocolEnabled( 304 settings->setHixie76WebSocketProtocolEnabled(
241 hixie76_websocket_protocol_enabled); 305 hixie76_websocket_protocol_enabled);
242 306
243 WebNetworkStateNotifier::setOnLine(is_online); 307 WebNetworkStateNotifier::setOnLine(is_online);
244 } 308 }
OLDNEW
« webkit/glue/webpreferences.h ('K') | « webkit/glue/webpreferences.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698