if (aIID.Equals(kCWindow)) { inst = new nsWindow(aOuter); }
if (aIID.Equals(kCWindow)) { inst = new nsWindow(aOuter); } else if (aIID.Equals(kIWidget)) { inst = new nsWindow(aOuter); } else if (mClassID.Equals(kCAppShellCID)) { nsAppShell *appInst = new nsAppShell(); if (appInst == NULL) { return NS_ERROR_OUT_OF_MEMORY; } nsresult res = appInst->QueryInterface(aIID, aResult); if (res != NS_OK) { delete appInst; } return res; }
nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,                                            const nsIID &aIID,                                            void **aResult)  {      if (aResult == NULL) {          return NS_ERROR_NULL_POINTER;      }      *aResult = NULL;        if (nsnull != aOuter && !aIID.Equals(kISupportsIID)) {        // aggregation with IID != nsISupports        return NS_ERROR_ILLEGAL_VALUE;    }    nsWindow *inst = nsnull;    if (aIID.Equals(kCWindow)) {        inst = new nsWindow(aOuter);    }#ifdef NOTNOW    else if ( mClassID.Equals(kCCheckButtonCID)) {        inst = new nsCheckButton(aOuter);    }    else if ( mClassID.Equals(kCButtonCID)) {        inst = new nsButton(aOuter);    }    else if (mClassID.Equals(kCVertScrollbarCID)) {        inst = new nsScrollbar(aOuter, PR_TRUE);    }    else if (mClassID.Equals(kCHorzScrollbarCID)) {        inst = new nsScrollbar(aOuter, PR_FALSE);    }    else if (aIID.Equals(kIScrollbar)) {        inst = nsnull;        fprintf(stderr, "------ NOT CreatingkIScrollbar Scrollbar\n");    }    else if (mClassID.Equals(kCTextWidgetCID)) {        inst = new nsTextWidget(aOuter);    }    else if (mClassID.Equals(kCTextAreaWidgetCID)) {        inst = new nsTextAreaWidget(aOuter);    }    else if ( mClassID.Equals(kCRadioButtonCID)) {        inst = new nsRadioButton(aOuter);    }    else if (mClassID.Equals(kCListBoxCID)) {        inst = new nsListBox(aOuter);    }    else if (mClassID.Equals(kCComboBoxCID)) {        inst = new nsComboBox(aOuter);    }    else if (mClassID.Equals(kCFileWidgetCID)) {        inst = new nsFileWidget(aOuter);    }    else if (aIID.Equals(kIWidget)) {        inst = new nsWindow(aOuter);    }    else if (mClassID.Equals(kCChild)) {        inst = new ChildWindow(aOuter);    }    else if (mClassID.Equals(kCLookAndFeelCID)) {        nsLookAndFeel *laf = new nsLookAndFeel(aOuter);        if (laf == NULL) {              return NS_ERROR_OUT_OF_MEMORY;          }          nsresult res = laf->QueryInterface(aIID, aResult);        if (res != NS_OK) {            delete laf;        }        return res;    }    else if (mClassID.Equals(kCAppShellCID)) {        nsAppShell *appInst = new nsAppShell();        if (appInst == NULL) {              return NS_ERROR_OUT_OF_MEMORY;          }          nsresult res = appInst->QueryInterface(aIID, aResult);        if (res != NS_OK) {            delete appInst;        }        return res;    }#endif    if (inst == NULL) {        return NS_ERROR_OUT_OF_MEMORY;      }            nsresult res = inst->QueryObject(aIID, aResult);    if (res != NS_OK) {        delete inst;             }    else {      NS_RELEASE(inst);    }            return res;}  