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
authorMike de Boer <mdeboer@mozilla.com>
Thu, 02 Feb 2017 14:59:53 +0100
changeset 469878 f2f8cc19b8565cddd554fe741c526de2fb918f5d
parent 469877 c34193caeedabd2834bd337a8b5551b8cafa1011
child 469879 f31ddcc843e8ff6e63c89cf185319feb60ab6572
push id43881
push userbmo:gps@mozilla.com
push dateThu, 02 Feb 2017 23:49:03 +0000
reviewersjaws
bugs1334213
milestone54.0a1
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
toolkit/modules/FinderHighlighter.jsm
--- 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.