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

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

Issue 10107014: Migrate WebKit "global script" font prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix after sync Created 8 years, 7 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
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 <unicode/uchar.h> 7 #include <unicode/uchar.h>
8 #include <unicode/uscript.h>
viettrungluu 2012/05/16 13:27:58 As I said elsewhere, these are really ICU includes
falken 2012/05/17 07:08:41 I've changed the existing include to "unicode/ucha
8 9
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
19 #include "webkit/glue/webkit_glue.h" 20 #include "webkit/glue/webkit_glue.h"
20 21
21 using WebKit::WebNetworkStateNotifier; 22 using WebKit::WebNetworkStateNotifier;
22 using WebKit::WebRuntimeFeatures; 23 using WebKit::WebRuntimeFeatures;
23 using WebKit::WebSettings; 24 using WebKit::WebSettings;
24 using WebKit::WebString; 25 using WebKit::WebString;
25 using WebKit::WebURL; 26 using WebKit::WebURL;
26 using WebKit::WebView; 27 using WebKit::WebView;
27 28
29 namespace {
30 const char* kCommonScript = uscript_getShortName(USCRIPT_COMMON);
viettrungluu 2012/05/16 13:27:58 Not wanting static initializers applies to all of
falken 2012/05/17 07:08:41 I've moved it back to the "Zyyy" constant. I think
31 }
32
28 namespace webkit_glue { 33 namespace webkit_glue {
29 34
30 WebPreferences::WebPreferences() 35 WebPreferences::WebPreferences()
31 : standard_font_family(ASCIIToUTF16("Times New Roman")), 36 : default_font_size(16),
32 fixed_font_family(ASCIIToUTF16("Courier New")),
33 serif_font_family(ASCIIToUTF16("Times New Roman")),
34 sans_serif_font_family(ASCIIToUTF16("Arial")),
35 cursive_font_family(ASCIIToUTF16("Script")),
36 fantasy_font_family(), // Not sure what to use on Windows.
37 default_font_size(16),
38 default_fixed_font_size(13), 37 default_fixed_font_size(13),
39 minimum_font_size(0), 38 minimum_font_size(0),
40 minimum_logical_font_size(6), 39 minimum_logical_font_size(6),
41 default_device_scale_factor(1), 40 default_device_scale_factor(1),
42 default_encoding("ISO-8859-1"), 41 default_encoding("ISO-8859-1"),
43 javascript_enabled(true), 42 javascript_enabled(true),
44 web_security_enabled(true), 43 web_security_enabled(true),
45 javascript_can_open_windows_automatically(true), 44 javascript_can_open_windows_automatically(true),
46 loads_images_automatically(true), 45 loads_images_automatically(true),
47 images_enabled(true), 46 images_enabled(true),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 allow_displaying_insecure_content(true), 99 allow_displaying_insecure_content(true),
101 allow_running_insecure_content(false), 100 allow_running_insecure_content(false),
102 password_echo_enabled(false), 101 password_echo_enabled(false),
103 should_print_backgrounds(false), 102 should_print_backgrounds(false),
104 enable_scroll_animator(false), 103 enable_scroll_animator(false),
105 hixie76_websocket_protocol_enabled(false), 104 hixie76_websocket_protocol_enabled(false),
106 visual_word_movement_enabled(false), 105 visual_word_movement_enabled(false),
107 per_tile_painting_enabled(false), 106 per_tile_painting_enabled(false),
108 css_regions_enabled(false), 107 css_regions_enabled(false),
109 css_shaders_enabled(false) { 108 css_shaders_enabled(false) {
109 standard_font_family_map[kCommonScript] =
110 ASCIIToUTF16("Times New Roman");
111 fixed_font_family_map[kCommonScript] =
112 ASCIIToUTF16("Courier New");
113 serif_font_family_map[kCommonScript] =
114 ASCIIToUTF16("Times New Roman");
115 sans_serif_font_family_map[kCommonScript] =
116 ASCIIToUTF16("Arial");
117 cursive_font_family_map[kCommonScript] =
118 ASCIIToUTF16("Script");
119 fantasy_font_family_map[kCommonScript] =
120 ASCIIToUTF16("Impact");
110 } 121 }
111 122
112 WebPreferences::~WebPreferences() { 123 WebPreferences::~WebPreferences() {
113 } 124 }
114 125
115 namespace { 126 namespace {
116 127
117 void setStandardFontFamilyWrapper(WebSettings* settings, 128 void setStandardFontFamilyWrapper(WebSettings* settings,
118 const string16& font, 129 const string16& font,
119 UScriptCode script) { 130 UScriptCode script) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); 172 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
162 if (script >= 0 && script < USCRIPT_CODE_LIMIT) 173 if (script >= 0 && script < USCRIPT_CODE_LIMIT)
163 (*setter)(settings, it->second, (UScriptCode) script); 174 (*setter)(settings, it->second, (UScriptCode) script);
164 } 175 }
165 } 176 }
166 177
167 } // namespace 178 } // namespace
168 179
169 void WebPreferences::Apply(WebView* web_view) const { 180 void WebPreferences::Apply(WebView* web_view) const {
170 WebSettings* settings = web_view->settings(); 181 WebSettings* settings = web_view->settings();
171 settings->setStandardFontFamily(standard_font_family);
172 settings->setFixedFontFamily(fixed_font_family);
173 settings->setSerifFontFamily(serif_font_family);
174 settings->setSansSerifFontFamily(sans_serif_font_family);
175 settings->setCursiveFontFamily(cursive_font_family);
176 settings->setFantasyFontFamily(fantasy_font_family);
177 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, 182 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
178 settings); 183 settings);
179 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings); 184 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
180 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); 185 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
181 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, 186 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
182 settings); 187 settings);
183 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, 188 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
184 settings); 189 settings);
185 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, 190 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
186 settings); 191 settings);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Enable per-tile painting if requested on the command line. 354 // Enable per-tile painting if requested on the command line.
350 settings->setPerTilePaintingEnabled(per_tile_painting_enabled); 355 settings->setPerTilePaintingEnabled(per_tile_painting_enabled);
351 356
352 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled); 357 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled);
353 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled); 358 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled);
354 359
355 WebNetworkStateNotifier::setOnLine(is_online); 360 WebNetworkStateNotifier::setOnLine(is_online);
356 } 361 }
357 362
358 } // namespace webkit_glue 363 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698