mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 917322 part.21 Ensure to cancel composition when TextInputProcessor is released r=smaug
This commit is contained in:
parent
59ab646b5e
commit
99c3b62e28
@ -65,6 +65,16 @@ TextInputProcessor::TextInputProcessor()
|
||||
|
||||
TextInputProcessor::~TextInputProcessor()
|
||||
{
|
||||
if (mDispatcher && mDispatcher->IsComposing()) {
|
||||
// If this is composing and not canceling the composition, nobody can steal
|
||||
// the rights of TextEventDispatcher from this instance. Therefore, this
|
||||
// needs to cancel the composition here.
|
||||
if (NS_SUCCEEDED(IsValidStateForComposition())) {
|
||||
nsRefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
mDispatcher->CommitComposition(status, &EmptyString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -34,9 +34,10 @@ public:
|
||||
NS_IMETHOD_(void)
|
||||
OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
~TextInputProcessor();
|
||||
protected:
|
||||
virtual ~TextInputProcessor();
|
||||
|
||||
private:
|
||||
nsresult InitInternal(nsIDOMWindow* aWindow,
|
||||
nsITextInputProcessorCallback* aCallback,
|
||||
bool aForTests,
|
||||
|
@ -250,6 +250,37 @@ function runInitMethodTests()
|
||||
}
|
||||
}
|
||||
|
||||
function runReleaseTests()
|
||||
{
|
||||
var description = "runReleaseTests(): ";
|
||||
|
||||
var TIP = createTIP();
|
||||
ok(TIP.initForTests(window),
|
||||
description + "TIP.initForTests() should succeed");
|
||||
|
||||
input.value = "";
|
||||
input.focus();
|
||||
|
||||
TIP.setPendingCompositionString("foo");
|
||||
TIP.appendClauseToPendingComposition(3, TIP.ATTR_RAW_CLAUSE);
|
||||
TIP.setCaretInPendingComposition(3);
|
||||
TIP.flushPendingComposition();
|
||||
is(input.value, "foo",
|
||||
description + "the input should have composition string");
|
||||
|
||||
// Release the TIP
|
||||
TIP = null;
|
||||
// Needs to run GC forcibly for testing this.
|
||||
SpecialPowers.gc();
|
||||
|
||||
is(input.value, "",
|
||||
description + "the input should be empty because the composition should be canceled");
|
||||
|
||||
TIP = createTIP();
|
||||
ok(TIP.initForTests(window),
|
||||
description + "TIP.initForTests() should succeed #2");
|
||||
}
|
||||
|
||||
function runCompositionTests()
|
||||
{
|
||||
var description = "runCompositionTests(): ";
|
||||
@ -988,6 +1019,7 @@ function runTests()
|
||||
textareaInFrame = iframe.contentDocument.getElementById("textarea");
|
||||
|
||||
runInitMethodTests();
|
||||
runReleaseTests();
|
||||
runCompositionTests();
|
||||
runErrorTests();
|
||||
runCommitCompositionTests();
|
||||
|
Loading…
Reference in New Issue
Block a user