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