nsCOMPtr<nsISVGGradient> aGrad = do_QueryInterface(grad); *result = aGrad;
*result = (nsSVGGradientFrame *)grad;
static nsresult GetSVGGradient(nsISVGGradient **result, nsCAutoString& aSpec, nsIContent *aContent,                               nsIPresShell *aPresShell){  nsresult rv = NS_OK;  *result = nsnull;  // Get the ID from the spec (no ID = an error)  PRInt32 pos = aSpec.FindChar('#');  if (pos == -1) {    NS_ASSERTION(pos != -1, "URI Spec not a reference");    return NS_ERROR_FAILURE;  }  // Strip off the hash and get the name  nsCAutoString aURICName;  aSpec.Right(aURICName, aSpec.Length()-(pos + 1));  // Get a unicode string  nsAutoString  aURIName;  CopyUTF8toUTF16(aURICName, aURIName);  // Get the domDocument  nsCOMPtr<nsIDOMDocument>domDoc = do_QueryInterface(aContent->GetDocument());  NS_ASSERTION(domDoc, "Content doesn't reference a dom Document");  if (domDoc == nsnull) {    return NS_ERROR_FAILURE;  }  // Get the gradient element  nsCOMPtr<nsIDOMElement> element;  nsIFrame *grad;  rv = domDoc->GetElementById(aURIName, getter_AddRefs(element));  if (!NS_SUCCEEDED(rv) || element == nsnull) {    return rv;    }  // Note: the following queries are not really required, but we want to make sure  // we're pointing to gradient elements.  nsCOMPtr<nsIDOMSVGLinearGradientElement> lGradient = do_QueryInterface(element);  if (!lGradient) {    nsCOMPtr<nsIDOMSVGRadialGradientElement> rGradient = do_QueryInterface(element);    if (!rGradient) {      NS_ASSERTION(PR_FALSE, "Not a gradient element!");      return NS_ERROR_FAILURE;    }   }   // Get the Primary Frame  nsCOMPtr<nsIContent> aGContent = do_QueryInterface(element);  NS_ASSERTION(aPresShell, "svg get gradient -- no pres shell provided");  if (!aPresShell)    return NS_ERROR_FAILURE;  rv = aPresShell->GetPrimaryFrameFor(aGContent, &grad);  nsCOMPtr<nsISVGGradient> aGrad = do_QueryInterface(grad);  *result = aGrad;  return rv;}