Bug 579576 - Thunderbird 3.1 cannot stop loading messages by pressing Escape. Change the quick filter bar to stop hijacking cmd_stop and get its own command, thereby allowing the stop button to work again. Additionally, make the stop button update to reflect reality using the same flicker-reducing heuristic used for the meteors. r=bienvenu
authorAndrew Sutherland <asutherland@asutherland.org>
Fri, 03 Dec 2010 11:05:29 -0800
changeset 6790 82e3af81389ee59a90d63c6030df9049743df666
parent 6789 bf57081301786fe000058d98a8859b00c386bf62
child 6791 ecb9513d50fb4bb635373b8a12b2d3c0bdbdb2a4
push id5208
push userbugmail@asutherland.org
push dateFri, 03 Dec 2010 19:05:52 +0000
treeherdercomm-central@82e3af81389e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs579576
Bug 579576 - Thunderbird 3.1 cannot stop loading messages by pressing Escape. Change the quick filter bar to stop hijacking cmd_stop and get its own command, thereby allowing the stop button to work again. Additionally, make the stop button update to reflect reality using the same flicker-reducing heuristic used for the meteors. r=bienvenu
mail/base/content/mailWindow.js
mail/base/content/mailWindowOverlay.xul
mail/base/content/quickFilterBar.js
mail/base/content/quickFilterBar.xul
mail/test/mozmill/quick-filter-bar/test-keyboard-interface.js
--- a/mail/base/content/mailWindow.js
+++ b/mail/base/content/mailWindow.js
@@ -161,16 +161,19 @@ function InitMsgWindow()
 
 function nsMsgStatusFeedback()
 {
   this._statusText = document.getElementById("statusText");
   this._progressBar = document.getElementById("statusbar-icon");
   this._progressBarContainer = document.getElementById("statusbar-progresspanel");
   this._throbber = document.getElementById("throbber-box");
   this._activeProcesses = new Array();
+
+  // make sure the stop button is accurate from the get-go
+  goUpdateCommand("cmd_stop");
 }
 
 nsMsgStatusFeedback.prototype =
 {
   // Document elements.
   _statusText: null,
   _progressBar: null,
   _progressBarContainer: null,
@@ -237,16 +240,19 @@ nsMsgStatusFeedback.prototype =
     this._startTimeoutID = null;
 
     // Turn progress meter on.
     this.updateProgress();
 
     // Start the throbber.
     if (this._throbber)
       this._throbber.setAttribute("busy", true);
+
+    // Update the stop button
+    goUpdateCommand("cmd_stop");
   },
 
   startMeteors: function() {
     this._startRequests++;
     // If we don't already have a start meteor timeout pending
     // and the meteors aren't spinning, then kick off a start.
     if (!this._startTimeoutID && !this._meteorsSpinning &&
         "MsgStatusFeedback" in window)
@@ -269,16 +275,19 @@ nsMsgStatusFeedback.prototype =
       this._throbber.setAttribute("busy", false);
 
     this._meteorsSpinning = false;
     this._stopTimeoutID = null;
 
     // Turn progress meter off.
     this._statusFeedbackProgress = -1;
     this.updateProgress();
+
+    // Update the stop button
+    goUpdateCommand("cmd_stop");
   },
 
   stopMeteors: function() {
     if (this._startRequests > 0)
       this._startRequests--;
 
     // If we are going to be starting the meteors, cancel the start.
     if (this._startRequests == 0 && this._startTimeoutID) {
--- a/mail/base/content/mailWindowOverlay.xul
+++ b/mail/base/content/mailWindowOverlay.xul
@@ -209,16 +209,17 @@
   <command id="cmd_selectFlagged" oncommand="goDoCommand('cmd_selectFlagged')"/>
   <command id="cmd_properties" oncommand="goDoCommand('cmd_properties')"
          valueNewsgroup="&folderPropsNewsgroupCmd.label;"
          valueFolder="&folderPropsFolderCmd.label;"
          valueGeneric="&folderPropsCmd.label;"/>
   <command id="cmd_find" oncommand="goDoCommand('cmd_find')" disabled="true"/>
   <command id="cmd_findAgain" oncommand="goDoCommand('cmd_findAgain')" disabled="true"/>
   <command id="cmd_findPrevious"  oncommand="goDoCommand('cmd_findPrevious')"  disabled="true"/>
+  <!-- Stop/abort current network activities. -->
   <command id="cmd_stop" oncommand="goDoCommand('cmd_stop')"/>
   <command id="cmd_reload" oncommand="goDoCommand('cmd_reload')"/>
 </commandset>
 
 <commandset id="mailEditContextMenuItems">
   <command id="cmd_copyLink"/>
   <command id="cmd_copyImage"/>
 </commandset>
@@ -432,17 +433,16 @@
        oncommand="goDoCommand('cmd_getMsgsForAuthAccounts');"
        modifiers="accel, shift"/>
   <key id="key_find" key="&findCmd.key;"  oncommand="goDoCommand('cmd_find')" modifiers="accel"/>
   <key id="key_findAgain" key="&findAgainCmd.key;"   oncommand="goDoCommand('cmd_findAgain')" modifiers="accel"/>
   <key id="key_findPrev"  key="&findPrevCmd.key;"    oncommand="goDoCommand('cmd_findPrevious')"  modifiers="accel, shift"/>
   <key keycode="&findAgainCmd.key2;"   oncommand="goDoCommand('cmd_findAgain')"/>
   <key keycode="&findPrevCmd.key2;"    oncommand="goDoCommand('cmd_findPrevious')"  modifiers="shift"/>
   <key id="key_quickSearchFocus" key="&quickSearchCmd.key;"  oncommand="QuickSearchFocus()" modifiers="accel"/>
-  <key id="key_stop" keycode="VK_ESCAPE" command="cmd_stop"/>
 
   <keyset id="viewZoomKeys">
     <key id="key_fullZoomReduce"  key="&fullZoomReduceCmd.commandkey;"
          command="cmd_fullZoomReduce"  modifiers="accel"/>
     <key                          key="&fullZoomReduceCmd.commandkey2;"
          command="cmd_fullZoomReduce"  modifiers="accel"/>
     <key id="key_fullZoomEnlarge" key="&fullZoomEnlargeCmd.commandkey;"
          command="cmd_fullZoomEnlarge" modifiers="accel"/>
--- a/mail/base/content/quickFilterBar.js
+++ b/mail/base/content/quickFilterBar.js
@@ -461,39 +461,41 @@ let QuickFilterBarMuxer = {
       document.getElementById("qfb-show-filter-bar").style.visibility = "hidden";
   },
 
   supportsCommand: function QFBM_supportsCommand(aCommand, aTab) {
     // we are not active on tab types we do not support (message tabs)
     if (!("quickFilter" in aTab._ext))
       return null;
 
-    if (aCommand == "cmd_stop" || aCommand == "cmd_find" ||
+    if (aCommand == "cmd_popQuickFilterBarStack" ||
+        aCommand == "cmd_find" ||
         aCommand == "cmd_toggleQuickFilterBar")
       return true;
     else
       return null;
   },
   isCommandEnabled: function QFBM_isCommandEnabled(aCommand, aTab) {
     // we are not active on tab types we do not support (message tabs)
     if (!("quickFilter" in aTab._ext))
       return null;
 
-    if (aCommand == "cmd_stop" || aCommand == "cmd_find" ||
+    if (aCommand == "cmd_popQuickFilterBarStack" ||
+        aCommand == "cmd_find" ||
         aCommand == "cmd_toggleQuickFilterBar")
       return true;
     else
       return null;
   },
   doCommand: function QFBM_doCommand(aCommand, aTab) {
     // we are not active on tab types we do not support (message tabs)
     if (!("quickFilter" in aTab._ext))
       return null;
 
-    if (aCommand == "cmd_stop") {
+    if (aCommand == "cmd_popQuickFilterBarStack") {
       QuickFilterBarMuxer.cmdEscapeFilterStack();
       return true;
     }
     else if (aCommand == "cmd_find") {
       let textWidget = document.getElementById(
                          QuickFilterManager.textBoxDomId);
       // if it's not already focused, then focus/select it
       if (document.commandDispatcher.focusedElement != textWidget.inputField) {
--- a/mail/base/content/quickFilterBar.xul
+++ b/mail/base/content/quickFilterBar.xul
@@ -36,20 +36,28 @@
   - ***** END LICENSE BLOCK ***** -->
 
 <?xml-stylesheet href="chrome://messenger/skin/quickFilterBar.css" type="text/css"?>
 <!DOCTYPE quickFilterBar SYSTEM "chrome://messenger/locale/quickFilterBar.dtd">
 <overlay id="quickFilterBar-overlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script src="quickFilterBar.js" type="application/javascript" />
 
+  <keyset id="mailKeys">
+    <key id="key_qfb_escape" keycode="VK_ESCAPE"
+         command="cmd_popQuickFilterBarStack"/>
+  </keyset>
+
   <commandset id="mailViewMenuItems">
     <command id="cmd_toggleQuickFilterBar"
              oncommand="goDoCommand('cmd_toggleQuickFilterBar');"
              />
+    <command id="cmd_popQuickFilterBarStack"
+             oncommand="goDoCommand('cmd_popQuickFilterBarStack');"
+             />
   </commandset>
 
   <menupopup id="view_toolbars_popup">
     <!-- gets disabled but stays visible when not legal -->
     <menuitem id="view_toolbars_popup_quickFilterBar"
               insertbefore="viewMenuBeforeCustomizeMailToolbarsSeparator"
               label="&quickFilterBar.toggleBarVisibility.menu.label;"
               accesskey="&quickFilterBar.toggleBarVisibility.menu.accesskey;"
--- a/mail/test/mozmill/quick-filter-bar/test-keyboard-interface.js
+++ b/mail/test/mozmill/quick-filter-bar/test-keyboard-interface.js
@@ -113,19 +113,19 @@ function test_escape_rules() {
   legwork();
 
   // 3) focus in the text box and pretend to type stuff...
   mc.e("qfb-qs-textbox").focus();
   set_filter_text("qxqxqxqx");
 
   // Escape should clear the text constraint but the bar should still be
   //  visible.  The trick here is that escape is clearing the text widget
-  //  and is not falling through to the cmd_stop case so we end up with a
-  //  situation where the _lastFilterAttr is the textbox but the textbox
-  //  does not actually have any active filter.
+  //  and is not falling through to the cmd_popQuickFilterBarStack case so we
+  //  end up with a situation where the _lastFilterAttr is the textbox but the
+  //  textbox does not actually have any active filter.
   mc.keypress(null, "VK_ESCAPE", {});
   assert_quick_filter_bar_visible(true);
   assert_constraints_expressed({});
   assert_filter_text("");
 
   // Next escape should close the box
   mc.keypress(null, "VK_ESCAPE", {});
   assert_quick_filter_bar_visible(false);