diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index 9cce637372e..28da2e554c9 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -73,6 +73,8 @@ REQUIRES = xpcom \ prefetch \ xuldoc \ uriloader \ + rdf \ + xultmpl \ $(NULL) EXPORTS = \ diff --git a/mozilla/content/base/src/nsNodeUtils.cpp b/mozilla/content/base/src/nsNodeUtils.cpp index 4395c99215c..0b5ed199ed3 100755 --- a/mozilla/content/base/src/nsNodeUtils.cpp +++ b/mozilla/content/base/src/nsNodeUtils.cpp @@ -50,6 +50,7 @@ #include "pldhash.h" #include "nsIDOMAttr.h" #include "nsCOMArray.h" +#include "nsXULElement.h" #define IMPL_MUTATION_NOTIFICATION(func_, content_, params_) \ PR_BEGIN_MACRO \ @@ -466,6 +467,24 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep, } } + // XXX setting document on some nodes not in a document so XBL will bind + // and chrome won't break. Make XBL bind to document-less nodes! + // XXXbz Once this is fixed, fix up the asserts in all implementations of + // BindToTree to assert what they would like to assert, and fix the + // ChangeDocumentFor() call in nsXULElement::BindToTree as well. Also, + // remove the UnbindFromTree call in ~nsXULElement, and add back in the + // precondition in nsXULElement::UnbindFromTree and remove the line in + // nsXULElement.h that makes nsNodeUtils a friend of nsXULElement. + // Note: Make sure to do this witchery _after_ we've done any deep + // cloning, so kids of the new node aren't confused about whether they're + // in a document. + if (aClone && !aParent && aNode->IsNodeOfType(nsINode::eXUL)) { + nsXULElement *xulElem = NS_STATIC_CAST(nsXULElement*, elem); + if (!xulElem->mPrototype || xulElem->IsInDoc()) { + clone->mParentPtrBits |= nsINode::PARENT_BIT_INDOCUMENT; + } + } + if (aNode->HasProperties()) { PRBool ok = aNodesWithProperties.AppendObject(aNode); if (aClone) { diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index c09fef824b0..c71d8dc3bf4 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -465,27 +465,12 @@ nsXULElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; - // XXX setting document on some nodes not in a document so XBL will bind - // and chrome won't break. Make XBL bind to document-less nodes! - // XXXbz Once this is fixed, fix up the asserts in all implementations of - // BindToTree to assert what they would like to assert, and fix the - // ChangeDocumentFor() call in nsXULElement::BindToTree as well. Also, - // remove the UnbindFromTree call in ~nsXULElement, and add back in the - // precondition in nsXULElement::UnbindFromTree. - // Note: Make sure to do this witchery _after_ we've done any deep - // cloning, so kids of the new node aren't confused about whether they're - // in a document. - - PRBool fakeBeingInDocument = PR_TRUE; - // If we have a prototype, so will our clone. nsRefPtr element; if (mPrototype) { element = nsXULElement::Create(mPrototype, aNodeInfo, PR_TRUE); NS_ASSERTION(GetScriptTypeID() == mPrototype->mScriptTypeID, "Didn't get the default language from proto?"); - - fakeBeingInDocument = IsInDoc(); } else { element = new nsXULElement(aNodeInfo); @@ -512,12 +497,6 @@ nsXULElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const NS_ADDREF(*aResult = element); } - if (fakeBeingInDocument) { - // Don't use BindToTree here so we don't confuse the descendant - // non-XUL nodes. - element->mParentPtrBits |= PARENT_BIT_INDOCUMENT; - } - return rv; } diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 096bac5dc9f..233a26c1ef5 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -576,6 +576,10 @@ public: virtual void RecompileScriptEventListeners(); protected: + // XXX This can be removed when nsNodeUtils::CloneAndAdopt doesn't need + // access to mPrototype anymore. + friend class nsNodeUtils; + nsXULElement(nsINodeInfo* aNodeInfo); virtual ~nsXULElement(void);