OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 (function() { | 5 (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | |
9 * This is the absolute difference maintained between standard and | |
10 * fixed-width font sizes. http://crbug.com/91922. | |
11 * @const @private {number} | |
12 */ | |
13 var SIZE_DIFFERENCE_FIXED_STANDARD_ = 3; | |
14 | |
15 /** @const @private {!Array<number>} */ | 8 /** @const @private {!Array<number>} */ |
16 var FONT_SIZE_RANGE_ = [ | 9 var FONT_SIZE_RANGE_ = [ |
17 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, | 10 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, |
18 40, 44, 48, 56, 64, 72, | 11 40, 44, 48, 56, 64, 72, |
19 ]; | 12 ]; |
20 | 13 |
21 /** @const @private {!Array<number>} */ | 14 /** @const @private {!Array<number>} */ |
22 var MINIMUM_FONT_SIZE_RANGE_ = [ | 15 var MINIMUM_FONT_SIZE_RANGE_ = [ |
23 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24 | 16 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24 |
24 ]; | 17 ]; |
25 | 18 |
26 /** | 19 /** |
27 * 'settings-appearance-fonts-page' is the settings page containing appearance | 20 * 'settings-appearance-fonts-page' is the settings page containing appearance |
28 * settings. | 21 * settings. |
29 * | |
30 * Example: | |
31 * | |
32 * <settings-appearance-fonts-page prefs="{{prefs}}"> | |
33 * </settings-appearance-fonts-page> | |
34 */ | 22 */ |
35 Polymer({ | 23 Polymer({ |
36 is: 'settings-appearance-fonts-page', | 24 is: 'settings-appearance-fonts-page', |
37 | 25 |
38 behaviors: [I18nBehavior, WebUIListenerBehavior], | 26 behaviors: [I18nBehavior, WebUIListenerBehavior], |
39 | 27 |
40 properties: { | 28 properties: { |
41 /** @private */ | 29 /** @private */ |
42 advancedExtensionInstalled_: Boolean, | 30 advancedExtensionInstalled_: Boolean, |
43 | 31 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 66 |
79 /** | 67 /** |
80 * Preferences state. | 68 * Preferences state. |
81 */ | 69 */ |
82 prefs: { | 70 prefs: { |
83 type: Object, | 71 type: Object, |
84 notify: true, | 72 notify: true, |
85 }, | 73 }, |
86 }, | 74 }, |
87 | 75 |
88 observers: [ | |
89 'fontSizeChanged_(prefs.webkit.webprefs.default_font_size.value)', | |
90 ], | |
91 | |
92 /** @private {?settings.FontsBrowserProxy} */ | 76 /** @private {?settings.FontsBrowserProxy} */ |
93 browserProxy_: null, | 77 browserProxy_: null, |
94 | 78 |
95 /** @override */ | 79 /** @override */ |
96 created: function() { | 80 created: function() { |
97 this.browserProxy_ = settings.FontsBrowserProxyImpl.getInstance(); | 81 this.browserProxy_ = settings.FontsBrowserProxyImpl.getInstance(); |
98 }, | 82 }, |
99 | 83 |
100 /** @override */ | 84 /** @override */ |
101 ready: function() { | 85 ready: function() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 fontMenuOptions.push({ | 121 fontMenuOptions.push({ |
138 value: response.fontList[i][0], | 122 value: response.fontList[i][0], |
139 name: response.fontList[i][1] | 123 name: response.fontList[i][1] |
140 }); | 124 }); |
141 } | 125 } |
142 this.fontOptions_ = fontMenuOptions; | 126 this.fontOptions_ = fontMenuOptions; |
143 this.advancedExtensionUrl_ = response.extensionUrl; | 127 this.advancedExtensionUrl_ = response.extensionUrl; |
144 }, | 128 }, |
145 | 129 |
146 /** | 130 /** |
147 * @param {number} value The changed font size slider value. | |
148 * @private | |
149 */ | |
150 fontSizeChanged_: function(value) { | |
151 // TODO(michaelpg): Whitelist this pref in prefs_utils.cc so it is | |
152 // included in the <settings-prefs> getAllPrefs call, otherwise this path | |
153 // is invalid and nothing happens. See crbug.com/612535. | |
154 this.set('prefs.webkit.webprefs.default_fixed_font_size.value', | |
155 value - SIZE_DIFFERENCE_FIXED_STANDARD_); | |
156 }, | |
157 | |
158 /** | |
159 * Get the minimum font size, accounting for unset prefs. | 131 * Get the minimum font size, accounting for unset prefs. |
160 * @return {?} | 132 * @return {?} |
161 * @private | 133 * @private |
162 */ | 134 */ |
163 computeMinimumFontSize_: function() { | 135 computeMinimumFontSize_: function() { |
164 return this.get('prefs.webkit.webprefs.minimum_font_size.value') || | 136 return this.get('prefs.webkit.webprefs.minimum_font_size.value') || |
165 MINIMUM_FONT_SIZE_RANGE_[0]; | 137 MINIMUM_FONT_SIZE_RANGE_[0]; |
166 }, | 138 }, |
167 }); | 139 }); |
168 })(); | 140 })(); |
OLD | NEW |