Bug 1279802 - do not hide the modal highlight on middle click. r?jaws
MozReview-Commit-ID: AAWIysniyuv
--- 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.