if (*iter == 'X') { ++iter; if (iter != end && *iter == '-') { ++iter; if (iter == end) {  mimeType.BeginReading(iter); } } else { --iter; } }
nsresult nsImageDocument::UpdateTitle( void ){#ifdef USE_EXTENSION_FOR_TYPE  // XXX TEMPORARY XXX  // We want to display the image type, however there is no way to right now  // so instead we just get the image-extension  //  - get the URL interface, get the extension, convert to upper-case  //  Unless the Imagerequest or Image can tell us the type this is the best we can do.  nsIURL *pURL=nsnull;  if(NS_SUCCEEDED(mDocumentURL->QueryInterface(NS_GET_IID(nsIURL),(void **)&pURL))) {    char *pExtension=nsnull;    pURL->GetFileExtension(&pExtension);    if(pExtension){      nsString strExt; strExt.AssignWithConversion(pExtension);      ToUpperCase(strExt);      titleStr.Append(strExt);      nsCRT::free(pExtension);      pExtension=nsnull;    }    NS_IF_RELEASE(pURL);  }#endif   nsCOMPtr<nsIStringBundle> bundle;  nsresult rv;   // Create a bundle for the localization  nsCOMPtr<nsIStringBundleService> stringService =            do_GetService(kStringBundleServiceCID, &rv);  if (NS_SUCCEEDED(rv) && stringService) {    rv = stringService->CreateBundle(NSIMAGEDOCUMENT_PROPERTIES_URI, getter_AddRefs(bundle));  }  if (NS_SUCCEEDED(rv) && bundle) {    nsXPIDLString valUni;    nsAutoString widthStr;    nsAutoString heightStr;    nsXPIDLString fileStr;    nsAutoString typeStr;    PRUint32 width = 0, height = 0;    nsCOMPtr<nsIURL> url = do_QueryInterface(mDocumentURL);    if (url) {      nsXPIDLCString pName;      url->GetFileName(getter_Copies(pName));      if(pName){        fileStr.Assign(NS_ConvertUTF8toUCS2(pName));      }    }    if (mImageRequest) {#ifdef USE_IMG2      imgIContainer* imgContainer;      rv = mImageRequest->GetImage(&imgContainer);      if (NS_SUCCEEDED(rv) && imgContainer) {        nscoord w = 0, h = 0;        imgContainer->GetWidth(&w);        imgContainer->GetHeight(&h);        width = w;        height = h;        NS_RELEASE(imgContainer);      }#else      mImageRequest->GetNaturalImageSize(&width, &height);#endif      widthStr.AppendInt(width);      heightStr.AppendInt(height);      nsXPIDLCString mimeType;      mImageRequest->GetMimeType(getter_Copies(mimeType));      ToUpperCase(mimeType);      nsXPIDLCString::const_iterator start, end;      mimeType.BeginReading(start);      mimeType.EndReading(end);      nsXPIDLCString::const_iterator iter = end;      if (FindInReadable(NS_LITERAL_CSTRING("IMAGE/"), start, iter) && iter != end) {        CopyASCIItoUCS2(Substring(iter, end), typeStr);      } else {        CopyASCIItoUCS2(mimeType, typeStr);      }    }    // If we got a filename, display it    if (!fileStr.IsEmpty()) {      // if we got a valid size (sometimes we do not) then display it      if (width != 0 && height != 0){        const PRUnichar *formatStrings[4]  = {fileStr.get(), typeStr.get(), widthStr.get(), heightStr.get()};        rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithDimensionsAndFile").get(), formatStrings, 4, getter_Copies(valUni));      } else {        const PRUnichar *formatStrings[2] = {fileStr.get(), typeStr.get()};        rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithoutDimensions").get(), formatStrings, 2, getter_Copies(valUni));      }    } else {      // if we got a valid size (sometimes we do not) then display it      if (width != 0 && height != 0){        const PRUnichar *formatStrings[3]  = {typeStr.get(), widthStr.get(), heightStr.get()};        rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithDimensions").get(), formatStrings, 3, getter_Copies(valUni));      } else {        const PRUnichar *formatStrings[1]  = {typeStr.get()};        rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithNeitherDimensionsNorFile").get(), formatStrings, 1, getter_Copies(valUni));      }    }    if (NS_SUCCEEDED(rv) && valUni) {      // set it on the document      SetTitle(valUni);    }  }  return NS_OK;}