Bug 641836 - [Regression] The search input should get the focus after loading about:config [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2011-05-20 12:18:19 +02:00
Родитель 0f7639f3dd
Коммит 50da2650a3
6 изменённых файлов: 25 добавлений и 26 удалений

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

@ -642,3 +642,6 @@ pref("urlclassifier.updatecachemax", 4194304);
pref("browser.safebrowsing.malware.reportURL", "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
#endif
// prevent focus to show/hide the virtual keyboard if the action is not
// initiated by a user
pref("content.ime.strict_policy", true);

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

@ -180,6 +180,13 @@ let Util = {
#else
return (window.innerWidth <= window.innerHeight);
#endif
},
get isKeyboardOpened() {
if (this.isParentProcess())
return ViewableAreaObserver.isKeyboardOpened;
return (sendSyncMessage("Content:IsKeyboardOpened", {}))[0];
}
};

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

@ -5,8 +5,6 @@ let Ci = Components.interfaces;
dump("!! remote browser loaded\n");
let WebProgressListener = {
_lastLocation: null,
init: function() {
let flags = Ci.nsIWebProgress.NOTIFY_LOCATION |
Ci.nsIWebProgress.NOTIFY_SECURITY |
@ -52,10 +50,6 @@ let WebProgressListener = {
sendAsyncMessage("Content:LocationChange", json);
// Keep track of hash changes
this.hashChanged = (location == this._lastLocation);
this._lastLocation = location;
// When a new page is loaded fire a message for the first paint
addEventListener("MozAfterPaint", function(aEvent) {
removeEventListener("MozAfterPaint", arguments.callee, true);
@ -217,15 +211,6 @@ let DOMEvents = {
persisted: aEvent.persisted
};
// 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
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);
}
sendAsyncMessage(aEvent.type, json);
break;
}

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

@ -321,6 +321,7 @@ var Browser = {
#if MOZ_PLATFORM_MAEMO == 6
os.addObserver(ViewableAreaObserver, "softkb-change", false);
#endif
messageManager.addMessageListener("Content:IsKeyboardOpened", ViewableAreaObserver);
window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
@ -3038,6 +3039,10 @@ var ViewableAreaObserver = {
#endif
},
receiveMessage: function receiveMessage(aMessage) {
return this.isKeyboardOpened;
},
update: function va_update() {
let oldHeight = parseInt(Browser.styles["viewable-height"].height);
let oldWidth = parseInt(Browser.styles["viewable-width"].width);

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

@ -829,7 +829,7 @@ var FormHelperUI = {
break;
case "FormAssist:Resize":
if (!ViewableAreaObserver.isKeyboardOpened)
if (!Util.isKeyboardOpened)
return;
let element = json.current;
@ -841,7 +841,7 @@ var FormHelperUI = {
break;
case "FormAssist:Update":
if (!ViewableAreaObserver.isKeyboardOpened)
if (!Util.isKeyboardOpened)
return;
Browser.hideSidebars();

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

@ -104,7 +104,7 @@ FormAssistant.prototype = {
if (this._isVisibleElement(element)) {
this._currentIndex = aIndex;
gFocusManager.setFocus(element, Ci.nsIFocusManager.FLAG_NOSCROLL);
gFocusManager.setFocus(element, Ci.nsIFocusManager.FLAG_NOSCROLL | Ci.nsIFocusManager.FLAG_BYMOUSE);
// To ensure we get the current caret positionning of the focused
// element we need to delayed a bit the event
@ -156,17 +156,16 @@ FormAssistant.prototype = {
if (this._isEditable(aElement))
aElement = this._getTopLevelEditable(aElement);
// hack bug 604351
// if the element is the same editable element and the VKB is closed, reopen it
if (aElement instanceof HTMLInputElement && aElement.mozIsTextField(false) && !Util.isKeyboardOpened) {
aElement.blur();
gFocusManager.setFocus(aElement, Ci.nsIFocusManager.FLAG_NOSCROLL | Ci.nsIFocusManager.FLAG_BYMOUSE);
}
// Checking if the element is the current focused one while the form assistant is open
// allow the user to reposition the caret into an input element
if (this._open && aElement == this.currentElement) {
//hack bug 604351
// if the element is the same editable element and the VKB is closed, reopen it
let utils = Util.getWindowUtils(content);
if (utils.IMEStatus == utils.IME_STATUS_DISABLED && aElement instanceof HTMLInputElement && aElement.mozIsTextField(false)) {
aElement.blur();
aElement.focus();
}
// If the element is a <select/> element and the user has manually click
// it we need to inform the UI of such a change to keep in sync with the
// new selected options once the event is finished