bindingManager->GetBinding(aContent, getter_AddRefs(binding)); if (binding && !aAugmentFlag) { nsCOMPtr<nsIXBLBinding> styleBinding; binding->GetFirstStyleBinding(getter_AddRefs(styleBinding)); if (styleBinding) { PRBool marked = PR_FALSE; binding->MarkedForDeath(&marked); if (marked) { FlushStyleBindings(aContent); binding = nsnull; } else {  nsCAutoString uri; styleBinding->GetBindingURI(uri); if (uri.EqualsWithConversion(aURL)) return NS_OK; else { FlushStyleBindings(aContent); binding = nsnull; } } } }
bindableContent->GetBinding(getter_AddRefs(binding)); if (binding) bindableContent->SetBinding(nsnull);
nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL, PRBool aAugmentFlag,                           nsIXBLBinding** aBinding) {   *aBinding = nsnull;  nsresult rv;  nsCOMPtr<nsIDocument> document;  aContent->GetDocument(*getter_AddRefs(document));  nsCOMPtr<nsIBindingManager> bindingManager;  document->GetBindingManager(getter_AddRefs(bindingManager));    nsCOMPtr<nsIXBLBinding> binding;  bindingManager->GetBinding(aContent, getter_AddRefs(binding));  if (binding && !aAugmentFlag) {    nsCOMPtr<nsIXBLBinding> styleBinding;    binding->GetFirstStyleBinding(getter_AddRefs(styleBinding));    if (styleBinding) {      PRBool marked = PR_FALSE;      binding->MarkedForDeath(&marked);      if (marked) {        FlushStyleBindings(aContent);        binding = nsnull;      }      else {        // See if the URIs match.        nsCAutoString uri;        styleBinding->GetBindingURI(uri);        if (uri.EqualsWithConversion(aURL))          return NS_OK;        else {          FlushStyleBindings(aContent);          binding = nsnull;        }      }    }  }  nsCOMPtr<nsIXBLBinding> newBinding;  nsCAutoString url; url.AssignWithConversion(aURL);  if (NS_FAILED(rv = GetBinding(aContent, url, getter_AddRefs(newBinding)))) {    return rv;  }  if (!newBinding) {    nsCAutoString str = "Failed to locate XBL binding. XBL is now using id instead of name to reference bindings. Make sure you have switched over.  The invalid binding name is: ";    str.AppendWithConversion(aURL);    NS_ERROR(str);    return NS_OK;  }  if (aAugmentFlag) {    nsCOMPtr<nsIXBLBinding> baseBinding;    nsCOMPtr<nsIXBLBinding> nextBinding = newBinding;    do {      baseBinding = nextBinding;      baseBinding->GetBaseBinding(getter_AddRefs(nextBinding));      baseBinding->SetIsStyleBinding(PR_FALSE);    } while (nextBinding);    // XXX Handle adjusting the prototype chain! We need to somehow indicate to    // InstallProperties that the whole chain should just be whacked and rebuilt.    // We are becoming the new binding.    bindingManager->SetBinding(aContent, newBinding);    baseBinding->SetBaseBinding(binding);  }  else {    // We loaded a style binding.  It goes on the end.    if (binding) {      // Get the last binding that is in the append layer.      nsCOMPtr<nsIXBLBinding> rootBinding;      binding->GetRootBinding(getter_AddRefs(rootBinding));      rootBinding->SetBaseBinding(newBinding);    }    else {      // Install the binding on the content node.      bindingManager->SetBinding(aContent, newBinding);    }  }  // Set the binding's bound element.  newBinding->SetBoundElement(aContent);  // Tell the binding to build the anonymous content.  newBinding->GenerateAnonymousContent(aContent);  // Tell the binding to install event handlers  newBinding->InstallEventHandlers(aContent, aBinding);  // Set up our properties  newBinding->InstallProperties(aContent);  return NS_OK; }