Bug 1437087 - Call Disconnect on Unlink of cycle collector. r=masayuki

This commit is contained in:
Makoto Kato 2018-02-21 21:08:17 -05:00
parent eca4b8510c
commit 4bc57cc3ec
2 changed files with 11 additions and 10 deletions

View File

@ -174,7 +174,12 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(EditorBase)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEditorObservers)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocStateListeners)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventListener)
if (tmp->mEventListener) {
tmp->mEventListener->Disconnect();
tmp->mEventListener = nullptr;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPlaceholderTransaction)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSavedSel);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRangeUpdater);
@ -330,9 +335,7 @@ EditorBase::PostCreate()
// If the text control gets reframed during focus, Focus() would not be
// called, so take a chance here to see if we need to spell check the text
// control.
EditorEventListener* listener =
reinterpret_cast<EditorEventListener*>(mEventListener.get());
listener->SpellCheckIfNeeded();
mEventListener->SpellCheckIfNeeded();
IMEState newState;
rv = GetPreferredIMEState(&newState);
@ -386,9 +389,7 @@ EditorBase::InstallEventListeners()
mEventTarget = do_QueryInterface(rootContent->GetParent());
NS_ENSURE_TRUE(mEventTarget, NS_ERROR_NOT_AVAILABLE);
EditorEventListener* listener =
reinterpret_cast<EditorEventListener*>(mEventListener.get());
nsresult rv = listener->Connect(this);
nsresult rv = mEventListener->Connect(this);
if (mComposition) {
// Restart to handle composition with new editor contents.
mComposition->StartHandlingComposition(this);
@ -402,7 +403,7 @@ EditorBase::RemoveEventListeners()
if (!IsInitialized() || !mEventListener) {
return;
}
reinterpret_cast<EditorEventListener*>(mEventListener.get())->Disconnect();
mEventListener->Disconnect();
if (mComposition) {
// Even if this is called, don't release mComposition because this is
// may be reused after reframing.

View File

@ -40,7 +40,6 @@ class nsAtom;
class nsIContent;
class nsIDOMDocument;
class nsIDOMEvent;
class nsIDOMEventListener;
class nsIDOMEventTarget;
class nsIDOMNode;
class nsIDocumentStateListener;
@ -65,6 +64,7 @@ class CreateElementTransaction;
class DeleteNodeTransaction;
class DeleteTextTransaction;
class EditAggregateTransaction;
class EditorEventListener;
class EditTransactionBase;
class ErrorResult;
class HTMLEditor;
@ -1503,7 +1503,7 @@ protected:
nsCOMPtr<Element> mRootElement;
// The form field as an event receiver.
nsCOMPtr<dom::EventTarget> mEventTarget;
nsCOMPtr<nsIDOMEventListener> mEventListener;
RefPtr<EditorEventListener> mEventListener;
// Strong reference to placeholder for begin/end batch purposes.
RefPtr<PlaceholderTransaction> mPlaceholderTransaction;
// Name of placeholder transaction.