Bug 1279802 - do not hide the modal highlight on middle click. r=jaws
authorMike de Boer <mdeboer@mozilla.com>
Tue, 02 Aug 2016 10:51:53 +0200
changeset 307950 fe5d0a5fa8fe7447abcd1e2e0dfd1cb478479682
parent 307949 be822ebbacc0b5e1495b032b1c83194bddc69fc8
child 307951 b214bedbeab67525c7c4526318808d46d400e47e
push id30524
push userkwierso@gmail.com
push dateWed, 03 Aug 2016 21:02:04 +0000
treeherdermozilla-central@de6fd5bb93d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1279802
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.