else if (iid.Equals(NS_GET_IID(nsIXMLContent))) { *result = NS_STATIC_CAST(nsIXMLContent*, this); } else if (iid.Equals(NS_GET_IID(nsIXULContent))) { *result = NS_STATIC_CAST(nsIXULContent*, this); } else if (iid.Equals(NS_GET_IID(nsIDOMXULElement)) || iid.Equals(kIDOMElementIID) || iid.Equals(kIDOMNodeIID)) { *result = NS_STATIC_CAST(nsIDOMElement*, this); } else if (iid.Equals(kIScriptObjectOwnerIID)) { *result = NS_STATIC_CAST(nsIScriptObjectOwner*, this); } else if (iid.Equals(NS_GET_IID(nsIScriptEventHandlerOwner))) { *result = NS_STATIC_CAST(nsIScriptEventHandlerOwner*, this); } else if (iid.Equals(kIDOMEventReceiverIID)) { *result = NS_STATIC_CAST(nsIDOMEventReceiver*, this); } else if (iid.Equals(kIDOMEventTargetIID)) { *result = NS_STATIC_CAST(nsIDOMEventTarget*, this); } else if (iid.Equals(kIJSScriptObjectIID)) { *result = NS_STATIC_CAST(nsIJSScriptObject*, this); } else if (iid.Equals(NS_GET_IID(nsIStyleRule))) { *result = NS_STATIC_CAST(nsIStyleRule*, this); } else if (iid.Equals(NS_GET_IID(nsIChromeEventHandler))) { *result = NS_STATIC_CAST(nsIChromeEventHandler*, this); } else if (iid.Equals(NS_GET_IID(nsIDOMXULMenuListElement)) && (NodeInfo()->NamespaceEquals(kNameSpaceID_XUL))) { nsCOMPtr<nsIAtom> tag; PRInt32 dummy; NS_WITH_SERVICE(nsIXBLService, xblService, "component: xblService->ResolveTag(NS_STATIC_CAST(nsIStyledContent*, this), &dummy, getter_AddRefs(tag)); if (tag.get() == kMenuListAtom) {  if (! InnerXULElement()) { rv = EnsureSlots(); if (NS_FAILED(rv)) return rv;  if ((mSlots->mInnerXULElement = new nsXULMenuListElement(this)) == nsnull) return NS_ERROR_OUT_OF_MEMORY; }  return InnerXULElement()->QueryInterface(iid, result); } else return NS_NOINTERFACE; } else if ((iid.Equals(NS_GET_IID(nsIDOMXULTreeElement)) || iid.Equals(NS_GET_IID(nsIXULTreeContent))) && (NodeInfo()->NamespaceEquals(kNameSpaceID_XUL))){ nsCOMPtr<nsIAtom> tag; PRInt32 dummy; NS_WITH_SERVICE(nsIXBLService, xblService, "component: xblService->ResolveTag(NS_STATIC_CAST(nsIStyledContent*, this), &dummy, getter_AddRefs(tag)); if (tag.get() == kTreeAtom) {  if (! InnerXULElement()) { rv = EnsureSlots(); if (NS_FAILED(rv)) return rv;  if ((mSlots->mInnerXULElement = new nsXULTreeElement(this)) == nsnull) return NS_ERROR_OUT_OF_MEMORY; }  return InnerXULElement()->QueryInterface(iid, result); } else return NS_NOINTERFACE; } else { *result = nsnull; return NS_NOINTERFACE; }   NS_ADDREF(this); return NS_OK; }
nsXULElement::QueryInterface(REFNSIID iid, void** result){    if (! result)        return NS_ERROR_NULL_POINTER;    *result = nsnull;    nsresult rv;    if (iid.Equals(NS_GET_IID(nsIStyledContent)) ||        iid.Equals(kIContentIID) ||        iid.Equals(kISupportsIID)) {        *result = NS_STATIC_CAST(nsIStyledContent*, this);    }    else if (iid.Equals(NS_GET_IID(nsIXMLContent))) {        *result = NS_STATIC_CAST(nsIXMLContent*, this);    }    else if (iid.Equals(NS_GET_IID(nsIXULContent))) {        *result = NS_STATIC_CAST(nsIXULContent*, this);    }    else if (iid.Equals(NS_GET_IID(nsIDOMXULElement)) ||             iid.Equals(kIDOMElementIID) ||             iid.Equals(kIDOMNodeIID)) {        *result = NS_STATIC_CAST(nsIDOMElement*, this);    }    else if (iid.Equals(kIScriptObjectOwnerIID)) {        *result = NS_STATIC_CAST(nsIScriptObjectOwner*, this);    }    else if (iid.Equals(NS_GET_IID(nsIScriptEventHandlerOwner))) {        *result = NS_STATIC_CAST(nsIScriptEventHandlerOwner*, this);    }    else if (iid.Equals(kIDOMEventReceiverIID)) {        *result = NS_STATIC_CAST(nsIDOMEventReceiver*, this);    }    else if (iid.Equals(kIDOMEventTargetIID)) {        *result = NS_STATIC_CAST(nsIDOMEventTarget*, this);    }    else if (iid.Equals(kIJSScriptObjectIID)) {        *result = NS_STATIC_CAST(nsIJSScriptObject*, this);    }    else if (iid.Equals(NS_GET_IID(nsIStyleRule))) {        *result = NS_STATIC_CAST(nsIStyleRule*, this);    }    else if (iid.Equals(NS_GET_IID(nsIChromeEventHandler))) {        *result = NS_STATIC_CAST(nsIChromeEventHandler*, this);    }    else if (iid.Equals(NS_GET_IID(nsIDOMXULMenuListElement)) &&             (NodeInfo()->NamespaceEquals(kNameSpaceID_XUL))) {      nsCOMPtr<nsIAtom> tag;      PRInt32 dummy;      NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv);      xblService->ResolveTag(NS_STATIC_CAST(nsIStyledContent*, this), &dummy, getter_AddRefs(tag));      if (tag.get() == kMenuListAtom) {        // We delegate XULMenuListElement APIs to an aggregate object        if (! InnerXULElement()) {            rv = EnsureSlots();            if (NS_FAILED(rv)) return rv;            if ((mSlots->mInnerXULElement = new nsXULMenuListElement(this)) == nsnull)                return NS_ERROR_OUT_OF_MEMORY;        }        return InnerXULElement()->QueryInterface(iid, result);      }      else        return NS_NOINTERFACE;    }    else if ((iid.Equals(NS_GET_IID(nsIDOMXULTreeElement)) ||              iid.Equals(NS_GET_IID(nsIXULTreeContent))) &&             (NodeInfo()->NamespaceEquals(kNameSpaceID_XUL))){      nsCOMPtr<nsIAtom> tag;      PRInt32 dummy;      NS_WITH_SERVICE(nsIXBLService, xblService, "component://netscape/xbl", &rv);      xblService->ResolveTag(NS_STATIC_CAST(nsIStyledContent*, this), &dummy, getter_AddRefs(tag));      if (tag.get() == kTreeAtom) {        // We delegate XULTreeElement APIs to an aggregate object        if (! InnerXULElement()) {            rv = EnsureSlots();            if (NS_FAILED(rv)) return rv;            if ((mSlots->mInnerXULElement = new nsXULTreeElement(this)) == nsnull)                return NS_ERROR_OUT_OF_MEMORY;        }        return InnerXULElement()->QueryInterface(iid, result);      }      else        return NS_NOINTERFACE;    }    else {        *result = nsnull;        return NS_NOINTERFACE;    }    // if we get here, we know one of the above IIDs was ok.    NS_ADDREF(this);    return NS_OK;}