if (mNextBinding) mNextBinding->AttributeChanged(aAttribute, aNameSpaceID, aRemoveFlag);  if (!mAttributeTable) return NS_OK;  nsISupportsKey key(aAttribute); nsCOMPtr<nsISupports> supports = getter_AddRefs(NS_STATIC_CAST(nsISupports*, mAttributeTable->Get(&key)));  nsCOMPtr<nsIXBLAttributeEntry> xblAttr = do_QueryInterface(supports); if (!xblAttr) return NS_OK;    while (xblAttr) { nsCOMPtr<nsIContent> element; nsCOMPtr<nsIAtom> setAttr; xblAttr->GetElement(getter_AddRefs(element)); xblAttr->GetAttribute(getter_AddRefs(setAttr));  if (aRemoveFlag) element->UnsetAttribute(aNameSpaceID, setAttr, PR_TRUE); else { nsAutoString value; nsresult result = mBoundElement->GetAttribute(aNameSpaceID, aAttribute, value); PRBool attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE || result == NS_CONTENT_ATTR_HAS_VALUE);  if (attrPresent) element->SetAttribute(aNameSpaceID, setAttr, value, PR_TRUE); }    nsCOMPtr<nsIAtom> tag; element->GetTag(*getter_AddRefs(tag)); if ((tag.get() == kHTMLAtom) && (setAttr.get() == kValueAtom)) {  PRInt32 childCount; element->ChildCount(childCount); if (childCount > 0) element->RemoveChildAt(0, PR_TRUE);  if (!aRemoveFlag) {  nsAutoString value; nsresult result = mBoundElement->GetAttribute(aNameSpaceID, aAttribute, value); if (!value.IsEmpty()) { nsCOMPtr<nsIDOMText> textNode; nsCOMPtr<nsIDocument> doc; mBoundElement->GetDocument(*getter_AddRefs(doc)); nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc)); domDoc->CreateTextNode(value, getter_AddRefs(textNode)); nsCOMPtr<nsIDOMNode> dummy; nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(element)); domElement->AppendChild(textNode, getter_AddRefs(dummy)); } } } nsCOMPtr<nsIXBLAttributeEntry> tmpAttr = xblAttr; tmpAttr->GetNext(getter_AddRefs(xblAttr));
if (!mContent) { if (mNextBinding) mNextBinding->AttributeChanged(aAttribute, aNameSpaceID, aRemoveFlag, aNotify); } else { mPrototypeBinding->AttributeChanged(aAttribute, aNameSpaceID, aRemoveFlag, mBoundElement, mContent, aNotify);
nsXBLBinding::AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID, PRBool aRemoveFlag){  if (mNextBinding)    mNextBinding->AttributeChanged(aAttribute, aNameSpaceID, aRemoveFlag);  if (!mAttributeTable)    return NS_OK;  nsISupportsKey key(aAttribute);  nsCOMPtr<nsISupports> supports = getter_AddRefs(NS_STATIC_CAST(nsISupports*,                                                                  mAttributeTable->Get(&key)));  nsCOMPtr<nsIXBLAttributeEntry> xblAttr = do_QueryInterface(supports);  if (!xblAttr)    return NS_OK;  // Iterate over the elements in the array.  while (xblAttr) {    nsCOMPtr<nsIContent> element;    nsCOMPtr<nsIAtom> setAttr;    xblAttr->GetElement(getter_AddRefs(element));    xblAttr->GetAttribute(getter_AddRefs(setAttr));    if (aRemoveFlag)      element->UnsetAttribute(aNameSpaceID, setAttr, PR_TRUE);    else {      nsAutoString value;      nsresult result = mBoundElement->GetAttribute(aNameSpaceID, aAttribute, value);      PRBool attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||                            result == NS_CONTENT_ATTR_HAS_VALUE);      if (attrPresent)        element->SetAttribute(aNameSpaceID, setAttr, value, PR_TRUE);    }    // See if we're the <html> tag in XUL, and see if value is being    // set or unset on us.    nsCOMPtr<nsIAtom> tag;    element->GetTag(*getter_AddRefs(tag));    if ((tag.get() == kHTMLAtom) && (setAttr.get() == kValueAtom)) {      // Flush out all our kids.      PRInt32 childCount;      element->ChildCount(childCount);      if (childCount > 0)        element->RemoveChildAt(0, PR_TRUE);            if (!aRemoveFlag) {        // Construct a new text node and insert it.        nsAutoString value;        nsresult result = mBoundElement->GetAttribute(aNameSpaceID, aAttribute, value);        if (!value.IsEmpty()) {          nsCOMPtr<nsIDOMText> textNode;          nsCOMPtr<nsIDocument> doc;          mBoundElement->GetDocument(*getter_AddRefs(doc));          nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));          domDoc->CreateTextNode(value, getter_AddRefs(textNode));          nsCOMPtr<nsIDOMNode> dummy;          nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(element));          domElement->AppendChild(textNode, getter_AddRefs(dummy));        }      }    }    nsCOMPtr<nsIXBLAttributeEntry> tmpAttr = xblAttr;    tmpAttr->GetNext(getter_AddRefs(xblAttr));  }  return NS_OK;}