зеркало из https://github.com/mozilla/pjs.git
Bug 683736 - Backspace key in form fields in desktop Linux Fennec goes back a page instead of deleting r=mbrubeck
This commit is contained in:
Родитель
bf22214087
Коммит
2a33e404b9
|
@ -182,6 +182,7 @@ var Browser = {
|
|||
/* handles web progress management for open browsers */
|
||||
Elements.browsers.webProgress = new Browser.WebProgress();
|
||||
|
||||
this.keyFilter = new KeyFilter(Elements.browsers);
|
||||
let mouseModule = new MouseModule();
|
||||
let gestureModule = new GestureModule(Elements.browsers);
|
||||
let scrollWheelModule = new ScrollwheelModule(Elements.browsers);
|
||||
|
@ -1225,14 +1226,19 @@ var Browser = {
|
|||
break;
|
||||
}
|
||||
|
||||
case "Browser:KeyPress":
|
||||
case "Browser:KeyPress": {
|
||||
let keyset = document.getElementById("mainKeyset");
|
||||
keyset.setAttribute("disabled", "false");
|
||||
if (json.preventDefault)
|
||||
break;
|
||||
|
||||
let event = document.createEvent("KeyEvents");
|
||||
event.initKeyEvent("keypress", true, true, null,
|
||||
json.ctrlKey, json.altKey, json.shiftKey, json.metaKey,
|
||||
json.keyCode, json.charCode);
|
||||
document.getElementById("mainKeyset").dispatchEvent(event);
|
||||
keyset.dispatchEvent(event);
|
||||
break;
|
||||
|
||||
}
|
||||
case "Browser:ZoomToPoint:Return":
|
||||
if (json.zoomTo) {
|
||||
let rect = Rect.fromRect(json.zoomTo);
|
||||
|
@ -1972,6 +1978,31 @@ const ContentTouchHandler = {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/** Prevent chrome from consuming key events before remote content has a chance. */
|
||||
function KeyFilter(container) {
|
||||
container.addEventListener("keypress", this, false);
|
||||
container.addEventListener("keyup", this, false);
|
||||
container.addEventListener("keydown", this, false);
|
||||
}
|
||||
|
||||
KeyFilter.prototype = {
|
||||
handleEvent: function handleEvent(aEvent) {
|
||||
if (Elements.contentShowing.getAttribute("disabled") == "true")
|
||||
return;
|
||||
|
||||
let browser = getBrowser();
|
||||
if (browser && browser.active && browser.getAttribute("remote") == "true") {
|
||||
document.getElementById("mainKeyset").setAttribute("disabled", "true");
|
||||
}
|
||||
},
|
||||
|
||||
toString: function toString() {
|
||||
return "[KeyFilter] { }";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Utility class to handle manipulations of the identity indicators in the UI
|
||||
*/
|
||||
|
|
|
@ -827,6 +827,7 @@ var FormHelperUI = {
|
|||
if (focusedElement && focusedElement.localName == "browser")
|
||||
return;
|
||||
|
||||
Browser.keyFilter.handleEvent(aEvent);
|
||||
break;
|
||||
|
||||
case "SizeChanged":
|
||||
|
|
|
@ -299,16 +299,14 @@ let Content = {
|
|||
// let's send it back to the chrome process to have it handle shortcuts
|
||||
case "keypress":
|
||||
let timer = new Util.Timeout(function() {
|
||||
if(aEvent.getPreventDefault())
|
||||
return;
|
||||
|
||||
let eventData = {
|
||||
ctrlKey: aEvent.ctrlKey,
|
||||
altKey: aEvent.altKey,
|
||||
shiftKey: aEvent.shiftKey,
|
||||
metaKey: aEvent.metaKey,
|
||||
keyCode: aEvent.keyCode,
|
||||
charCode: aEvent.charCode
|
||||
charCode: aEvent.charCode,
|
||||
preventDefault: aEvent.getPreventDefault()
|
||||
};
|
||||
sendAsyncMessage("Browser:KeyPress", eventData);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче