Bug 1279802 - do not hide the modal highlight on middle click. r?jaws draft
authorMike de Boer <mdeboer@mozilla.com>
Tue, 02 Aug 2016 10:51:53 +0200
changeset 395472 7138cb37fca7be9f2853570bd23a85a66727efbf
parent 395471 46045ec8a4aa09a341b7209170089ade3c27c1a5
child 527001 809178f13d14fc76636ac63a84a5711852b62594
push id24781
push usermdeboer@mozilla.com
push dateTue, 02 Aug 2016 08:52:42 +0000
reviewersjaws
bugs1279802
milestone51.0a1
Bug 1279802 - do not hide the modal highlight on middle click. r?jaws MozReview-Commit-ID: AAWIysniyuv
toolkit/modules/FinderHighlighter.jsm
--- a/toolkit/modules/FinderHighlighter.jsm
+++ b/toolkit/modules/FinderHighlighter.jsm
@@ -278,18 +278,24 @@ FinderHighlighter.prototype = {
   /**
    * Clear all highlighted matches. If modal highlighting is enabled and
    * the outline + dimmed background is currently visible, both will be hidden.
    *
    * @param {nsIDOMWindow} window    The dimmed background will overlay this window.
    *                                 Optional, defaults to the finder window.
    * @param {nsIDOMRange}  skipRange A range that should not be removed from the
    *                                 find selection.
+   * @param {nsIDOMEvent}  event     When called from an event handler, this will
+   *                                 be the triggering event.
    */
-  hide(window = null, skipRange = null) {
+  hide(window = null, skipRange = null, event = null) {
+    // Do not hide on anything but a left-click.
+    if (event && event.type == "click" && event.button !== 0)
+      return;
+
     window = window || this.finder._getWindow();
 
     let doc = window.document;
     this._clearSelection(this.finder._getSelectionController(window), skipRange);
 
     // Next, check our editor cache, for editors belonging to this
     // document
     if (this._editors) {
@@ -831,37 +837,35 @@ FinderHighlighter.prototype = {
    * @param {nsIDOMWindow} window
    */
   _addModalHighlightListeners(window) {
     if (this._highlightListeners)
       return;
 
     this._highlightListeners = [
       this._scheduleRepaintOfMask.bind(this, window),
-      this.hide.bind(this, window)
+      this.hide.bind(this, window, null)
     ];
     window.addEventListener("DOMContentLoaded", this._highlightListeners[0]);
-    window.addEventListener("mousedown", this._highlightListeners[1]);
+    window.addEventListener("click", this._highlightListeners[1]);
     window.addEventListener("resize", this._highlightListeners[1]);
-    window.addEventListener("touchstart", this._highlightListeners[1]);
   },
 
   /**
    * Remove event listeners from content.
    *
    * @param {nsIDOMWindow} window
    */
   _removeModalHighlightListeners(window) {
     if (!this._highlightListeners)
       return;
 
     window.removeEventListener("DOMContentLoaded", this._highlightListeners[0]);
-    window.removeEventListener("mousedown", this._highlightListeners[1]);
+    window.removeEventListener("click", this._highlightListeners[1]);
     window.removeEventListener("resize", this._highlightListeners[1]);
-    window.removeEventListener("touchstart", this._highlightListeners[1]);
 
     this._highlightListeners = null;
   },
 
   /**
    * For a given node returns its editable parent or null if there is none.
    * It's enough to check if node is a text node and its parent's parent is
    * instance of nsIDOMNSEditableElement.