Bug 1479536 - Fix SessionFinder.clear(); r=droeh a=ritu
authorJim Chen <nchen@mozilla.com>
Mon, 30 Jul 2018 16:21:29 -0400
changeset 480727 e17c9454ca9479fe6f3552b714109b740cfa711f
parent 480726 cdb16820b53eca89322572a56d008cb8d4635df8
child 480728 0249442a741cb771fdd23cd5670d07ac63f920e2
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh, ritu
bugs1479536
milestone62.0
Bug 1479536 - Fix SessionFinder.clear(); r=droeh a=ritu Fix the clear() call to clear highlights in addition to the selection. MozReview-Commit-ID: 1DNXa8fIGTP
mobile/android/modules/geckoview/GeckoViewContent.jsm
--- a/mobile/android/modules/geckoview/GeckoViewContent.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContent.jsm
@@ -265,20 +265,17 @@ class GeckoViewContent extends GeckoView
       },
 
       onHighlightFinished() {
       },
     };
 
     finder.caseSensitive = !!aData.matchCase;
     finder.entireWord = !!aData.wholeWord;
-
-    if (aCallback) {
-      finder.addResultListener(this._finderListener);
-    }
+    finder.addResultListener(this._finderListener);
 
     const drawOutline = this._matchDisplayOptions &&
                         !!this._matchDisplayOptions.drawOutline;
 
     if (!aData.searchString || aData.searchString === finder.searchString) {
       // Search again.
       aData.searchString = finder.searchString;
       finder.findAgain(!!aData.backwards,
@@ -287,19 +284,31 @@ class GeckoViewContent extends GeckoView
     } else {
       finder.fastFind(aData.searchString,
                       !!aData.linksOnly,
                       drawOutline);
     }
   }
 
   _clearMatches() {
+    debug `clearMatches`;
+
+    let finder;
     try {
-      this.browser.finder.removeSelection();
+      finder = this.browser.finder;
     } catch (e) {
+      return;
+    }
+
+    finder.removeSelection();
+    finder.highlight(false);
+
+    if (this._finderListener) {
+      finder.removeResultListener(this._finderListener);
+      this._finderListener = null;
     }
   }
 
   _displayMatches(aData) {
     debug `displayMatches: data=${aData}`;
 
     let finder;
     try {
@@ -307,20 +316,20 @@ class GeckoViewContent extends GeckoView
     } catch (e) {
       return;
     }
 
     this._matchDisplayOptions = aData;
     finder.onModalHighlightChange(!!aData.dimPage);
     finder.onHighlightAllChange(!!aData.highlightAll);
 
-    if (!finder.searchString) {
-      return;
-    }
     if (!aData.highlightAll && !aData.dimPage) {
       finder.highlight(false);
       return;
     }
-    const linksOnly = this._finderListener &&
-                      this._finderListener.response.linksOnly;
+
+    if (!this._finderListener || !finder.searchString) {
+      return;
+    }
+    const linksOnly = this._finderListener.response.linksOnly;
     finder.highlight(true, finder.searchString, linksOnly, !!aData.drawOutline);
   }
 }