else if (mClassID.Equals(kCFontRetrieverService)) { inst = (nsISupports*)(nsIFontRetrieverService *) new nsFontRetrieverService(); }
nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,                                            const nsIID &aIID,                                            void **aResult)  {      if (aResult == NULL) {          return NS_ERROR_NULL_POINTER;      }      *aResult = NULL;      if (nsnull != aOuter)      return NS_ERROR_NO_AGGREGATION;      nsISupports *inst = nsnull;    if (mClassID.Equals(kCWindow)) {      inst = (nsISupports *)new nsWindow();    }    else if (mClassID.Equals(kCChild)) {      inst = (nsISupports *)new ChildWindow();    }    else if (mClassID.Equals(kCButton)) {      inst = (nsISupports*)(nsWindow *)new nsButton();    }    else if (mClassID.Equals(kCCheckButton)) {        inst = (nsISupports*)(nsWindow *)new nsCheckButton();    }    else if (mClassID.Equals(kCFilePicker)) {        inst = (nsISupports*)(nsBaseFilePicker*)new nsFilePicker();    }    else if (mClassID.Equals(kCHorzScrollbar)) {        inst = (nsISupports*)(nsWindow *)new nsScrollbar(PR_FALSE);    }    else if (mClassID.Equals(kCVertScrollbar)) {        inst = (nsISupports*)(nsWindow *)new nsScrollbar(PR_TRUE);    }    else if (mClassID.Equals(kCTextField)) {        inst = (nsISupports*)(nsWindow *)new nsTextWidget();    }    else if (mClassID.Equals(kCAppShell)) {        inst = (nsISupports*)new nsAppShell();    }    else if (mClassID.Equals(kCToolkit)) {        inst = (nsISupports*)new nsToolkit();    }    else if (mClassID.Equals(kCLookAndFeel)) {        inst = (nsISupports*)new nsLookAndFeel();    }    else if (mClassID.Equals(kCLabel)) {        inst = (nsISupports*)(nsWindow *)new nsLabel();    }    else if (mClassID.Equals(kCSound)) {        inst = (nsISupports*)new nsSound();    }    else if (mClassID.Equals(kCTransferable)) {        inst = (nsISupports*)new nsTransferable();    }    else if (mClassID.Equals(kCClipboard)) {        inst = (nsISupports*)new nsClipboard();    }    else if (mClassID.Equals(kCClipboardHelper)) {        inst = (nsISupports*)new nsClipboardHelper();    }    else if (mClassID.Equals(kCHTMLFormatConverter)) {        inst = (nsISupports*)new nsHTMLFormatConverter();    }    else if (mClassID.Equals(kCFontRetrieverService)) {        inst = (nsISupports*)(nsIFontRetrieverService *) new nsFontRetrieverService();    }    else if (mClassID.Equals(kCDragService)) {        inst = (nsISupports*) (nsIDragService *) new nsDragService();    }#ifdef IBMBIDI    else if (mClassID.Equals(kCBidiKeyboard)) {        inst = (nsISupports*)(nsIBidiKeyboard*) new nsBidiKeyboard();    }#endif // IBMBIDI    else {        printf("nsWidgetFactory::CreateInstance(), unhandled class.\n");    }      if (inst == NULL) {          return NS_ERROR_OUT_OF_MEMORY;      }      nsresult res = inst->QueryInterface(aIID, aResult);    if (res != NS_OK) {          // We didn't get the right interface, so clean up          delete inst;      }    return res;}  