Bug 612447 - Part 2: Protect the HTML editor from dying while a mutation event handler is in progress; r=bzbarsky a=blocking-beta8
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 18 Nov 2010 16:01:12 -0500
changeset 57959 406748270073ffdf35ccb1a203943751c38a4a37
parent 57958 64fdcad8cb1111c18e75face950d9c707b2b5673
child 57960 70116ee1ea9a56be36377a6a067c73c4ffeec2af
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbzbarsky, blocking-beta8
bugs612447
milestone2.0b8pre
Bug 612447 - Part 2: Protect the HTML editor from dying while a mutation event handler is in progress; r=bzbarsky a=blocking-beta8
editor/libeditor/html/nsHTMLEditor.cpp
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -3850,16 +3850,18 @@ nsHTMLEditor::ContentAppended(nsIDocumen
 void
 nsHTMLEditor::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
                               nsIContent* aChild, PRInt32 /* unused */)
 {
   if (!aChild) {
     return;
   }
 
+  nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
+
   if (ShouldReplaceRootElement()) {
     ResetRootElementAndEventTarget();
   }
   // We don't need to handle our own modifications
   else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) {
     nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aChild);
     if (node && IsMozEditorBogusNode(node)) {
       // Ignore insertion of the bogus node
@@ -3869,16 +3871,18 @@ nsHTMLEditor::ContentInserted(nsIDocumen
   }
 }
 
 void
 nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
                              nsIContent* aChild, PRInt32 aIndexInContainer,
                              nsIContent* aPreviousSibling)
 {
+  nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
+
   if (SameCOMIdentity(aChild, mRootElement)) {
     ResetRootElementAndEventTarget();
   }
   // We don't need to handle our own modifications
   else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) {
     nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aChild);
     if (node && IsMozEditorBogusNode(node)) {
       // Ignore removal of the bogus node