if (IsInDoc()) { bindingManager = GetOwnerDoc()->GetBindingManager();
nsIDocument* ownerDoc = GetOwnerDoc(); if (ownerDoc) { bindingManager = ownerDoc->GetBindingManager();
nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval){  nsCOMPtr<nsIDOMSVGMatrix> CTM;  nsIBindingManager *bindingManager = nsnull;  if (IsInDoc()) {    bindingManager = GetOwnerDoc()->GetBindingManager();  }  nsCOMPtr<nsIContent> parent;    if (bindingManager) {    // we have a binding manager -- do we have an anonymous parent?    bindingManager->GetInsertionParent(this, getter_AddRefs(parent));  }  if (!parent) {    // if we didn't find an anonymous parent, use the explicit one,    // whether it's null or not...    parent = GetParent();  }    while (parent) {    nsCOMPtr<nsIDOMSVGSVGElement> viewportElement = do_QueryInterface(parent);    if (viewportElement) {      // Our nearest SVG parent is a viewport element.      viewportElement->GetViewboxToViewportTransform(getter_AddRefs(CTM));      break;     }        nsCOMPtr<nsIDOMSVGLocatable> locatableElement = do_QueryInterface(parent);    if (locatableElement) {      // Our nearest SVG parent is a locatable object that is not a      // viewport. Its GetCTM function will give us a ctm from the      // viewport to itself:      locatableElement->GetCTM(getter_AddRefs(CTM));      break;    }    // Our parent was not svg content. We allow interdispersed non-SVG    // content to coexist with XBL. Loop until we find the first SVG    // parent.        nsCOMPtr<nsIContent> next;    if (bindingManager) {      bindingManager->GetInsertionParent(parent, getter_AddRefs(next));    }    if (!next) {      // no anonymous parent, so use explicit one      next = parent->GetParent();    }    parent = next;  }  if (!CTM) {    // We either didn't find an SVG parent, or our parent failed in    // giving us a CTM. In either case:    nsSVGMatrix::Create(getter_AddRefs(CTM));  }    // XXX do we have to append our viewboxToViewport  transformation?  // if we do we have to change nsSVGGraphicElement::GetCTM()    *_retval = CTM;  NS_IF_ADDREF(*_retval);  return NS_OK;}