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

Side by Side Diff: chrome/browser/resources/options/font_settings.js

Issue 8467004: Update on Issue 8118003. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Changes corresponding comments. Created 9 years, 1 month 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 | « no previous file | 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 cr.define('options', function() { 5 cr.define('options', function() {
6 6
7 var OptionsPage = options.OptionsPage; 7 var OptionsPage = options.OptionsPage;
8 8
9 /** 9 /**
10 * This is the absolute difference maintained between standard and
11 * fixed-width font sizes. Refer http://crbug.com/91922.
12 */
13 const SIZE_DIFFERENCE_FIXED_STANDARD = 3;
14
15 /**
10 * FontSettings class 16 * FontSettings class
11 * Encapsulated handling of the 'Fonts and Encoding' page. 17 * Encapsulated handling of the 'Fonts and Encoding' page.
12 * @class 18 * @class
13 */ 19 */
14 function FontSettings() { 20 function FontSettings() {
15 OptionsPage.call(this, 21 OptionsPage.call(this,
16 'fonts', 22 'fonts',
17 templateData.fontSettingsPageTabTitle, 23 templateData.fontSettingsPageTabTitle,
18 'font-settings'); 24 'font-settings');
19 } 25 }
20 26
21 cr.addSingletonGetter(FontSettings); 27 cr.addSingletonGetter(FontSettings);
22 28
23 FontSettings.prototype = { 29 FontSettings.prototype = {
24 __proto__: OptionsPage.prototype, 30 __proto__: OptionsPage.prototype,
25 31
26 /** 32 /**
27 * Initialize the page. 33 * Initialize the page.
28 */ 34 */
29 initializePage: function() { 35 initializePage: function() {
30 OptionsPage.prototype.initializePage.call(this); 36 OptionsPage.prototype.initializePage.call(this);
31 37
32 var standardFontRange = $('standard-font-size'); 38 var standardFontRange = $('standard-font-size');
33 standardFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 39 standardFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20,
34 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 56, 64, 72]; 40 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 56, 64, 72];
35 standardFontRange.continuous = false; 41 standardFontRange.continuous = false;
36 standardFontRange.notifyChange = this.standardRangeChanged_.bind(this); 42 standardFontRange.notifyChange = this.standardRangeChanged_.bind(this);
43 standardFontRange.notifyPrefChange =
44 this.standardFontSizeChanged_.bind(this);
37 45
38 var minimumFontRange = $('minimum-font-size'); 46 var minimumFontRange = $('minimum-font-size');
39 minimumFontRange.valueMap = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 47 minimumFontRange.valueMap = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
40 18, 20, 22, 24]; 48 18, 20, 22, 24];
41 minimumFontRange.continuous = false; 49 minimumFontRange.continuous = false;
42 minimumFontRange.notifyChange = this.minimumRangeChanged_.bind(this); 50 minimumFontRange.notifyChange = this.minimumRangeChanged_.bind(this);
43 minimumFontRange.notifyPrefChange = 51 minimumFontRange.notifyPrefChange =
44 this.minimumFontSizeChanged_.bind(this); 52 this.minimumFontSizeChanged_.bind(this);
45 53
46 var placeholder = localStrings.getString('fontSettingsPlaceholder'); 54 var placeholder = localStrings.getString('fontSettingsPlaceholder');
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, 87 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily,
80 true); 88 true);
81 89
82 fontSampleEl = $('serif-font-sample'); 90 fontSampleEl = $('serif-font-sample');
83 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, 91 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily,
84 true); 92 true);
85 93
86 fontSampleEl = $('sans-serif-font-sample'); 94 fontSampleEl = $('sans-serif-font-sample');
87 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, 95 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily,
88 true); 96 true);
97
98 fontSampleEl = $('fixed-font-sample');
99 this.setUpFontSample_(fontSampleEl,
100 value - SIZE_DIFFERENCE_FIXED_STANDARD,
101 fontSampleEl.style.fontFamily, false);
89 }, 102 },
90 103
91 /** 104 /**
105 * Sets the 'default_fixed_font_size' preference when the standard font
106 * size has been changed by the user.
107 * @param {Element} el The slider input element.
108 * @param {number} value The mapped value that has been saved.
109 * @private
110 */
111 standardFontSizeChanged_: function(el, value) {
112 Preferences.setIntegerPref('webkit.webprefs.default_fixed_font_size',
113 value - SIZE_DIFFERENCE_FIXED_STANDARD, '');
114 },
115
116 /**
92 * Called as the user changes the miniumum font size. This allows for 117 * Called as the user changes the miniumum font size. This allows for
93 * reflecting the change in the UI before the preference has been changed. 118 * reflecting the change in the UI before the preference has been changed.
94 * @param {Element} el The slider input element. 119 * @param {Element} el The slider input element.
95 * @param {number} value The mapped value currently set by the slider. 120 * @param {number} value The mapped value currently set by the slider.
96 * @private 121 * @private
97 */ 122 */
98 minimumRangeChanged_: function(el, value) { 123 minimumRangeChanged_: function(el, value) {
99 var fontSampleEl = $('minimum-font-sample'); 124 var fontSampleEl = $('minimum-font-sample');
100 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, 125 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily,
101 true); 126 true);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 FontSettings.getInstance().setUpFontSample_($('minimum-font-sample'), size, 225 FontSettings.getInstance().setUpFontSample_($('minimum-font-sample'), size,
201 null, true); 226 null, true);
202 }; 227 };
203 228
204 // Export 229 // Export
205 return { 230 return {
206 FontSettings: FontSettings 231 FontSettings: FontSettings
207 }; 232 };
208 }); 233 });
209 234
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698