Bug 1675313 - Don't update IMEState during composition when element.focus() is called. r=masayuki

This is regression by bug 1658948.

We shouldn't update IME state during composition even if element.focus() is
called to current focused element.

Also, although this depends on netive impelentation of IME handling, I would
like to add unit test for this situation since we might add mock tests for
native IME handling.

Differential Revision: https://phabricator.services.mozilla.com/D96308
This commit is contained in:
Makoto Kato 2020-11-08 08:36:58 +00:00
Родитель 353f334d13
Коммит 499ac3195b
3 изменённых файлов: 48 добавлений и 1 удалений

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

@ -824,6 +824,16 @@ void IMEStateManager::OnReFocus(nsPresContext* aPresContext,
nsCOMPtr<nsIWidget> widget(sWidget);
// Don't update IME state during composition.
if (sTextCompositions) {
if (TextComposition* composition =
sTextCompositions->GetCompositionFor(widget)) {
if (composition->IsComposing()) {
return;
}
}
}
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::FOCUS_NOT_CHANGED);
IMEState newState = GetNewIMEState(aPresContext, &aContent);

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

@ -71,7 +71,7 @@ with Files("*chrome_context_menus_win*"):
BUG_COMPONENT = ("Core", "General")
with Files("*composition_text_querycontent*"):
BUG_COMPONENT = ("Core", "Internationalization")
BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling")
with Files("*key_event_counts*"):
BUG_COMPONENT = ("Core", "Widget: Cocoa")

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

@ -5363,6 +5363,42 @@ async function runBug1584901Test()
"runBug1584901Test: space must not be removed by composition change");
}
function runBug1675313Test()
{
input.value = "";
input.focus();
let count = 0;
function handler() {
input.focus();
count++;
}
input.addEventListener("keyup", handler);
synthesizeCompositionChange({
composition: {
string: "a",
clauses: [{length: 1, attr: COMPOSITION_ATTR_RAW_CLAUSE}],
key: { key: "a", type: "keyup" },
},
});
synthesizeCompositionChange({
composition: {
string: "b",
clauses: [{length: 1, attr: COMPOSITION_ATTR_RAW_CLAUSE}],
key: { key: "b", type: "keyup" },
},
});
synthesizeComposition({type: "compositioncommitasis"});
is(count, 3, "runBug1675313Test: keyup event is fired correctly");
is(input.value, "b",
"runBug1675313Test: re-focus element doesn't commit composition if re-focus isn't click by user");
input.removeEventListener("keyup", handler);
}
function runCommitCompositionWithSpaceKey()
{
contenteditable.focus();
@ -9567,6 +9603,7 @@ async function runTest()
runBug1375825Test();
runBug1530649Test();
runBug1571375Test();
runBug1675313Test();
runCommitCompositionWithSpaceKey();
runForceCommitTest();
runNestedSettingValue();