mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 995489 - Generalize AutoCompleteE10S.jsm for use from other code. r=felipe
This commit is contained in:
parent
ee1482244a
commit
42a47eaadc
@ -75,29 +75,18 @@ this.AutoCompleteE10S = {
|
||||
messageManager.addMessageListener("FormAutoComplete:ClosePopup", this);
|
||||
},
|
||||
|
||||
search: function(message) {
|
||||
let browserWindow = message.target.ownerDocument.defaultView;
|
||||
_initPopup: function(browserWindow, rect) {
|
||||
this.browser = browserWindow.gBrowser.selectedBrowser;
|
||||
this.popup = this.browser.autoCompletePopup;
|
||||
this.popup.hidden = false;
|
||||
this.popup.setAttribute("width", message.data.width);
|
||||
this.popup.setAttribute("width", rect.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));
|
||||
},
|
||||
|
||||
onSearchComplete: function(results) {
|
||||
_showPopup: function(results) {
|
||||
AutoCompleteE10SView.clearResults();
|
||||
|
||||
let resultsArray = [];
|
||||
@ -110,11 +99,6 @@ this.AutoCompleteE10S = {
|
||||
|
||||
this.popup.view = AutoCompleteE10SView;
|
||||
|
||||
this.browser.messageManager.sendAsyncMessage(
|
||||
"FormAutoComplete:AutoCompleteSearchAsyncResult",
|
||||
{results: resultsArray}
|
||||
);
|
||||
|
||||
this.popup.selectedIndex = -1;
|
||||
this.popup.invalidate();
|
||||
|
||||
@ -128,6 +112,46 @@ this.AutoCompleteE10S = {
|
||||
} 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) {
|
||||
|
@ -438,7 +438,7 @@ FormAutoCompleteResult.prototype = {
|
||||
searchString : null,
|
||||
errorDescription : "",
|
||||
get defaultIndex() {
|
||||
if (entries.length == 0)
|
||||
if (this.entries.length == 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user