(const char*) qnameC, aNode.GetSourceLineNumber()));
qnameC.get(), aNode.GetSourceLineNumber()));
XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode, nsXULPrototypeElement* aElement){    // Add tag attributes to the element    nsresult rv;    PRInt32 count = aNode.GetAttributeCount();    // Create storage for the attributes    nsXULPrototypeAttribute* attrs = nsnull;    if (count > 0) {      attrs = new nsXULPrototypeAttribute[count];      if (! attrs)        return NS_ERROR_OUT_OF_MEMORY;    }    aElement->mAttributes    = attrs;    aElement->mNumAttributes = count;    // Copy the attributes into the prototype    for (PRInt32 i = 0; i < count; i++) {        const nsAReadableString& qname = aNode.GetKeyAt(i);        rv = NormalizeAttributeString(qname,                                      *getter_AddRefs(attrs->mNodeInfo));        if (NS_FAILED(rv)) {            nsCAutoString qnameC;            qnameC.AssignWithConversion(qname);            PR_LOG(gLog, PR_LOG_ALWAYS,                   ("xul: unable to parse attribute '%s' at line %d",                    (const char*) qnameC, aNode.GetSourceLineNumber()));            // Bring it. We'll just fail to copy an attribute that we            // can't parse. And that's one less attribute to worry            // about.            --(aElement->mNumAttributes);            continue;        }        nsAutoString    valueStr;        valueStr = aNode.GetValueAt(i);        attrs->mValue.SetValue( valueStr );#ifdef PR_LOGGING        if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {            nsCAutoString extraWhiteSpace;            PRInt32 cnt = mContextStack.Depth();            while (--cnt >= 0)                extraWhiteSpace += "  ";            nsCAutoString qnameC,valueC;            qnameC.AssignWithConversion(qname);            valueC.AssignWithConversion(valueStr);            PR_LOG(gLog, PR_LOG_DEBUG,                   ("xul: %.5d. %s    %s=%s",                    aNode.GetSourceLineNumber(),                    NS_STATIC_CAST(const char*, extraWhiteSpace),                    NS_STATIC_CAST(const char*, qnameC),                    NS_STATIC_CAST(const char*, valueC)));        }#endif        ++attrs;    }    // XUL elements may require some additional work to compute    // derived information.    if (aElement->mNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) {        nsAutoString value;        // Compute the element's class list if the element has a 'class' attribute.        rv = aElement->GetAttr(kNameSpaceID_None, kClassAtom, value);        if (NS_FAILED(rv)) return rv;        if (rv == NS_CONTENT_ATTR_HAS_VALUE) {            rv = nsClassList::ParseClasses(&aElement->mClassList, value);            if (NS_FAILED(rv)) return rv;        }        // Parse the element's 'style' attribute        rv = aElement->GetAttr(kNameSpaceID_None, kStyleAtom, value);        if (NS_FAILED(rv)) return rv;        if (rv == NS_CONTENT_ATTR_HAS_VALUE) {            if (! mCSSParser) {                rv = nsComponentManager::CreateInstance(kCSSParserCID,                                                        nsnull,                                                        NS_GET_IID(nsICSSParser),                                                        getter_AddRefs(mCSSParser));                if (NS_FAILED(rv)) return rv;            }            rv = mCSSParser->ParseStyleAttribute(value, mDocumentURL,                                   getter_AddRefs(aElement->mInlineStyleRule));            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse style rule");            if (NS_FAILED(rv)) return rv;        }    }    return NS_OK;}