Bug 562717 - Form helper should disappear when reloading the page [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Fri, 02 Jul 2010 07:50:47 +0200
changeset 66353 b6a3acc77e44ffb6187a7fdc4ad91fd3c8a495c0
parent 66352 b335f24b2e7d592bd83fb1c9c39d56e8b7dc5eb1
child 66354 47b71fe6798d0f19f4ab6385119b6f88a39bf69b
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
bugs562717
Bug 562717 - Form helper should disappear when reloading the page [r=mfinkle]
mobile/chrome/content/InputHandler.js
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -63,18 +63,16 @@ const kStateActive = 0x00000001;
  * The input handler is an arbiter between the Fennec chrome window inputs and any
  * registered input modules.  It keeps an array of input module objects.  Incoming
  * input events are wrapped in an EventInfo object and passed down to the input modules
  * in the order of the modules array.  Every registed module thus gets called with
  * an EventInfo for each event that the InputHandler is registered to listen for.
  * Currently, the InputHandler listens for the following events by default.
  *
  * On the Fennec global chrome window:
- *   URLChanged
- *   TabSelect
  *   mousedown
  *   mouseup
  *   mousemove
  *   click
  *
  * On the browserViewContainer:
  *   keydown
  *   keyup
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -481,19 +481,16 @@ var BrowserUI = {
 
     // FIXME: deckbrowser should not fire TabSelect on the initial tab (bug 454028)
     if (!browser.currentURI)
       return;
 
     // Update the navigation buttons
     this._updateButtons(browser);
 
-    // Close the forms assistant
-    FormHelper.close();
-
     // Check for a bookmarked page
     this.updateStar();
 
     var urlString = this.getDisplayURI(browser);
     if (Util.isURLEmpty(urlString))
       urlString = "";
 
     this._setURI(urlString);
@@ -1649,16 +1646,19 @@ var FormHelper = {
 
 
 var FormMessageReceiver = {
   start: function() {
     messageManager.addMessageListener("FormAssist:Show", this);
     messageManager.addMessageListener("FormAssist:Hide", this);
     messageManager.addMessageListener("FormAssist:Update", this);
     messageManager.addMessageListener("FormAssist:AutoComplete", this);
+
+    document.getElementById("tabs").addEventListener("TabSelect", this, true);
+    document.getElementById("browsers").addEventListener("URLChanged", this, true);
   },
 
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     switch (aMessage.name) {
       case "FormAssist:Update":
         let bv = Browser._browserView;
         let visible = bv.getVisibleRect();
@@ -1681,16 +1681,21 @@ var FormMessageReceiver = {
         let current = json.current;
         if (current.canAutocomplete) {
           FormHelper.updateAutocompleteFor(current);
         }
         break;
     }
   },
 
+  handleEvent: function(aEvent) {
+    if (aEvent.type == "TabSelect" || aEvent.type == "URLChanged")
+      FormHelper.close();
+  },
+
   _getOffsetForCaret: function formHelper_getOffsetForCaret(aCaretRect, aRect) {
     // Determine if we need to move left or right to bring the caret into view
     let deltaX = 0;
     if (aCaretRect.right > aRect.right)
       deltaX = aCaretRect.right - aRect.right;
     if (aCaretRect.left < aRect.left)
       deltaX = aCaretRect.left - aRect.left;
 
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2324,17 +2324,16 @@ ProgressController.prototype = {
       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();
     }
 
-    // broadcast a URLChanged message for consumption by InputHandler
     let event = document.createEvent("Events");
     event.initEvent("URLChanged", true, false);
     this.browser.dispatchEvent(event);
   },
 
   _networkStop: function _networkStop() {
     this._tab.endLoading();