Bug 615171 - Form assistant remains open even after loading another webpage [r=mfinkle]
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1684,16 +1684,17 @@ var BookmarkHelper = {
var FindHelperUI = {
type: "find",
commands: {
next: "cmd_findNext",
previous: "cmd_findPrevious",
close: "cmd_findClose"
},
+ _open: false,
_status: null,
get status() {
return this._status;
},
set status(val) {
if (val != this._status) {
@@ -1739,26 +1740,33 @@ var FindHelperUI = {
if (aEvent.type == "TabSelect" || aEvent.type == "URLChanged")
this.hide();
},
show: function findHelperShow() {
this._container.show(this);
this.search("");
this._textbox.focus();
+ this._open = true;
// Prevent the view to scroll automatically while searching
Browser.selectedBrowser.scrollSync = false;
},
hide: function findHelperHide() {
+ if (!this._open)
+ return;
+
this._textbox.value = "";
this.status = null;
this._textbox.blur();
this._container.hide(this);
+ this._open = false;
+
+ // Restore the scroll synchronisation
Browser.selectedBrowser.scrollSync = true;
},
goToPrevious: function findHelperGoToPrevious() {
Browser.selectedBrowser.messageManager.sendAsyncMessage("FindAssist:Previous", { });
},
goToNext: function findHelperGoToNext() {
@@ -1894,16 +1902,19 @@ var FormHelperUI = {
this._updateContainerForSelect(this._currentElement, null);
this._open = false;
Browser.selectedBrowser.messageManager.sendAsyncMessage("FormAssist:Closed", { });
},
handleEvent: function formHelperHandleEvent(aEvent) {
+ if (!this._open)
+ return;
+
switch (aEvent.type) {
case "TabSelect":
case "URLChanged":
this.hide();
break;
case "resize":
setTimeout(function(self) {
--- a/mobile/chrome/content/forms.js
+++ b/mobile/chrome/content/forms.js
@@ -169,16 +169,22 @@ FormAssistant.prototype = {
this.currentIndex--;
break;
case "FormAssist:Next":
this.currentIndex++;
break;
case "Content:SetWindowSize":
+ // We don't want to react to size change if the form assistant is not
+ // active, and since this message is the only one not sent by the Form
+ // Helper UI, it needs a check to ensure the Assistant is actually used
+ if (this._open)
+ return;
+
// If the CSS viewport change just show the current element to the new
// position
sendAsyncMessage("FormAssist:Show", this._getJSON());
break;
case "FormAssist:ChoiceSelect": {
this._selectWrapper = getWrapperForElement(currentElement);
this._selectWrapper.select(json.index, json.selected, json.clearAll);