Bug 1387317 - part3: HTMLEditor should use RefPtr<HTMLEditor> rather than nsCOMPtr<nsIHTMLEditor> for kungFuDeathGrip r?m_kato
MozReview-Commit-ID: 1F6wwjvdD8H
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3267,17 +3267,20 @@ HTMLEditor::DoContentInserted(nsIDocumen
nsIContent* aChild,
int32_t aIndexInContainer,
InsertedOrAppended aInsertedOrAppended)
{
if (!IsInObservedSubtree(aDocument, aContainer, aChild)) {
return;
}
- nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
+ // XXX Why do we need this? This method is a helper of mutation observer.
+ // So, the callers of mutation observer should guarantee that this won't
+ // be deleted at least during the call.
+ RefPtr<HTMLEditor> kungFuDeathGrip(this);
if (ShouldReplaceRootElement()) {
nsContentUtils::AddScriptRunner(
NewRunnableMethod("HTMLEditor::ResetRootElementAndEventTarget",
this,
&HTMLEditor::ResetRootElementAndEventTarget));
}
// We don't need to handle our own modifications
@@ -3317,17 +3320,20 @@ HTMLEditor::ContentRemoved(nsIDocument*
nsIContent* aChild,
int32_t aIndexInContainer,
nsIContent* aPreviousSibling)
{
if (!IsInObservedSubtree(aDocument, aContainer, aChild)) {
return;
}
- nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
+ // XXX Why do we need to do this? This method is a mutation observer's
+ // method. Therefore, the caller should guarantee that this won't be
+ // deleted during the call.
+ RefPtr<HTMLEditor> kungFuDeathGrip(this);
if (SameCOMIdentity(aChild, mRootElement)) {
nsContentUtils::AddScriptRunner(
NewRunnableMethod("HTMLEditor::ResetRootElementAndEventTarget",
this,
&HTMLEditor::ResetRootElementAndEventTarget));
}
// We don't need to handle our own modifications