Bug 945572 part 5. Make NS_NewSVGElement take an Element** outparam instead of an nsIContent** one. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 03 Dec 2013 09:40:11 -0500
changeset 174210 15480b9592fcc84c760bd84dc052ba0ea89b5d50
parent 174209 fb6538f6d647f4768e2381c5263be6e5ada7064a
child 174211 6b17d20681a58615f4f8ce0b65b40327ecfb780d
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs945572
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 945572 part 5. Make NS_NewSVGElement take an Element** outparam instead of an nsIContent** one. r=smaug
content/base/public/nsContentCreatorFunctions.h
content/base/src/nsNameSpaceManager.cpp
content/svg/content/src/SVGElementFactory.cpp
content/svg/content/src/nsSVGElement.cpp
content/svg/content/src/nsSVGElement.h
--- a/content/base/public/nsContentCreatorFunctions.h
+++ b/content/base/public/nsContentCreatorFunctions.h
@@ -57,17 +57,18 @@ nsresult
 NS_NewXULElement(mozilla::dom::Element** aResult,
                  already_AddRefed<nsINodeInfo> aNodeInfo);
 
 void
 NS_TrustedNewXULElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo);
 #endif
 
 nsresult
-NS_NewSVGElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
+NS_NewSVGElement(mozilla::dom::Element** aResult,
+                 already_AddRefed<nsINodeInfo> aNodeInfo,
                  mozilla::dom::FromParser aFromParser);
 
 nsresult
 NS_NewGenConImageContent(nsIContent** aResult,
                          already_AddRefed<nsINodeInfo> aNodeInfo,
                          imgRequestProxy* aImageRequest);
 
 #endif // nsContentCreatorFunctions_h__
--- a/content/base/src/nsNameSpaceManager.cpp
+++ b/content/base/src/nsNameSpaceManager.cpp
@@ -209,17 +209,20 @@ NS_NewElement(nsIContent** aResult,
 #endif
   if (ns == kNameSpaceID_MathML) {
     nsCOMPtr<Element> el;
     nsresult rv = NS_NewMathMLElement(getter_AddRefs(el), aNodeInfo);
     el.forget(aResult);
     return rv;
   }
   if (ns == kNameSpaceID_SVG) {
-    return NS_NewSVGElement(aResult, aNodeInfo, aFromParser);
+    nsCOMPtr<Element> el;
+    nsresult rv = NS_NewSVGElement(getter_AddRefs(el), aNodeInfo, aFromParser);
+    el.forget(aResult);
+    return rv;
   }
   if (ns == kNameSpaceID_XBL && aNodeInfo.get()->Equals(nsGkAtoms::children)) {
     NS_ADDREF(*aResult = new XBLChildrenElement(aNodeInfo));
     return NS_OK;
   }
 
   nsCOMPtr<Element> el;
   nsresult rv = NS_NewXMLElement(getter_AddRefs(el), aNodeInfo);
--- a/content/svg/content/src/SVGElementFactory.cpp
+++ b/content/svg/content/src/SVGElementFactory.cpp
@@ -38,17 +38,17 @@ nsresult \
 NS_NewSVG##_classname##Element(nsIContent** aResult, \
                                already_AddRefed<nsINodeInfo> aNodeInfo, \
                                FromParser aFromParser);
 #include "SVGTagList.h"
 #undef SVG_TAG
 #undef SVG_FROM_PARSER_TAG
 
 nsresult
-NS_NewSVGElement(nsIContent** aResult,
+NS_NewSVGElement(Element** aResult,
                  already_AddRefed<nsINodeInfo> aNodeInfo);
 
 typedef nsresult
   (*contentCreatorCallback)(nsIContent** aResult,
                             already_AddRefed<nsINodeInfo> aNodeInfo,
                             FromParser aFromParser);
 
 static const contentCreatorCallback sContentCreatorCallbacks[] = {
@@ -98,17 +98,17 @@ SVGElementFactory::Shutdown()
 {
   if (sTagAtomTable) {
     PL_HashTableDestroy(sTagAtomTable);
     sTagAtomTable = nullptr;
   }
 }
 
 nsresult
-NS_NewSVGElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
+NS_NewSVGElement(Element** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
                  FromParser aFromParser)
 {
   NS_ASSERTION(sTagAtomTable, "no lookup table, needs SVGElementFactory::Init");
 
   nsIAtom* name = aNodeInfo.get()->NameAtom();
 
   NS_ASSERTION(aNodeInfo.get()->NamespaceEquals(kNameSpaceID_SVG), 
                "Trying to create SVG elements that aren't in the SVG namespace");
@@ -118,14 +118,17 @@ NS_NewSVGElement(nsIContent** aResult, a
     int32_t index = NS_PTR_TO_INT32(tag) - TABLE_VALUE_OFFSET;
     if (index < 0 || index >= eSVGTag_Count) {
       NS_WARNING("About to index out of array bounds - crashing instead");
       MOZ_CRASH();
     }
 
     contentCreatorCallback cb = sContentCreatorCallbacks[index];
 
-    return cb(aResult, aNodeInfo, aFromParser);
+    nsCOMPtr<nsIContent> content;
+    nsresult rv = cb(getter_AddRefs(content), aNodeInfo, aFromParser);
+    *aResult = content.forget().get()->AsElement();
+    return rv;
   }
 
   // if we don't know what to create, just create a standard svg element:
   return NS_NewSVGElement(aResult, aNodeInfo);
 }
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -56,17 +56,17 @@ using namespace mozilla::dom;
 // This is needed to ensure correct handling of calls to the
 // vararg-list methods in this file:
 //   nsSVGElement::GetAnimated{Length,Number,Integer}Values
 // See bug 547964 for details:
 static_assert(sizeof(void*) == sizeof(nullptr),
               "nullptr should be the correct size");
 
 nsresult
-NS_NewSVGElement(nsIContent **aResult, already_AddRefed<nsINodeInfo> aNodeInfo) 
+NS_NewSVGElement(Element **aResult, already_AddRefed<nsINodeInfo> aNodeInfo) 
 {
   nsRefPtr<nsSVGElement> it = new nsSVGElement(aNodeInfo);
   nsresult rv = it->Init();
 
   if (NS_FAILED(rv)) {
     return rv;
   }
 
--- a/content/svg/content/src/nsSVGElement.h
+++ b/content/svg/content/src/nsSVGElement.h
@@ -64,17 +64,17 @@ struct nsSVGEnumMapping;
 
 typedef nsStyledElementNotElementCSSInlineStyle nsSVGElementBase;
 
 class nsSVGElement : public nsSVGElementBase    // nsIContent
                    , public nsIDOMSVGElement
 {
 protected:
   nsSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  friend nsresult NS_NewSVGElement(nsIContent **aResult,
+  friend nsresult NS_NewSVGElement(mozilla::dom::Element **aResult,
                                    already_AddRefed<nsINodeInfo> aNodeInfo);
   nsresult Init();
   virtual ~nsSVGElement(){}
 
 public:
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;