Bug 1427350 - Part 2 - Rename _matchCount to matchCount. r=mak draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Sun, 04 Feb 2018 15:00:58 +0000
changeset 751022 a4e568ba1d61c4ffc6ebea04b644d3f727adb95c
parent 751021 ce53efd0820edc02e5a29274077a141e8ebd232b
child 751023 dca0d5536794877fbf43138ac7b35be5b6f9f200
child 751024 13302171d42fa7d0a97c49c23ec54a9a388b034c
push id97817
push userpaolo.mozmail@amadzone.org
push dateSun, 04 Feb 2018 15:20:05 +0000
reviewersmak
bugs1427350
milestone60.0a1
Bug 1427350 - Part 2 - Rename _matchCount to matchCount. r=mak MozReview-Commit-ID: 2oo0Nxp3Qot
browser/base/content/test/performance/browser_urlbar_search_reflows.js
browser/base/content/test/urlbar/Panel.jsm
browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js
browser/base/content/urlbarBindings.xml
browser/components/search/content/search.xml
testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
toolkit/content/widgets/autocomplete.xml
--- a/browser/base/content/test/performance/browser_urlbar_search_reflows.js
+++ b/browser/base/content/test/performance/browser_urlbar_search_reflows.js
@@ -165,17 +165,17 @@ add_task(async function() {
     };
 
     URLBar.controller.startSearch(URLBar.value);
     await BrowserTestUtils.waitForEvent(URLBar.popup, "popupshown");
     await BrowserTestUtils.waitForCondition(() => {
       return URLBar.controller.searchStatus >=
         Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
     });
-    let matchCount = URLBar.popup._matchCount;
+    let matchCount = URLBar.popup.matchCount;
     await BrowserTestUtils.waitForCondition(() => {
       return URLBar.popup.richlistbox.childNodes.length == matchCount;
     });
 
     URLBar.controller.stopSearch();
     // There are several setTimeout(fn, 0); calls inside autocomplete.xml
     // that we need to wait for. Since those have higher priority than
     // idle callbacks, we can be sure they will have run once this
--- a/browser/base/content/test/urlbar/Panel.jsm
+++ b/browser/base/content/test/urlbar/Panel.jsm
@@ -92,17 +92,17 @@ this.Panel.prototype = {
   },
 
   // This emulates the popup's own _appendCurrentResult method, except instead
   // of appending results to the popup, it emits "result" events to the iframe.
   _appendCurrentResult() {
     let controller = this.p.mInput.controller;
     for (let i = 0; i < this.p.maxResults; i++) {
       let idx = this._currentIndex;
-      if (idx >= this.p._matchCount) {
+      if (idx >= this.p.matchCount) {
         break;
       }
       let url = controller.getValueAt(idx);
       let action = this.urlbar._parseActionUrl(url);
       this._emit("result", {
         url,
         action,
         image: controller.getImageAt(idx),
--- a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js
+++ b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js
@@ -39,17 +39,17 @@ add_task(async function focus() {
   setupVisibleHint();
   gURLBar.blur();
   let popupPromise = promisePopupShown(gURLBar.popup);
   focusAndSelectUrlBar(true);
   await popupPromise;
   Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
   assertVisible(true);
   assertFooterVisible(false);
-  Assert.equal(gURLBar.popup._matchCount, 0, "popup should have no results");
+  Assert.equal(gURLBar.popup.matchCount, 0, "popup should have no results");
 
   // Start searching.
   EventUtils.synthesizeKey("r", {});
   EventUtils.synthesizeKey("n", {});
   EventUtils.synthesizeKey("d", {});
   await promiseSearchComplete();
   Assert.ok(suggestionsPresent());
   assertVisible(true);
@@ -78,17 +78,17 @@ add_task(async function click_on_focused
 
   let popupPromise = promisePopupShown(gURLBar.popup);
   EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {});
   await popupPromise;
 
   Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
   assertVisible(true);
   assertFooterVisible(false);
-  Assert.equal(gURLBar.popup._matchCount, 0, "popup should have no results");
+  Assert.equal(gURLBar.popup.matchCount, 0, "popup should have no results");
   gURLBar.blur();
   Assert.ok(!gURLBar.popup.popupOpen, "popup should be closed");
 });
 
 add_task(async function new_tab() {
   // Opening a new tab when the urlbar is unfocused, should focus it but not
   // open the popup.
   setupVisibleHint();
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -310,19 +310,19 @@ file, You can obtain one at http://mozil
             // In this case, the popup is closed and the user pressed the Tab
             // key.  The focus should move out of the urlbar immediately.
             return false;
           }
           if (!this.gotResultForCurrentQuery || !this.popupOpen) {
             return true;
           }
           let maxResultsRemaining =
-            this.popup.maxResults - this.popup._matchCount;
+            this.popup.maxResults - this.popup.matchCount;
           let lastResultSelected =
-            this.popup.selectedIndex + 1 == this.popup._matchCount;
+            this.popup.selectedIndex + 1 == this.popup.matchCount;
           return maxResultsRemaining > 0 && lastResultSelected;
         ]]></body>
       </method>
 
       <!--
         Adds a key event to the deferred event queue.
 
         @param event
@@ -2012,18 +2012,18 @@ file, You can obtain one at http://mozil
           // sometimes fails to complete, leaving the popup too tall.  Work
           // around that problem by disabling the listbox animation.
           this.richlistbox.flex = 0;
           this.setAttribute("dontanimate", "true");
 
           this.classList.add("showSearchSuggestionsNotification");
           // Don't show the one-off buttons if we are showing onboarding and
           // there's no result, since it would be ugly and pointless.
-          this.footer.collapsed = this._matchCount == 0;
-          this.input.tabScrolling = this._matchCount != 0;
+          this.footer.collapsed = this.matchCount == 0;
+          this.input.tabScrolling = this.matchCount != 0;
 
           // This event allows accessibility APIs to see the notification.
           if (!this.popupOpen) {
             let event = document.createEvent("Events");
             event.initEvent("AlertActive", true, true);
             this.searchSuggestionsNotification.dispatchEvent(event);
           }
           ]]>
@@ -2032,17 +2032,17 @@ file, You can obtain one at http://mozil
 
       <method name="_hideSearchSuggestionsNotification">
         <body>
           <![CDATA[
           this.classList.remove("showSearchSuggestionsNotification");
           this.richlistbox.flex = 1;
           this.removeAttribute("dontanimate");
           this.searchSuggestionsNotification.removeAttribute("animate");
-          if (this._matchCount) {
+          if (this.matchCount) {
             // Update popup height.
             this._invalidate();
           } else {
             this.closePopup();
           }
           ]]>
         </body>
       </method>
@@ -2067,17 +2067,17 @@ file, You can obtain one at http://mozil
       </method>
 
       <!-- This handles keypress changes to the selection among the one-off
            search buttons and between the one-offs and the listbox.  It returns
            true if the keypress was consumed and false if not. -->
       <method name="handleKeyPress">
         <parameter name="aEvent"/>
         <body><![CDATA[
-          this.oneOffSearchButtons.handleKeyPress(aEvent, this._matchCount,
+          this.oneOffSearchButtons.handleKeyPress(aEvent, this.matchCount,
                                                   !this._isFirstResultHeuristic,
                                                   gBrowser.userTypedValue);
           return aEvent.defaultPrevented && !aEvent.urlbarDeferred;
         ]]></body>
       </method>
 
       <!-- This is called when a one-off is clicked and when "search in new tab"
            is selected from a one-off context menu. -->
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -837,17 +837,17 @@
 
           // accel + up/down changes the default engine and shouldn't affect
           // the selection on the one-off buttons.
           if (aEvent.getModifierState("Accel"))
             return;
 
           let suggestionsHidden =
             popup.richlistbox.getAttribute("collapsed") == "true";
-          let numItems = suggestionsHidden ? 0 : this.popup._matchCount;
+          let numItems = suggestionsHidden ? 0 : this.popup.matchCount;
           this.popup.oneOffButtons.handleKeyPress(aEvent, numItems, true);
         ]]></body>
       </method>
 
       <!-- nsIController -->
       <field name="searchbarController" readonly="true"><![CDATA[({
         _self: this,
         supportsCommand(aCommand) {
@@ -1111,17 +1111,17 @@
           // second time the user clicks the glass icon for some reason...
           this.richlistbox.collapsed = true;
         } else {
           this.removeAttribute("showonlysettings");
           // Uncollapse as long as we have a view which has >= 1 row.
           // The autocomplete binding itself will take care of uncollapsing later,
           // if we currently have no rows but end up having some in the future
           // when the search string changes
-          this.richlistbox.collapsed = (this._matchCount == 0);
+          this.richlistbox.collapsed = (this.matchCount == 0);
         }
 
         // Show the current default engine in the top header of the panel.
         this.updateHeader();
       ]]></handler>
 
       <handler event="popuphiding"><![CDATA[
         this._isHiding = true;
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
@@ -347,17 +347,17 @@ class AutocompleteResults(UIBaseLib):
         return [node.get_property('textContent') for node in emphasized_nodes]
 
     @property
     def visible_results(self):
         """Supplies the list of visible autocomplete result nodes.
 
         :returns: The list of visible results.
         """
-        match_count = self.element.get_property('_matchCount')
+        match_count = self.element.get_property('matchCount')
 
         return self.marionette.execute_script("""
           let rv = [];
           let node = arguments[0];
           let count = arguments[1];
 
           for (let i = 0; i < count; ++i) {
             rv.push(node.getItemAtIndex(i));
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1125,17 +1125,17 @@ extends="chrome://global/content/binding
         </body>
       </method>
 
       <method name="_invalidate">
         <parameter name="reason"/>
         <body>
           <![CDATA[
           // collapsed if no matches
-          this.richlistbox.collapsed = (this._matchCount == 0);
+          this.richlistbox.collapsed = (this.matchCount == 0);
 
           // Update the richlistbox height.
           if (this._adjustHeightTimeout) {
             clearTimeout(this._adjustHeightTimeout);
           }
           if (this._shrinkTimeout) {
             clearTimeout(this._shrinkTimeout);
           }
@@ -1167,46 +1167,46 @@ extends="chrome://global/content/binding
               return Infinity;
             }
 
             return 20;
           ]]>
         </getter>
       </property>
 
-      <property name="_matchCount" readonly="true">
+      <property name="matchCount" readonly="true">
         <getter>
           <![CDATA[
           return Math.min(this.mInput.controller.matchCount, this.maxResults);
           ]]>
         </getter>
       </property>
 
       <method name="_collapseUnusedItems">
         <body>
           <![CDATA[
             let existingItemsCount = this.richlistbox.childNodes.length;
-            for (let i = this._matchCount; i < existingItemsCount; ++i) {
+            for (let i = this.matchCount; i < existingItemsCount; ++i) {
               let item = this.richlistbox.childNodes[i];
 
               item.collapsed = true;
               if (typeof item._onCollapse == "function") {
                 item._onCollapse();
               }
             }
           ]]>
         </body>
       </method>
 
       <method name="adjustHeight">
         <body>
           <![CDATA[
           // Figure out how many rows to show
           let rows = this.richlistbox.childNodes;
-          let numRows = Math.min(this._matchCount, this.maxRows, rows.length);
+          let numRows = Math.min(this.matchCount, this.maxRows, rows.length);
 
           this.removeAttribute("height");
 
           // Default the height to 0 if we have no rows to show
           let height = 0;
           if (numRows) {
             let firstRowRect = rows[0].getBoundingClientRect();
             if (this._rlbPadding == undefined) {
@@ -1272,17 +1272,17 @@ extends="chrome://global/content/binding
         </body>
       </method>
 
       <method name="_appendCurrentResult">
         <parameter name="invalidateReason"/>
         <body>
           <![CDATA[
           var controller = this.mInput.controller;
-          var matchCount = this._matchCount;
+          var matchCount = this.matchCount;
           var existingItemsCount = this.richlistbox.childNodes.length;
 
           // Process maxRows per chunk to improve performance and user experience
           for (let i = 0; i < this.maxRows; i++) {
             if (this._currentIndex >= matchCount) {
               break;
             }
             let item;
@@ -1395,17 +1395,17 @@ extends="chrome://global/content/binding
         <parameter name="aReverse"/>
         <parameter name="aPage"/>
         <body>
           <![CDATA[
           try {
             var amount = aPage ? 5 : 1;
 
             // because we collapsed unused items, we can't use this.richlistbox.getRowCount(), we need to use the matchCount
-            this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this._matchCount - 1);
+            this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this.matchCount - 1);
             if (this.selectedIndex == -1) {
               this.input._focus();
             }
           } catch (ex) {
             // do nothing - occasionally timer-related js errors happen here
             // e.g. "this.selectedIndex has no properties", when you type fast and hit a
             // navigation key before this popup has opened
           }