Bug 476245. Keep better track of our anonymous content. r=smaug, sr=dbaron

This commit is contained in:
Boris Zbarsky
2009-02-24 13:39:09 -05:00
parent 28117f093d
commit 6880712c98
6 changed files with 37 additions and 11 deletions

View File

@@ -2545,8 +2545,7 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
(aParent && aParent->IsInNativeAnonymousSubtree()),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
if (IsRootOfNativeAnonymousSubtree() ||
aParent && aParent->IsInNativeAnonymousSubtree()) {
if (aParent && aParent->IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE);
}
@@ -3893,6 +3892,13 @@ nsGenericElement::doReplaceOrInsertBefore(PRBool aReplace,
else {
// Not inserting a fragment but rather a single node.
if (newContent->IsRootOfAnonymousSubtree()) {
// This is anonymous content. Don't allow its insertion
// anywhere, since it might have UnbindFromTree calls coming
// its way.
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
// Remove the element from the old parent if one exists
nsINode* oldParent = newContent->GetNodeParent();
@@ -3901,6 +3907,7 @@ nsGenericElement::doReplaceOrInsertBefore(PRBool aReplace,
if (removeIndex < 0) {
// newContent is anonymous. We can't deal with this, so just bail
NS_ERROR("How come our flags didn't catch this?");
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}