Bug 614540 - Form Helper should not close when data are load in the background [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Thu, 09 Dec 2010 10:58:01 -0500
changeset 67092 06ede92e11ea3c4bddbcdba60af1cc0f52e4694b
parent 67091 cc359a6baeffe3ecb102ca5f09c46bfd3383a502
child 67093 50379c2993664dad40debb0562ab479fddff758c
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
bugs614540
Bug 614540 - Form Helper should not close when data are load in the background [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/chrome/content/forms.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1732,17 +1732,17 @@ var FindHelperUI = {
       case "FindAssist:Hide":
         if (this._container.getAttribute("type") == this.type)
           this.hide();
         break;
     }
   },
 
   handleEvent: function findHelperHandleEvent(aEvent) {
-    if (aEvent.type == "TabSelect" || aEvent.type == "URLChanged")
+    if (aEvent.type == "TabSelect" || (aEvent.type == "URLChanged" && aEvent.target == Browser.selectedBrowser))
       this.hide();
   },
 
   show: function findHelperShow() {
     this._container.show(this);
     this.search("");
     this._textbox.focus();
     this._open = true;
@@ -1913,18 +1913,22 @@ var FormHelperUI = {
 
   handleEvent: function formHelperHandleEvent(aEvent) {
     if (!this._open)
       return;
 
     switch (aEvent.type) {
       case "TabSelect":
       case "TabClose":
+        this.hide();
+        break;
+
       case "URLChanged":
-        this.hide();
+        if (aEvent.target == Browser.selectedBrowser)
+          this.hide();
         break;
 
       case "resize":
         setTimeout(function(self) {
           SelectHelperUI.resize();
           self._container.contentHasChanged();
         }, 0, this);
         break;
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1865,17 +1865,17 @@ IdentityHandler.prototype = {
         (aEvent.type == "keypress" && aEvent.charCode != KeyEvent.DOM_VK_SPACE &&
          aEvent.keyCode != KeyEvent.DOM_VK_RETURN))
       return; // Left click, space or enter only
 
     this.toggle();
   },
 
   handleEvent: function(aEvent) {
-    if (aEvent.type == "URLChanged" && !this._identityPopup.hidden)
+    if (aEvent.type == "URLChanged" && aEvent.target == Browser.selectedBrowser && !this._identityPopup.hidden)
       this.hide();
   }
 };
 
 var gIdentityHandler;
 
 /**
  * Returns the singleton instance of the identity handler class.  Should always be
@@ -2342,16 +2342,20 @@ ProgressController.prototype = {
 
       if (this._tab == Browser.selectedTab) {
         // We're about to have new page content, so scroll the content area
         // to the top so the new paints will draw correctly.
         // (background tabs are delayed scrolled to top in _documentStop)
         Browser.scrollContentToTop({ x: 0 });
       }
     }
+
+    let event = document.createEvent("Events");
+    event.initEvent("URLChanged", true, false);
+    this.browser.dispatchEvent(event);
   },
 
   /**
    * This method is called to indicate a status changes for the currently
    * loading page.  The message is already formatted for display.
    */
   onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
     // To use this method, add NOTIFY_STATUS to the flags in Tab._createBrowser
@@ -2386,20 +2390,16 @@ ProgressController.prototype = {
     if (this._tab == Browser.selectedTab) {
       BrowserUI.update(TOOLBARSTATE_LOADING);
 
       // We should at least show something in the URLBar until
       // the load has progressed further along
       if (this._tab.browser.currentURI.spec == "about:blank")
         BrowserUI.updateURI();
     }
-
-    let event = document.createEvent("Events");
-    event.initEvent("URLChanged", true, false);
-    this.browser.dispatchEvent(event);
   },
 
   _networkStop: function _networkStop() {
     this._tab.endLoading();
 
     if (this._tab == Browser.selectedTab)
       BrowserUI.update(TOOLBARSTATE_LOADED);
 
--- a/mobile/chrome/content/forms.js
+++ b/mobile/chrome/content/forms.js
@@ -86,17 +86,19 @@ FormAssistant.prototype = {
 
   get currentIndex() {
     return this._currentIndex;
   },
 
   set currentIndex(aIndex) {
     let element = this._elements[aIndex];
     if (element) {
+      this.focusSync = false;
       gFocusManager.setFocus(element, Ci.nsIFocusManager.FLAG_NOSCROLL);
+      this.focusSync = true;
       this._currentIndex = aIndex;
       sendAsyncMessage("FormAssist:Show", this._getJSON());
     }
     return element;
   },
 
   _open: false,
   open: function formHelperOpen(aElement) {