Bug 1302470 Part 3: Call the new isRangeVisible function to determine whether or not to draw a highlight rect. r=mikedeboer
authorMike de Boer <mdeboer@mozilla.com>
Thu, 10 Nov 2016 09:03:58 -0800
changeset 325583 3d2569996ebc5b4625f9a221c78c00cb982a8735
parent 325582 b92b78271941789fc06c7b9ec7cd9c566b7fc20a
child 325584 113f7b13475cc8de15f8d253cee720e3a9df8ce1
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmikedeboer
bugs1302470
milestone53.0a1
Bug 1302470 Part 3: Call the new isRangeVisible function to determine whether or not to draw a highlight rect. r=mikedeboer MozReview-Commit-ID: ExO6zdjHGVO
toolkit/modules/FinderHighlighter.jsm
toolkit/modules/FinderIterator.jsm
--- a/toolkit/modules/FinderHighlighter.jsm
+++ b/toolkit/modules/FinderHighlighter.jsm
@@ -1134,16 +1134,19 @@ FinderHighlighter.prototype = {
     this._updateRangeOutline(dict);
 
     let allRects = [];
     if (paintContent || dict.modalHighlightAllMask) {
       this._updateDynamicRangesRects(dict);
 
       let DOMRect = window.DOMRect;
       for (let [range, rects] of dict.modalHighlightRectsMap) {
+        if (!this.finder._fastFind.isRangeVisible(range, false))
+          continue;
+
         if (dict.updateAllRanges)
           rects = this._updateRangeRects(range);
 
         // If a geometry change was detected, we bail out right away here, because
         // the current set of ranges has been invalidated.
         if (dict.detectedGeometryChange)
           return;
 
--- a/toolkit/modules/FinderIterator.jsm
+++ b/toolkit/modules/FinderIterator.jsm
@@ -562,24 +562,17 @@ this.FinderIterator = {
       return frames;
 
     // Casting `window.frames` to an Iterator doesn't work, so we're stuck with
     // a plain, old for-loop.
     for (let i = 0, l = window.frames.length; i < l; ++i) {
       let frame = window.frames[i];
       // Don't count matches in hidden frames.
       let frameEl = frame && frame.frameElement;
-      if (!frameEl)
-        continue;
-      // Construct a range around the frame element to check its visiblity.
-      let range = window.document.createRange();
-      range.setStart(frameEl, 0);
-      range.setEnd(frameEl, 0);
-      // Pass `true` to flush layout.
-      if (!finder._fastFind.isRangeVisible(range, true))
+      if (!frameEl || !frameEl.getClientRects().length)
         continue;
       // All conditions pass, so push the current frame and its children on the
       // stack.
       frames.push(frame, ...this._collectFrames(frame, finder));
     }
 
     return frames;
   },