Bug 855412 - Change the signature of NS_NewSVGRect to not use the outparam. r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-04-18 07:40:09 -04:00
parent 8e4e3ebabe
commit 1b1855494c
5 changed files with 16 additions and 26 deletions

View File

@ -38,21 +38,19 @@ NS_INTERFACE_MAP_END
////////////////////////////////////////////////////////////////////////
// Exported creation functions:
nsresult
NS_NewSVGRect(mozilla::dom::SVGRect** result, float x, float y,
float width, float height)
already_AddRefed<mozilla::dom::SVGRect>
NS_NewSVGRect(float x, float y, float width, float height)
{
*result = new mozilla::dom::SVGRect(x, y, width, height);
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*result);
return NS_OK;
nsRefPtr<mozilla::dom::SVGRect> rect =
new mozilla::dom::SVGRect(x, y, width, height);
return rect.forget();
}
nsresult
NS_NewSVGRect(mozilla::dom::SVGRect** result, const gfxRect& rect)
already_AddRefed<mozilla::dom::SVGRect>
NS_NewSVGRect(const gfxRect& rect)
{
return NS_NewSVGRect(result,
rect.X(), rect.Y(),
return NS_NewSVGRect(rect.X(), rect.Y(),
rect.Width(), rect.Height());
}

View File

@ -76,12 +76,10 @@ protected:
} // namespace dom
} // namespace mozilla
nsresult
NS_NewSVGRect(mozilla::dom::SVGRect** result,
float x=0.0f, float y=0.0f,
float width=0.0f, float height=0.0f);
already_AddRefed<mozilla::dom::SVGRect>
NS_NewSVGRect(float x=0.0f, float y=0.0f, float width=0.0f, float height=0.0f);
nsresult
NS_NewSVGRect(mozilla::dom::SVGRect** result, const gfxRect& rect);
already_AddRefed<mozilla::dom::SVGRect>
NS_NewSVGRect(const gfxRect& rect);
#endif //mozilla_dom_SVGRect_h

View File

@ -411,9 +411,7 @@ SVGSVGElement::CreateSVGMatrix()
already_AddRefed<SVGIRect>
SVGSVGElement::CreateSVGRect()
{
nsRefPtr<SVGRect> rect;
NS_NewSVGRect(getter_AddRefs(rect));
return rect.forget();
return NS_NewSVGRect();
}
already_AddRefed<SVGTransform>

View File

@ -173,9 +173,7 @@ SVGTransformableElement::GetBBox(ErrorResult& rv)
return nullptr;
}
nsRefPtr<SVGRect> rect;
rv = NS_NewSVGRect(getter_AddRefs(rect), nsSVGUtils::GetBBox(frame));
return rect.forget();
return NS_NewSVGRect(nsSVGUtils::GetBBox(frame));
}
already_AddRefed<SVGMatrix>

View File

@ -1285,9 +1285,7 @@ nsSVGGlyphFrame::GetExtentOfChar(uint32_t charnum, dom::SVGIRect **_retval)
metrics.mAscent + metrics.mDescent));
tmpCtx->IdentityMatrix();
nsRefPtr<dom::SVGRect> rect;
nsresult rv = NS_NewSVGRect(getter_AddRefs(rect), tmpCtx->GetUserPathExtent());
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<dom::SVGRect> rect = NS_NewSVGRect(tmpCtx->GetUserPathExtent());
rect.forget(_retval);
return NS_OK;