Bug 338129, r+a=glazman, sr=Neil

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@200107 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
Olli.Pettay%helsinki.fi
2006-06-16 08:19:59 +00:00
parent 3ce0a5efc0
commit dea6285361
6 changed files with 78 additions and 43 deletions

View File

@@ -41,6 +41,7 @@
#include "nsIDocument.h"
#include "nsIEditor.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsISelection.h"
@@ -51,6 +52,7 @@
#include "nsIDOMHTMLElement.h"
#include "nsIDOMNSHTMLElement.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMCSSValue.h"
#include "nsIDOMCSSPrimitiveValue.h"
@@ -167,11 +169,27 @@ nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode * aPare
return NS_OK;
}
// Removes event listener and calls DeleteRefToAnonymousNode.
void
nsHTMLEditor::RemoveListenerAndDeleteRef(const nsAString& aEvent,
nsIDOMEventListener* aListener,
PRBool aUseCapture,
nsIDOMElement* aElement,
nsIContent * aParentContent,
nsIPresShell* aShell)
{
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
if (evtTarget) {
evtTarget->RemoveEventListener(aEvent, aListener, aUseCapture);
}
DeleteRefToAnonymousNode(aElement, aParentContent, aShell);
}
// Deletes all references to an anonymous element
void
nsHTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
nsIContent * aParentContent,
nsIDocumentObserver * aDocObserver)
nsIContent* aParentContent,
nsIPresShell* aShell)
{
// call ContentRemoved() for the anonymous content
// node so its references get removed from the frame manager's
@@ -180,8 +198,17 @@ nsHTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
if (aElement) {
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
if (content) {
aDocObserver->ContentRemoved(content->GetCurrentDoc(),
aParentContent, content, -1);
// Need to check whether aShell has been destroyed (but not yet deleted).
// In that case presContext->GetPresShell() returns nsnull.
// See bug 338129.
if (aShell && aShell->GetPresContext() &&
aShell->GetPresContext()->GetPresShell() == aShell) {
nsCOMPtr<nsIDocumentObserver> docObserver = do_QueryInterface(aShell);
if (docObserver) {
docObserver->ContentRemoved(content->GetCurrentDoc(),
aParentContent, content, -1);
}
}
content->UnbindFromTree();
}
}