Bug 858454 - Deliver MozKeyboard key events from the event loop instead of synchronously (r=fabrice).

This commit is contained in:
Andreas Gal 2013-04-07 02:38:40 -07:00
parent 1d9fb84fc5
commit c5ccedacf6

View File

@ -14,6 +14,9 @@ Cu.import("resource://gre/modules/ObjectWrapper.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender");
XPCOMUtils.defineLazyServiceGetter(this, "tm",
"@mozilla.org/thread-manager;1", "nsIThreadManager");
// -----------------------------------------------------------------------
// MozKeyboard
// -----------------------------------------------------------------------
@ -72,9 +75,19 @@ MozKeyboard.prototype = {
sendKey: function mozKeyboardSendKey(keyCode, charCode) {
charCode = (charCode == undefined) ? keyCode : charCode;
["keydown", "keypress", "keyup"].forEach((function sendKey(type) {
this._utils.sendKeyEvent(type, keyCode, charCode, null);
}).bind(this));
let mainThread = tm.mainThread;
let utils = this._utils;
function send(type) {
mainThread.dispatch(function() {
utils.sendKeyEvent(type, keyCode, charCode, null);
}, mainThread.DISPATCH_NORMAL);
}
send("keydown");
send("keypress");
send("keyup");
},
setSelectedOption: function mozKeyboardSetSelectedOption(index) {