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

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: 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
« no previous file with comments | « webkit/glue/webpreferences.h ('k') | webkit/tools/test_shell/test_shell.cc » ('j') | 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 <unicode/uchar.h>
8
9 #include "base/string_util.h" 7 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
17 #include "unicode/uchar.h"
19 #include "webkit/glue/webkit_glue.h" 18 #include "webkit/glue/webkit_glue.h"
20 19
21 using WebKit::WebNetworkStateNotifier; 20 using WebKit::WebNetworkStateNotifier;
22 using WebKit::WebRuntimeFeatures; 21 using WebKit::WebRuntimeFeatures;
23 using WebKit::WebSettings; 22 using WebKit::WebSettings;
24 using WebKit::WebString; 23 using WebKit::WebString;
25 using WebKit::WebURL; 24 using WebKit::WebURL;
26 using WebKit::WebView; 25 using WebKit::WebView;
27 26
28 namespace webkit_glue { 27 namespace webkit_glue {
29 28
29 // "Zyyy" is the ISO 15924 script code for undetermined script aka Common.
30 const char WebPreferences::kCommonScript[] = "Zyyy";
31
30 WebPreferences::WebPreferences() 32 WebPreferences::WebPreferences()
31 : standard_font_family(ASCIIToUTF16("Times New Roman")), 33 : 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), 34 default_fixed_font_size(13),
39 minimum_font_size(0), 35 minimum_font_size(0),
40 minimum_logical_font_size(6), 36 minimum_logical_font_size(6),
41 default_device_scale_factor(1), 37 default_device_scale_factor(1),
42 default_encoding("ISO-8859-1"), 38 default_encoding("ISO-8859-1"),
43 javascript_enabled(true), 39 javascript_enabled(true),
44 web_security_enabled(true), 40 web_security_enabled(true),
45 javascript_can_open_windows_automatically(true), 41 javascript_can_open_windows_automatically(true),
46 loads_images_automatically(true), 42 loads_images_automatically(true),
47 images_enabled(true), 43 images_enabled(true),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 allow_displaying_insecure_content(true), 96 allow_displaying_insecure_content(true),
101 allow_running_insecure_content(false), 97 allow_running_insecure_content(false),
102 password_echo_enabled(false), 98 password_echo_enabled(false),
103 should_print_backgrounds(false), 99 should_print_backgrounds(false),
104 enable_scroll_animator(false), 100 enable_scroll_animator(false),
105 hixie76_websocket_protocol_enabled(false), 101 hixie76_websocket_protocol_enabled(false),
106 visual_word_movement_enabled(false), 102 visual_word_movement_enabled(false),
107 per_tile_painting_enabled(false), 103 per_tile_painting_enabled(false),
108 css_regions_enabled(false), 104 css_regions_enabled(false),
109 css_shaders_enabled(false) { 105 css_shaders_enabled(false) {
106 standard_font_family_map[kCommonScript] =
107 ASCIIToUTF16("Times New Roman");
108 fixed_font_family_map[kCommonScript] =
109 ASCIIToUTF16("Courier New");
110 serif_font_family_map[kCommonScript] =
111 ASCIIToUTF16("Times New Roman");
112 sans_serif_font_family_map[kCommonScript] =
113 ASCIIToUTF16("Arial");
114 cursive_font_family_map[kCommonScript] =
115 ASCIIToUTF16("Script");
116 fantasy_font_family_map[kCommonScript] =
117 ASCIIToUTF16("Impact");
110 } 118 }
111 119
112 WebPreferences::~WebPreferences() { 120 WebPreferences::~WebPreferences() {
113 } 121 }
114 122
115 namespace { 123 namespace {
116 124
117 void setStandardFontFamilyWrapper(WebSettings* settings, 125 void setStandardFontFamilyWrapper(WebSettings* settings,
118 const string16& font, 126 const string16& font,
119 UScriptCode script) { 127 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()); 169 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
162 if (script >= 0 && script < USCRIPT_CODE_LIMIT) 170 if (script >= 0 && script < USCRIPT_CODE_LIMIT)
163 (*setter)(settings, it->second, (UScriptCode) script); 171 (*setter)(settings, it->second, (UScriptCode) script);
164 } 172 }
165 } 173 }
166 174
167 } // namespace 175 } // namespace
168 176
169 void WebPreferences::Apply(WebView* web_view) const { 177 void WebPreferences::Apply(WebView* web_view) const {
170 WebSettings* settings = web_view->settings(); 178 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, 179 ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
178 settings); 180 settings);
179 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings); 181 ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
180 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings); 182 ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
181 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper, 183 ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
182 settings); 184 settings);
183 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper, 185 ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
184 settings); 186 settings);
185 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper, 187 ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
186 settings); 188 settings);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Enable per-tile painting if requested on the command line. 351 // Enable per-tile painting if requested on the command line.
350 settings->setPerTilePaintingEnabled(per_tile_painting_enabled); 352 settings->setPerTilePaintingEnabled(per_tile_painting_enabled);
351 353
352 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled); 354 settings->setExperimentalCSSRegionsEnabled(css_regions_enabled);
353 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled); 355 settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled);
354 356
355 WebNetworkStateNotifier::setOnLine(is_online); 357 WebNetworkStateNotifier::setOnLine(is_online);
356 } 358 }
357 359
358 } // namespace webkit_glue 360 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webpreferences.h ('k') | webkit/tools/test_shell/test_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698