Index: chrome/browser/resources/settings/controls/settings_slider.js |
diff --git a/chrome/browser/resources/settings/controls/settings_slider.js b/chrome/browser/resources/settings/controls/settings_slider.js |
index 1d7e2a94372ca4f788a7972bb1dc37e8c08cf372..5c5388af35fafb8bcfb36c16a0a00bde837f321c 100644 |
--- a/chrome/browser/resources/settings/controls/settings_slider.js |
+++ b/chrome/browser/resources/settings/controls/settings_slider.js |
@@ -23,6 +23,16 @@ Polymer({ |
/** @type {!Array<number>} Values corresponding to each tick. */ |
tickValues: {type: Array, value: []}, |
+ /** |
+ * A scale factor used to support fractional pref values since paper-slider |
+ * only supports integers. This is not compatible with |tickValues|, |
+ * i.e. if |scale| is not 1 then |tickValues| must be empty. |
+ */ |
+ scale: { |
+ type: Number, |
+ value: 1, |
+ }, |
+ |
min: Number, |
max: Number, |
@@ -58,7 +68,7 @@ Polymer({ |
if (this.tickValues && this.tickValues.length > 0) |
newValue = this.tickValues[sliderValue]; |
else |
- newValue = sliderValue; |
+ newValue = sliderValue / this.scale; |
this.set('pref.value', newValue); |
}, |
@@ -77,9 +87,11 @@ Polymer({ |
valueChanged_: function() { |
// If |tickValues| is empty, simply set current value to the slider. |
if (this.tickValues.length == 0) { |
- this.$.slider.value = this.pref.value; |
+ this.$.slider.value = |
+ /** @type {number} */ (this.pref.value) * this.scale; |
return; |
} |
+ assert(this.scale == 1); |
// First update the slider settings if |tickValues| was set. |
var numTicks = Math.max(1, this.tickValues.length); |