diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 72af96ad1943..58d269da428b 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -660,21 +660,6 @@ public: return NS_ERROR_NOT_IMPLEMENTED; } - /** - * Clones this node, using aNodeInfoManager to get the nodeinfo for the - * clone. When cloning an element, all attributes of the element will be - * cloned. If aDeep is set, all descendants will also be cloned (by calling - * the DOM method cloneNode on them if aNodeInfoManager is the same as - * the nodeinfo manager of the mNodeInfo of this content node or by calling - * the DOM method importNode if they differ). - * - * @param aNodeInfoManager the nodeinfo manager to get the nodeinfo for the - * clone, it should not be null - * @param aDeep whether to clone the descendants of this node - */ - virtual nsresult CloneContent(nsNodeInfoManager *aNodeInfoManager, - PRBool aDeep, nsIContent **aResult) const = 0; - /** * Get the ID of this content node (the atom corresponding to the * value of the null-namespace attribute whose name is given by diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 8622215d00e0..e9ab028804e4 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -557,6 +557,17 @@ public: */ virtual void RemoveMutationObserver(nsIMutationObserver* aMutationObserver); + /** + * Clones this node. This needs to be overriden by all node classes. aNodeInfo + * should be identical to this node's nodeInfo, except for the document which + * may be different. When cloning an element, all attributes of the element + * will be cloned. The children of the node will not be cloned. + * + * @param aNodeInfo the nodeinfo to use for the clone + * @param aResult the clone + */ + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const = 0; + // This class can be extended by subclasses that wish to store more // information in the slots. class nsSlots @@ -650,7 +661,6 @@ protected: *flags &= ~aFlagsToUnset; } - friend class nsDocument; nsCOMPtr mNodeInfo; enum { PARENT_BIT_INDOCUMENT = 1 << 0, PARENT_BIT_PARENT_IS_CONTENT = 1 << 1 }; diff --git a/content/base/src/nsCommentNode.cpp b/content/base/src/nsCommentNode.cpp index d3fb298c79f6..cec823c20428 100644 --- a/content/base/src/nsCommentNode.cpp +++ b/content/base/src/nsCommentNode.cpp @@ -44,8 +44,6 @@ #include "nsLayoutAtoms.h" #include "nsCOMPtr.h" #include "nsIDocument.h" -#include "nsContentUtils.h" - class nsCommentNode : public nsGenericDOMDataNode, public nsIDOMComment @@ -164,7 +162,7 @@ nsCommentNode::GetNodeType(PRUint16* aNodeType) } nsGenericDOMDataNode* -nsCommentNode::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const +nsCommentNode::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { nsCommentNode *it = new nsCommentNode(aNodeInfo); if (it && aCloneText) { diff --git a/content/base/src/nsDOMAttribute.cpp b/content/base/src/nsDOMAttribute.cpp index 0507486e08a8..6cb4fbe1dac7 100644 --- a/content/base/src/nsDOMAttribute.cpp +++ b/content/base/src/nsDOMAttribute.cpp @@ -372,48 +372,28 @@ nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) +nsresult +nsDOMAttribute::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { - *aReturn = nsnull; - nsAutoString value; - GetValue(value); + NS_CONST_CAST(nsDOMAttribute*, this)->GetValue(value); - nsCOMPtr newAttr = new nsDOMAttribute(nsnull, mNodeInfo, value); - if (!newAttr) { + *aResult = new nsDOMAttribute(nsnull, aNodeInfo, value); + if (!*aResult) { return NS_ERROR_OUT_OF_MEMORY; } - nsIDocument *document = GetOwnerDoc(); - if (document) { - // XXX For now, nsDOMAttribute has only one child. We need to notify about - // cloning it, so we force creation here. - nsCOMPtr child; - GetFirstChild(getter_AddRefs(child)); - nsCOMPtr childNode = do_QueryInterface(child); - if (childNode && childNode->HasProperties()) { - nsCOMPtr newChild; - newAttr->GetFirstChild(getter_AddRefs(newChild)); - if (newChild) { - nsContentUtils::CallUserDataHandler(document, - nsIDOMUserDataHandler::NODE_CLONED, - childNode, child, newChild); - } - } - - if (HasProperties()) { - nsContentUtils::CallUserDataHandler(document, - nsIDOMUserDataHandler::NODE_CLONED, - this, this, newAttr); - } - } - - newAttr.swap(*aReturn); + NS_ADDREF(*aResult); return NS_OK; } +NS_IMETHODIMP +nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aResult) +{ + return nsNodeUtils::CloneNodeImpl(this, aDeep, aResult); +} + NS_IMETHODIMP nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { diff --git a/content/base/src/nsDOMAttribute.h b/content/base/src/nsDOMAttribute.h index fc11a0945d03..72dde0a6fe6c 100644 --- a/content/base/src/nsDOMAttribute.h +++ b/content/base/src/nsDOMAttribute.h @@ -121,6 +121,8 @@ public: virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + static void Initialize(); static void Shutdown(); diff --git a/content/base/src/nsDOMAttributeMap.h b/content/base/src/nsDOMAttributeMap.h index 4fc3e6c388f4..89441f0aa1bf 100644 --- a/content/base/src/nsDOMAttributeMap.h +++ b/content/base/src/nsDOMAttributeMap.h @@ -43,13 +43,11 @@ #ifndef nsDOMAttributeMap_h___ #define nsDOMAttributeMap_h___ -#include "nsIAtom.h" #include "nsIDOMNamedNodeMap.h" -#include "nsVoidArray.h" #include "nsString.h" -#include "plhash.h" #include "nsInterfaceHashtable.h" +class nsIAtom; class nsIContent; class nsDOMAttribute; class nsINodeInfo; diff --git a/content/base/src/nsDOMDocumentType.cpp b/content/base/src/nsDOMDocumentType.cpp index 76d0a2541d72..c8e15d2e0676 100644 --- a/content/base/src/nsDOMDocumentType.cpp +++ b/content/base/src/nsDOMDocumentType.cpp @@ -232,7 +232,7 @@ nsDOMDocumentType::GetNodeType(PRUint16* aNodeType) } nsGenericDOMDataNode* -nsDOMDocumentType::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const +nsDOMDocumentType::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { return new nsDOMDocumentType(aNodeInfo, mName, mEntities, mNotations, mPublicId, mSystemId, mInternalSubset); diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 2abc423aeb61..b74fb6026faf 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2868,59 +2868,10 @@ nsDocument::ImportNode(nsIDOMNode* aImportedNode, return rv; } - nsIDocument *document; PRUint16 nodeType; aImportedNode->GetNodeType(&nodeType); switch (nodeType) { case nsIDOMNode::ATTRIBUTE_NODE: - { - nsCOMPtr attr = do_QueryInterface(aImportedNode); - NS_ENSURE_TRUE(attr, NS_ERROR_FAILURE); - - document = attr->GetOwnerDoc(); - - nsCOMPtr domAttr = do_QueryInterface(aImportedNode); - nsAutoString value; - rv = domAttr->GetValue(value); - NS_ENSURE_SUCCESS(rv, rv); - - nsINodeInfo *nodeInfo = attr->NodeInfo(); - nsCOMPtr newNodeInfo; - if (document != this) { - rv = mNodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(), - nodeInfo->GetPrefixAtom(), - nodeInfo->NamespaceID(), - getter_AddRefs(newNodeInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - nodeInfo = newNodeInfo; - } - - nsCOMPtr clone = new nsDOMAttribute(nsnull, nodeInfo, value); - if (!clone) { - return NS_ERROR_OUT_OF_MEMORY; - } - - if (document) { - // XXX For now, nsDOMAttribute has only one child. We need to notify - // about importing it, so we force creation here. - nsCOMPtr child; - aImportedNode->GetFirstChild(getter_AddRefs(child)); - nsCOMPtr childNode = do_QueryInterface(child); - if (childNode && childNode->HasProperties()) { - nsCOMPtr newChild; - clone->GetFirstChild(getter_AddRefs(newChild)); - if (newChild) { - nsContentUtils::CallUserDataHandler(document, - nsIDOMUserDataHandler::NODE_IMPORTED, - childNode, child, newChild); - } - } - } - - clone.swap(*aResult); - break; - } case nsIDOMNode::DOCUMENT_FRAGMENT_NODE: case nsIDOMNode::ELEMENT_NODE: case nsIDOMNode::PROCESSING_INSTRUCTION_NODE: @@ -2928,19 +2879,26 @@ nsDocument::ImportNode(nsIDOMNode* aImportedNode, case nsIDOMNode::CDATA_SECTION_NODE: case nsIDOMNode::COMMENT_NODE: { - nsCOMPtr imported = do_QueryInterface(aImportedNode); + nsCOMPtr imported = do_QueryInterface(aImportedNode); NS_ENSURE_TRUE(imported, NS_ERROR_FAILURE); - document = imported->GetOwnerDoc(); - nsCOMPtr clone; - rv = imported->CloneContent(mNodeInfoManager, aDeep, - getter_AddRefs(clone)); + nsCOMPtr newNode; + nsCOMArray nodesWithProperties; + rv = nsNodeUtils::Clone(imported, aDeep, mNodeInfoManager, + nodesWithProperties, getter_AddRefs(newNode)); NS_ENSURE_SUCCESS(rv, rv); - rv = CallQueryInterface(clone, aResult); - NS_ENSURE_SUCCESS(rv, rv); + nsIDocument *ownerDoc = imported->GetOwnerDoc(); + if (ownerDoc) { + rv = nsNodeUtils::CallUserDataHandlers(nodesWithProperties, ownerDoc, + nsIDOMUserDataHandler::NODE_IMPORTED, + PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); + } - break; + newNode.swap(*aResult); + + return NS_OK; } case nsIDOMNode::ENTITY_NODE: case nsIDOMNode::ENTITY_REFERENCE_NODE: @@ -2955,15 +2913,6 @@ nsDocument::ImportNode(nsIDOMNode* aImportedNode, return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } } - - nsCOMPtr importedNode = do_QueryInterface(aImportedNode); - if (document && importedNode && importedNode->HasProperties()) { - nsContentUtils::CallUserDataHandler(document, - nsIDOMUserDataHandler::NODE_IMPORTED, - importedNode, aImportedNode, *aResult); - } - - return NS_OK; } NS_IMETHODIMP @@ -3856,107 +3805,6 @@ nsDocument::SetDocumentURI(const nsAString& aDocumentURI) return NS_ERROR_NOT_IMPLEMENTED; } -class AdoptFuncData { -public: - AdoptFuncData(nsNodeInfoManager *aNewNodeInfoManager, JSContext *aCx, - JSObject *aOldScope, JSObject *aNewScope, - nsCOMArray &aNodesWithProperties) - : mNewNodeInfoManager(aNewNodeInfoManager), - mCx(aCx), - mOldScope(aOldScope), - mNewScope(aNewScope), - mNodesWithProperties(aNodesWithProperties) - { - }; - - nsNodeInfoManager *mNewNodeInfoManager; - JSContext *mCx; - JSObject *mOldScope; - JSObject *mNewScope; - nsCOMArray &mNodesWithProperties; -}; - -PLDHashOperator PR_CALLBACK -AdoptFunc(nsAttrHashKey::KeyType aKey, nsIDOMNode *aData, void* aUserArg) -{ - nsCOMPtr attr = do_QueryInterface(aData); - NS_ASSERTION(attr, "non-nsIAttribute somehow made it into the hashmap?!"); - - AdoptFuncData *data = NS_STATIC_CAST(AdoptFuncData*, aUserArg); - nsresult rv = nsDocument::Adopt(attr, data->mNewNodeInfoManager, data->mCx, - data->mOldScope, data->mNewScope, - data->mNodesWithProperties); - - return NS_SUCCEEDED(rv) ? PL_DHASH_NEXT : PL_DHASH_STOP; -} - -/* static */ -nsresult -nsDocument::Adopt(nsINode *aNode, nsNodeInfoManager *aNewNodeInfoManager, - JSContext *aCx, JSObject *aOldScope, JSObject *aNewScope, - nsCOMArray &aNodesWithProperties) -{ - NS_PRECONDITION(!aCx || (aOldScope && aNewScope), "Must have scopes"); - - // First walk aNode's attributes (and their children), then walk aNode's - // children (and recurse into their attributes and children) and finally deal - // with aNode. - - if (aNode->IsNodeOfType(eELEMENT)) { - // aNode's attributes. - nsGenericElement *element = NS_STATIC_CAST(nsGenericElement*, aNode); - const nsDOMAttributeMap *map = element->GetAttributeMap(); - if (map) { - AdoptFuncData data(aNewNodeInfoManager, aCx, aOldScope, aNewScope, - aNodesWithProperties); - - PRUint32 count = map->Enumerate(AdoptFunc, &data); - NS_ENSURE_TRUE(count == map->Count(), NS_ERROR_FAILURE); - } - } - - // aNode's children. - nsresult rv; - PRUint32 i, length = aNode->GetChildCount(); - for (i = 0; i < length; ++i) { - rv = Adopt(aNode->GetChildAt(i), aNewNodeInfoManager, aCx, aOldScope, - aNewScope, aNodesWithProperties); - NS_ENSURE_SUCCESS(rv, rv); - } - - // aNode. - if (aNewNodeInfoManager) { - nsINodeInfo *nodeInfo = aNode->mNodeInfo; - nsCOMPtr newNodeInfo; - rv = aNewNodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(), - nodeInfo->GetPrefixAtom(), - nodeInfo->NamespaceID(), - getter_AddRefs(newNodeInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - aNode->mNodeInfo.swap(newNodeInfo); - - nsIXPConnect *xpc = nsContentUtils::XPConnect(); - if (xpc && aCx) { - nsCOMPtr oldWrapper; - rv = xpc->ReparentWrappedNativeIfFound(aCx, aOldScope, aNewScope, aNode, - getter_AddRefs(oldWrapper)); - if (NS_FAILED(rv)) { - newNodeInfo.swap(aNode->mNodeInfo); - - return rv; - } - } - } - - if (aNode->HasProperties()) { - PRBool ok = aNodesWithProperties.AppendObject(aNode); - NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY); - } - - return NS_OK; -} - static void BlastSubtreeToPieces(nsINode *aNode); PLDHashOperator PR_CALLBACK @@ -4115,8 +3963,8 @@ nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult) } nsCOMArray nodesWithProperties; - rv = Adopt(adoptedNode, sameDocument ? nsnull : mNodeInfoManager, cx, - oldScope, newScope, nodesWithProperties); + rv = nsNodeUtils::Adopt(adoptedNode, sameDocument ? nsnull : mNodeInfoManager, + cx, oldScope, newScope, nodesWithProperties); if (NS_FAILED(rv)) { // Disconnect all nodes from their parents, since some have the old document // as their ownerDocument and some have this as their ownerDocument. @@ -4147,15 +3995,10 @@ nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult) } } - for (i = 0; i < count; ++i) { - nsINode *nodeWithProperties = nodesWithProperties[i]; - - nsCOMPtr source = do_QueryInterface(nodeWithProperties, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsContentUtils::CallUserDataHandler(this, - nsIDOMUserDataHandler::NODE_ADOPTED, - nodeWithProperties, source, nsnull); - } + rv = nsNodeUtils::CallUserDataHandlers(nodesWithProperties, this, + nsIDOMUserDataHandler::NODE_ADOPTED, + PR_FALSE); + NS_ENSURE_SUCCESS(rv, rv); return CallQueryInterface(adoptedNode, aResult); } diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index fb9f09f2a426..e8deaed22a03 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -517,6 +517,10 @@ public: virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const + { + return NS_ERROR_NOT_IMPLEMENTED; + } // nsIRadioGroupContainer NS_IMETHOD WalkRadioGroup(const nsAString& aName, @@ -765,32 +769,6 @@ private: already_AddRefed CheckAncestryAndGetFrame(nsIDocument* aDocument) const; - /** - * Walks the attribute and descendant nodes of aNode. If aNewNodeInfoManager - * is not null, it is used to create new nodeinfos for the nodes. Also - * reparents the XPConnect wrappers for the nodes in aNewScope. - * aNodesWithProperties will be filled with all the nodes that have - * properties. - * - * @param aNode Node to adopt. - * @param aNewNodeInfoManager The nodeinfo manager to use to create new - * nodeinfos for aNode and its attributes and - * descendants. May be null if the nodeinfos - * shouldn't be changed. - * @param aCx Context to use for reparenting the wrappers. - * @param aOldScope Old scope for the wrappers. - * @param aNewScope New scope for the wrappers. - * @param aNodesWithProperties All nodes (from amongst aNode and its - * descendants) with properties. - */ - static nsresult Adopt(nsINode *aNode, nsNodeInfoManager *aNewNodeInfoManager, - JSContext *aCx, JSObject *aOldScope, - JSObject *aNewScope, - nsCOMArray &aNodesWithProperties); - - friend PLDHashOperator PR_CALLBACK - AdoptFunc(nsAttrHashKey::KeyType aKey, nsIDOMNode *aData, void* aUserArg); - // These are not implemented and not supported. nsDocument(const nsDocument& aOther); nsDocument& operator=(const nsDocument& aOther); diff --git a/content/base/src/nsDocumentFragment.cpp b/content/base/src/nsDocumentFragment.cpp index 3aa793f07540..1610c7b6e9cd 100644 --- a/content/base/src/nsDocumentFragment.cpp +++ b/content/base/src/nsDocumentFragment.cpp @@ -107,7 +107,8 @@ public: { return nsGenericElement::HasChildNodes(aReturn); } NS_IMETHOD HasAttributes(PRBool* aReturn) { return nsGenericElement::HasAttributes(aReturn); } - NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); + NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn) + { return nsGenericElement::CloneNode(aDeep, aReturn); } NS_IMETHOD GetPrefix(nsAString& aPrefix) { return nsGenericElement::GetPrefix(aPrefix); } NS_IMETHOD SetPrefix(const nsAString& aPrefix); @@ -158,8 +159,7 @@ public: virtual PRBool IsNodeOfType(PRUint32 aFlags) const; protected: - nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const; + nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; nsresult @@ -229,7 +229,7 @@ nsDocumentFragment::SetPrefix(const nsAString& aPrefix) return NS_ERROR_DOM_NAMESPACE_ERR; } -NS_IMPL_DOM_CLONENODE(nsDocumentFragment) +NS_IMPL_ELEMENT_CLONE(nsDocumentFragment) NS_IMETHODIMP nsDocumentFragment::GetBaseURI(nsAString& aURI) diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index feefc5940cc8..110da842ac31 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -257,29 +257,6 @@ nsGenericDOMDataNode::GetBaseURI(nsAString& aURI) return NS_OK; } -nsresult -nsGenericDOMDataNode::CloneNode(PRBool aDeep, nsIDOMNode *aSource, - nsIDOMNode **aResult) const -{ - *aResult = nsnull; - - nsCOMPtr newContent; - nsresult rv = CloneContent(mNodeInfo->NodeInfoManager(), aDeep, - getter_AddRefs(newContent)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = CallQueryInterface(newContent, aResult); - - nsIDocument *ownerDoc = GetOwnerDoc(); - if (NS_SUCCEEDED(rv) && ownerDoc && HasProperties()) { - nsContentUtils::CallUserDataHandler(ownerDoc, - nsIDOMUserDataHandler::NODE_CLONED, - this, aSource, *aResult); - } - - return rv; -} - nsresult nsGenericDOMDataNode::LookupPrefix(const nsAString& aNamespaceURI, nsAString& aPrefix) @@ -920,7 +897,7 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn) * as this node! */ - nsCOMPtr newContent = Clone(mNodeInfo, PR_FALSE); + nsCOMPtr newContent = CloneDataNode(mNodeInfo, PR_FALSE); if (!newContent) { return NS_ERROR_OUT_OF_MEMORY; } @@ -1063,32 +1040,6 @@ nsGenericDOMDataNode::GetCurrentValueAtom() return NS_NewAtom(val); } -nsresult -nsGenericDOMDataNode::CloneContent(nsNodeInfoManager *aNodeInfoManager, - PRBool aDeep, nsIContent **aResult) const -{ - nsINodeInfo *nodeInfo = NodeInfo(); - nsCOMPtr newNodeInfo; - if (aNodeInfoManager != nodeInfo->NodeInfoManager()) { - nsresult rv = aNodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(), - nodeInfo->GetPrefixAtom(), - nodeInfo->NamespaceID(), - getter_AddRefs(newNodeInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - nodeInfo = newNodeInfo; - } - - *aResult = Clone(nodeInfo, PR_TRUE); - if (!*aResult) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aResult); - - return NS_OK; -} - nsIAtom* nsGenericDOMDataNode::GetID() const { diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index fd58c047bccd..5ddcb2392144 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -151,17 +151,6 @@ public: PRBool* aReturn); nsresult GetBaseURI(nsAString& aURI); - /** - * A basic implementation of the DOM cloneNode method. Calls CloneContent to - * do the actual cloning of the node. - * - * @param aDeep if true all descendants will be cloned too - * @param aSource nsIDOMNode pointer to this node - * @param aResult the clone - */ - nsresult CloneNode(PRBool aDeep, nsIDOMNode *aSource, - nsIDOMNode **aResult) const; - nsresult LookupPrefix(const nsAString& aNamespaceURI, nsAString& aPrefix); nsresult LookupNamespaceURI(const nsAString& aNamespacePrefix, @@ -243,13 +232,6 @@ public: virtual PRBool MayHaveFrame() const; - /** - * This calls Clone to do the actual cloning so that we end up with the - * right class for the clone. - */ - virtual nsresult CloneContent(nsNodeInfoManager *aNodeInfoManager, - PRBool aDeep, nsIContent **aResult) const; - virtual nsIAtom* GetID() const; virtual const nsAttrValue* GetClasses() const; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); @@ -260,6 +242,17 @@ public: PRInt32 aModType) const; virtual nsIAtom *GetClassAttributeName() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const + { + *aResult = CloneDataNode(aNodeInfo, PR_TRUE); + if (!*aResult) { + return NS_ERROR_OUT_OF_MEMORY; + } + + NS_ADDREF(*aResult); + + return NS_OK; + } //---------------------------------------- @@ -318,8 +311,8 @@ protected: * @param aCloneText if true the text content will be cloned too * @return the clone */ - virtual nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo, - PRBool aCloneText) const = 0; + virtual nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, + PRBool aCloneText) const = 0; nsTextFragment mText; @@ -337,8 +330,8 @@ private: * * Note that classes using this macro will need to implement: * NS_IMETHOD GetNodeType(PRUint16* aNodeType); - * nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo, - * PRBool aCloneText) const; + * nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, + * PRBool aCloneText) const; */ #define NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA \ NS_IMETHOD GetNodeName(nsAString& aNodeName); \ @@ -412,9 +405,9 @@ private: return nsGenericDOMDataNode::IsSupported(aFeature, aVersion, aReturn); \ } \ NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn) { \ - return nsGenericDOMDataNode::CloneNode(aDeep, this, aReturn); \ + return nsNodeUtils::CloneNodeImpl(this, aDeep, aReturn); \ } \ - virtual nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo, \ - PRBool aCloneText) const; + virtual nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, \ + PRBool aCloneText) const; #endif /* nsGenericDOMDataNode_h___ */ diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index cabab12a3e8e..6973f753f239 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3165,80 +3165,16 @@ nsGenericElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) co } nsresult -nsGenericElement::CopyInnerTo(nsGenericElement* aDst, PRBool aDeep) const +nsGenericElement::CopyInnerTo(nsGenericElement* aDst) const { - nsresult rv = NS_OK; PRUint32 i, count = mAttrsAndChildren.AttrCount(); for (i = 0; i < count; ++i) { - // XXX Once we have access to existing nsDOMAttributes for this element, we - // should call CloneNode or ImportNode on them. const nsAttrName* name = mAttrsAndChildren.AttrNameAt(i); const nsAttrValue* value = mAttrsAndChildren.AttrAt(i); nsAutoString valStr; value->ToString(valStr); - rv = aDst->SetAttr(name->NamespaceID(), name->LocalName(), - name->GetPrefix(), valStr, PR_FALSE); - NS_ENSURE_SUCCESS(rv, rv); - } - - if (aDeep) { - nsIDocument *doc = GetOwnerDoc(); - nsIDocument *newDoc = aDst->GetOwnerDoc(); - if (doc == newDoc) { - rv = CloneChildrenTo(aDst); - } - else { - nsCOMPtr domDoc = do_QueryInterface(newDoc); - rv = ImportChildrenTo(aDst, domDoc); - } - } - - return rv; -} - -nsresult -nsGenericElement::ImportChildrenTo(nsGenericElement *aDst, - nsIDOMDocument *aImportDocument) const -{ - PRUint32 i, count = mAttrsAndChildren.ChildCount(); - for (i = 0; i < count; ++i) { - nsresult rv; - nsCOMPtr node = - do_QueryInterface(mAttrsAndChildren.ChildAt(i), &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr newNode; - rv = aImportDocument->ImportNode(node, PR_TRUE, getter_AddRefs(newNode)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr newContent = do_QueryInterface(newNode, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = aDst->AppendChildTo(newContent, PR_FALSE); - NS_ENSURE_SUCCESS(rv, rv); - } - - return NS_OK; -} - -nsresult -nsGenericElement::CloneChildrenTo(nsGenericElement *aDst) const -{ - PRUint32 i, count = mAttrsAndChildren.ChildCount(); - for (i = 0; i < count; ++i) { - nsresult rv; - nsCOMPtr node = - do_QueryInterface(mAttrsAndChildren.ChildAt(i), &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr newNode; - rv = node->CloneNode(PR_TRUE, getter_AddRefs(newNode)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr newContent = do_QueryInterface(newNode, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = aDst->AppendChildTo(newContent, PR_FALSE); + nsresult rv = aDst->SetAttr(name->NamespaceID(), name->LocalName(), + name->GetPrefix(), valStr, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); } @@ -3804,45 +3740,3 @@ nsGenericElement::GetContentsAsText(nsAString& aText) } } } - -nsresult -nsGenericElement::CloneNode(PRBool aDeep, nsIDOMNode *aSource, - nsIDOMNode **aResult) const -{ - *aResult = nsnull; - - nsCOMPtr newContent; - nsresult rv = CloneContent(mNodeInfo->NodeInfoManager(), aDeep, - getter_AddRefs(newContent)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = CallQueryInterface(newContent, aResult); - - nsIDocument *ownerDoc = GetOwnerDoc(); - if (NS_SUCCEEDED(rv) && ownerDoc && HasProperties()) { - nsContentUtils::CallUserDataHandler(ownerDoc, - nsIDOMUserDataHandler::NODE_CLONED, - this, aSource, *aResult); - } - - return rv; -} - -nsresult -nsGenericElement::CloneContent(nsNodeInfoManager *aNodeInfoManager, - PRBool aDeep, nsIContent **aResult) const -{ - nsINodeInfo *nodeInfo = NodeInfo(); - nsCOMPtr newNodeInfo; - if (aNodeInfoManager != nodeInfo->NodeInfoManager()) { - nsresult rv = aNodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(), - nodeInfo->GetPrefixAtom(), - nodeInfo->NamespaceID(), - getter_AddRefs(newNodeInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - nodeInfo = newNodeInfo; - } - - return Clone(nodeInfo, aDeep, aResult); -} diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index 9220e53ff74b..de0bf9419f7d 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -56,6 +56,7 @@ #include "nsILinkHandler.h" #include "nsGenericDOMNodeList.h" #include "nsContentUtils.h" +#include "nsNodeUtils.h" #include "nsAttrAndChildArray.h" #include "mozFlushType.h" #include "nsDOMAttributeMap.h" @@ -386,13 +387,6 @@ public: virtual PRUint32 GetScriptTypeID() const; virtual nsresult SetScriptTypeID(PRUint32 aLang); - /** - * This calls Clone to do the actual cloning so that we end up with the - * right class for the clone. - */ - nsresult CloneContent(nsNodeInfoManager *aNodeInfoManager, PRBool aDeep, - nsIContent **aResult) const; - #ifdef DEBUG virtual void List(FILE* out, PRInt32 aIndent) const; virtual void DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const; @@ -492,6 +486,10 @@ public: NS_IMETHOD HasAttributeNS(const nsAString& aNamespaceURI, const nsAString& aLocalName, PRBool* aReturn); + nsresult CloneNode(PRBool aDeep, nsIDOMNode **aResult) + { + return nsNodeUtils::CloneNodeImpl(this, aDeep, aResult); + } //---------------------------------------- @@ -856,28 +854,10 @@ protected: virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const; /** - * Duplicate children by calling importNode and append them to another - * element. - * - * @param aDst the element to append the imported children to - * @param aImportDocument the document to use to call importNode - */ - nsresult ImportChildrenTo(nsGenericElement *aDst, - nsIDOMDocument *aImportDocument) const; - - /** - * Clone children and append them to another element. - * - * @param aDst the element to append the imported children to - */ - nsresult CloneChildrenTo(nsGenericElement *aDst) const; - - /** - * Copy attributes and children to another content object + * Copy attributes and state to another element * @param aDest the object to copy to - * @param aDeep whether to copy children */ - nsresult CopyInnerTo(nsGenericElement* aDest, PRBool aDeep) const; + nsresult CopyInnerTo(nsGenericElement* aDest) const; /** * Internal hook for converting an attribute name-string to an atomized name @@ -959,130 +939,19 @@ protected: */ void GetContentsAsText(nsAString& aText); - /** - * Method to clone this element. This needs to be overriden by all element - * classes. aNodeInfo should be identical to this element's nodeInfo, except - * for the document which may be different. If aDeep is true all descendants - * will be cloned too (by calling the DOM method cloneNode on them if the - * ownerDocument of aNodeInfo is the same as the ownerDocument of this - * element or by calling the DOM method importNode if they differ). - * - * @param aNodeInfo the nodeinfo to use for the clone - * @param aDeep if true all descendants will be cloned too (attributes are - * always cloned) - * @param aResult the clone - */ - virtual nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const = 0; - - /** - * A basic implementation of the DOM cloneNode method. Calls CloneContent to - * do the actual cloning of the element. - * - * @param aDeep if true all descendants will be cloned too (attributes on the - * element are always cloned) - * @param aSource nsIDOMNode pointer to this node - * @param aResult the clone - */ - nsresult CloneNode(PRBool aDeep, nsIDOMNode *aSource, - nsIDOMNode **aResult) const; - /** * Array containing all attributes and children for this element */ nsAttrAndChildArray mAttrsAndChildren; }; -#define NS_FORWARD_NSIDOMNODE_NO_CLONENODE(_to) \ - NS_IMETHOD GetNodeName(nsAString& aNodeName) { \ - return _to GetNodeName(aNodeName); \ - } \ - NS_IMETHOD GetNodeValue(nsAString& aNodeValue) { \ - return _to GetNodeValue(aNodeValue); \ - } \ - NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) { \ - return _to SetNodeValue(aNodeValue); \ - } \ - NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \ - return _to GetNodeType(aNodeType); \ - } \ - NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \ - return _to GetParentNode(aParentNode); \ - } \ - NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \ - return _to GetChildNodes(aChildNodes); \ - } \ - NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \ - return _to GetFirstChild(aFirstChild); \ - } \ - NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \ - return _to GetLastChild(aLastChild); \ - } \ - NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \ - return _to GetPreviousSibling(aPreviousSibling); \ - } \ - NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \ - return _to GetNextSibling(aNextSibling); \ - } \ - NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \ - return _to GetAttributes(aAttributes); \ - } \ - NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \ - return _to GetOwnerDocument(aOwnerDocument); \ - } \ - NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) { \ - return _to GetNamespaceURI(aNamespaceURI); \ - } \ - NS_IMETHOD GetPrefix(nsAString& aPrefix) { \ - return _to GetPrefix(aPrefix); \ - } \ - NS_IMETHOD SetPrefix(const nsAString& aPrefix) { \ - return _to SetPrefix(aPrefix); \ - } \ - NS_IMETHOD GetLocalName(nsAString& aLocalName) { \ - return _to GetLocalName(aLocalName); \ - } \ - NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \ - nsIDOMNode** aReturn) { \ - return _to InsertBefore(aNewChild, aRefChild, aReturn); \ - } \ - NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \ - nsIDOMNode** aReturn) { \ - return _to ReplaceChild(aNewChild, aOldChild, aReturn); \ - } \ - NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \ - return _to RemoveChild(aOldChild, aReturn); \ - } \ - NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) { \ - return _to AppendChild(aNewChild, aReturn); \ - } \ - NS_IMETHOD HasChildNodes(PRBool* aReturn) { \ - return _to HasChildNodes(aReturn); \ - } \ - NS_IMETHOD Normalize() { \ - return _to Normalize(); \ - } \ - NS_IMETHOD IsSupported(const nsAString& aFeature, \ - const nsAString& aVersion, PRBool* aReturn) { \ - return _to IsSupported(aFeature, aVersion, aReturn); \ - } \ - NS_IMETHOD HasAttributes(PRBool* aReturn) { \ - return _to HasAttributes(aReturn); \ - } \ - NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); \ - virtual nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, \ - nsIContent **aResult) const; - - /** - * Macros to implement CloneNode(). _elementName is the class for which to - * implement CloneNode, _implClass is the class to use to cast to - * nsIDOMNode*. + * Macros to implement Clone(). _elementName is the class for which to implement + * Clone. */ -#define NS_IMPL_DOM_CLONENODE_AMBIGUOUS(_elementName, _implClass) \ +#define NS_IMPL_ELEMENT_CLONE(_elementName) \ nsresult \ -_elementName::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, \ - nsIContent **aResult) const \ +_elementName::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const \ { \ *aResult = nsnull; \ \ @@ -1091,29 +960,18 @@ _elementName::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, \ return NS_ERROR_OUT_OF_MEMORY; \ } \ \ - nsCOMPtr kungFuDeathGrip = it; \ - nsresult rv = CopyInnerTo(it, aDeep); \ + nsCOMPtr kungFuDeathGrip = it; \ + nsresult rv = CopyInnerTo(it); \ if (NS_SUCCEEDED(rv)) { \ kungFuDeathGrip.swap(*aResult); \ } \ \ return rv; \ -} \ -NS_IMETHODIMP \ -_elementName::CloneNode(PRBool aDeep, nsIDOMNode **aResult) \ -{ \ - return nsGenericElement::CloneNode(aDeep, \ - NS_STATIC_CAST(_implClass*, this), \ - aResult); \ } -#define NS_IMPL_DOM_CLONENODE(_elementName) \ -NS_IMPL_DOM_CLONENODE_AMBIGUOUS(_elementName, _elementName) - -#define NS_IMPL_DOM_CLONENODE_WITH_INIT(_elementName) \ +#define NS_IMPL_ELEMENT_CLONE_WITH_INIT(_elementName) \ nsresult \ -_elementName::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, \ - nsIContent **aResult) const \ +_elementName::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const \ { \ *aResult = nsnull; \ \ @@ -1122,19 +980,14 @@ _elementName::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, \ return NS_ERROR_OUT_OF_MEMORY; \ } \ \ - nsCOMPtr kungFuDeathGrip = it; \ + nsCOMPtr kungFuDeathGrip = it; \ nsresult rv = it->Init(); \ - rv |= CopyInnerTo(it, aDeep); \ + rv |= CopyInnerTo(it); \ if (NS_SUCCEEDED(rv)) { \ kungFuDeathGrip.swap(*aResult); \ } \ \ return rv; \ -} \ -NS_IMETHODIMP \ -_elementName::CloneNode(PRBool aDeep, nsIDOMNode **aResult) \ -{ \ - return nsGenericElement::CloneNode(aDeep, this, aResult); \ } #endif /* nsGenericElement_h___ */ diff --git a/content/base/src/nsNodeUtils.cpp b/content/base/src/nsNodeUtils.cpp index dbc4c34f7cf8..69be1a40737f 100755 --- a/content/base/src/nsNodeUtils.cpp +++ b/content/base/src/nsNodeUtils.cpp @@ -44,6 +44,12 @@ #include "nsIDocument.h" #include "nsIDOMUserDataHandler.h" #include "nsIEventListenerManager.h" +#include "nsIAttribute.h" +#include "nsIXPConnect.h" +#include "nsGenericElement.h" +#include "pldhash.h" +#include "nsIDOMAttr.h" +#include "nsCOMArray.h" #define IMPL_MUTATION_NOTIFICATION(func_, content_, params_) \ PR_BEGIN_MACRO \ @@ -212,3 +218,255 @@ nsNodeUtils::LastRelease(nsINode* aNode, PRBool aDelete) } } +/* static */ +nsresult +nsNodeUtils::CallUserDataHandlers(nsCOMArray &aNodesWithProperties, + nsIDocument *aOwnerDocument, + PRUint16 aOperation, PRBool aCloned) +{ + NS_PRECONDITION(!aCloned || (aNodesWithProperties.Count() % 2 == 0), + "Expected aNodesWithProperties to contain original and " + "cloned nodes."); + + // Keep the document alive, just in case one of the handlers causes it to go + // away. + nsCOMPtr ownerDoc = aOwnerDocument; + + PRUint32 i, count = aNodesWithProperties.Count(); + for (i = 0; i < count; ++i) { + nsINode *nodeWithProperties = aNodesWithProperties[i]; + + nsresult rv; + nsCOMPtr source = do_QueryInterface(nodeWithProperties, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr dest; + if (aCloned) { + dest = do_QueryInterface(aNodesWithProperties[++i], &rv); + NS_ENSURE_SUCCESS(rv, rv); + } + + nsContentUtils::CallUserDataHandler(aOwnerDocument, aOperation, + nodeWithProperties, source, dest); + } + + return NS_OK; +} + +/* static */ +nsresult +nsNodeUtils::CloneNodeImpl(nsINode *aNode, PRBool aDeep, nsIDOMNode **aResult) +{ + *aResult = nsnull; + + nsCOMPtr newNode; + nsCOMArray nodesWithProperties; + nsresult rv = Clone(aNode, aDeep, nsnull, nodesWithProperties, + getter_AddRefs(newNode)); + NS_ENSURE_SUCCESS(rv, rv); + + nsIDocument *ownerDoc = aNode->GetOwnerDoc(); + if (ownerDoc) { + rv = CallUserDataHandlers(nodesWithProperties, ownerDoc, + nsIDOMUserDataHandler::NODE_CLONED, PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); + } + + newNode.swap(*aResult); + + return NS_OK; +} + +class AdoptFuncData { +public: + AdoptFuncData(nsIDOMElement *aElement, nsNodeInfoManager *aNewNodeInfoManager, + JSContext *aCx, JSObject *aOldScope, JSObject *aNewScope, + nsCOMArray &aNodesWithProperties) + : mElement(aElement), + mNewNodeInfoManager(aNewNodeInfoManager), + mCx(aCx), + mOldScope(aOldScope), + mNewScope(aNewScope), + mNodesWithProperties(aNodesWithProperties) + { + }; + + nsIDOMElement *mElement; + nsNodeInfoManager *mNewNodeInfoManager; + JSContext *mCx; + JSObject *mOldScope; + JSObject *mNewScope; + nsCOMArray &mNodesWithProperties; +}; + +PLDHashOperator PR_CALLBACK +AdoptFunc(nsAttrHashKey::KeyType aKey, nsIDOMNode *aData, void* aUserArg) +{ + nsCOMPtr attr = do_QueryInterface(aData); + NS_ASSERTION(attr, "non-nsIAttribute somehow made it into the hashmap?!"); + + AdoptFuncData *data = NS_STATIC_CAST(AdoptFuncData*, aUserArg); + + // If we were passed an element we need to clone the attribute nodes and + // insert them into the element. + PRBool clone = data->mElement != nsnull; + nsCOMPtr node; + nsresult rv = nsNodeUtils::CloneAndAdopt(attr, clone, PR_TRUE, + data->mNewNodeInfoManager, + data->mCx, data->mOldScope, + data->mNewScope, + data->mNodesWithProperties, + nsnull, getter_AddRefs(node)); + + if (NS_SUCCEEDED(rv) && clone) { + nsCOMPtr dummy, attribute = do_QueryInterface(node, &rv); + if (NS_SUCCEEDED(rv)) { + rv = data->mElement->SetAttributeNode(attribute, getter_AddRefs(dummy)); + } + } + + return NS_SUCCEEDED(rv) ? PL_DHASH_NEXT : PL_DHASH_STOP; +} + +/* static */ +nsresult +nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep, + nsNodeInfoManager *aNewNodeInfoManager, + JSContext *aCx, JSObject *aOldScope, + JSObject *aNewScope, + nsCOMArray &aNodesWithProperties, + nsINode *aParent, nsIDOMNode **aResult) +{ + NS_PRECONDITION((!aClone && aNewNodeInfoManager) || !aCx, + "If cloning or not getting a new nodeinfo we shouldn't " + "rewrap"); + NS_PRECONDITION(!aCx || (aOldScope && aNewScope), "Must have scopes"); + NS_PRECONDITION(!aParent || !aNode->IsNodeOfType(nsINode::eDOCUMENT), + "Can't insert document nodes into a parent"); + + *aResult = nsnull; + + // First deal with aNode and walk its attributes (and their children). Then, + // if aDeep is PR_TRUE, deal with aNode's children (and recurse into their + // attributes and children). + + nsresult rv; + nsNodeInfoManager *nodeInfoManager = aNewNodeInfoManager; + + // aNode. + nsINodeInfo *nodeInfo = aNode->mNodeInfo; + nsCOMPtr newNodeInfo; + if (nodeInfoManager) { + rv = nodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(), + nodeInfo->GetPrefixAtom(), + nodeInfo->NamespaceID(), + getter_AddRefs(newNodeInfo)); + NS_ENSURE_SUCCESS(rv, rv); + + nodeInfo = newNodeInfo; + } + + nsCOMPtr clone; + if (aClone) { + rv = aNode->Clone(nodeInfo, getter_AddRefs(clone)); + NS_ENSURE_SUCCESS(rv, rv); + + if (aParent) { + // If we're cloning we need to insert the cloned children into the cloned + // parent. + nsCOMPtr cloneContent = do_QueryInterface(clone, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + rv = aParent->AppendChildTo(cloneContent, PR_FALSE); + NS_ENSURE_SUCCESS(rv, rv); + } + else if (aDeep && clone->IsNodeOfType(nsINode::eDOCUMENT)) { + // After cloning the document itself, we want to clone the children into + // the cloned document (somewhat like cloning and importing them into the + // cloned document). + nodeInfoManager = clone->mNodeInfo->NodeInfoManager(); + } + } + else if (nodeInfoManager) { + aNode->mNodeInfo.swap(newNodeInfo); + + if (aCx) { + nsIXPConnect *xpc = nsContentUtils::XPConnect(); + if (xpc) { + nsCOMPtr oldWrapper; + rv = xpc->ReparentWrappedNativeIfFound(aCx, aOldScope, aNewScope, aNode, + getter_AddRefs(oldWrapper)); + if (NS_FAILED(rv)) { + aNode->mNodeInfo.swap(nodeInfo); + + return rv; + } + } + } + } + + if (aNode->IsNodeOfType(nsINode::eELEMENT)) { + // aNode's attributes. + nsGenericElement *elem = NS_STATIC_CAST(const nsGenericElement*, aNode); + const nsDOMAttributeMap *map = elem->GetAttributeMap(); + if (map) { + nsCOMPtr element; + if (aClone) { + // If we're cloning we need to insert the cloned attribute nodes into + // the cloned element. + element = do_QueryInterface(clone, &rv); + NS_ENSURE_SUCCESS(rv, rv); + } + + AdoptFuncData data(element, nodeInfoManager, aCx, aOldScope, + aNewScope, aNodesWithProperties); + + PRUint32 count = map->Enumerate(AdoptFunc, &data); + NS_ENSURE_TRUE(count == map->Count(), NS_ERROR_FAILURE); + } + } + + // The DOM spec says to always adopt/clone/import the children of attribute + // nodes. + // XXX The following block is here because our implementation of attribute + // nodes is broken when it comes to inserting children. Instead of cloning + // their children we force creation of the only child by calling + // GetChildAt(0). We can remove this when + // https://bugzilla.mozilla.org/show_bug.cgi?id=56758 is fixed. + if (aClone && aNode->IsNodeOfType(nsINode::eATTRIBUTE)) { + nsCOMPtr attrChildNode = aNode->GetChildAt(0); + // We only need to do this if the child node has properties (because we + // might need to call a userdata handler). + if (attrChildNode && attrChildNode->HasProperties()) { + nsCOMPtr clonedAttrChildNode = clone->GetChildAt(0); + if (clonedAttrChildNode) { + PRBool ok = aNodesWithProperties.AppendObject(attrChildNode) && + aNodesWithProperties.AppendObject(clonedAttrChildNode); + NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY); + } + } + } + // XXX End of workaround for broken attribute nodes. + else if (aDeep || aNode->IsNodeOfType(nsINode::eATTRIBUTE)) { + // aNode's children. + PRUint32 i, length = aNode->GetChildCount(); + for (i = 0; i < length; ++i) { + nsCOMPtr child; + rv = CloneAndAdopt(aNode->GetChildAt(i), aClone, PR_TRUE, nodeInfoManager, + aCx, aOldScope, aNewScope, aNodesWithProperties, + clone, getter_AddRefs(child)); + NS_ENSURE_SUCCESS(rv, rv); + } + } + + if (aNode->HasProperties()) { + PRBool ok = aNodesWithProperties.AppendObject(aNode); + if (aClone) { + ok = ok && aNodesWithProperties.AppendObject(clone); + } + + NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY); + } + + return clone ? CallQueryInterface(clone, aResult) : NS_OK; +} diff --git a/content/base/src/nsNodeUtils.h b/content/base/src/nsNodeUtils.h index 81afce60a786..d2124e1cfc8a 100755 --- a/content/base/src/nsNodeUtils.h +++ b/content/base/src/nsNodeUtils.h @@ -38,12 +38,13 @@ #ifndef nsNodeUtils_h___ #define nsNodeUtils_h___ -#include "prtypes.h" +#include "nsDOMAttributeMap.h" +struct JSContext; +struct JSObject; class nsINode; -class nsIContent; -class nsIDocument; -class nsIAtom; +class nsNodeInfoManager; +template class nsCOMArray; class nsNodeUtils { @@ -105,6 +106,137 @@ public: * @param aDelete If PR_TRUE, calling this method also deletes aNode. */ static void LastRelease(nsINode* aNode, PRBool aDelete); + + /** + * Clones aNode, its attributes and, if aDeep is PR_TRUE, its descendant nodes + * If aNewNodeInfoManager is not null, it is used to create new nodeinfos for + * the clones. aNodesWithProperties will be filled with all the nodes that + * have properties, and every node in it will be followed by its clone. + * + * @param aNode Node to clone. + * @param aDeep If PR_TRUE the function will be called recursively on + * descendants of the node + * @param aNewNodeInfoManager The nodeinfo manager to use to create new + * nodeinfos for aNode and its attributes and + * descendants. May be null if the nodeinfos + * shouldn't be changed. + * @param aNodesWithProperties All nodes (from amongst aNode and its + * descendants) with properties. Every node will + * be followed by its clone. + * @param aResult *aResult will contain the cloned node. + */ + static nsresult Clone(nsINode *aNode, PRBool aDeep, + nsNodeInfoManager *aNewNodeInfoManager, + nsCOMArray &aNodesWithProperties, + nsIDOMNode **aResult) + { + return CloneAndAdopt(aNode, PR_TRUE, aDeep, aNewNodeInfoManager, nsnull, + nsnull, nsnull, aNodesWithProperties, nsnull, + aResult); + } + + /** + * Walks aNode, its attributes and descendant nodes. If aNewNodeInfoManager is + * not null, it is used to create new nodeinfos for the nodes. Also reparents + * the XPConnect wrappers for the nodes in aNewScope if aCx is not null. + * aNodesWithProperties will be filled with all the nodes that have + * properties. + * + * @param aNode Node to adopt. + * @param aNewNodeInfoManager The nodeinfo manager to use to create new + * nodeinfos for aNode and its attributes and + * descendants. May be null if the nodeinfos + * shouldn't be changed. + * @param aCx Context to use for reparenting the wrappers, or null if no + * reparenting should be done. Must be null if aNewNodeInfoManager + * is null. + * @param aOldScope Old scope for the wrappers. May be null if aCx is null. + * @param aNewScope New scope for the wrappers. May be null if aCx is null. + * @param aNodesWithProperties All nodes (from amongst aNode and its + * descendants) with properties. + */ + static nsresult Adopt(nsINode *aNode, nsNodeInfoManager *aNewNodeInfoManager, + JSContext *aCx, JSObject *aOldScope, + JSObject *aNewScope, + nsCOMArray &aNodesWithProperties) + { + nsCOMPtr dummy; + return CloneAndAdopt(aNode, PR_FALSE, PR_TRUE, aNewNodeInfoManager, aCx, + aOldScope, aNewScope, aNodesWithProperties, + nsnull, getter_AddRefs(dummy)); + } + + /** + * Call registered userdata handlers for operation aOperation for the nodes in + * aNodesWithProperties. If aCloned is PR_TRUE aNodesWithProperties should + * contain both the original and the cloned nodes (and only the userdata + * handlers registered for the original nodes will be called). + * + * @param aNodesWithProperties Contains the nodes that might have properties + * registered on them. If aCloned is PR_TRUE every + * one of those nodes should be immediately + * followed in the array by the cloned node. + * @param aOwnerDocument The ownerDocument of the original nodes. + * @param aOperation The operation to call a userdata handler for. + * @param aCloned If PR_TRUE aNodesWithProperties will contain both original + * and cloned nodes. + */ + static nsresult CallUserDataHandlers(nsCOMArray &aNodesWithProperties, + nsIDocument *aOwnerDocument, + PRUint16 aOperation, PRBool aCloned); + + /** + * A basic implementation of the DOM cloneNode method. Calls nsINode::Clone to + * do the actual cloning of the node. + * + * @param aNode the node to clone + * @param aDeep if true all descendants will be cloned too + * @param aResult the clone + */ + static nsresult CloneNodeImpl(nsINode *aNode, PRBool aDeep, + nsIDOMNode **aResult); + +private: + friend PLDHashOperator PR_CALLBACK + AdoptFunc(nsAttrHashKey::KeyType aKey, nsIDOMNode *aData, void* aUserArg); + + /** + * Walks aNode, its attributes and, if aDeep is PR_TRUE, its descendant nodes. + * If aClone is PR_TRUE the nodes will be cloned. If aNewNodeInfoManager is + * not null, it is used to create new nodeinfos for the nodes. Also reparents + * the XPConnect wrappers for the nodes in aNewScope if aCx is not null. + * aNodesWithProperties will be filled with all the nodes that have + * properties. + * + * @param aNode Node to adopt/clone. + * @param aClone If PR_TRUE the node will be cloned and the cloned node will + * be in aResult. + * @param aDeep If PR_TRUE the function will be called recursively on + * descendants of the node + * @param aNewNodeInfoManager The nodeinfo manager to use to create new + * nodeinfos for aNode and its attributes and + * descendants. May be null if the nodeinfos + * shouldn't be changed. + * @param aCx Context to use for reparenting the wrappers, or null if no + * reparenting should be done. Must be null if aClone is PR_TRUE or + * if aNewNodeInfoManager is null. + * @param aOldScope Old scope for the wrappers. May be null if aCx is null. + * @param aNewScope New scope for the wrappers. May be null if aCx is null. + * @param aNodesWithProperties All nodes (from amongst aNode and its + * descendants) with properties. If aClone is + * PR_TRUE every node will be followed by its + * clone. + * @param aParent If aClone is PR_TRUE the cloned node will be appended to + * aParent's children. May be null. + * @param aResult *aResult will contain the cloned node (if aClone is + * PR_TRUE). + */ + static nsresult CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep, + nsNodeInfoManager *aNewNodeInfoManager, + JSContext *aCx, JSObject *aOldScope, + JSObject *aNewScope, + nsCOMArray &aNodesWithProperties, + nsINode *aParent, nsIDOMNode **aResult); }; #endif // nsNodeUtils_h___ diff --git a/content/base/src/nsTextNode.cpp b/content/base/src/nsTextNode.cpp index dc974367b679..891e69de090d 100644 --- a/content/base/src/nsTextNode.cpp +++ b/content/base/src/nsTextNode.cpp @@ -125,8 +125,8 @@ public: virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, PRBool aNullParent = PR_TRUE); - virtual nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo, - PRBool aCloneText) const + virtual nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, + PRBool aCloneText) const { nsAttributeTextNode *it = new nsAttributeTextNode(aNodeInfo); if (it && aCloneText) { @@ -218,7 +218,7 @@ nsTextNode::IsNodeOfType(PRUint32 aFlags) const } nsGenericDOMDataNode* -nsTextNode::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const +nsTextNode::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { nsTextNode *it = new nsTextNode(aNodeInfo); if (it && aCloneText) { diff --git a/content/events/src/nsXMLEventsElement.cpp b/content/events/src/nsXMLEventsElement.cpp index 9cd19ec2c535..c38519edce18 100644 --- a/content/events/src/nsXMLEventsElement.cpp +++ b/content/events/src/nsXMLEventsElement.cpp @@ -44,11 +44,13 @@ class nsXMLEventsElement : public nsXMLElement { public: nsXMLEventsElement(nsINodeInfo *aNodeInfo); virtual ~nsXMLEventsElement(); - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsXMLElement::) + NS_FORWARD_NSIDOMNODE(nsXMLElement::) + virtual nsIAtom *GetIDAttributeName() const; virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; nsXMLEventsElement::nsXMLEventsElement(nsINodeInfo *aNodeInfo) @@ -80,7 +82,7 @@ nsXMLEventsElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPref aNotify); } -NS_IMPL_DOM_CLONENODE(nsXMLEventsElement) +NS_IMPL_ELEMENT_CLONE(nsXMLEventsElement) nsresult NS_NewXMLEventsElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index c813ccf5143f..dcb52f17abf6 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -277,15 +277,11 @@ nsGenericHTMLElement::Shutdown() } nsresult -nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst, PRBool aDeep) const +nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst) const { - nsresult rv = NS_OK; + nsresult rv; PRInt32 i, count = GetAttrCount(); - nsAutoString value; - for (i = 0; i < count; ++i) { - // XXX Once we have access to existing nsDOMAttributes for this element, we - // should call CloneNode or ImportNode on them. const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i); const nsAttrValue *value = mAttrsAndChildren.AttrAt(i); if (name->Equals(nsHTMLAtoms::style, kNameSpaceID_None) && @@ -330,20 +326,7 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst, PRBool aDeep) const } } - nsIDocument *newDoc = aDst->GetOwnerDoc(); - - if (aDeep) { - nsIDocument *doc = GetOwnerDoc(); - if (doc == newDoc) { - rv = CloneChildrenTo(aDst); - } - else { - nsCOMPtr domDoc = do_QueryInterface(newDoc); - rv = ImportChildrenTo(aDst, domDoc); - } - } - - return rv; + return NS_OK; } nsresult diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 77a4589b835e..6f30be26f10d 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -105,7 +105,7 @@ public: void **aInstancePtr); // From nsGenericElement - nsresult CopyInnerTo(nsGenericElement* aDest, PRBool aDeep) const; + nsresult CopyInnerTo(nsGenericElement* aDest) const; // Implementation for nsIDOMNode NS_METHOD GetNodeName(nsAString& aNodeName); diff --git a/content/html/content/src/nsHTMLAnchorElement.cpp b/content/html/content/src/nsHTMLAnchorElement.cpp index b81f5b49a816..40a91030d081 100644 --- a/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/content/html/content/src/nsHTMLAnchorElement.cpp @@ -79,7 +79,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -124,6 +124,8 @@ public: virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // The cached visited state nsLinkState mLinkState; @@ -158,7 +160,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLAnchorElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLAnchorElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLAnchorElement) NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset) diff --git a/content/html/content/src/nsHTMLAreaElement.cpp b/content/html/content/src/nsHTMLAreaElement.cpp index 36f56ca9fdd7..482c6da486f5 100644 --- a/content/html/content/src/nsHTMLAreaElement.cpp +++ b/content/html/content/src/nsHTMLAreaElement.cpp @@ -63,7 +63,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -107,6 +107,8 @@ public: virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // The cached visited state nsLinkState mLinkState; @@ -140,7 +142,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLAreaElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLAreaElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLAreaElement) NS_IMPL_STRING_ATTR(nsHTMLAreaElement, AccessKey, accesskey) diff --git a/content/html/content/src/nsHTMLBRElement.cpp b/content/html/content/src/nsHTMLBRElement.cpp index 4452b2a1918b..859d5904da0b 100644 --- a/content/html/content/src/nsHTMLBRElement.cpp +++ b/content/html/content/src/nsHTMLBRElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -71,6 +71,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -97,7 +98,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLBRElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLBRElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLBRElement) NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear) diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index 3ea1b3edaa7b..6c1f45af6d1c 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -96,7 +96,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -117,6 +117,7 @@ public: NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual already_AddRefed GetAssociatedEditor(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: BodyRule* mContentStyleRule; @@ -306,7 +307,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLBodyElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLBodyElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLBodyElement) NS_IMPL_URI_ATTR(nsHTMLBodyElement, Background, background) diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index 43f6be0fa7cb..8fa466e8ed3c 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -73,7 +73,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -108,6 +108,8 @@ public: virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: PRInt8 mType; PRPackedBool mHandlingClick; @@ -153,7 +155,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLButtonElement -NS_IMPL_DOM_CLONENODE(nsHTMLButtonElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLButtonElement) // nsIDOMHTMLButtonElement diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp index 5652a6e50678..68c53b4e1413 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/nsHTMLCanvasElement.cpp @@ -74,7 +74,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -111,6 +111,8 @@ public: virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsIntSize GetWidthHeight(); nsresult UpdateContext(); @@ -158,7 +160,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLCanvasElement, nsGenericElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLCanvasElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLCanvasElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLCanvasElement) nsIntSize nsHTMLCanvasElement::GetWidthHeight() diff --git a/content/html/content/src/nsHTMLDelElement.cpp b/content/html/content/src/nsHTMLDelElement.cpp index c416f1bb9a8a..441ce5078020 100644 --- a/content/html/content/src/nsHTMLDelElement.cpp +++ b/content/html/content/src/nsHTMLDelElement.cpp @@ -53,7 +53,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -63,6 +63,8 @@ public: // nsIDOMHTMLModElement NS_DECL_NSIDOMHTMLMODELEMENT + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -91,7 +93,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLModElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLModElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLModElement) NS_IMPL_URI_ATTR(nsHTMLModElement, Cite, cite) diff --git a/content/html/content/src/nsHTMLDivElement.cpp b/content/html/content/src/nsHTMLDivElement.cpp index a471609f4bbf..787dadd5ff18 100644 --- a/content/html/content/src/nsHTMLDivElement.cpp +++ b/content/html/content/src/nsHTMLDivElement.cpp @@ -53,7 +53,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -70,6 +70,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -98,7 +99,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLDivElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLDivElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLDivElement) NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align) diff --git a/content/html/content/src/nsHTMLFieldSetElement.cpp b/content/html/content/src/nsHTMLFieldSetElement.cpp index 9a7473b28e83..fb02ccc3263a 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.cpp +++ b/content/html/content/src/nsHTMLFieldSetElement.cpp @@ -56,7 +56,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -72,6 +72,7 @@ public: NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; // construction, destruction @@ -106,7 +107,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLFieldSetElement -NS_IMPL_DOM_CLONENODE(nsHTMLFieldSetElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLFieldSetElement) // nsIDOMHTMLFieldSetElement diff --git a/content/html/content/src/nsHTMLFontElement.cpp b/content/html/content/src/nsHTMLFontElement.cpp index 2c31c883e5f8..59d517bf9501 100644 --- a/content/html/content/src/nsHTMLFontElement.cpp +++ b/content/html/content/src/nsHTMLFontElement.cpp @@ -58,7 +58,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -75,6 +75,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -101,7 +102,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLFontElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLFontElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLFontElement) NS_IMPL_STRING_ATTR(nsHTMLFontElement, Color, color) diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 1c9816b10c7f..2ab0c665f787 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -146,7 +146,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -245,6 +245,8 @@ public: nsIDOMNode* b, PRInt32* retval); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsresult DoSubmitOrReset(nsEvent* aEvent, PRInt32 aMessage); @@ -567,7 +569,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLFormElement -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsHTMLFormElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsHTMLFormElement) NS_IMETHODIMP nsHTMLFormElement::GetElements(nsIDOMHTMLCollection** aElements) diff --git a/content/html/content/src/nsHTMLFrameElement.cpp b/content/html/content/src/nsHTMLFrameElement.cpp index 1365aeb2598f..6cd3b5ecf9f4 100644 --- a/content/html/content/src/nsHTMLFrameElement.cpp +++ b/content/html/content/src/nsHTMLFrameElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFrameElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::) @@ -72,6 +72,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -100,7 +101,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLFrameElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLFrameElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLFrameElement) NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder) diff --git a/content/html/content/src/nsHTMLFrameSetElement.cpp b/content/html/content/src/nsHTMLFrameSetElement.cpp index d6c771cf6f03..5f4671e51f33 100644 --- a/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -56,7 +56,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -88,6 +88,9 @@ public: nsAttrValue& aResult); virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + private: nsresult ParseRowCol(const nsAString& aValue, PRInt32& aNumSpecs, @@ -143,7 +146,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLFrameSetElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLFrameSetElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLFrameSetElement) NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Cols, cols) diff --git a/content/html/content/src/nsHTMLHRElement.cpp b/content/html/content/src/nsHTMLHRElement.cpp index 7457c0d7afea..a0b52f07a8a3 100644 --- a/content/html/content/src/nsHTMLHRElement.cpp +++ b/content/html/content/src/nsHTMLHRElement.cpp @@ -56,7 +56,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -76,6 +76,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -104,7 +105,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLHRElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLHRElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLHRElement) NS_IMPL_STRING_ATTR(nsHTMLHRElement, Align, align) diff --git a/content/html/content/src/nsHTMLHeadElement.cpp b/content/html/content/src/nsHTMLHeadElement.cpp index 668a83a88ca4..c8007edc7d94 100644 --- a/content/html/content/src/nsHTMLHeadElement.cpp +++ b/content/html/content/src/nsHTMLHeadElement.cpp @@ -53,7 +53,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -63,6 +63,8 @@ public: // nsIDOMHTMLHeadElement NS_DECL_NSIDOMHTMLHEADELEMENT + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -90,7 +92,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLHeadElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLHeadElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLHeadElement) NS_IMPL_URI_ATTR(nsHTMLHeadElement, Profile, profile) diff --git a/content/html/content/src/nsHTMLHeadingElement.cpp b/content/html/content/src/nsHTMLHeadingElement.cpp index 4cc3935c3438..3b3df533c467 100644 --- a/content/html/content/src/nsHTMLHeadingElement.cpp +++ b/content/html/content/src/nsHTMLHeadingElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -71,6 +71,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -98,7 +99,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLHeadingElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLHeadingElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLHeadingElement) NS_IMPL_STRING_ATTR(nsHTMLHeadingElement, Align, align) diff --git a/content/html/content/src/nsHTMLHtmlElement.cpp b/content/html/content/src/nsHTMLHtmlElement.cpp index 8da6989c3cfa..a22379f99a57 100644 --- a/content/html/content/src/nsHTMLHtmlElement.cpp +++ b/content/html/content/src/nsHTMLHtmlElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -64,6 +64,8 @@ public: // nsIDOMHTMLHtmlElement NS_DECL_NSIDOMHTMLHTMLELEMENT + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -92,7 +94,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLHtmlElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLHtmlElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLHtmlElement) NS_IMPL_STRING_ATTR(nsHTMLHtmlElement, Version, version) diff --git a/content/html/content/src/nsHTMLIFrameElement.cpp b/content/html/content/src/nsHTMLIFrameElement.cpp index 0c29e2415ff3..65be9be5be46 100644 --- a/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/content/html/content/src/nsHTMLIFrameElement.cpp @@ -55,7 +55,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFrameElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::) @@ -73,6 +73,8 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -99,7 +101,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLIFrameElement, nsGenericHTMLFrameEleme NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLIFrameElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLIFrameElement) NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Align, align) diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index f8abf64c5337..5b968977576f 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -95,7 +95,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -146,6 +146,7 @@ public: PRBool aCompileEventHandlers); virtual PRInt32 IntrinsicState() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: void GetImageFrame(nsIImageFrame** aImageFrame); @@ -203,7 +204,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLImageElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLImageElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLImageElement) NS_IMPL_STRING_ATTR(nsHTMLImageElement, Name, name) diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 1c41b6c97a33..6dc26aca5638 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -161,7 +161,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -237,6 +237,8 @@ public: */ virtual already_AddRefed GetRadioGroupContainer(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // Helper method nsresult SetValueInternal(const nsAString& aValue, @@ -393,8 +395,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMNode nsresult -nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const +nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; @@ -403,8 +404,8 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr kungFuDeathGrip = it; - nsresult rv = CopyInnerTo(it, aDeep); + nsCOMPtr kungFuDeathGrip = it; + nsresult rv = CopyInnerTo(it); NS_ENSURE_SUCCESS(rv, rv); switch (mType) { @@ -445,12 +446,6 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return NS_OK; } -NS_IMETHODIMP -nsHTMLInputElement::CloneNode(PRBool aDeep, nsIDOMNode **aResult) -{ - return nsGenericElement::CloneNode(aDeep, this, aResult); -} - nsresult nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString* aValue, diff --git a/content/html/content/src/nsHTMLLIElement.cpp b/content/html/content/src/nsHTMLLIElement.cpp index bc2af275dd72..ccbe68cddf50 100644 --- a/content/html/content/src/nsHTMLLIElement.cpp +++ b/content/html/content/src/nsHTMLLIElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -71,6 +71,7 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -98,7 +99,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLLIElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLLIElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLLIElement) NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type) diff --git a/content/html/content/src/nsHTMLLabelElement.cpp b/content/html/content/src/nsHTMLLabelElement.cpp index 701adb805c85..0bf950533fa2 100644 --- a/content/html/content/src/nsHTMLLabelElement.cpp +++ b/content/html/content/src/nsHTMLLabelElement.cpp @@ -64,7 +64,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -101,6 +101,7 @@ public: PRBool aNotify); virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: already_AddRefed GetForContent(); @@ -144,7 +145,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLLabelElement -NS_IMPL_DOM_CLONENODE(nsHTMLLabelElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLLabelElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLLegendElement.cpp b/content/html/content/src/nsHTMLLegendElement.cpp index 70f4ed28db14..433e313d5955 100644 --- a/content/html/content/src/nsHTMLLegendElement.cpp +++ b/content/html/content/src/nsHTMLLegendElement.cpp @@ -61,7 +61,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -101,6 +101,8 @@ public: PRBool aNotify); virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -132,7 +134,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLLegendElement -NS_IMPL_DOM_CLONENODE(nsHTMLLegendElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLLegendElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLLinkElement.cpp b/content/html/content/src/nsHTMLLinkElement.cpp index 35702b5ef1f3..0bde3aebbeb3 100644 --- a/content/html/content/src/nsHTMLLinkElement.cpp +++ b/content/html/content/src/nsHTMLLinkElement.cpp @@ -72,7 +72,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -109,6 +109,8 @@ public: virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual void GetStyleSheetURL(PRBool* aIsInline, nsIURI** aURI); @@ -150,7 +152,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLLinkElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLLinkElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLLinkElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLMapElement.cpp b/content/html/content/src/nsHTMLMapElement.cpp index 868a319a8b91..f55be23c025f 100644 --- a/content/html/content/src/nsHTMLMapElement.cpp +++ b/content/html/content/src/nsHTMLMapElement.cpp @@ -56,7 +56,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -72,6 +72,8 @@ public: PRBool aCompileEventHandlers); virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, PRBool aNullParent = PR_TRUE); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsRefPtr mAreas; }; @@ -127,7 +129,7 @@ nsHTMLMapElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent) nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent); } -NS_IMPL_DOM_CLONENODE(nsHTMLMapElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLMapElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLMetaElement.cpp b/content/html/content/src/nsHTMLMetaElement.cpp index b8c65978cac6..21261840b0b7 100644 --- a/content/html/content/src/nsHTMLMetaElement.cpp +++ b/content/html/content/src/nsHTMLMetaElement.cpp @@ -53,7 +53,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -63,6 +63,8 @@ public: // nsIDOMHTMLMetaElement NS_DECL_NSIDOMHTMLMETAELEMENT + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -92,7 +94,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLMetaElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLMetaElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLMetaElement) NS_IMPL_STRING_ATTR(nsHTMLMetaElement, Content, content) diff --git a/content/html/content/src/nsHTMLOListElement.cpp b/content/html/content/src/nsHTMLOListElement.cpp index 8fcd40fd4b79..52f3557d6e27 100644 --- a/content/html/content/src/nsHTMLOListElement.cpp +++ b/content/html/content/src/nsHTMLOListElement.cpp @@ -58,7 +58,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -81,6 +81,7 @@ public: nsAttrValue& aResult); virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -115,8 +116,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_AMBIGOUS_BEGIN(nsHTMLSharedListElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE_AMBIGUOUS(nsHTMLSharedListElement, - nsIDOMHTMLOListElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLSharedListElement) NS_IMPL_BOOL_ATTR(nsHTMLSharedListElement, Compact, compact) diff --git a/content/html/content/src/nsHTMLObjectElement.cpp b/content/html/content/src/nsHTMLObjectElement.cpp index 2189b0b17326..8dc88347c0ed 100644 --- a/content/html/content/src/nsHTMLObjectElement.cpp +++ b/content/html/content/src/nsHTMLObjectElement.cpp @@ -60,7 +60,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -107,6 +107,8 @@ public: // nsObjectLoadingContent virtual PRUint32 GetCapabilities() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + private: /** * Calls LoadObject with the correct arguments to start the plugin load. @@ -168,7 +170,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLObjectElement, NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLObjectElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLObjectElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLObjectElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLOptGroupElement.cpp b/content/html/content/src/nsHTMLOptGroupElement.cpp index c091997d4636..480b4cd3962b 100644 --- a/content/html/content/src/nsHTMLOptGroupElement.cpp +++ b/content/html/content/src/nsHTMLOptGroupElement.cpp @@ -63,7 +63,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -93,6 +93,7 @@ public: AfterSetAttr(aNameSpaceID, aAttribute, nsnull, aNotify); return rv; } + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: @@ -135,7 +136,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLOptGroupElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLOptGroupElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLOptGroupElement) NS_IMPL_BOOL_ATTR(nsHTMLOptGroupElement, Disabled, disabled) diff --git a/content/html/content/src/nsHTMLOptionElement.cpp b/content/html/content/src/nsHTMLOptionElement.cpp index 261af749eef8..f29dac431aa1 100644 --- a/content/html/content/src/nsHTMLOptionElement.cpp +++ b/content/html/content/src/nsHTMLOptionElement.cpp @@ -87,7 +87,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -123,6 +123,7 @@ public: AfterSetAttr(aNameSpaceID, aAttribute, nsnull, aNotify); return rv; } + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: /** @@ -194,7 +195,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLOptionElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLOptionElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLOptionElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLParagraphElement.cpp b/content/html/content/src/nsHTMLParagraphElement.cpp index 40d873d7169b..15d5ac9a709b 100644 --- a/content/html/content/src/nsHTMLParagraphElement.cpp +++ b/content/html/content/src/nsHTMLParagraphElement.cpp @@ -57,7 +57,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -74,6 +74,8 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -102,7 +104,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLParagraphElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLParagraphElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLParagraphElement) NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align) diff --git a/content/html/content/src/nsHTMLPreElement.cpp b/content/html/content/src/nsHTMLPreElement.cpp index e8f14164cf22..505e29ab80b2 100644 --- a/content/html/content/src/nsHTMLPreElement.cpp +++ b/content/html/content/src/nsHTMLPreElement.cpp @@ -58,7 +58,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -76,6 +76,8 @@ public: nsAttrValue& aResult); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -103,7 +105,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLPreElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLPreElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLPreElement) NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width) diff --git a/content/html/content/src/nsHTMLScriptElement.cpp b/content/html/content/src/nsHTMLScriptElement.cpp index deda40b464bb..ad1f96d2e99a 100644 --- a/content/html/content/src/nsHTMLScriptElement.cpp +++ b/content/html/content/src/nsHTMLScriptElement.cpp @@ -327,7 +327,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -372,6 +372,8 @@ public: virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: PRBool IsOnloadEventForWindow(); @@ -486,8 +488,7 @@ nsHTMLScriptElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, } nsresult -nsHTMLScriptElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const +nsHTMLScriptElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; @@ -496,8 +497,8 @@ nsHTMLScriptElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr kungFuDeathGrip = it; - nsresult rv = CopyInnerTo(it, aDeep); + nsCOMPtr kungFuDeathGrip = it; + nsresult rv = CopyInnerTo(it); NS_ENSURE_SUCCESS(rv, rv); // The clone should be marked evaluated if we are. It should also be marked @@ -512,12 +513,6 @@ nsHTMLScriptElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return NS_OK; } -NS_IMETHODIMP -nsHTMLScriptElement::CloneNode(PRBool aDeep, nsIDOMNode **aResult) -{ - return nsGenericElement::CloneNode(aDeep, this, aResult); -} - NS_IMETHODIMP nsHTMLScriptElement::GetText(nsAString& aValue) { diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index 51460d7412b4..bfa4d623ee15 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -231,7 +231,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -283,6 +283,7 @@ public: PRInt32 aModType) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: // Helper Methods @@ -525,7 +526,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLSelectElement -NS_IMPL_DOM_CLONENODE(nsHTMLSelectElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLSelectElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLSharedElement.cpp b/content/html/content/src/nsHTMLSharedElement.cpp index 94b818a659d7..1ac04a1e54c9 100644 --- a/content/html/content/src/nsHTMLSharedElement.cpp +++ b/content/html/content/src/nsHTMLSharedElement.cpp @@ -69,7 +69,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -105,6 +105,8 @@ public: nsAttrValue& aResult); virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -151,7 +153,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_AMBIGOUS_BEGIN(nsHTMLSharedElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE_AMBIGUOUS(nsHTMLSharedElement, nsIDOMHTMLParamElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLSharedElement) // nsIDOMHTMLParamElement NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Name, name) diff --git a/content/html/content/src/nsHTMLSharedObjectElement.cpp b/content/html/content/src/nsHTMLSharedObjectElement.cpp index f94e05e9fddc..5387a63c4745 100644 --- a/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -73,7 +73,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -126,6 +126,8 @@ public: // nsObjectLoadingContent virtual PRUint32 GetCapabilities() const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + private: /** * Calls LoadObject with the correct arguments to start the plugin load. @@ -217,8 +219,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_AMBIGOUS_BEGIN(nsHTMLSharedObjectElement, NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLEmbedElement, embed) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE_AMBIGUOUS(nsHTMLSharedObjectElement, - nsIDOMHTMLAppletElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLSharedObjectElement) nsresult nsHTMLSharedObjectElement::BindToTree(nsIDocument *aDocument, diff --git a/content/html/content/src/nsHTMLSpanElement.cpp b/content/html/content/src/nsHTMLSpanElement.cpp index 9927799fab47..33aa6e626c62 100644 --- a/content/html/content/src/nsHTMLSpanElement.cpp +++ b/content/html/content/src/nsHTMLSpanElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -64,6 +64,8 @@ public: virtual nsresult GetInnerHTML(nsAString& aInnerHTML); virtual nsresult SetInnerHTML(const nsAString& aInnerHTML); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -90,7 +92,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLSpanElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLSpanElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLSpanElement) nsresult @@ -124,9 +126,7 @@ public: nsHTMLUnknownElement(nsINodeInfo *aNodeInfo); NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const; - NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode **aResult); + nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_INTERFACE_MAP_BEGIN(nsHTMLUnknownElement) @@ -142,4 +142,4 @@ nsHTMLUnknownElement::nsHTMLUnknownElement(nsINodeInfo *aNodeInfo) NS_IMPL_NS_NEW_HTML_ELEMENT(Unknown) -NS_IMPL_DOM_CLONENODE(nsHTMLUnknownElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLUnknownElement) diff --git a/content/html/content/src/nsHTMLStyleElement.cpp b/content/html/content/src/nsHTMLStyleElement.cpp index db5e1800aa94..4a9b3775795a 100644 --- a/content/html/content/src/nsHTMLStyleElement.cpp +++ b/content/html/content/src/nsHTMLStyleElement.cpp @@ -63,7 +63,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -96,6 +96,8 @@ public: virtual nsresult GetInnerHTML(nsAString& aInnerHTML); virtual nsresult SetInnerHTML(const nsAString& aInnerHTML); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: void GetStyleSheetURL(PRBool* aIsInline, nsIURI** aURI); @@ -132,7 +134,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLStyleElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLStyleElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLStyleElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLTableCaptionElement.cpp b/content/html/content/src/nsHTMLTableCaptionElement.cpp index 5e6a9859d445..c96b24cf018f 100644 --- a/content/html/content/src/nsHTMLTableCaptionElement.cpp +++ b/content/html/content/src/nsHTMLTableCaptionElement.cpp @@ -54,7 +54,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -71,6 +71,8 @@ public: nsAttrValue& aResult); virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -99,7 +101,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTableCaptionElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTableCaptionElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTableCaptionElement) NS_IMPL_STRING_ATTR(nsHTMLTableCaptionElement, Align, align) diff --git a/content/html/content/src/nsHTMLTableCellElement.cpp b/content/html/content/src/nsHTMLTableCellElement.cpp index 38d3a95d49f1..da53b0f5872b 100644 --- a/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/content/html/content/src/nsHTMLTableCellElement.cpp @@ -57,7 +57,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -76,6 +76,8 @@ public: NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // This does not return a nsresult since all we care about is if we // found the row element that this cell is in or not. @@ -108,7 +110,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTableCellElement, nsGenericHTMLElement NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTableCellElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTableCellElement) // protected method diff --git a/content/html/content/src/nsHTMLTableColElement.cpp b/content/html/content/src/nsHTMLTableColElement.cpp index c02138e60cec..723ef98e1734 100644 --- a/content/html/content/src/nsHTMLTableColElement.cpp +++ b/content/html/content/src/nsHTMLTableColElement.cpp @@ -58,7 +58,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -75,6 +75,8 @@ public: nsAttrValue& aResult); nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -103,7 +105,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTableColElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTableColElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTableColElement) NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Align, align, "left") diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp index 3ee6ba98519e..1ef9e48f5026 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/nsHTMLTableElement.cpp @@ -70,7 +70,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -88,6 +88,8 @@ public: virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: already_AddRefed GetSection(nsIAtom *aTag); @@ -342,7 +344,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTableElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTableElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTableElement) // the DOM spec says border, cellpadding, cellSpacing are all "wstring" diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp index 199d3680a44b..56cc22b3909d 100644 --- a/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/content/html/content/src/nsHTMLTableRowElement.cpp @@ -64,7 +64,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -82,6 +82,8 @@ public: virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsresult GetSection(nsIDOMHTMLTableSectionElement** aSection); nsresult GetTable(nsIDOMHTMLTableElement** aTable); @@ -134,7 +136,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTableRowElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTableRowElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTableRowElement) // protected method diff --git a/content/html/content/src/nsHTMLTableSectionElement.cpp b/content/html/content/src/nsHTMLTableSectionElement.cpp index 68326da1b495..df58d4f079ff 100644 --- a/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -59,7 +59,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -77,6 +77,8 @@ public: virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsRefPtr mRows; }; @@ -102,7 +104,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTableSectionElement, NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTableSectionElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTableSectionElement) NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableSectionElement, Align, align, "left") diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 5833e6827839..f8ab2321ee6b 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -91,7 +91,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) @@ -141,6 +141,8 @@ public: virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsCOMPtr mControllers; /** The current value. This is null if the frame owns the value. */ @@ -208,7 +210,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_END // nsIDOMHTMLTextAreaElement -NS_IMPL_DOM_CLONENODE(nsHTMLTextAreaElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTextAreaElement) NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLTitleElement.cpp b/content/html/content/src/nsHTMLTitleElement.cpp index 573847f13519..24b6d16b3441 100644 --- a/content/html/content/src/nsHTMLTitleElement.cpp +++ b/content/html/content/src/nsHTMLTitleElement.cpp @@ -56,7 +56,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLElement::) + NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) @@ -66,6 +66,8 @@ public: // nsIDOMHTMLTitleElement NS_DECL_NSIDOMHTMLTITLEELEMENT + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; @@ -93,7 +95,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTitleElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_MAP_END -NS_IMPL_DOM_CLONENODE(nsHTMLTitleElement) +NS_IMPL_ELEMENT_CLONE(nsHTMLTitleElement) NS_IMETHODIMP diff --git a/content/svg/content/src/nsSVGCircleElement.cpp b/content/svg/content/src/nsSVGCircleElement.cpp index 398da93b82c8..0323529732c6 100644 --- a/content/svg/content/src/nsSVGCircleElement.cpp +++ b/content/svg/content/src/nsSVGCircleElement.cpp @@ -58,13 +58,15 @@ public: NS_DECL_NSIDOMSVGCIRCLEELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGCircleElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGCircleElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGCircleElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::) // nsSVGPathGeometryElement methods: virtual void ConstructPath(cairo_t *aCtx); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -108,7 +110,7 @@ nsSVGCircleElement::nsSVGCircleElement(nsINodeInfo *aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGCircleElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGCircleElement) //---------------------------------------------------------------------- // nsIDOMSVGCircleElement methods diff --git a/content/svg/content/src/nsSVGClipPathElement.cpp b/content/svg/content/src/nsSVGClipPathElement.cpp index c1c8813e81c1..9e37454c2c90 100644 --- a/content/svg/content/src/nsSVGClipPathElement.cpp +++ b/content/svg/content/src/nsSVGClipPathElement.cpp @@ -58,10 +58,12 @@ public: NS_DECL_NSIDOMSVGCLIPPATHELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGClipPathElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGClipPathElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGClipPathElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGClipPathElementBase::) + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // nsIDOMSVGClipPathElement values @@ -140,5 +142,5 @@ NS_IMETHODIMP nsSVGClipPathElement::GetClipPathUnits(nsIDOMSVGAnimatedEnumeratio //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGClipPathElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGClipPathElement) diff --git a/content/svg/content/src/nsSVGDefsElement.cpp b/content/svg/content/src/nsSVGDefsElement.cpp index b1d63bf10ff3..73e5103fa12b 100644 --- a/content/svg/content/src/nsSVGDefsElement.cpp +++ b/content/svg/content/src/nsSVGDefsElement.cpp @@ -57,13 +57,14 @@ public: NS_DECL_NSIDOMSVGDEFSELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGDefsElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGDefsElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGDefsElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDefsElementBase::) // nsIContent NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; -protected: + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; //////////////////////////////////////////////////////////////////////// @@ -99,7 +100,7 @@ nsSVGDefsElement::nsSVGDefsElement(nsINodeInfo *aNodeInfo) // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGDefsElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDefsElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGDescElement.cpp b/content/svg/content/src/nsSVGDescElement.cpp index 01d5389d700d..b2496035819b 100644 --- a/content/svg/content/src/nsSVGDescElement.cpp +++ b/content/svg/content/src/nsSVGDescElement.cpp @@ -57,9 +57,11 @@ public: NS_DECL_NSIDOMSVGDESCELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGDescElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGDescElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGDescElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDescElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(Desc) @@ -99,5 +101,5 @@ nsSVGDescElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGDescElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDescElement) diff --git a/content/svg/content/src/nsSVGEllipseElement.cpp b/content/svg/content/src/nsSVGEllipseElement.cpp index acd7af458992..d5dc9066a1e0 100644 --- a/content/svg/content/src/nsSVGEllipseElement.cpp +++ b/content/svg/content/src/nsSVGEllipseElement.cpp @@ -59,13 +59,15 @@ public: NS_DECL_NSIDOMSVGELLIPSEELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGEllipseElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGEllipseElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGEllipseElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGEllipseElementBase::) // nsSVGPathGeometryElement methods: virtual void ConstructPath(cairo_t *aCtx); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -110,7 +112,7 @@ nsSVGEllipseElement::nsSVGEllipseElement(nsINodeInfo *aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGEllipseElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGEllipseElement) //---------------------------------------------------------------------- // nsIDOMSVGEllipseElement methods diff --git a/content/svg/content/src/nsSVGFilterElement.cpp b/content/svg/content/src/nsSVGFilterElement.cpp index e71e98330572..230fcbf03488 100644 --- a/content/svg/content/src/nsSVGFilterElement.cpp +++ b/content/svg/content/src/nsSVGFilterElement.cpp @@ -135,7 +135,7 @@ nsSVGFilterElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFilterElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFilterElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGFilterElement.h b/content/svg/content/src/nsSVGFilterElement.h index ec754c57879e..65ed9da338de 100644 --- a/content/svg/content/src/nsSVGFilterElement.h +++ b/content/svg/content/src/nsSVGFilterElement.h @@ -67,7 +67,7 @@ public: NS_DECL_NSIDOMSVGFILTERELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFilterElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFilterElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFilterElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFilterElementBase::) @@ -79,6 +79,8 @@ public: nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index 284ff125bba7..dfced00ebc6f 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -219,12 +219,13 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEGaussianBlurElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFEGaussianBlurElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEGaussianBlurElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFEGaussianBlurElementBase::) virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: virtual NumberAttributesInfo GetNumberInfo(); @@ -289,7 +290,7 @@ nsSVGFEGaussianBlurElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEGaussianBlurElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEGaussianBlurElement) //---------------------------------------------------------------------- @@ -653,7 +654,7 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEComponentTransferElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFEComponentTransferElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEComponentTransferElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFEComponentTransferElementBase::) // nsIContent @@ -661,6 +662,8 @@ public: PRBool aNotify); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsCOMPtr mIn1; @@ -712,7 +715,7 @@ nsSVGFEComponentTransferElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEComponentTransferElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEComponentTransferElement) //---------------------------------------------------------------------- // nsIDOMSVGFEComponentTransferElement methods @@ -1173,10 +1176,10 @@ public: NS_DECL_NSIDOMSVGFEFUNCRELEMENT NS_FORWARD_NSIDOMSVGELEMENT(nsSVGComponentTransferFunctionElement::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGComponentTransferFunctionElement::) + NS_FORWARD_NSIDOMNODE(nsSVGComponentTransferFunctionElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::) -protected: + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncRElement,nsSVGComponentTransferFunctionElement) @@ -1192,7 +1195,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncRElement) NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement) NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncR) -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEFuncRElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncRElement) class nsSVGFEFuncGElement : public nsSVGComponentTransferFunctionElement, @@ -1213,10 +1216,10 @@ public: NS_DECL_NSIDOMSVGFEFUNCGELEMENT NS_FORWARD_NSIDOMSVGELEMENT(nsSVGComponentTransferFunctionElement::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGComponentTransferFunctionElement::) + NS_FORWARD_NSIDOMNODE(nsSVGComponentTransferFunctionElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::) -protected: + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncGElement,nsSVGComponentTransferFunctionElement) @@ -1232,7 +1235,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncGElement) NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement) NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncG) -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEFuncGElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncGElement) class nsSVGFEFuncBElement : public nsSVGComponentTransferFunctionElement, @@ -1253,10 +1256,10 @@ public: NS_DECL_NSIDOMSVGFEFUNCBELEMENT NS_FORWARD_NSIDOMSVGELEMENT(nsSVGComponentTransferFunctionElement::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGComponentTransferFunctionElement::) + NS_FORWARD_NSIDOMNODE(nsSVGComponentTransferFunctionElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::) -protected: + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncBElement,nsSVGComponentTransferFunctionElement) @@ -1272,7 +1275,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncBElement) NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement) NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncB) -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEFuncBElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncBElement) class nsSVGFEFuncAElement : public nsSVGComponentTransferFunctionElement, @@ -1293,10 +1296,10 @@ public: NS_DECL_NSIDOMSVGFEFUNCAELEMENT NS_FORWARD_NSIDOMSVGELEMENT(nsSVGComponentTransferFunctionElement::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGComponentTransferFunctionElement::) + NS_FORWARD_NSIDOMNODE(nsSVGComponentTransferFunctionElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::) -protected: + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncAElement,nsSVGComponentTransferFunctionElement) @@ -1312,7 +1315,7 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncAElement) NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement) NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncA) -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEFuncAElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncAElement) //---------------------Merge------------------------ @@ -1344,7 +1347,7 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEMergeElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFEMergeElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEMergeElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFEMergeElementBase::) // nsIContent @@ -1352,8 +1355,7 @@ public: PRBool aNotify); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); -protected: - + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(FEMerge) @@ -1389,7 +1391,7 @@ nsSVGFEMergeElement::~nsSVGFEMergeElement() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEMergeElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEMergeElement) NS_IMETHODIMP nsSVGFEMergeElement::Filter(nsSVGFilterInstance *instance) @@ -1552,9 +1554,11 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEMergeNodeElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFEMergeNodeElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEMergeNodeElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFEMergeNodeElementBase::) + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsCOMPtr mIn1; }; @@ -1603,7 +1607,7 @@ nsSVGFEMergeNodeElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEMergeNodeElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEMergeNodeElement) NS_IMETHODIMP nsSVGFEMergeNodeElement::WillModifySVGObservable(nsISVGValue* observable, @@ -1679,9 +1683,11 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEOffsetElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFEOffsetElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEOffsetElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFEOffsetElementBase::) + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual NumberAttributesInfo GetNumberInfo(); @@ -1744,7 +1750,7 @@ nsSVGFEOffsetElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEOffsetElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEOffsetElement) //---------------------------------------------------------------------- @@ -1896,11 +1902,10 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEUnimplementedMOZElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGFEUnimplementedMOZElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGFEUnimplementedMOZElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGFEUnimplementedMOZElementBase::) -protected: - + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(FEUnimplementedMOZ) @@ -1936,7 +1941,7 @@ nsSVGFEUnimplementedMOZElement::~nsSVGFEUnimplementedMOZElement() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGFEUnimplementedMOZElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEUnimplementedMOZElement) NS_IMETHODIMP nsSVGFEUnimplementedMOZElement::Filter(nsSVGFilterInstance *instance) diff --git a/content/svg/content/src/nsSVGForeignObjectElement.cpp b/content/svg/content/src/nsSVGForeignObjectElement.cpp index 1739eb68f8bd..ef92e9abe67c 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.cpp +++ b/content/svg/content/src/nsSVGForeignObjectElement.cpp @@ -78,7 +78,7 @@ nsSVGForeignObjectElement::nsSVGForeignObjectElement(nsINodeInfo *aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGForeignObjectElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGForeignObjectElement) //---------------------------------------------------------------------- // nsIDOMSVGForeignObjectElement methods: diff --git a/content/svg/content/src/nsSVGForeignObjectElement.h b/content/svg/content/src/nsSVGForeignObjectElement.h index 802c8a233a13..369b8f35dae7 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.h +++ b/content/svg/content/src/nsSVGForeignObjectElement.h @@ -62,13 +62,15 @@ public: NS_DECL_NSIDOMSVGFOREIGNOBJECTELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGForeignObjectElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGForeignObjectElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGForeignObjectElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::) // nsIContent interface NS_IMETHODIMP_(PRBool) IsAttributeMapped(const nsIAtom* name) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); diff --git a/content/svg/content/src/nsSVGGElement.cpp b/content/svg/content/src/nsSVGGElement.cpp index f940a7457c64..135f530a8286 100644 --- a/content/svg/content/src/nsSVGGElement.cpp +++ b/content/svg/content/src/nsSVGGElement.cpp @@ -57,13 +57,14 @@ public: NS_DECL_NSIDOMSVGGELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGGElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGGElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGGElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGGElementBase::) // nsIContent NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; -protected: + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; //////////////////////////////////////////////////////////////////////// @@ -101,7 +102,7 @@ nsSVGGElement::nsSVGGElement(nsINodeInfo *aNodeInfo) // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGGElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGGElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGGradientElement.cpp b/content/svg/content/src/nsSVGGradientElement.cpp index 81653b0ff06c..8b7db9bb84b6 100644 --- a/content/svg/content/src/nsSVGGradientElement.cpp +++ b/content/svg/content/src/nsSVGGradientElement.cpp @@ -245,7 +245,7 @@ nsSVGLinearGradientElement::nsSVGLinearGradientElement(nsINodeInfo* aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGLinearGradientElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGLinearGradientElement) //---------------------------------------------------------------------- // nsIDOMSVGLinearGradientElement methods @@ -324,7 +324,7 @@ nsSVGRadialGradientElement::nsSVGRadialGradientElement(nsINodeInfo* aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGRadialGradientElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRadialGradientElement) //---------------------------------------------------------------------- // nsIDOMSVGRadialGradientElement methods diff --git a/content/svg/content/src/nsSVGGradientElement.h b/content/svg/content/src/nsSVGGradientElement.h index a3df61f4b72c..79345cde0080 100644 --- a/content/svg/content/src/nsSVGGradientElement.h +++ b/content/svg/content/src/nsSVGGradientElement.h @@ -110,9 +110,11 @@ public: // The Gradient Element base class implements these NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLinearGradientElementBase::) - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGLinearGradientElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGLinearGradientElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGLinearGradientElementBase::) + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -149,10 +151,12 @@ public: NS_DECL_NSIDOMSVGRADIALGRADIENTELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGRadialGradientElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGRadialGradientElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGRadialGradientElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRadialGradientElementBase::) + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); diff --git a/content/svg/content/src/nsSVGImageElement.cpp b/content/svg/content/src/nsSVGImageElement.cpp index 030fc776c333..ae115f4ce910 100644 --- a/content/svg/content/src/nsSVGImageElement.cpp +++ b/content/svg/content/src/nsSVGImageElement.cpp @@ -79,7 +79,7 @@ public: NS_DECL_NSIDOMSVGURIREFERENCE // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGImageElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGImageElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGImageElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGImageElementBase::) @@ -99,6 +99,8 @@ public: // nsSVGPathGeometryElement methods: virtual void ConstructPath(cairo_t *aCtx); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -193,7 +195,7 @@ nsSVGImageElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGImageElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGImageElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGLineElement.cpp b/content/svg/content/src/nsSVGLineElement.cpp index c98f8912ff56..a2a8bef38cef 100644 --- a/content/svg/content/src/nsSVGLineElement.cpp +++ b/content/svg/content/src/nsSVGLineElement.cpp @@ -58,7 +58,7 @@ public: NS_DECL_NSIDOMSVGLINEELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGLineElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGLineElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGLineElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLineElementBase::) @@ -70,6 +70,8 @@ public: virtual void GetMarkPoints(nsTArray *aMarks); virtual void ConstructPath(cairo_t *aCtx); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -114,7 +116,7 @@ nsSVGLineElement::nsSVGLineElement(nsINodeInfo *aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGLineElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGLineElement) //---------------------------------------------------------------------- // nsIDOMSVGLineElement methods diff --git a/content/svg/content/src/nsSVGMarkerElement.cpp b/content/svg/content/src/nsSVGMarkerElement.cpp index 76a56cf0a7a8..3a870112dfd6 100644 --- a/content/svg/content/src/nsSVGMarkerElement.cpp +++ b/content/svg/content/src/nsSVGMarkerElement.cpp @@ -152,7 +152,7 @@ nsSVGMarkerElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGMarkerElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMarkerElement) //---------------------------------------------------------------------- // nsIDOMSVGFitToViewBox methods diff --git a/content/svg/content/src/nsSVGMarkerElement.h b/content/svg/content/src/nsSVGMarkerElement.h index 911d0cdf8695..04cac32c0d6e 100644 --- a/content/svg/content/src/nsSVGMarkerElement.h +++ b/content/svg/content/src/nsSVGMarkerElement.h @@ -64,7 +64,7 @@ public: NS_DECL_NSIDOMSVGFITTOVIEWBOX // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGElement::) + NS_FORWARD_NSIDOMNODE(nsSVGElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGElement::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) @@ -88,6 +88,8 @@ public: nsIDOMSVGMatrix **_retval); nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: void SetParentCoordCtxProvider(nsSVGCoordCtxProvider *aContext); diff --git a/content/svg/content/src/nsSVGMaskElement.cpp b/content/svg/content/src/nsSVGMaskElement.cpp index 7465421c8a1b..54bbce2f09f2 100644 --- a/content/svg/content/src/nsSVGMaskElement.cpp +++ b/content/svg/content/src/nsSVGMaskElement.cpp @@ -121,7 +121,7 @@ nsSVGMaskElement::Init() //---------------------------------------------------------------------- // nsIDOMNode method -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGMaskElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMaskElement) //---------------------------------------------------------------------- // nsIDOMSVGMaskElement methods diff --git a/content/svg/content/src/nsSVGMaskElement.h b/content/svg/content/src/nsSVGMaskElement.h index 258ecfe8d23b..1a465ae431d8 100644 --- a/content/svg/content/src/nsSVGMaskElement.h +++ b/content/svg/content/src/nsSVGMaskElement.h @@ -63,10 +63,12 @@ public: // Mask Element NS_DECL_NSIDOMSVGMASKELEMENT - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGElement::) + NS_FORWARD_NSIDOMNODE(nsSVGElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGElement::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); diff --git a/content/svg/content/src/nsSVGMetadataElement.cpp b/content/svg/content/src/nsSVGMetadataElement.cpp index 1802f5c0f32b..73918eb2950c 100644 --- a/content/svg/content/src/nsSVGMetadataElement.cpp +++ b/content/svg/content/src/nsSVGMetadataElement.cpp @@ -57,9 +57,11 @@ public: NS_DECL_NSIDOMSVGMETADATAELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGElement::) + NS_FORWARD_NSIDOMNODE(nsSVGElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGElement::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(Metadata) @@ -99,4 +101,4 @@ nsSVGMetadataElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGMetadataElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMetadataElement) diff --git a/content/svg/content/src/nsSVGPathElement.cpp b/content/svg/content/src/nsSVGPathElement.cpp index 8ef3806c512c..d4a56f0acb34 100644 --- a/content/svg/content/src/nsSVGPathElement.cpp +++ b/content/svg/content/src/nsSVGPathElement.cpp @@ -86,7 +86,7 @@ nsSVGPathElement::~nsSVGPathElement() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGPathElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPathElement) //---------------------------------------------------------------------- // nsIDOMSVGPathElement methods: diff --git a/content/svg/content/src/nsSVGPathElement.h b/content/svg/content/src/nsSVGPathElement.h index 63d83e8869f7..c84c056cbbcb 100644 --- a/content/svg/content/src/nsSVGPathElement.h +++ b/content/svg/content/src/nsSVGPathElement.h @@ -104,7 +104,7 @@ public: NS_DECL_NSIDOMSVGANIMATEDPATHDATA // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGPathElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGPathElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGPathElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPathElementBase::) @@ -123,6 +123,8 @@ public: virtual nsSVGFlattenedPath *GetFlattenedPath(nsIDOMSVGMatrix *aMatrix); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual NumberAttributesInfo GetNumberInfo(); diff --git a/content/svg/content/src/nsSVGPatternElement.cpp b/content/svg/content/src/nsSVGPatternElement.cpp index 51d01f9a7bdc..bc4bd1a9182b 100644 --- a/content/svg/content/src/nsSVGPatternElement.cpp +++ b/content/svg/content/src/nsSVGPatternElement.cpp @@ -186,7 +186,7 @@ nsSVGPatternElement::Init() //---------------------------------------------------------------------- // nsIDOMNode method -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGPatternElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPatternElement) //---------------------------------------------------------------------- // nsIDOMSVGFitToViewBox methods diff --git a/content/svg/content/src/nsSVGPatternElement.h b/content/svg/content/src/nsSVGPatternElement.h index 0bf924baf90a..1dcbc956b977 100644 --- a/content/svg/content/src/nsSVGPatternElement.h +++ b/content/svg/content/src/nsSVGPatternElement.h @@ -80,13 +80,15 @@ public: // Mutation Observer NS_DECL_NSIMUTATIONOBSERVER - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGElement::) + NS_FORWARD_NSIDOMNODE(nsSVGElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGElement::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) // nsIContent interface NS_IMETHODIMP_(PRBool) IsAttributeMapped(const nsIAtom* name) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: void PushUpdate(); diff --git a/content/svg/content/src/nsSVGPolygonElement.cpp b/content/svg/content/src/nsSVGPolygonElement.cpp index c1cc56208c6f..bff1046da0cf 100644 --- a/content/svg/content/src/nsSVGPolygonElement.cpp +++ b/content/svg/content/src/nsSVGPolygonElement.cpp @@ -56,13 +56,15 @@ public: NS_DECL_NSIDOMSVGPOLYGONELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGPolygonElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGPolygonElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGPolygonElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolygonElementBase::) // nsSVGPathGeometryElement methods: virtual void GetMarkPoints(nsTArray *aMarks); virtual void ConstructPath(cairo_t *aCtx); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(Polygon) @@ -93,7 +95,7 @@ nsSVGPolygonElement::nsSVGPolygonElement(nsINodeInfo* aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGPolygonElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPolygonElement) //---------------------------------------------------------------------- // nsSVGPathGeometryElement methods diff --git a/content/svg/content/src/nsSVGPolylineElement.cpp b/content/svg/content/src/nsSVGPolylineElement.cpp index 5fa2e5833734..76e2909d650f 100644 --- a/content/svg/content/src/nsSVGPolylineElement.cpp +++ b/content/svg/content/src/nsSVGPolylineElement.cpp @@ -56,10 +56,12 @@ public: NS_DECL_NSIDOMSVGPOLYLINEELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGPolylineElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGPolylineElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGPolylineElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolylineElementBase::) + // nsIContent interface + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(Polyline) @@ -90,5 +92,4 @@ nsSVGPolylineElement::nsSVGPolylineElement(nsINodeInfo* aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGPolylineElement) - +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPolylineElement) diff --git a/content/svg/content/src/nsSVGRectElement.cpp b/content/svg/content/src/nsSVGRectElement.cpp index 28c4afa7542e..ae80273010bc 100644 --- a/content/svg/content/src/nsSVGRectElement.cpp +++ b/content/svg/content/src/nsSVGRectElement.cpp @@ -58,13 +58,15 @@ public: NS_DECL_NSIDOMSVGRECTELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGRectElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGRectElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGRectElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::) // nsSVGPathGeometryElement methods: virtual void ConstructPath(cairo_t *aCtx); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -111,7 +113,7 @@ nsSVGRectElement::nsSVGRectElement(nsINodeInfo *aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGRectElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRectElement) //---------------------------------------------------------------------- // nsIDOMSVGRectElement methods diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index 947938c0fa5b..c766127504b4 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -193,7 +193,7 @@ nsSVGSVGElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGSVGElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGSVGElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGSVGElement.h b/content/svg/content/src/nsSVGSVGElement.h index 107d4e97e1f5..1156bf442692 100644 --- a/content/svg/content/src/nsSVGSVGElement.h +++ b/content/svg/content/src/nsSVGSVGElement.h @@ -81,7 +81,7 @@ public: NS_DECL_NSIDOMSVGZOOMANDPAN // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGSVGElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGSVGElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGSVGElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGSVGElementBase::) @@ -116,6 +116,7 @@ public: // public helpers: nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: // nsSVGElement overrides diff --git a/content/svg/content/src/nsSVGScriptElement.cpp b/content/svg/content/src/nsSVGScriptElement.cpp index 32aa2a5e2811..157c324fbb23 100644 --- a/content/svg/content/src/nsSVGScriptElement.cpp +++ b/content/svg/content/src/nsSVGScriptElement.cpp @@ -79,7 +79,7 @@ public: // xxx If xpcom allowed virtual inheritance we wouldn't need to // forward here :-( - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGScriptElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGScriptElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGScriptElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGScriptElementBase::) @@ -103,6 +103,8 @@ public: PRBool aCompileEventHandlers); virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: /** @@ -180,7 +182,7 @@ nsSVGScriptElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGScriptElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGScriptElement) //---------------------------------------------------------------------- // nsIDOMSVGScriptElement methods diff --git a/content/svg/content/src/nsSVGStopElement.cpp b/content/svg/content/src/nsSVGStopElement.cpp index 465d7c4e0fbf..a35ea43ac41b 100644 --- a/content/svg/content/src/nsSVGStopElement.cpp +++ b/content/svg/content/src/nsSVGStopElement.cpp @@ -61,7 +61,7 @@ public: // xxx If xpcom allowed virtual inheritance we wouldn't need to // forward here :-( - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGStopElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGStopElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGStopElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStopElementBase::) @@ -70,6 +70,7 @@ public: PRBool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: @@ -109,7 +110,7 @@ nsSVGStopElement::nsSVGStopElement(nsINodeInfo* aNodeInfo) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGStopElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement) //---------------------------------------------------------------------- // nsIDOMSVGStopElement methods diff --git a/content/svg/content/src/nsSVGStyleElement.cpp b/content/svg/content/src/nsSVGStyleElement.cpp index f36916721549..f88efad3bf42 100644 --- a/content/svg/content/src/nsSVGStyleElement.cpp +++ b/content/svg/content/src/nsSVGStyleElement.cpp @@ -59,7 +59,7 @@ public: NS_DECL_NSIDOMSVGSTYLEELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGStyleElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGStyleElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGStyleElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::) @@ -82,9 +82,12 @@ public: PRBool aNotify); virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and - // NS_IMPL_DOM_CLONENODE_WITH_INIT usable with this class. This should be + // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be // completely optimized away. inline nsresult Init() { @@ -134,7 +137,7 @@ nsSVGStyleElement::nsSVGStyleElement(nsINodeInfo *aNodeInfo) // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGStyleElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGSymbolElement.cpp b/content/svg/content/src/nsSVGSymbolElement.cpp index 3301fc70167f..d61a7c54ba1b 100644 --- a/content/svg/content/src/nsSVGSymbolElement.cpp +++ b/content/svg/content/src/nsSVGSymbolElement.cpp @@ -65,13 +65,15 @@ public: NS_DECL_NSIDOMSVGFITTOVIEWBOX // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGElement::) + NS_FORWARD_NSIDOMNODE(nsSVGElement::) NS_FORWARD_NSIDOMELEMENT(nsSVGElement::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) // nsIContent interface NS_IMETHODIMP_(PRBool) IsAttributeMapped(const nsIAtom* name) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: nsCOMPtr mViewBox; @@ -142,7 +144,7 @@ nsSVGSymbolElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGSymbolElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGSymbolElement) //---------------------------------------------------------------------- // nsIDOMSVGFitToViewBox methods diff --git a/content/svg/content/src/nsSVGTSpanElement.cpp b/content/svg/content/src/nsSVGTSpanElement.cpp index 8c2f7ae7fb44..e4e4248fcb20 100644 --- a/content/svg/content/src/nsSVGTSpanElement.cpp +++ b/content/svg/content/src/nsSVGTSpanElement.cpp @@ -70,7 +70,7 @@ public: // xxx If xpcom allowed virtual inheritance we wouldn't need to // forward here :-( - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGTSpanElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGTSpanElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGTSpanElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTSpanElementBase::) @@ -80,6 +80,8 @@ public: // nsISVGContent specializations: virtual void ParentChainChanged(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: // nsSVGElement overrides virtual PRBool IsEventName(nsIAtom* aName); @@ -187,7 +189,7 @@ nsSVGTSpanElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGTSpanElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTSpanElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGTextElement.cpp b/content/svg/content/src/nsSVGTextElement.cpp index 64f00dee05b6..8be20549ec21 100644 --- a/content/svg/content/src/nsSVGTextElement.cpp +++ b/content/svg/content/src/nsSVGTextElement.cpp @@ -70,7 +70,7 @@ public: // xxx If xpcom allowed virtual inheritance we wouldn't need to // forward here :-( - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGTextElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGTextElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGTextElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTextElementBase::) @@ -80,6 +80,8 @@ public: // nsISVGContent specializations: virtual void ParentChainChanged(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: already_AddRefed GetTextContentMetrics(); @@ -184,7 +186,7 @@ nsSVGTextElement::Init() // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGTextElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTextElement) //---------------------------------------------------------------------- diff --git a/content/svg/content/src/nsSVGTextPathElement.cpp b/content/svg/content/src/nsSVGTextPathElement.cpp index dc190dc19574..d14af743c2b3 100644 --- a/content/svg/content/src/nsSVGTextPathElement.cpp +++ b/content/svg/content/src/nsSVGTextPathElement.cpp @@ -69,13 +69,15 @@ public: // xxx If xpcom allowed virtual inheritance we wouldn't need to // forward here :-( - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGTextPathElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGTextPathElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGTextPathElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTextPathElementBase::) // nsIContent interface NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -186,7 +188,7 @@ nsSVGTextPathElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGTextPathElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTextPathElement) //---------------------------------------------------------------------- // nsIDOMSVGURIReference methods diff --git a/content/svg/content/src/nsSVGTitleElement.cpp b/content/svg/content/src/nsSVGTitleElement.cpp index 05ef7d0c4df5..ae4c8d42ab03 100644 --- a/content/svg/content/src/nsSVGTitleElement.cpp +++ b/content/svg/content/src/nsSVGTitleElement.cpp @@ -57,9 +57,11 @@ public: NS_DECL_NSIDOMSVGTITLEELEMENT // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGTitleElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGTitleElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGTitleElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; }; NS_IMPL_NS_NEW_SVG_ELEMENT(Title) @@ -99,5 +101,5 @@ nsSVGTitleElement::Init() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_DOM_CLONENODE_WITH_INIT(nsSVGTitleElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement) diff --git a/content/svg/content/src/nsSVGUseElement.cpp b/content/svg/content/src/nsSVGUseElement.cpp index 8ea27a9d76ee..238764b39254 100644 --- a/content/svg/content/src/nsSVGUseElement.cpp +++ b/content/svg/content/src/nsSVGUseElement.cpp @@ -86,7 +86,7 @@ public: NS_DECL_NSIMUTATIONOBSERVER // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsSVGUseElementBase::) + NS_FORWARD_NSIDOMNODE(nsSVGUseElementBase::) NS_FORWARD_NSIDOMELEMENT(nsSVGUseElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGUseElementBase::) @@ -104,6 +104,8 @@ public: // nsSVGElement specializations: virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual LengthAttributesInfo GetLengthInfo(); @@ -196,8 +198,7 @@ nsSVGUseElement::Init() // nsIDOMNode methods nsresult -nsSVGUseElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const +nsSVGUseElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; @@ -206,9 +207,9 @@ nsSVGUseElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr kungFuDeathGrip(it); + nsCOMPtr kungFuDeathGrip(it); nsresult rv = it->Init(); - rv |= CopyInnerTo(it, aDeep); + rv |= CopyInnerTo(it); // nsSVGUseElement specific portion - record who we cloned from it->mOriginal = NS_CONST_CAST(nsSVGUseElement*, this); @@ -220,12 +221,6 @@ nsSVGUseElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return rv; } -NS_IMETHODIMP -nsSVGUseElement::CloneNode(PRBool aDeep, nsIDOMNode **aResult) -{ - return nsGenericElement::CloneNode(aDeep, this, aResult); -} - //---------------------------------------------------------------------- // nsIDOMSVGURIReference methods @@ -402,9 +397,12 @@ nsSVGUseElement::CreateAnonymousContent(nsPresContext* aPresContext, } } - nsCOMPtr newcontent; - targetContent->CloneContent(mNodeInfo->NodeInfoManager(), PR_TRUE, - getter_AddRefs(newcontent)); + nsCOMPtr newnode; + nsCOMArray unused; + nsNodeUtils::Clone(targetContent, PR_TRUE, nsnull, unused, + getter_AddRefs(newnode)); + + nsCOMPtr newcontent = do_QueryInterface(newnode); if (!newcontent) return NS_ERROR_FAILURE; diff --git a/content/xml/content/src/nsXMLCDATASection.cpp b/content/xml/content/src/nsXMLCDATASection.cpp index de9087e52d4d..702a6f72746f 100644 --- a/content/xml/content/src/nsXMLCDATASection.cpp +++ b/content/xml/content/src/nsXMLCDATASection.cpp @@ -152,7 +152,7 @@ nsXMLCDATASection::GetNodeType(PRUint16* aNodeType) } nsGenericDOMDataNode* -nsXMLCDATASection::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const +nsXMLCDATASection::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { nsXMLCDATASection *it = new nsXMLCDATASection(aNodeInfo); if (it && aCloneText) { diff --git a/content/xml/content/src/nsXMLElement.cpp b/content/xml/content/src/nsXMLElement.cpp index a768b7789334..508a213fddf5 100644 --- a/content/xml/content/src/nsXMLElement.cpp +++ b/content/xml/content/src/nsXMLElement.cpp @@ -385,4 +385,4 @@ nsXMLElement::IsFocusable(PRInt32 *aTabIndex) } -NS_IMPL_DOM_CLONENODE(nsXMLElement) +NS_IMPL_ELEMENT_CLONE(nsXMLElement) diff --git a/content/xml/content/src/nsXMLElement.h b/content/xml/content/src/nsXMLElement.h index a6e586ed5221..8ca3e1b407ce 100644 --- a/content/xml/content/src/nsXMLElement.h +++ b/content/xml/content/src/nsXMLElement.h @@ -60,7 +60,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericElement::) + NS_FORWARD_NSIDOMNODE(nsGenericElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericElement::) @@ -80,6 +80,8 @@ public: virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: PRBool mIsLink; }; diff --git a/content/xml/content/src/nsXMLProcessingInstruction.cpp b/content/xml/content/src/nsXMLProcessingInstruction.cpp index 83784483dd6d..d06fc0831f6d 100644 --- a/content/xml/content/src/nsXMLProcessingInstruction.cpp +++ b/content/xml/content/src/nsXMLProcessingInstruction.cpp @@ -170,8 +170,8 @@ nsXMLProcessingInstruction::GetNodeType(PRUint16* aNodeType) } nsGenericDOMDataNode* -nsXMLProcessingInstruction::Clone(nsINodeInfo *aNodeInfo, - PRBool aCloneText) const +nsXMLProcessingInstruction::CloneDataNode(nsINodeInfo *aNodeInfo, + PRBool aCloneText) const { nsAutoString data; nsGenericDOMDataNode::GetData(data); diff --git a/content/xml/content/src/nsXMLStylesheetPI.cpp b/content/xml/content/src/nsXMLStylesheetPI.cpp index d557219a1a9a..531b5033c429 100644 --- a/content/xml/content/src/nsXMLStylesheetPI.cpp +++ b/content/xml/content/src/nsXMLStylesheetPI.cpp @@ -78,8 +78,8 @@ protected: nsAString& aType, nsAString& aMedia, PRBool* aIsAlternate); - virtual nsGenericDOMDataNode* Clone(nsINodeInfo *aNodeInfo, - PRBool aCloneText) const; + virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, + PRBool aCloneText) const; }; // nsISupports implementation @@ -230,7 +230,7 @@ nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle, } nsGenericDOMDataNode* -nsXMLStylesheetPI::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const +nsXMLStylesheetPI::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { nsAutoString data; nsGenericDOMDataNode::GetData(data); diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp index 3ebde2ea918f..12d907d5270f 100644 --- a/content/xml/document/src/nsXMLDocument.cpp +++ b/content/xml/document/src/nsXMLDocument.cpp @@ -91,9 +91,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIDOMUserDataHandler.h" #include "nsEventDispatcher.h" - -// XXX The XML world depends on the html atoms -#include "nsHTMLAtoms.h" +#include "nsNodeUtils.h" // ================================================================== @@ -662,76 +660,7 @@ nsXMLDocument::IsLoadedAsData() NS_IMETHODIMP nsXMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) { - NS_ENSURE_ARG_POINTER(aReturn); - *aReturn = nsnull; - - nsresult rv; - nsCOMPtr docType, newDocType; - nsCOMPtr newDoc; - - // Get the doctype prior to new document construction. There's no big - // advantage now to dealing with the doctype separately, but maybe one - // day we'll do something significant with the doctype on document creation. - GetDoctype(getter_AddRefs(docType)); - if (docType) { - nsCOMPtr newDocTypeNode; - rv = docType->CloneNode(PR_TRUE, getter_AddRefs(newDocTypeNode)); - if (NS_FAILED(rv)) return rv; - newDocType = do_QueryInterface(newDocTypeNode); - } - - // Create an empty document - rv = NS_NewDOMDocument(getter_AddRefs(newDoc), EmptyString(), EmptyString(), - newDocType, nsIDocument::GetDocumentURI(), - nsIDocument::GetBaseURI(), NodePrincipal()); - if (NS_FAILED(rv)) return rv; - - if (aDeep) { - // If there was a doctype, a new one has already been inserted into the - // new document. We might have to add nodes before it. - PRBool beforeDocType = (docType.get() != nsnull); - nsCOMPtr childNodes; - - GetChildNodes(getter_AddRefs(childNodes)); - if (childNodes) { - PRUint32 index, count; - childNodes->GetLength(&count); - for (index=0; index < count; index++) { - nsCOMPtr child; - childNodes->Item(index, getter_AddRefs(child)); - if (child && (child != docType)) { - nsCOMPtr newChild; - rv = child->CloneNode(aDeep, getter_AddRefs(newChild)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr dummyNode; - if (beforeDocType) { - rv = newDoc->InsertBefore(newChild, - docType, - getter_AddRefs(dummyNode)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - } - else { - rv = newDoc->AppendChild(newChild, - getter_AddRefs(dummyNode)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - } - } - else { - beforeDocType = PR_FALSE; - } - } - } - } - - rv = CallQueryInterface(newDoc, aReturn); - if (NS_SUCCEEDED(rv) && HasProperties()) { - nsContentUtils::CallUserDataHandler(this, - nsIDOMUserDataHandler::NODE_CLONED, - this, this, *aReturn); - } - - return rv; + return nsNodeUtils::CloneNodeImpl(this, aDeep, aReturn); } // nsIDOMDocument interface @@ -765,3 +694,19 @@ nsXMLDocument::GetElementById(const nsAString& aElementId, return CallQueryInterface(content, aReturn); } + +nsresult +nsXMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const +{ + NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager, + "Can't import this document into another document!"); + + nsCOMPtr newDoc; + nsresult rv = NS_NewDOMDocument(getter_AddRefs(newDoc), EmptyString(), + EmptyString(), nsnull, + nsIDocument::GetDocumentURI(), + nsIDocument::GetBaseURI(), NodePrincipal()); + NS_ENSURE_SUCCESS(rv, rv); + + return CallQueryInterface(newDoc, aResult); +} diff --git a/content/xml/document/src/nsXMLDocument.h b/content/xml/document/src/nsXMLDocument.h index 5afd9ab3b05a..514dee0202c7 100644 --- a/content/xml/document/src/nsXMLDocument.h +++ b/content/xml/document/src/nsXMLDocument.h @@ -94,6 +94,8 @@ public: virtual nsresult Init(); + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + protected: virtual nsresult GetLoadGroup(nsILoadGroup **aLoadGroup); diff --git a/content/xtf/src/nsXTFElementWrapper.cpp b/content/xtf/src/nsXTFElementWrapper.cpp index 5284f6e2fae9..aaccc015677a 100644 --- a/content/xtf/src/nsXTFElementWrapper.cpp +++ b/content/xtf/src/nsXTFElementWrapper.cpp @@ -492,8 +492,7 @@ nsXTFElementWrapper::IntrinsicState() const } nsresult -nsXTFElementWrapper::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const +nsXTFElementWrapper::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; nsCOMPtr it; @@ -505,7 +504,7 @@ nsXTFElementWrapper::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, nsXTFElementWrapper* wrapper = NS_STATIC_CAST(nsXTFElementWrapper*, NS_STATIC_CAST(nsIContent*, it.get())); - nsresult rv = CopyInnerTo(wrapper, aDeep); + nsresult rv = CopyInnerTo(wrapper); if (NS_SUCCEEDED(rv)) { if (mAttributeHandler) { @@ -521,7 +520,7 @@ nsXTFElementWrapper::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, } } } - it.swap(*aResult); + NS_ADDREF(*aResult = it); } // XXX CloneState should take |const nIDOMElement*| diff --git a/content/xtf/src/nsXTFElementWrapper.h b/content/xtf/src/nsXTFElementWrapper.h index 61ae6c81d65d..c23ce2687ecd 100644 --- a/content/xtf/src/nsXTFElementWrapper.h +++ b/content/xtf/src/nsXTFElementWrapper.h @@ -128,8 +128,7 @@ public: { return GetXTFElement()->CloneState(aElement); } - nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const; + nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: // to be implemented by subclasses: diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 54dfc3c6b727..e901fb32693e 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -437,8 +437,7 @@ nsXULElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) // nsIDOMNode interface nsresult -nsXULElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, - nsIContent **aResult) const +nsXULElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; @@ -484,7 +483,7 @@ nsXULElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, // Note that we're _not_ copying mControllers. - nsresult rv = CopyInnerTo(element, aDeep); + nsresult rv = CopyInnerTo(element); if (NS_SUCCEEDED(rv)) { NS_ADDREF(*aResult = element); } @@ -498,12 +497,6 @@ nsXULElement::Clone(nsINodeInfo *aNodeInfo, PRBool aDeep, return rv; } -NS_IMETHODIMP -nsXULElement::CloneNode(PRBool aDeep, nsIDOMNode **aResult) -{ - return nsGenericElement::CloneNode(aDeep, this, aResult); -} - //---------------------------------------------------------------------- NS_IMETHODIMP diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 47791caf21f8..c66867cf31b5 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -549,7 +549,7 @@ public: { return GetFlags() & (aFlag << XUL_ELEMENT_LAZY_STATE_OFFSET); } // nsIDOMNode - NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericElement::) + NS_FORWARD_NSIDOMNODE(nsGenericElement::) // nsIDOMElement NS_FORWARD_NSIDOMELEMENT(nsGenericElement::) @@ -571,6 +571,7 @@ public: // nsIChromeEventHandler NS_DECL_NSICHROMEEVENTHANDLER + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: nsXULElement(nsINodeInfo* aNodeInfo);