зеркало из https://github.com/mozilla/pjs.git
Bug 713502 Fire input event even during composition r=smaug+ehsan
This commit is contained in:
Родитель
db812ca83d
Коммит
bce8ec45a6
|
@ -1000,7 +1000,8 @@ nsEditor::EndPlaceHolderTransaction()
|
|||
// since that is the only known case where the placeholdertxn would disappear on us.
|
||||
// For now just removing the assert.
|
||||
}
|
||||
// notify editor observers of action unless it is uncommitted IME
|
||||
// notify editor observers of action but if composing, it's done by
|
||||
// text event handler.
|
||||
if (!mInIMEMode) NotifyEditorObservers();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -988,6 +988,13 @@ nsPlaintextEditor::UpdateIMEComposition(const nsAString& aCompositionString,
|
|||
if (aCompositionString.IsEmpty()) {
|
||||
mIMETextNode = nsnull;
|
||||
}
|
||||
|
||||
// If still composing, we should fire input event via observer.
|
||||
// Note that if committed, we don't need to notify it since it will be
|
||||
// notified at followed compositionend event.
|
||||
if (mIsIMEComposing) {
|
||||
NotifyEditorObservers();
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1202,7 +1202,8 @@ function runCompositionTest()
|
|||
function runCompositionEventTest()
|
||||
{
|
||||
const kDescription = "runCompositionEventTest: ";
|
||||
const kEvents = ["compositionstart", "compositionupdate", "compositionend"];
|
||||
const kEvents = ["compositionstart", "compositionupdate", "compositionend",
|
||||
"input"];
|
||||
|
||||
input.value = "";
|
||||
input.focus();
|
||||
|
@ -1237,6 +1238,12 @@ function runCompositionEventTest()
|
|||
}
|
||||
}
|
||||
|
||||
function formEventHandlerForWindow(aEvent)
|
||||
{
|
||||
windowEventCounts[aEvent.type]++;
|
||||
windowEventData[aEvent.type] = input.value;
|
||||
}
|
||||
|
||||
function compositionEventHandlerForInput(aEvent)
|
||||
{
|
||||
inputEventCounts[aEvent.type]++;
|
||||
|
@ -1250,12 +1257,20 @@ function runCompositionEventTest()
|
|||
}
|
||||
}
|
||||
|
||||
function formEventHandlerForInput(aEvent)
|
||||
{
|
||||
inputEventCounts[aEvent.type]++;
|
||||
inputEventData[aEvent.type] = input.value;
|
||||
}
|
||||
|
||||
window.addEventListener("compositionstart", compositionEventHandlerForWindow,
|
||||
true, true);
|
||||
window.addEventListener("compositionend", compositionEventHandlerForWindow,
|
||||
true, true);
|
||||
window.addEventListener("compositionupdate", compositionEventHandlerForWindow,
|
||||
true, true);
|
||||
window.addEventListener("input", formEventHandlerForWindow,
|
||||
true, true);
|
||||
|
||||
input.addEventListener("compositionstart", compositionEventHandlerForInput,
|
||||
true, true);
|
||||
|
@ -1263,6 +1278,8 @@ function runCompositionEventTest()
|
|||
true, true);
|
||||
input.addEventListener("compositionupdate", compositionEventHandlerForInput,
|
||||
true, true);
|
||||
input.addEventListener("input", formEventHandlerForInput,
|
||||
true, true);
|
||||
|
||||
// test for normal case
|
||||
initResults();
|
||||
|
@ -1311,6 +1328,15 @@ function runCompositionEventTest()
|
|||
is(inputEventCounts["compositionend"], 0,
|
||||
kDescription + "compositionend has been handled by input #1");
|
||||
|
||||
is(windowEventCounts["input"], 1,
|
||||
kDescription + "input hasn't been handled by window #1");
|
||||
is(windowEventData["input"], "\u3089",
|
||||
kDescription + "value of input element wasn't modified (window) #1");
|
||||
is(inputEventCounts["input"], 1,
|
||||
kDescription + "input hasn't been handled by input #1");
|
||||
is(inputEventData["input"], "\u3089",
|
||||
kDescription + "value of input element wasn't modified (input) #1");
|
||||
|
||||
synthesizeComposition({ type: "compositionupdate", data: "\u3089\u30FC" });
|
||||
synthesizeText(
|
||||
{ "composition":
|
||||
|
@ -1346,6 +1372,15 @@ function runCompositionEventTest()
|
|||
is(inputEventCounts["compositionend"], 0,
|
||||
kDescription + "compositionend has been handled during composition by input #2");
|
||||
|
||||
is(windowEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by window #2");
|
||||
is(windowEventData["input"], "\u3089\u30FC",
|
||||
kDescription + "value of input element wasn't modified (window) #2");
|
||||
is(inputEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by input #2");
|
||||
is(inputEventData["input"], "\u3089\u30FC",
|
||||
kDescription + "value of input element wasn't modified (input) #2");
|
||||
|
||||
// text event shouldn't cause composition update, e.g., at committing.
|
||||
synthesizeText(
|
||||
{ "composition":
|
||||
|
@ -1383,6 +1418,15 @@ function runCompositionEventTest()
|
|||
is(inputEventLocale["compositionend"], "",
|
||||
kDescription + "locale of compositionend isn't empty (input) #3");
|
||||
|
||||
is(windowEventCounts["input"], 3,
|
||||
kDescription + "input hasn't been handled by window #3");
|
||||
is(windowEventData["input"], "\u3089\u30FC",
|
||||
kDescription + "value of input element wasn't modified (window) #3");
|
||||
is(inputEventCounts["input"], 3,
|
||||
kDescription + "input hasn't been handled by input #3");
|
||||
is(inputEventData["input"], "\u3089\u30FC",
|
||||
kDescription + "value of input element wasn't modified (input) #3");
|
||||
|
||||
// select the second character, then, data of composition start should be
|
||||
// the selected character.
|
||||
initResults();
|
||||
|
@ -1454,6 +1498,15 @@ function runCompositionEventTest()
|
|||
is(inputEventLocale["compositionend"], "",
|
||||
kDescription + "locale of compositionend isn't empty (input) #4");
|
||||
|
||||
is(windowEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by window #4");
|
||||
is(windowEventData["input"], "\u3089\u3089",
|
||||
kDescription + "value of input element wasn't modified (window) #4");
|
||||
is(inputEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by input #4");
|
||||
is(inputEventData["input"], "\u3089\u3089",
|
||||
kDescription + "value of input element wasn't modified (input) #4");
|
||||
|
||||
// preventDefault() should effect nothing.
|
||||
preventDefault = true;
|
||||
|
||||
|
@ -1526,6 +1579,15 @@ function runCompositionEventTest()
|
|||
is(inputEventLocale["compositionend"], "",
|
||||
kDescription + "locale of compositionend isn't empty (input) #5");
|
||||
|
||||
is(windowEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by window #5");
|
||||
is(windowEventData["input"], "\u306D",
|
||||
kDescription + "value of input element wasn't modified (window) #5");
|
||||
is(inputEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by input #5");
|
||||
is(inputEventData["input"], "\u306D",
|
||||
kDescription + "value of input element wasn't modified (input) #5");
|
||||
|
||||
prevnetDefault = false;
|
||||
|
||||
// stopPropagation() should effect nothing (except event count)
|
||||
|
@ -1588,6 +1650,15 @@ function runCompositionEventTest()
|
|||
is(inputEventCounts["compositionend"], 0,
|
||||
kDescription + "compositionend has been handled by input #6");
|
||||
|
||||
is(windowEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by window #6");
|
||||
is(windowEventData["input"], "\u306E",
|
||||
kDescription + "value of input element wasn't modified (window) #6");
|
||||
is(inputEventCounts["input"], 2,
|
||||
kDescription + "input hasn't been handled by input #6");
|
||||
is(inputEventData["input"], "\u306E",
|
||||
kDescription + "value of input element wasn't modified (input) #6");
|
||||
|
||||
stopPropagation = false;
|
||||
|
||||
// create event and dispatch it.
|
||||
|
@ -1726,6 +1797,8 @@ function runCompositionEventTest()
|
|||
compositionEventHandlerForWindow, true);
|
||||
window.removeEventListener("compositionupdate",
|
||||
compositionEventHandlerForWindow, true);
|
||||
window.removeEventListener("input",
|
||||
formEventHandlerForWindow, true);
|
||||
|
||||
input.removeEventListener("compositionstart",
|
||||
compositionEventHandlerForInput, true);
|
||||
|
@ -1733,6 +1806,8 @@ function runCompositionEventTest()
|
|||
compositionEventHandlerForInput, true);
|
||||
input.removeEventListener("compositionupdate",
|
||||
compositionEventHandlerForInput, true);
|
||||
input.removeEventListener("input",
|
||||
formEventHandlerForInput, true);
|
||||
}
|
||||
|
||||
function runCharAtPointTest(aFocusedEditor, aTargetName)
|
||||
|
|
Загрузка…
Ссылка в новой задаче