Bug 562717 - Form helper should disappear when reloading the page [r=mfinkle]
--- 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();