Bug 1119133 Implement TextEventDispatcher::EndInputTransaction() for ensuring TextEventDispatcher forgets the link with TextInputProcessor r=smaug

This commit is contained in:
Masayuki Nakano 2015-06-11 12:53:42 +09:00
parent 8f646e388c
commit 4da3f7c13c
3 changed files with 36 additions and 1 deletions

View File

@ -186,7 +186,14 @@ TextInputProcessor::BeginInputTransactionInternal(
// This instance has finished preparing to link to the dispatcher. Therefore,
// let's forget the old dispatcher and purpose.
UnlinkFromTextEventDispatcher();
if (mDispatcher) {
mDispatcher->EndInputTransaction(this);
if (NS_WARN_IF(mDispatcher)) {
// Forcibly initialize the members if we failed to end the input
// transaction.
UnlinkFromTextEventDispatcher();
}
}
if (aForTests) {
rv = dispatcher->BeginInputTransactionForTests(this);

View File

@ -83,6 +83,26 @@ TextEventDispatcher::BeginInputTransactionInternal(
return NS_OK;
}
void
TextEventDispatcher::EndInputTransaction(TextEventDispatcherListener* aListener)
{
if (NS_WARN_IF(IsComposing()) || NS_WARN_IF(IsDispatchingEvent())) {
return;
}
nsCOMPtr<TextEventDispatcherListener> listener = do_QueryReferent(mListener);
if (NS_WARN_IF(!listener)) {
return;
}
if (NS_WARN_IF(listener != aListener)) {
return;
}
mListener = nullptr;
listener->OnRemovedFrom(this);
}
void
TextEventDispatcher::OnDestroyWidget()
{

View File

@ -59,6 +59,14 @@ public:
nsresult BeginInputTransactionForTests(
TextEventDispatcherListener* aListener);
/**
* EndInputTransaction() should be called when the listener stops using
* the TextEventDispatcher.
*
* @param aListener The listener using the TextEventDispatcher instance.
*/
void EndInputTransaction(TextEventDispatcherListener* aListener);
/**
* OnDestroyWidget() is called when mWidget is being destroyed.
*/