Bug 615171 - Form assistant remains open even after loading another webpage [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 01 Dec 2010 16:31:56 +0100
changeset 67073 0197e9fbe28adc684282344d6a523b6d9cf4a92a
parent 67072 04b189d1694a0ab066bca99cbaa5a8505a65f948
child 67074 41b8c8f3ac7d9f44917955bf0a8a087b1cc37c56
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs615171
Bug 615171 - Form assistant remains open even after loading another webpage [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/forms.js
--- 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);