Bug 620982 - focus is cleared when there is an XHR in the background [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2010-12-22 18:55:45 +01:00
Родитель f39d906efc
Коммит 4b5c314adb
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -246,7 +246,8 @@ let DOMEvents = {
// Clear onload focus to prevent the VKB to be shown unexpectingly
// but only if the location has really changed and not only the
// fragment identifier
if (!WebProgressListener.hashChanged) {
let contentWindowID = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
if (!WebProgressListener.hashChanged && contentWindowID == util.currentInnerWindowID) {
let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
focusManager.clearFocus(content);
}

Просмотреть файл

@ -71,6 +71,8 @@ function FormAssistant() {
addEventListener("keyup", this, false);
addEventListener("focus", this, true);
addEventListener("DOMWindowCreated", this, false);
addEventListener("pageshow", this, false);
this._enabled = Services.prefs.getBoolPref("formhelper.enabled");
};
@ -254,10 +256,16 @@ FormAssistant.prototype = {
focusSync: false,
handleEvent: function formHelperHandleEvent(aEvent) {
if (!this._enabled || (!this.currentElement && (aEvent.type != "focus" || !this.focusSync)))
if (!this._enabled || (!this.currentElement && aEvent.type != "focus") || (aEvent.type == "focus" && !this.focusSync))
return;
switch (aEvent.type) {
case "DOMWindowCreated":
this.focusSync = false;
break;
case "pageshow":
this.focusSync = true;
break;
case "focus":
let focusedElement = gFocusManager.getFocusedElementForWindow(content, true, {}) || aEvent.target;