Bug 1334213 - listen to scroll events at the capturing phase to make sure to catch them when event propagation is stopped by a script in the current document. Also make sure to always update the yellow range outline position. r?jaws
MozReview-Commit-ID: 8C5uccBFGJ7
--- a/toolkit/modules/FinderHighlighter.jsm
+++ b/toolkit/modules/FinderHighlighter.jsm
@@ -880,17 +880,17 @@ FinderHighlighter.prototype = {
let range = dict.currentFoundRange;
if (!range)
return;
let fontStyle = this._getRangeFontStyle(range);
// Text color in the outline is determined by kModalStyles.
delete fontStyle.color;
- let rectsAndTexts = this._getRangeRectsAndTexts(range);
+ let rectsAndTexts = this._updateRangeRects(range, true, dict);
let outlineAnonNode = dict.modalHighlightOutline;
let rectCount = rectsAndTexts.rectList.length;
let previousRectCount = dict.previousRangeRectsAndTexts.rectList.length;
// (re-)Building the outline is conditional and happens when one of the
// following conditions is met:
// 1. No outline nodes were built before, or
// 2. When the amount of rectangles to draw is different from before, or
// 3. When there's more than one rectangle to draw, because it's impossible
@@ -1274,17 +1274,17 @@ FinderHighlighter.prototype = {
this._scheduleRepaintOfMask.bind(this, window, { updateAllRanges: true }),
this._scheduleRepaintOfMask.bind(this, window, { scrollOnly: true }),
this.hide.bind(this, window, null),
() => dict.busySelecting = true
];
let target = this.iterator._getDocShell(window).chromeEventHandler;
target.addEventListener("MozAfterPaint", dict.highlightListeners[0]);
target.addEventListener("resize", dict.highlightListeners[1]);
- target.addEventListener("scroll", dict.highlightListeners[2]);
+ target.addEventListener("scroll", dict.highlightListeners[2], { capture: true, passive: true });
target.addEventListener("click", dict.highlightListeners[3]);
target.addEventListener("selectstart", dict.highlightListeners[4]);
},
/**
* Remove event listeners from content.
*
* @param {nsIDOMWindow} window
@@ -1293,17 +1293,17 @@ FinderHighlighter.prototype = {
window = window.top;
let dict = this.getForWindow(window);
if (!dict.highlightListeners)
return;
let target = this.iterator._getDocShell(window).chromeEventHandler;
target.removeEventListener("MozAfterPaint", dict.highlightListeners[0]);
target.removeEventListener("resize", dict.highlightListeners[1]);
- target.removeEventListener("scroll", dict.highlightListeners[2]);
+ target.removeEventListener("scroll", dict.highlightListeners[2], { capture: true, passive: true });
target.removeEventListener("click", dict.highlightListeners[3]);
target.removeEventListener("selectstart", dict.highlightListeners[4]);
dict.highlightListeners = null;
},
/**
* For a given node returns its editable parent or null if there is none.