Backed out changeset 4a6ff8b73d5c (bug 995489)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 27 Jun 2014 15:17:43 +0200
changeset 204893 115171f8216d3b15f142e53e11a495b6c79d3c8b
parent 204892 990442eb272d99a69197242b2f9093cefae2c4c6
child 204894 83f9b25520bfa86866822d7be16e3c0c61686df0
push idunknown
push userunknown
push dateunknown
bugs995489
milestone33.0a1
backs out4a6ff8b73d5cf1866be2b2264af140d03d19c86b
Backed out changeset 4a6ff8b73d5c (bug 995489)
toolkit/components/satchel/AutoCompleteE10S.jsm
toolkit/components/satchel/nsFormAutoComplete.js
--- a/toolkit/components/satchel/AutoCompleteE10S.jsm
+++ b/toolkit/components/satchel/AutoCompleteE10S.jsm
@@ -70,93 +70,69 @@ this.AutoCompleteE10S = {
   init: function() {
     let messageManager = Cc["@mozilla.org/globalmessagemanager;1"].
                          getService(Ci.nsIMessageListenerManager);
     messageManager.addMessageListener("FormAutoComplete:SelectBy", this);
     messageManager.addMessageListener("FormAutoComplete:GetSelectedIndex", this);
     messageManager.addMessageListener("FormAutoComplete:ClosePopup", this);
   },
 
-  _initPopup: function(browserWindow, rect) {
+  search: function(message) {
+    let browserWindow = message.target.ownerDocument.defaultView;
     this.browser = browserWindow.gBrowser.selectedBrowser;
     this.popup = this.browser.autoCompletePopup;
     this.popup.hidden = false;
-    this.popup.setAttribute("width", rect.width);
+    this.popup.setAttribute("width", message.data.width);
 
+    let rect = message.data;
     let {x, y} = this.browser.mapScreenCoordinatesFromContent(rect.left, rect.top + rect.height);
     this.x = x;
     this.y = y;
+
+    let formAutoComplete = Cc["@mozilla.org/satchel/form-autocomplete;1"]
+                             .getService(Ci.nsIFormAutoComplete);
+
+    formAutoComplete.autoCompleteSearchAsync(message.data.inputName,
+                                             message.data.untrimmedSearchString,
+                                             null,
+                                             null,
+                                             this.onSearchComplete.bind(this));
   },
 
-  _showPopup: function(results) {
+  onSearchComplete: function(results) {
     AutoCompleteE10SView.clearResults();
 
     let resultsArray = [];
     let count = results.matchCount;
     for (let i = 0; i < count; i++) {
       let result = results.getValueAt(i);
       resultsArray.push(result);
       AutoCompleteE10SView.addResult(result);
     }
 
     this.popup.view = AutoCompleteE10SView;
 
+    this.browser.messageManager.sendAsyncMessage(
+      "FormAutoComplete:AutoCompleteSearchAsyncResult",
+      {results: resultsArray}
+    );
+
     this.popup.selectedIndex = -1;
     this.popup.invalidate();
 
     if (count > 0) {
       this.popup.openPopupAtScreen(this.x, this.y, true);
       // Bug 947503 - This openPopup call is not triggering the "popupshowing"
       // event, which autocomplete.xml uses to track the openness of the popup
       // by setting its mPopupOpen flag. This flag needs to be properly set
       // for closePopup to work. For now, we set it manually.
       this.popup.mPopupOpen = true;
     } else {
       this.popup.closePopup();
     }
-
-    return resultsArray;
-  },
-
-  // This function is used by the login manager, which uses a single message
-  // to fill in the autocomplete results. See
-  // "RemoteLogins:autoCompleteLogins".
-  showPopupWithResults: function(browserWindow, rect, results) {
-    this._initPopup(browserWindow, rect);
-    this._showPopup(results);
-  },
-
-  // This function is called in response to AutoComplete requests from the
-  // child (received via the message manager, see
-  // "FormHistory:AutoCompleteSearchAsync").
-  search: function(message) {
-    let browserWindow = message.target.ownerDocument.defaultView;
-    let rect = message.data;
-
-    this._initPopup(browserWindow, rect);
-
-    let formAutoComplete = Cc["@mozilla.org/satchel/form-autocomplete;1"]
-                             .getService(Ci.nsIFormAutoComplete);
-
-    formAutoComplete.autoCompleteSearchAsync(message.data.inputName,
-                                             message.data.untrimmedSearchString,
-                                             null,
-                                             null,
-                                             this.onSearchComplete.bind(this));
-  },
-
-  // The second half of search, this fills in the popup and returns the
-  // results to the child.
-  onSearchComplete: function(results) {
-    let resultsArray = this._showPopup(results);
-
-    this.browser.messageManager.sendAsyncMessage(
-      "FormAutoComplete:AutoCompleteSearchAsyncResult",
-      {results: resultsArray}
-    );
   },
 
   receiveMessage: function(message) {
     switch (message.name) {
       case "FormAutoComplete:SelectBy":
         this.popup.selectBy(message.data.reverse, message.data.page);
         break;
 
--- a/toolkit/components/satchel/nsFormAutoComplete.js
+++ b/toolkit/components/satchel/nsFormAutoComplete.js
@@ -433,17 +433,17 @@ FormAutoCompleteResult.prototype = {
     get wrappedJSObject() {
         return this;
     },
 
     // Interfaces from idl...
     searchString : null,
     errorDescription : "",
     get defaultIndex() {
-        if (this.entries.length == 0)
+        if (entries.length == 0)
             return -1;
         else
             return 0;
     },
     get searchResult() {
         if (this.entries.length == 0)
             return Ci.nsIAutoCompleteResult.RESULT_NOMATCH;
         return Ci.nsIAutoCompleteResult.RESULT_SUCCESS;