PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance\n"));
nsresult nsGfxFactoryPh::CreateInstance(nsISupports *aOuter,                                            const nsIID &aIID,                                            void **aResult)  {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance\n"));  if (aResult == NULL) {      return NS_ERROR_NULL_POINTER;    }    *aResult = NULL;      nsISupports *inst = nsnull;  if (mClassID.Equals(kCFontMetrics))  {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsFontMetricsPh.\n"));    inst = (nsISupports *) new nsFontMetricsPh();  }  else if (mClassID.Equals(kCDeviceContext)) {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsDeviceContextPh.\n"));    inst = (nsISupports *)new nsDeviceContextPh();  }  else if (mClassID.Equals(kCRenderingContext)) {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsRenderingContextPh.\n"));    inst = (nsISupports *)new nsRenderingContextPh();  }  else if (mClassID.Equals(kCImage)) {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsImagePh.\n"));    inst = (nsISupports *)new nsImagePh();  }  else if (mClassID.Equals(kCRegion)) {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsRegionPh.\n"));    nsRegionPh*  region;    NS_NEWXPCOM(region, nsRegionPh);    inst = (nsISupports *)region;  }  else if (mClassID.Equals(kCBlender)) {    inst = (nsISupports *)new nsBlender;  }  else if (mClassID.Equals(kCDeviceContextSpec)) {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsDeviceContextSpecPh.\n"));    nsDeviceContextSpecPh* dcs;    NS_NEWXPCOM(dcs, nsDeviceContextSpecPh);    inst = (nsISupports *)dcs;  }  else if (mClassID.Equals(kCDeviceContextSpecFactory)) {    PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsDeviceContextSpecFactoryPh.\n"));    nsDeviceContextSpecFactoryPh* dcs;    NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryPh);    inst = (nsISupports *)dcs;  }  if (inst == NULL)  {      PR_LOG(PhGfxLog, PR_LOG_ERROR,("nsGfxFactoryPh::CreateInstance Failed.\n"));    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      PR_LOG(PhGfxLog, PR_LOG_ERROR,("nsGfxFactoryPh::CreateInstance Did not get the right interface, Failed.\n"));    delete inst;    }  //  else {//    inst->Release();//  }  return res;  }  