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

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: compile fixes Created 8 years, 8 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 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
19 #include "webkit/glue/webkit_glue.h" 19 #include "webkit/glue/webkit_glue.h"
20 20
21 using WebKit::WebNetworkStateNotifier; 21 using WebKit::WebNetworkStateNotifier;
22 using WebKit::WebRuntimeFeatures; 22 using WebKit::WebRuntimeFeatures;
23 using WebKit::WebSettings; 23 using WebKit::WebSettings;
24 using WebKit::WebString; 24 using WebKit::WebString;
25 using WebKit::WebURL; 25 using WebKit::WebURL;
26 using WebKit::WebView; 26 using WebKit::WebView;
27 27
28 namespace {
29 const char kWebKitCommonScript[] = "Zyyy";
darin (slow to review) 2012/04/23 17:00:35 How was this string literal chosen? What is the s
falken 2012/04/24 01:27:10 The font maps are from ISO 15924 script code to fo
30 }
31
28 WebPreferences::WebPreferences() 32 WebPreferences::WebPreferences()
29 : standard_font_family(ASCIIToUTF16("Times New Roman")), 33 : default_font_size(16),
30 fixed_font_family(ASCIIToUTF16("Courier New")),
31 serif_font_family(ASCIIToUTF16("Times New Roman")),
32 sans_serif_font_family(ASCIIToUTF16("Arial")),
33 cursive_font_family(ASCIIToUTF16("Script")),
34 fantasy_font_family(), // Not sure what to use on Windows.
35 default_font_size(16),
36 default_fixed_font_size(13), 34 default_fixed_font_size(13),
37 minimum_font_size(0), 35 minimum_font_size(0),
38 minimum_logical_font_size(6), 36 minimum_logical_font_size(6),
39 default_device_scale_factor(1), 37 default_device_scale_factor(1),
40 default_encoding("ISO-8859-1"), 38 default_encoding("ISO-8859-1"),
41 javascript_enabled(true), 39 javascript_enabled(true),
42 web_security_enabled(true), 40 web_security_enabled(true),
43 javascript_can_open_windows_automatically(true), 41 javascript_can_open_windows_automatically(true),
44 loads_images_automatically(true), 42 loads_images_automatically(true),
45 images_enabled(true), 43 images_enabled(true),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 allow_displaying_insecure_content(true), 96 allow_displaying_insecure_content(true),
99 allow_running_insecure_content(false), 97 allow_running_insecure_content(false),
100 password_echo_enabled(false), 98 password_echo_enabled(false),
101 should_print_backgrounds(false), 99 should_print_backgrounds(false),
102 enable_scroll_animator(false), 100 enable_scroll_animator(false),
103 hixie76_websocket_protocol_enabled(false), 101 hixie76_websocket_protocol_enabled(false),
104 visual_word_movement_enabled(false), 102 visual_word_movement_enabled(false),
105 per_tile_painting_enabled(false), 103 per_tile_painting_enabled(false),
106 css_regions_enabled(false), 104 css_regions_enabled(false),
107 css_shaders_enabled(false) { 105 css_shaders_enabled(false) {
106 standard_font_family_map[kWebKitCommonScript] =
107 ASCIIToUTF16("Times New Roman");
108 fixed_font_family_map[kWebKitCommonScript] =
109 ASCIIToUTF16("Courier New");
110 serif_font_family_map[kWebKitCommonScript] =
111 ASCIIToUTF16("Times New Roman");
112 sans_serif_font_family_map[kWebKitCommonScript] =
113 ASCIIToUTF16("Arial");
114 cursive_font_family_map[kWebKitCommonScript] =
115 ASCIIToUTF16("Script");
116 fantasy_font_family_map[kWebKitCommonScript] =
117 ASCIIToUTF16(""); // Not sure what to use on Windows
tony 2012/04/27 17:22:18 Impact is the default on Windows.
falken 2012/05/09 06:48:08 Done.
108 } 118 }
109 119
110 WebPreferences::~WebPreferences() { 120 WebPreferences::~WebPreferences() {
111 } 121 }
112 122
113 namespace { 123 namespace {
114 124
115 void setStandardFontFamilyWrapper(WebSettings* settings, 125 void setStandardFontFamilyWrapper(WebSettings* settings,
116 const string16& font, 126 const string16& font,
117 UScriptCode script) { 127 UScriptCode script) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); 169 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
160 if (script >= 0 && script < USCRIPT_CODE_LIMIT) 170 if (script >= 0 && script < USCRIPT_CODE_LIMIT)
161 (*setter)(settings, it->second, (UScriptCode) script); 171 (*setter)(settings, it->second, (UScriptCode) script);
162 } 172 }
163 } 173 }
164 174
165 } // namespace 175 } // namespace
166 176
167 void WebPreferences::Apply(WebView* web_view) const { 177 void WebPreferences::Apply(WebView* web_view) const {
168 WebSettings* settings = web_view->settings(); 178 WebSettings* settings = web_view->settings();
169 settings->setStandardFontFamily(standard_font_family);
170 settings->setFixedFontFamily(fixed_font_family);
171 settings->setSerifFontFamily(serif_font_family);
172 settings->setSansSerifFontFamily(sans_serif_font_family);
173 settings->setCursiveFontFamily(cursive_font_family);
174 settings->setFantasyFontFamily(fantasy_font_family);
175 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper, 179 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
176 settings); 180 settings);
177 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings); 181 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
178 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); 182 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
179 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, 183 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
180 settings); 184 settings);
181 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, 185 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
182 settings); 186 settings);
183 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, 187 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
184 settings); 188 settings);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 settings->setVisualWordMovementEnabled(visual_word_movement_enabled); 349 settings->setVisualWordMovementEnabled(visual_word_movement_enabled);
346 350
347 // Enable per-tile painting if requested on the command line. 351 // Enable per-tile painting if requested on the command line.
348 settings->setPerTilePaintingEnabled(per_tile_painting_enabled); 352 settings->setPerTilePaintingEnabled(per_tile_painting_enabled);
349 353
350 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled); 354 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled);
351 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled); 355 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled);
352 356
353 WebNetworkStateNotifier::setOnLine(is_online); 357 WebNetworkStateNotifier::setOnLine(is_online);
354 } 358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698