Bug 780191 - Commit composition string before sending autocomplete text event. r=blassey

This commit is contained in:
Chris Peterson 2012-07-11 17:29:33 -07:00
Родитель 1e8552f4c9
Коммит f8dde392f7
1 изменённых файлов: 11 добавлений и 2 удалений

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

@ -4067,12 +4067,21 @@ var FormAssistant = {
if (!this._currentInputElement)
break;
this._currentInputElement.QueryInterface(Ci.nsIDOMNSEditableElement).setUserInput(aData);
let editableElement = this._currentInputElement.QueryInterface(Ci.nsIDOMNSEditableElement);
// If we have an active composition string, commit it before sending
// the autocomplete event with the text that will replace it.
try {
let imeEditor = editableElement.editor.QueryInterface(Ci.nsIEditorIMESupport);
if (imeEditor.composing)
imeEditor.forceCompositionEnd();
} catch (e) {}
editableElement.setUserInput(aData);
let event = this._currentInputElement.ownerDocument.createEvent("Events");
event.initEvent("DOMAutoComplete", true, true);
this._currentInputElement.dispatchEvent(event);
break;
case "FormAssist:Blocklisted":