Bug 918863 - MutationObserver doesnt recognize all deleted elements, keypress is fired if keydown is canceled. r=yxl, r=kanru

This commit is contained in:
Jan Jongboom 2013-12-03 08:37:38 -05:00
parent ed8efdf3a8
commit c43a7623dc

View File

@ -283,7 +283,7 @@ let FormAssistant = {
this._observer = new MutationObserver(function(mutations) {
var del = [].some.call(mutations, function(m) {
return [].some.call(m.removedNodes, function(n) {
return n === element;
return n.contains(element);
});
});
if (del && element === self.focusedElement) {
@ -292,8 +292,9 @@ let FormAssistant = {
}
});
this._observer.observe(element.parentNode, {
childList: true
this._observer.observe(element.ownerDocument.body, {
childList: true,
subtree: true
});
}
@ -517,10 +518,16 @@ let FormAssistant = {
case "Forms:Input:SendKey":
CompositionManager.endComposition('');
["keydown", "keypress", "keyup"].forEach(function(type) {
domWindowUtils.sendKeyEvent(type, json.keyCode, json.charCode,
json.modifiers);
});
this._editing = true;
let doKeypress = domWindowUtils.sendKeyEvent('keydown', json.keyCode,
json.charCode, json.modifiers);
if (doKeypress) {
domWindowUtils.sendKeyEvent('keypress', json.keyCode,
json.charCode, json.modifiers);
}
domWindowUtils.sendKeyEvent('keyup', json.keyCode,
json.charCode, json.modifiers);
this._editing = false;
if (json.requestId) {
sendAsyncMessage("Forms:SendKey:Result:OK", {