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

Side by Side Diff: webkit/glue/webpreferences.cc

Issue 10532105: Use ICU script code "Jpan" instead of "Hrkt" in Japanese pref names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 5 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
« no previous file with comments | « chrome/common/pref_names.cc ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 void setFantasyFontFamilyWrapper(WebSettings* settings, 169 void setFantasyFontFamilyWrapper(WebSettings* settings,
170 const string16& font, 170 const string16& font,
171 UScriptCode script) { 171 UScriptCode script) {
172 settings->setFantasyFontFamily(font, script); 172 settings->setFantasyFontFamily(font, script);
173 } 173 }
174 174
175 typedef void (*SetFontFamilyWrapper)( 175 typedef void (*SetFontFamilyWrapper)(
176 WebKit::WebSettings*, const string16&, UScriptCode); 176 WebKit::WebSettings*, const string16&, UScriptCode);
177 177
178 // If |scriptCode| is a member of a family of "similar" script codes, returns
179 // the script code in that family that is used by WebKit for font selection
180 // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are
181 // considered equivalent for the purposes of font selection. WebKit uses the
182 // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is
183 // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit
184 // uses different scripts than the ones in Chrome pref names because the version
185 // of ICU included on certain ports does not have some of the newer scripts. If
186 // |scriptCode| is not a member of such a family, returns |scriptCode|.
187 UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) {
188 switch (scriptCode) {
189 case USCRIPT_HIRAGANA:
190 case USCRIPT_KATAKANA:
191 case USCRIPT_JAPANESE:
192 return USCRIPT_KATAKANA_OR_HIRAGANA;
193 case USCRIPT_KOREAN:
194 return USCRIPT_HANGUL;
195 default:
196 return scriptCode;
197 }
198 }
199
178 void ApplyFontsFromMap(const WebPreferences::ScriptFontFamilyMap& map, 200 void ApplyFontsFromMap(const WebPreferences::ScriptFontFamilyMap& map,
179 SetFontFamilyWrapper setter, 201 SetFontFamilyWrapper setter,
180 WebSettings* settings) { 202 WebSettings* settings) {
181 for (WebPreferences::ScriptFontFamilyMap::const_iterator it = map.begin(); 203 for (WebPreferences::ScriptFontFamilyMap::const_iterator it = map.begin();
182 it != map.end(); ++it) { 204 it != map.end(); ++it) {
183 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); 205 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
184 if (script >= 0 && script < USCRIPT_CODE_LIMIT) 206 if (script >= 0 && script < USCRIPT_CODE_LIMIT) {
185 (*setter)(settings, it->second, (UScriptCode) script); 207 UScriptCode code = static_cast<UScriptCode>(script);
208 (*setter)(settings, it->second, GetScriptForWebSettings(code));
209 }
186 } 210 }
187 } 211 }
188 212
189 } // namespace 213 } // namespace
190 214
191 void WebPreferences::Apply(WebView* web_view) const { 215 void WebPreferences::Apply(WebView* web_view) const {
192 WebSettings* settings = web_view->settings(); 216 WebSettings* settings = web_view->settings();
193 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, 217 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
194 settings); 218 settings);
195 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings); 219 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 settings->setMaxUntiledLayerSize( 407 settings->setMaxUntiledLayerSize(
384 WebSize(max_untiled_layer_width, max_untiled_layer_height)); 408 WebSize(max_untiled_layer_width, max_untiled_layer_height));
385 409
386 settings->setFixedPositionCreatesStackingContext( 410 settings->setFixedPositionCreatesStackingContext(
387 fixed_position_creates_stacking_context); 411 fixed_position_creates_stacking_context);
388 412
389 WebNetworkStateNotifier::setOnLine(is_online); 413 WebNetworkStateNotifier::setOnLine(is_online);
390 } 414 }
391 415
392 } // namespace webkit_glue 416 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « chrome/common/pref_names.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698