From 690581075f992fb75821aa49962c8483995dbc52 Mon Sep 17 00:00:00 2001 From: "cvshook%sicking.cc" Date: Tue, 29 Nov 2005 19:09:41 +0000 Subject: [PATCH] Bug 308120: Deal better with anonymous (direct) children being moved in the DOM. r=bz sr=bryner --- content/base/src/nsGenericElement.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index a40a9eb9c50c..3bada160544a 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3401,11 +3401,11 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, doc_fragment->DropChildReferences(); } else { - nsCOMPtr oldParent; - res = aNewChild->GetParentNode(getter_AddRefs(oldParent)); - - if (NS_FAILED(res)) { - return res; + nsIContent* bindingParent = newContent->GetBindingParent(); + if (bindingParent == newContent || + (bindingParent && bindingParent == newContent->GetParent())) { + // We can't deal with this so just bail + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } /* @@ -3414,6 +3414,9 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, * aNewChild is a document. This code also handles the case where the * new child is alleady a child of this node-- jst@citec.fi */ + nsCOMPtr oldParent; + res = aNewChild->GetParentNode(getter_AddRefs(oldParent)); + NS_ENSURE_SUCCESS(res, res); if (oldParent) { nsCOMPtr tmpNode;