Bug 1291839 - Change the Narrate input[type=range] to use 'change' events instead of 'input' events because we are not interested in intermediate values of the slider. r?eeejay draft
authorJared Wein <jwein@mozilla.com>
Tue, 16 Aug 2016 01:17:22 -0400
changeset 401009 e0a8fc9d904d4c2e4ace6051ce05862094e0dc86
parent 401008 c1e05ecbb0124b3a8e5b7b8d0e4151743a9fd6e3
child 528371 b66675dd6f4ae94f4db83201cda412beeb147db6
push id26333
push userjwein@mozilla.com
push dateTue, 16 Aug 2016 05:18:03 +0000
reviewerseeejay
bugs1291839
milestone51.0a1
Bug 1291839 - Change the Narrate input[type=range] to use 'change' events instead of 'input' events because we are not interested in intermediate values of the slider. r?eeejay MozReview-Commit-ID: 8p1XAHYEbY1
toolkit/components/narrate/NarrateControls.jsm
--- a/toolkit/components/narrate/NarrateControls.jsm
+++ b/toolkit/components/narrate/NarrateControls.jsm
@@ -116,46 +116,40 @@ function NarrateControls(mm, win) {
   this.voiceSelect.element.id = "voice-select";
   win.speechSynthesis.addEventListener("voiceschanged", this);
   dropdown.querySelector("#narrate-voices").appendChild(
     this.voiceSelect.element);
 
   dropdown.addEventListener("click", this, true);
 
   let rateRange = dropdown.querySelector("#narrate-rate > input");
-  rateRange.addEventListener("input", this);
-  rateRange.addEventListener("mousedown", this);
-  rateRange.addEventListener("mouseup", this);
+  rateRange.addEventListener("change", this);
 
   // The rate is stored as an integer.
   rateRange.value = branch.getIntPref("rate");
 
   if (this._setupVoices(branch.getCharPref("voice"))) {
     // We disable this entire feature if there are no synthesis voices.
     dropdown.querySelector("#narrate-toggle").hidden = false;
   }
 
   let tb = win.document.getElementById("reader-toolbar");
   tb.appendChild(dropdown);
 }
 
 NarrateControls.prototype = {
   handleEvent: function(evt) {
     switch (evt.type) {
-      case "mousedown":
-        this._rateMousedown = true;
-        break;
-      case "mouseup":
-        this._rateMousedown = false;
-        break;
-      case "input":
-        this._onRateInput(evt);
-        break;
       case "change":
-        this._onVoiceChange();
+        let rateRange = this._doc.querySelector("#narrate-rate > input");
+        if (evt.target == rateRange) {
+          this._onRateInput(evt);
+        } else {
+          this._onVoiceChange();
+        }
         break;
       case "click":
         this._onButtonClick(evt);
         break;
       case "voiceschanged":
         // We disable this entire feature if there are no synthesis voices.
         this._doc.getElementById("narrate-toggle").hidden =
           !this._setupVoices(Services.prefs.getCharPref("narrate.voice"));
@@ -185,20 +179,18 @@ NarrateControls.prototype = {
       });
       this.voiceSelect.addOptions(options, selectedVoice);
     }
 
     return !!options.length;
   },
 
   _onRateInput: function(evt) {
-    if (!this._rateMousedown) {
-      AsyncPrefs.set("narrate.rate", parseInt(evt.target.value, 10));
-      this.narrator.setRate(this._convertRate(evt.target.value));
-    }
+    AsyncPrefs.set("narrate.rate", parseInt(evt.target.value, 10));
+    this.narrator.setRate(this._convertRate(evt.target.value));
   },
 
   _onVoiceChange: function() {
     let voice = this.voice;
     AsyncPrefs.set("narrate.voice", voice);
     this.narrator.setVoice(voice);
   },