if (attributeName.EqualsIgnoreCase("onclick") || attributeName.EqualsIgnoreCase("ondblclick") || attributeName.EqualsIgnoreCase("onmousedown") || attributeName.EqualsIgnoreCase("onmouseup") || attributeName.EqualsIgnoreCase("onmouseover") || attributeName.EqualsIgnoreCase("onmouseout")) AddScriptEventListener(aName, aValue, kIDOMMouseListenerIID); else if (attributeName.EqualsIgnoreCase("onkeydown") || attributeName.EqualsIgnoreCase("onkeyup") || attributeName.EqualsIgnoreCase("onkeypress")) AddScriptEventListener(aName, aValue, kIDOMKeyListenerIID); else if (attributeName.EqualsIgnoreCase("onmousemove")) AddScriptEventListener(aName, aValue, kIDOMMouseMotionListenerIID); else if (attributeName.EqualsIgnoreCase("onload")) AddScriptEventListener(aName, aValue, kIDOMLoadListenerIID); else if (attributeName.EqualsIgnoreCase("onunload") || attributeName.EqualsIgnoreCase("onabort") || attributeName.EqualsIgnoreCase("onerror")) AddScriptEventListener(aName, aValue, kIDOMLoadListenerIID); else if (attributeName.EqualsIgnoreCase("onfocus") || attributeName.EqualsIgnoreCase("onblur")) AddScriptEventListener(aName, aValue, kIDOMFocusListenerIID); else if (attributeName.EqualsIgnoreCase("onsubmit") || attributeName.EqualsIgnoreCase("onreset") || attributeName.EqualsIgnoreCase("onchange")) AddScriptEventListener(aName, aValue, kIDOMFormListenerIID); else if (attributeName.EqualsIgnoreCase("onpaint")) AddScriptEventListener(aName, aValue, kIDOMPaintListenerIID);
mAttributes->AppendElement(attr); }
RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,                             nsIAtom* aName,                              const nsString& aValue,                             PRBool aNotify){    NS_ASSERTION(kNameSpaceID_Unknown != aNameSpaceID, "must have name space ID");    if (kNameSpaceID_Unknown == aNameSpaceID)        return NS_ERROR_ILLEGAL_VALUE;    NS_ASSERTION(nsnull != aName, "must have attribute name");    if (nsnull == aName)        return NS_ERROR_NULL_POINTER;    if (nsnull == mAttributes) {        if ((mAttributes = new nsVoidArray()) == nsnull)            return NS_ERROR_OUT_OF_MEMORY;    }    nsresult rv;    nsGenericAttribute* attr;    PRBool successful = PR_FALSE;    PRInt32 index;    PRInt32 count = mAttributes->Count();    for (index = 0; index < count; index++) {        attr = (nsGenericAttribute*)mAttributes->ElementAt(index);        if ((aNameSpaceID == attr->mNameSpaceID) && (aName == attr->mName)) {            attr->mValue = aValue;            rv = NS_OK;            successful = PR_TRUE;            break;        }    }        if (index >= count) { // didn't find it        attr = new nsGenericAttribute(aNameSpaceID, aName, aValue);        if (nsnull != attr) {            mAttributes->AppendElement(attr);            rv = NS_OK;            successful = PR_TRUE;        }    }    // XUL Only. Check for event handlers and notify broadcast listeners.    if (successful) {                      // Check for event handlers        nsString attributeName;        aName->ToString(attributeName);        if (attributeName.EqualsIgnoreCase("onclick") ||            attributeName.EqualsIgnoreCase("ondblclick") ||            attributeName.EqualsIgnoreCase("onmousedown") ||            attributeName.EqualsIgnoreCase("onmouseup") ||            attributeName.EqualsIgnoreCase("onmouseover") ||            attributeName.EqualsIgnoreCase("onmouseout"))            AddScriptEventListener(aName, aValue, kIDOMMouseListenerIID);        else if (attributeName.EqualsIgnoreCase("onkeydown") ||                 attributeName.EqualsIgnoreCase("onkeyup") ||                 attributeName.EqualsIgnoreCase("onkeypress"))            AddScriptEventListener(aName, aValue, kIDOMKeyListenerIID);        else if (attributeName.EqualsIgnoreCase("onmousemove"))            AddScriptEventListener(aName, aValue, kIDOMMouseMotionListenerIID);         else if (attributeName.EqualsIgnoreCase("onload"))            AddScriptEventListener(aName, aValue, kIDOMLoadListenerIID);         else if (attributeName.EqualsIgnoreCase("onunload") ||                 attributeName.EqualsIgnoreCase("onabort") ||                 attributeName.EqualsIgnoreCase("onerror"))            AddScriptEventListener(aName, aValue, kIDOMLoadListenerIID);        else if (attributeName.EqualsIgnoreCase("onfocus") ||                 attributeName.EqualsIgnoreCase("onblur"))            AddScriptEventListener(aName, aValue, kIDOMFocusListenerIID);        else if (attributeName.EqualsIgnoreCase("onsubmit") ||                 attributeName.EqualsIgnoreCase("onreset") ||                 attributeName.EqualsIgnoreCase("onchange"))            AddScriptEventListener(aName, aValue, kIDOMFormListenerIID);        else if (attributeName.EqualsIgnoreCase("onpaint"))            AddScriptEventListener(aName, aValue, kIDOMPaintListenerIID);         // Notify any broadcasters that are listening to this node.        count = mBroadcastListeners.Count();        for (PRInt32 i = 0; i < count; i++) {            XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners[i];            nsString aString;            aName->ToString(aString);            if (xulListener->mAttribute.EqualsIgnoreCase(aString)) {                // Set the attribute in the broadcast listener.                nsCOMPtr<nsIContent> contentNode(do_QueryInterface(xulListener->mListener));                if (contentNode) {                                        // If the namespace of the attribute and the namespace of the                    // tag are identical, then use the namespace of the listener's tag.                    // This allows you to do things like set xul:disabled on a xul tag                    // and have an html tag be annotated with an html:disabled instead.                                        PRInt32 thisNameSpaceID, listenerNameSpaceID;                    GetNameSpaceID(thisNameSpaceID);                    contentNode->GetNameSpaceID(listenerNameSpaceID);                    if (aNameSpaceID == thisNameSpaceID)                        contentNode->SetAttribute(listenerNameSpaceID, aName, aValue, aNotify);                    else contentNode->SetAttribute(aNameSpaceID, aName, aValue, aNotify);                }            }        }    }    // End XUL Only Code    if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {        mDocument->AttributeChanged(this, aName, NS_STYLE_HINT_UNKNOWN);    }    // Check to see if this is the RDF:container property; if so, and    // the value is "true", then remember to generate our kids on    // demand.    if ((aNameSpaceID == kNameSpaceID_RDF) &&        (aName == kContainerAtom) &&        (aValue.EqualsIgnoreCase("true"))) {        mContentsMustBeGenerated = PR_TRUE;    }    return rv;}