Bug 1092549 - Only allow FocusChange message to change formMM. r=yxl

This commit is contained in:
Tim Chien 2014-11-03 01:37:00 +01:00
parent 723ddecec4
commit 3318db5d52

View File

@ -251,22 +251,22 @@ this.Keyboard = {
forwardEvent: function keyboardForwardEvent(newEventName, msg) {
let mm = msg.target.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader.messageManager;
if (newEventName === 'Keyboard:FocusChange' &&
msg.data.type === 'blur') {
// A blur message can't be sent to the keyboard if the focus has
// already taken away at first place.
// This check is here to prevent problem caused by out-of-order
// ipc messages from two processes.
if (mm !== this.formMM) {
return false;
if (newEventName === 'Keyboard:FocusChange') {
if (msg.data.type !== 'blur') { // Focus on a new input field
// Set the formMM to the new message manager so that
// message gets to the right form now on.
this.formMM = mm;
} else { // input is blurred
// A blur message can't be sent to the keyboard if the focus has
// already been taken away at first place.
// This check is here to prevent problem caused by out-of-order
// ipc messages from two processes.
if (mm !== this.formMM) {
return false;
}
}
this.sendToKeyboard(newEventName, msg.data);
return true;
}
this.formMM = mm;
this.sendToKeyboard(newEventName, msg.data);
return true;
},