Bug 571070 - [e10s] Add support for cross process keyevents [r=stechz]

This commit is contained in:
Mark Finkle 2010-06-10 13:37:03 -04:00
Родитель dbdffedae5
Коммит e2386a6fc7
2 изменённых файлов: 60 добавлений и 2 удалений

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

@ -130,13 +130,15 @@ function InputHandler(browserViewContainer) {
window.addEventListener("click", this, true);
/* these handle key strokes in the browser view (where page content appears) */
browserViewContainer.addEventListener("keydown", this, true);
browserViewContainer.addEventListener("keyup", this, true);
browserViewContainer.addEventListener("keypress", this, false);
browserViewContainer.addEventListener("keyup", this, false);
browserViewContainer.addEventListener("keydown", this, false);
browserViewContainer.addEventListener("DOMMouseScroll", this, true);
browserViewContainer.addEventListener("MozMousePixelScroll", this, true);
browserViewContainer.addEventListener("contextmenu", this, false);
this.addModule(new MouseModule(this, browserViewContainer));
this.addModule(new KeyModule(this, browserViewContainer));
this.addModule(new ScrollwheelModule(this, browserViewContainer));
}
@ -1129,6 +1131,39 @@ KineticController.prototype = {
}
};
/**
* Input module for basic key input.
*/
function KeyModule(owner, browserViewContainer) {
this._owner = owner;
this._browserViewContainer = browserViewContainer;
}
KeyModule.prototype = {
getClickerFromElement: function getClickerFromElement(elem) {
for (; elem; elem = elem.parentNode)
if (elem.customKeySender)
break;
return (elem) ? elem : null;
},
handleEvent: function handleEvent(evInfo) {
if (evInfo.event.type == "keydown" || evInfo.event.type == "keyup" || evInfo.event.type == "keypress") {
let keyer = this._browserViewContainer.customKeySender;
if (keyer) {
keyer.dispatchKeyEvent(evInfo.event);
evInfo.event.preventDefault();
evInfo.event.stopPropagation();
}
}
},
/* We don't have much state to reset if we lose event focus */
cancelPending: function cancelPending() {}
};
/**
* Input module for basic scrollwheel input. Currently just zooms the browser
* view accordingly.

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

@ -375,6 +375,7 @@ var Browser = {
/* handles dispatching clicks on tiles into clicks in content or zooms */
container.customClicker = new ContentCustomClicker(bv);
container.customKeySender = new ContentCustomKeySender(bv);
/* scrolling box that contains tiles */
let contentScrollbox = this.contentScrollbox = document.getElementById("content-scrollbox");
@ -1975,6 +1976,28 @@ ContentCustomClicker.prototype = {
}
};
/** Watches for mouse events in chrome and sends them to content. */
function ContentCustomKeySender(browserView) {
this._browserView = browserView;
}
ContentCustomKeySender.prototype = {
/** Dispatch a mouse event with chrome client coordinates. */
dispatchKeyEvent: function _dispatchKeyEvent(event) {
let browser = this._browserView.getBrowser();
if (browser) {
let fl = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
try {
fl.sendCrossProcessKeyEvent(event.type, event.keyCode, event.charCode, event.modifiers);
} catch (e) {}
}
},
toString: function toString() {
return "[ContentCustomClicker] { }";
}
};
/** Watches for mouse click in content and redirect them to the best found target **/
const ElementTouchHelper = {
get radius() {