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
Родитель 200b1f45f3
Коммит b644f506c1
1 изменённых файлов: 14 добавлений и 7 удалений

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

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