diff --git a/content/base/public/nsContentCreatorFunctions.h b/content/base/public/nsContentCreatorFunctions.h index f31e9baeed29..b4c7255ce8e7 100644 --- a/content/base/public/nsContentCreatorFunctions.h +++ b/content/base/public/nsContentCreatorFunctions.h @@ -58,7 +58,7 @@ class nsNodeInfoManager; class nsGenericHTMLElement; nsresult -NS_NewElement(nsIContent** aResult, PRInt32 aElementType, +NS_NewElement(nsIContent** aResult, already_AddRefed aNodeInfo, mozilla::dom::FromParser aFromParser); diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 8915d789ec7d..a3fa55c43ef4 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -4421,9 +4421,7 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI, getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); - PRInt32 ns = nodeInfo->NamespaceID(); - return NS_NewElement(aReturn, ns, - nodeInfo.forget(), NOT_FROM_PARSER); + return NS_NewElement(aReturn, nodeInfo.forget(), NOT_FROM_PARSER); } NS_IMETHODIMP @@ -6754,8 +6752,7 @@ nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix, PRInt32 aNamesp getter_AddRefs(nodeInfo)); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); - return NS_NewElement(aResult, aNamespaceID, nodeInfo.forget(), - NOT_FROM_PARSER); + return NS_NewElement(aResult, nodeInfo.forget(), NOT_FROM_PARSER); } bool diff --git a/content/base/src/nsNameSpaceManager.cpp b/content/base/src/nsNameSpaceManager.cpp index e174563a0701..4e681d92d71f 100644 --- a/content/base/src/nsNameSpaceManager.cpp +++ b/content/base/src/nsNameSpaceManager.cpp @@ -224,28 +224,29 @@ NameSpaceManagerImpl::GetNameSpaceID(const nsAString& aURI) } nsresult -NS_NewElement(nsIContent** aResult, PRInt32 aElementType, +NS_NewElement(nsIContent** aResult, already_AddRefed aNodeInfo, FromParser aFromParser) { - if (aElementType == kNameSpaceID_XHTML) { + PRInt32 ns = aNodeInfo.get()->NamespaceID(); + if (ns == kNameSpaceID_XHTML) { return NS_NewHTMLElement(aResult, aNodeInfo, aFromParser); } #ifdef MOZ_XUL - if (aElementType == kNameSpaceID_XUL) { + if (ns == kNameSpaceID_XUL) { return NS_NewXULElement(aResult, aNodeInfo); } #endif - if (aElementType == kNameSpaceID_MathML) { + if (ns == kNameSpaceID_MathML) { return NS_NewMathMLElement(aResult, aNodeInfo); } - if (aElementType == kNameSpaceID_SVG) { + if (ns == kNameSpaceID_SVG) { return NS_NewSVGElement(aResult, aNodeInfo, aFromParser); } - if (aElementType == kNameSpaceID_XMLEvents) { + if (ns == kNameSpaceID_XMLEvents) { return NS_NewXMLEventsElement(aResult, aNodeInfo); } #ifdef MOZ_XTF - if (aElementType > kNameSpaceID_LastBuiltin) { + if (ns > kNameSpaceID_LastBuiltin) { nsIXTFService* xtfService = nsContentUtils::GetXTFService(); NS_ASSERTION(xtfService, "could not get xtf service"); if (xtfService && diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index e709e59a6eef..d045306c39a5 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -78,12 +78,11 @@ #include "nsXBLResourceLoader.h" #include "mozilla/dom/Element.h" -using namespace mozilla; - #ifdef MOZ_XUL #include "nsXULElement.h" #endif +using namespace mozilla; using namespace mozilla::dom; // Helper Classes ===================================================================== @@ -1904,9 +1903,7 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream, } else { #endif - nsCOMPtr ni = nodeInfo; - NS_NewElement(getter_AddRefs(content), nodeInfo->NamespaceID(), - ni.forget(), mozilla::dom::NOT_FROM_PARSER); + NS_NewElement(getter_AddRefs(content), nodeInfo.forget(), NOT_FROM_PARSER); for (PRUint32 i = 0; i < attrCount; i++) { rv = ReadNamespace(aStream, namespaceID); diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index f811fe09e788..c5af9edc15e2 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -497,8 +497,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, nsCOMPtr ni = aNodeInfo; nsCOMPtr content; - rv = NS_NewElement(getter_AddRefs(content), aNodeInfo->NamespaceID(), - ni.forget(), aFromParser); + rv = NS_NewElement(getter_AddRefs(content), ni.forget(), aFromParser); NS_ENSURE_SUCCESS(rv, rv); if (aNodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_XHTML) diff --git a/content/xslt/src/xslt/txMozillaXMLOutput.cpp b/content/xslt/src/xslt/txMozillaXMLOutput.cpp index 4f5bfd57cf50..1755e5ef6722 100644 --- a/content/xslt/src/xslt/txMozillaXMLOutput.cpp +++ b/content/xslt/src/xslt/txMozillaXMLOutput.cpp @@ -555,12 +555,12 @@ txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix, mOpenedElementIsHTML = false; // Create the element - nsCOMPtr ni; - ni = mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID, - nsIDOMNode::ELEMENT_NODE); + nsCOMPtr ni = + mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID, + nsIDOMNode::ELEMENT_NODE); NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY); - NS_NewElement(getter_AddRefs(mOpenedElement), aNsID, ni.forget(), + NS_NewElement(getter_AddRefs(mOpenedElement), ni.forget(), mCreatingNewDocument ? FROM_PARSER_XSLT : FROM_PARSER_FRAGMENT); diff --git a/content/xul/content/src/nsXULContextMenuBuilder.cpp b/content/xul/content/src/nsXULContextMenuBuilder.cpp index 4df7292b1f16..cdb4202fef12 100644 --- a/content/xul/content/src/nsXULContextMenuBuilder.cpp +++ b/content/xul/content/src/nsXULContextMenuBuilder.cpp @@ -39,6 +39,8 @@ #include "nsIDOMHTMLMenuItemElement.h" #include "nsXULContextMenuBuilder.h" +using namespace mozilla; +using namespace mozilla::dom; nsXULContextMenuBuilder::nsXULContextMenuBuilder() : mCurrentGeneratedItemId(0) @@ -247,8 +249,7 @@ nsXULContextMenuBuilder::CreateElement(nsIAtom* aTag, aTag, nsnull, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); - nsresult rv = NS_NewElement(aResult, kNameSpaceID_XUL, nodeInfo.forget(), - mozilla::dom::NOT_FROM_PARSER); + nsresult rv = NS_NewElement(aResult, nodeInfo.forget(), NOT_FROM_PARSER); if (NS_FAILED(rv)) { return rv; } diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index fe6846cd10c2..4175a4bed355 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -3703,9 +3703,8 @@ nsXULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype, nsIDOMNode::ELEMENT_NODE); if (!newNodeInfo) return NS_ERROR_OUT_OF_MEMORY; nsCOMPtr content; - PRInt32 ns = newNodeInfo->NamespaceID(); nsCOMPtr xtfNi = newNodeInfo; - rv = NS_NewElement(getter_AddRefs(content), ns, newNodeInfo.forget(), + rv = NS_NewElement(getter_AddRefs(content), newNodeInfo.forget(), NOT_FROM_PARSER); if (NS_FAILED(rv)) return rv; diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 88f23be62a5f..d158b50e5a44 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1399,20 +1399,17 @@ nsXULContentBuilder::CreateElement(PRInt32 aNameSpaceID, if (! doc) return NS_ERROR_NOT_INITIALIZED; - nsresult rv; nsCOMPtr result; + nsCOMPtr nodeInfo = + doc->NodeInfoManager()->GetNodeInfo(aTag, nsnull, aNameSpaceID, + nsIDOMNode::ELEMENT_NODE); - nsCOMPtr nodeInfo; - nodeInfo = doc->NodeInfoManager()->GetNodeInfo(aTag, nsnull, aNameSpaceID, - nsIDOMNode::ELEMENT_NODE); - - rv = NS_NewElement(getter_AddRefs(result), aNameSpaceID, nodeInfo.forget(), - NOT_FROM_PARSER); + nsresult rv = NS_NewElement(getter_AddRefs(result), nodeInfo.forget(), + NOT_FROM_PARSER); if (NS_FAILED(rv)) return rv; - *aResult = result; - NS_ADDREF(*aResult); + result.forget(aResult); return NS_OK; } diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index bfae5c444a6b..4e709e292a8e 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -386,7 +386,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder, GetNodeInfo(name, nsnull, ns, nsIDOMNode::ELEMENT_NODE); NS_ASSERTION(nodeInfo, "Got null nodeinfo."); NS_NewElement(getter_AddRefs(newContent), - ns, nodeInfo.forget(), + nodeInfo.forget(), (mOpCode == eTreeOpCreateElementNetwork ? dom::FROM_PARSER_NETWORK : (aBuilder->IsFragmentMode() ? @@ -431,7 +431,6 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder, nsCOMPtr optionElt; nsCOMPtr ni = optionNodeInfo; NS_NewElement(getter_AddRefs(optionElt), - optionNodeInfo->NamespaceID(), ni.forget(), (mOpCode == eTreeOpCreateElementNetwork ? dom::FROM_PARSER_NETWORK