int typeIndex=0; while(gValidTypes[typeIndex]) { if (0== PL_strcmp(gValidTypes[typeIndex++], aContentType)) { return CreateDefaultDocument(aURL, aCommand, aContainer, aDocListener, aDocViewer); }
if (nsnull == aResult) { rv = NS_ERROR_NULL_POINTER; goto done; } *aResult = nsnull;  if (nsnull != aOuter) { rv = NS_ERROR_NO_AGGREGATION; goto done;
nsDocFactoryImpl::CreateInstance(nsIURL* aURL,                                  const char* aContentType,                                  const char *aCommand,                                 nsIContentViewerContainer* aContainer,                                 nsIStreamListener** aDocListener,                                 nsIContentViewer** aDocViewer){    nsresult rv = NS_ERROR_FAILURE;    if(0==PL_strcmp(gXMLTypes[0],aContentType))      if(0==PL_strcmp(aCommand,"view-source"))        aContentType=gValidTypes[0];    int typeIndex=0;    while(gValidTypes[typeIndex]) {      if (0== PL_strcmp(gValidTypes[typeIndex++], aContentType)) {          return CreateDefaultDocument(aURL, aCommand,                                       aContainer,                                       aDocListener,                                       aDocViewer);      }    }    // Try XML    typeIndex = 0;    while(gXMLTypes[typeIndex]) {      if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) {          return CreateXMLDocument(aURL, aCommand,                                   aContainer,                                   aDocListener,                                   aDocViewer);      }    }    // Try RDF    typeIndex = 0;    while (gRDFTypes[typeIndex]) {        if (0 == PL_strcmp(gRDFTypes[typeIndex++], aContentType)) {            return CreateRDFDocument(aURL, aCommand,                                     aContainer,                                     aDocListener,                                     aDocViewer);        }    }    // Try image types    typeIndex = 0;    while(gImageTypes[typeIndex]) {      if (0== PL_strcmp(gImageTypes[typeIndex++], aContentType)) {          return CreateImageDocument(aURL, aCommand,                                     aContainer,                                     aDocListener,                                     aDocViewer);      }    }    // Try plugin types    typeIndex = 0;    while(gPluginTypes[typeIndex]) {      if (0== PL_strcmp(gPluginTypes[typeIndex++], aContentType)) {          return CreatePluginDocument(aURL, aCommand, aContentType,                                      aContainer,                                      aDocListener,                                      aDocViewer);      }    }    return rv;}