NS_IMETHODIMP nsXBLService::GetBinding(nsCAutoString& aURLStr, nsIXBLBinding** aResult)
nsresult nsXBLService::GetBinding(nsIContent* aBoundElement, nsIURI* aURI, nsIXBLBinding** aResult)
NS_IMETHODIMP nsXBLService::GetBinding(nsCAutoString& aURLStr, nsIXBLBinding** aResult){  *aResult = nsnull;  if (aURLStr.IsEmpty())    return NS_ERROR_FAILURE;  nsCOMPtr<nsIURL> uri;  nsComponentManager::CreateInstance("component://netscape/network/standard-url",                                        nsnull,                                        NS_GET_IID(nsIURL),                                        getter_AddRefs(uri));  uri->SetSpec(aURLStr);  // XXX Obtain the # marker and remove it from the URL.  nsXPIDLCString ref;  uri->GetRef(getter_Copies(ref));  uri->SetRef("");  nsCOMPtr<nsIDocument> doc;  GetBindingDocument(uri, getter_AddRefs(doc));  if (!doc)    return NS_ERROR_FAILURE;  // We have a doc. Obtain our specific binding element.  // Walk the children looking for the binding that matches the ref  // specified in the URL.  nsCOMPtr<nsIContent> root = getter_AddRefs(doc->GetRootContent());  if (!root)    return NS_ERROR_FAILURE;  nsAutoString bindingName(ref);  PRInt32 count;  root->ChildCount(count);  for (PRInt32 i = 0; i < count; i++) {    nsCOMPtr<nsIContent> child;    root->ChildAt(i, *getter_AddRefs(child));    nsAutoString value;    child->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::name, value);        // If no ref is specified just use this.    if ((bindingName.IsEmpty()) || (bindingName == value)) {      // Make a new binding      NS_NewXBLBinding(aResult);      // Initialize its bound element.      (*aResult)->SetBindingElement(child);      // Check for the presence of an extends attribute      child->GetAttribute(kNameSpaceID_None, kExtendsAtom, value);      if (!value.IsEmpty()) {        // See if we are extending a builtin tag.        nsCOMPtr<nsIAtom> tag;        (*aResult)->GetBaseTag(getter_AddRefs(tag));        if (!tag) {          // We have a base class binding. Load it right now.          nsCOMPtr<nsIXBLBinding> baseBinding;          nsCAutoString url = value;          GetBinding(url, getter_AddRefs(baseBinding));          if (!baseBinding)            return NS_OK; // At least we got the derived class binding loaded.          (*aResult)->SetBaseBinding(baseBinding);        }      }      break;    }  }  return NS_OK;}