Bug 761051 - Use image/jpeg as the standard internal transferable image type, but continue respecting image/jpg as well; r=roc
☠☠ backed out by 8af411a52d3f ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 07 Jun 2012 19:27:07 -0400
changeset 96119 125438dda90335ed85669717327c1d1ee84c5430
parent 96118 e2e32b584809784f4bf333c6280d3a2157784b55
child 96120 ebbc966ba9b8cc1b3198fa8cff4bf0af8109ba4b
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs761051
milestone16.0a1
Bug 761051 - Use image/jpeg as the standard internal transferable image type, but continue respecting image/jpg as well; r=roc
editor/libeditor/html/nsHTMLDataTransfer.cpp
widget/cocoa/nsClipboard.mm
widget/cocoa/nsDragService.mm
widget/gtk2/nsClipboard.cpp
widget/nsITransferable.idl
widget/os2/nsClipboard.cpp
widget/qt/nsClipboard.cpp
widget/tests/test_bug444800.xul
widget/windows/nsClipboard.cpp
widget/windows/nsImageClipboard.cpp
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -997,28 +997,31 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLT
       }
       (*aTransferable)->AddDataFlavor(kHTMLMime);
       (*aTransferable)->AddDataFlavor(kFileMime);
 
       switch (Preferences::GetInt("clipboard.paste_image_type", 1))
       {
         case 0:  // prefer JPEG over PNG over GIF encoding
           (*aTransferable)->AddDataFlavor(kJPEGImageMime);
+          (*aTransferable)->AddDataFlavor(kJPGImageMime);
           (*aTransferable)->AddDataFlavor(kPNGImageMime);
           (*aTransferable)->AddDataFlavor(kGIFImageMime);
           break;
         case 1:  // prefer PNG over JPEG over GIF encoding (default)
         default:
           (*aTransferable)->AddDataFlavor(kPNGImageMime);
           (*aTransferable)->AddDataFlavor(kJPEGImageMime);
+          (*aTransferable)->AddDataFlavor(kJPGImageMime);
           (*aTransferable)->AddDataFlavor(kGIFImageMime);
           break;
         case 2:  // prefer GIF over JPEG over PNG encoding
           (*aTransferable)->AddDataFlavor(kGIFImageMime);
           (*aTransferable)->AddDataFlavor(kJPEGImageMime);
+          (*aTransferable)->AddDataFlavor(kJPGImageMime);
           (*aTransferable)->AddDataFlavor(kPNGImageMime);
           break;
       }
     }
     (*aTransferable)->AddDataFlavor(kUnicodeMime);
     (*aTransferable)->AddDataFlavor(kMozTextInternal);
   }
   
@@ -1230,16 +1233,17 @@ nsresult nsHTMLEditor::InsertObject(cons
       if (StringBeginsWith(contentType, NS_LITERAL_CSTRING("image/"))) {
         insertAsImage = true;
         type = contentType.get();
       }
     }
   }
 
   if (0 == nsCRT::strcmp(type, kJPEGImageMime) ||
+      0 == nsCRT::strcmp(type, kJPGImageMime) ||
       0 == nsCRT::strcmp(type, kPNGImageMime) ||
       0 == nsCRT::strcmp(type, kGIFImageMime) ||
       insertAsImage)
   {
     nsCOMPtr<nsIInputStream> imageStream;
     if (insertAsImage) {
       NS_ASSERTION(fileURI, "The file URI should be retrieved earlier");
       rv = NS_OpenURI(getter_AddRefs(imageStream), fileURI);
@@ -1299,16 +1303,17 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTr
 #ifdef DEBUG_clipboard
     printf("Got flavor [%s]\n", bestFlavor.get());
 #endif
 
     bool isSafe = IsSafeToInsertData(aSourceDoc);
 
     if (0 == nsCRT::strcmp(bestFlavor, kFileMime) ||
         0 == nsCRT::strcmp(bestFlavor, kJPEGImageMime) ||
+        0 == nsCRT::strcmp(bestFlavor, kJPGImageMime) ||
         0 == nsCRT::strcmp(bestFlavor, kPNGImageMime) ||
         0 == nsCRT::strcmp(bestFlavor, kGIFImageMime)) {
       rv = InsertObject(bestFlavor, genericDataObj, isSafe,
                         aSourceDoc, aDestinationNode, aDestOffset, aDoDeleteSelection);
     }
     else if (0 == nsCRT::strcmp(bestFlavor, kNativeHTMLMime))
     {
       // note cf_html uses utf8, hence use length = len, not len/2 as in flavors below
@@ -1398,16 +1403,17 @@ nsresult nsHTMLEditor::InsertFromDataTra
   types->GetLength(&length);
   for (PRUint32 t = 0; t < length; t++) {
     nsAutoString type;
     types->Item(t, type);
 
     if (!isText) {
       if (type.EqualsLiteral(kFileMime) ||
           type.EqualsLiteral(kJPEGImageMime) ||
+          type.EqualsLiteral(kJPGImageMime) ||
           type.EqualsLiteral(kPNGImageMime) ||
           type.EqualsLiteral(kGIFImageMime)) {
         nsCOMPtr<nsIVariant> variant;
         aDataTransfer->MozGetDataAt(type, aIndex, getter_AddRefs(variant));
         if (variant) {
           nsCOMPtr<nsISupports> object;
           variant->GetAsISupports(getter_AddRefs(object));
           rv = InsertObject(NS_ConvertUTF16toUTF8(type).get(), object, isSafe,
@@ -1619,18 +1625,18 @@ NS_IMETHODIMP nsHTMLEditor::PasteNoForma
 }
 
 
 // The following arrays contain the MIME types that we can paste. The arrays
 // are used by CanPaste() and CanPasteTransferable() below.
 
 static const char* textEditorFlavors[] = { kUnicodeMime };
 static const char* textHtmlEditorFlavors[] = { kUnicodeMime, kHTMLMime,
-                                               kJPEGImageMime, kPNGImageMime,
-                                               kGIFImageMime };
+                                               kJPEGImageMime, kJPGImageMime,
+                                               kPNGImageMime, kGIFImageMime };
 
 NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, bool *aCanPaste)
 {
   NS_ENSURE_ARG_POINTER(aCanPaste);
   *aCanPaste = false;
 
   // can't paste if readonly
   if (!IsModifiable()) {
--- a/widget/cocoa/nsClipboard.mm
+++ b/widget/cocoa/nsClipboard.mm
@@ -160,31 +160,33 @@ nsClipboard::TransferableFromPasteboard(
       nsCOMPtr<nsISupports> genericDataWrapper;
       nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, clipboardDataPtrNoBOM, dataLength,
                                                  getter_AddRefs(genericDataWrapper));
       aTransferable->SetTransferData(flavorStr, genericDataWrapper, dataLength);
       free(clipboardDataPtr);
       break;
     }
     else if (flavorStr.EqualsLiteral(kJPEGImageMime) ||
+             flavorStr.EqualsLiteral(kJPGImageMime) ||
              flavorStr.EqualsLiteral(kPNGImageMime) ||
              flavorStr.EqualsLiteral(kGIFImageMime)) {
       // Figure out if there's data on the pasteboard we can grab (sanity check)
       NSString *type = [cocoaPasteboard availableTypeFromArray:[NSArray arrayWithObjects:IMAGE_PASTEBOARD_TYPES]];
       if (!type)
         continue;
 
       // Read data off the clipboard
       NSData *pasteboardData = GetDataFromPasteboard(cocoaPasteboard, type);
       if (!pasteboardData)
         continue;
 
       // Figure out what type we're converting to
       CFStringRef outputType = NULL; 
-      if (flavorStr.EqualsLiteral(kJPEGImageMime))
+      if (flavorStr.EqualsLiteral(kJPEGImageMime) ||
+          flavorStr.EqualsLiteral(kJPGImageMime))
         outputType = CFSTR("public.jpeg");
       else if (flavorStr.EqualsLiteral(kPNGImageMime))
         outputType = CFSTR("public.png");
       else if (flavorStr.EqualsLiteral(kGIFImageMime))
         outputType = CFSTR("com.compuserve.gif");
       else
         continue;
 
@@ -334,16 +336,17 @@ nsClipboard::HasDataMatchingFlavors(cons
 
     if (nsClipboard::IsStringType(mimeType, &pboardType)) {
       NSString* availableType = [generalPBoard availableTypeFromArray:[NSArray arrayWithObject:pboardType]];
       if (availableType && [availableType isEqualToString:pboardType]) {
         *outResult = true;
         break;
       }
     } else if (!strcmp(aFlavorList[i], kJPEGImageMime) ||
+               !strcmp(aFlavorList[i], kJPGImageMime) ||
                !strcmp(aFlavorList[i], kPNGImageMime) ||
                !strcmp(aFlavorList[i], kGIFImageMime)) {
       NSString* availableType = [generalPBoard availableTypeFromArray:
                                   [NSArray arrayWithObjects:IMAGE_PASTEBOARD_TYPES]];
       if (availableType) {
         *outResult = true;
         break;
       }
@@ -405,17 +408,18 @@ nsClipboard::PasteboardDictFromTransfera
       // be nice to Carbon apps, normalize the receiver's contents using Form C.
       nativeString = [nativeString precomposedStringWithCanonicalMapping];
 
       [pasteboardOutputDict setObject:nativeString forKey:pboardType];
       
       nsMemory::Free(data);
     }
     else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
-             flavorStr.EqualsLiteral(kGIFImageMime) || flavorStr.EqualsLiteral(kNativeImageMime)) {
+             flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) ||
+             flavorStr.EqualsLiteral(kNativeImageMime)) {
       PRUint32 dataSize = 0;
       nsCOMPtr<nsISupports> transferSupports;
       aTransferable->GetTransferData(flavorStr, getter_AddRefs(transferSupports), &dataSize);
       nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive(do_QueryInterface(transferSupports));
       if (!ptrPrimitive)
         continue;
 
       nsCOMPtr<nsISupports> primitiveData;
--- a/widget/cocoa/nsDragService.mm
+++ b/widget/cocoa/nsDragService.mm
@@ -421,17 +421,17 @@ nsDragService::GetData(nsITransferable* 
       free(clipboardDataPtr);
       break;
     }
 
     // We have never supported this on Mac OS X, we should someday. Normally dragging images
     // in is accomplished with a file path drag instead of the image data itself.
     /*
     if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
-        flavorStr.EqualsLiteral(kGIFImageMime)) {
+        flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime)) {
 
     }
     */
   }
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
--- a/widget/gtk2/nsClipboard.cpp
+++ b/widget/gtk2/nsClipboard.cpp
@@ -202,16 +202,17 @@ nsClipboard::SetData(nsITransferable *aT
                 gtk_target_list_add(list, gdk_atom_intern("TEXT", FALSE), 0, 0);
                 gtk_target_list_add(list, GDK_SELECTION_TYPE_STRING, 0, 0);
                 continue;
             }
 
             if (flavorStr.EqualsLiteral(kNativeImageMime) ||
                 flavorStr.EqualsLiteral(kPNGImageMime) ||
                 flavorStr.EqualsLiteral(kJPEGImageMime) ||
+                flavorStr.EqualsLiteral(kJPGImageMime) ||
                 flavorStr.EqualsLiteral(kGIFImageMime)) {
                 // don't bother adding image targets twice
                 if (!imagesAdded) {
                     // accept any writable image type
                     gtk_target_list_add_image_targets(list, 0, TRUE);
                     imagesAdded = true;
                 }
                 continue;
@@ -309,22 +310,26 @@ nsClipboard::GetData(nsITransferable *aT
                 // If the type was text/unicode and we couldn't get
                 // text off the clipboard, run the next loop
                 // iteration.
                 continue;
             }
 
             // For images, we must wrap the data in an nsIInputStream then return instead of break,
             // because that code below won't help us.
-            if (!strcmp(flavorStr, kJPEGImageMime) || !strcmp(flavorStr, kPNGImageMime) || !strcmp(flavorStr, kGIFImageMime)) {
-                GdkAtom atom;
-                if (!strcmp(flavorStr, kJPEGImageMime)) // This is image/jpg, but X only understands image/jpeg
-                    atom = gdk_atom_intern("image/jpeg", FALSE);
-                else
-                    atom = gdk_atom_intern(flavorStr, FALSE);
+            if (!strcmp(flavorStr, kJPEGImageMime) ||
+                !strcmp(flavorStr, kJPGImageMime) ||
+                !strcmp(flavorStr, kPNGImageMime) ||
+                !strcmp(flavorStr, kGIFImageMime)) {
+                // Emulate support for image/jpg
+                if (!strcmp(flavorStr, kJPGImageMime)) {
+                    flavorStr.Assign(kJPEGImageMime);
+                }
+
+                GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
 
                 GtkSelectionData *selectionData = wait_for_contents(clipboard, atom);
                 if (!selectionData)
                     continue;
 
                 nsCOMPtr<nsIInputStream> byteStream;
                 NS_NewByteInputStream(getter_AddRefs(byteStream), (const char*)selectionData->data,
                                       selectionData->length, NS_ASSIGNMENT_COPY);
@@ -436,18 +441,19 @@ nsClipboard::HasDataMatchingFlavors(cons
         for (PRInt32 j = 0; j < n_targets; j++) {
             gchar *atom_name = gdk_atom_name(targets[j]);
             if (!atom_name)
                 continue;
 
             if (!strcmp(atom_name, aFlavorList[i]))
                 *_retval = true;
 
-            // X clipboard wants image/jpeg, not image/jpg
-            if (!strcmp(aFlavorList[i], kJPEGImageMime) && !strcmp(atom_name, "image/jpeg"))
+            // X clipboard supports image/jpeg, but we want to emulate support
+            // for image/jpg as well
+            if (!strcmp(aFlavorList[i], kJPGImageMime) && !strcmp(atom_name, kJPEGImageMime))
                 *_retval = true;
 
             g_free(atom_name);
 
             if (*_retval)
                 break;
         }
     }
@@ -559,17 +565,17 @@ nsClipboard::SelectionGetEvent(GtkClipbo
         nsMemory::Free(utf8string);
         return;
     }
 
     // Check to see if the selection data is an image type
     if (gtk_targets_include_image(&aSelectionData->target, 1, TRUE)) {
         // Look through our transfer data for the image
         static const char* const imageMimeTypes[] = {
-            kNativeImageMime, kPNGImageMime, kJPEGImageMime, kGIFImageMime };
+            kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime };
         nsCOMPtr<nsISupports> item;
         PRUint32 len;
         nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive;
         for (PRUint32 i = 0; !ptrPrimitive && i < ArrayLength(imageMimeTypes); i++) {
             rv = trans->GetTransferData(imageMimeTypes[i], getter_AddRefs(item), &len);
             ptrPrimitive = do_QueryInterface(item);
         }
         if (!ptrPrimitive)
--- a/widget/nsITransferable.idl
+++ b/widget/nsITransferable.idl
@@ -14,17 +14,18 @@
 // these probably shouldn't live here, but in some central repository shared
 // by the entire app.
 #define kTextMime                   "text/plain"
 #define kUnicodeMime                "text/unicode"
 #define kMozTextInternal          "text/x-moz-text-internal"  // text data which isn't suppoed to be parsed by other apps.
 #define kHTMLMime                   "text/html"
 #define kAOLMailMime                "AOLMAIL"
 #define kPNGImageMime               "image/png"
-#define kJPEGImageMime              "image/jpg"
+#define kJPEGImageMime              "image/jpeg"
+#define kJPGImageMime               "image/jpg"
 #define kGIFImageMime               "image/gif"
 #define kFileMime                   "application/x-moz-file"
 
 #define kURLMime                    "text/x-moz-url"        // data contains url\ntitle
 #define kURLDataMime                "text/x-moz-url-data"   // data contains url only
 #define kURLDescriptionMime         "text/x-moz-url-desc"   // data contains description
 #define kURLPrivateMime             "text/x-moz-url-priv"   // same as kURLDataMime but for private uses
 #define kNativeImageMime            "application/x-moz-nativeimage"
--- a/widget/os2/nsClipboard.cpp
+++ b/widget/os2/nsClipboard.cpp
@@ -29,16 +29,17 @@ inline PRUint32 RegisterClipboardFormat(
 nsClipboard::nsClipboard() : nsBaseClipboard()
 {
   RegisterClipboardFormat(kTextMime);
   RegisterClipboardFormat(kUnicodeMime);
   RegisterClipboardFormat(kHTMLMime);
   RegisterClipboardFormat(kAOLMailMime);
   RegisterClipboardFormat(kPNGImageMime);
   RegisterClipboardFormat(kJPEGImageMime);
+  RegisterClipboardFormat(kJPGImageMime);
   RegisterClipboardFormat(kGIFImageMime);
   RegisterClipboardFormat(kFileMime);
   RegisterClipboardFormat(kURLMime);
   RegisterClipboardFormat(kNativeImageMime);
   RegisterClipboardFormat(kNativeHTMLMime);
 }
 
 nsClipboard::~nsClipboard()
@@ -133,17 +134,17 @@ bool nsClipboard::GetClipboardDataByID(P
     nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks( aFlavor, &pDataMem,   // pDataMem could be reallocated !!
                                                         reinterpret_cast<PRInt32*>(&NumOfBytes) );  // yuck
 
   }
   else                             // Assume rest of flavors are binary data
   {
     if (aFormatID == CF_BITMAP)
     {
-      if (!strcmp( aFlavor, kJPEGImageMime ))
+      if (!strcmp( aFlavor, kJPEGImageMime ) || !strcmp( aFlavor, kJPGImageMime ))
       {
         // OS2TODO  Convert bitmap to jpg
 #ifdef DEBUG
         printf( "nsClipboard:: No JPG found on clipboard; need to convert BMP\n");
 #endif
       }
       else if (!strcmp( aFlavor, kGIFImageMime ))
       {
--- a/widget/qt/nsClipboard.cpp
+++ b/widget/qt/nsClipboard.cpp
@@ -148,22 +148,23 @@ nsClipboard::SetNativeClipboardData( nsI
                 mimeData->setHtml(str);
             }
 
             // image?
             else if (!imageAdded // image is added only once to the clipboard
                      && (!strcmp(flavorStr.get(), kNativeImageMime)
                      ||  !strcmp(flavorStr.get(), kPNGImageMime)
                      ||  !strcmp(flavorStr.get(), kJPEGImageMime)
+                     ||  !strcmp(flavorStr.get(), kJPGImageMime)
                      ||  !strcmp(flavorStr.get(), kGIFImageMime))
                     )
             {
                 // Look through our transfer data for the image
                 static const char* const imageMimeTypes[] = {
-                    kNativeImageMime, kPNGImageMime, kJPEGImageMime, kGIFImageMime };
+                    kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime };
                 nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive;
                 for (PRUint32 i = 0; !ptrPrimitive && i < ArrayLength(imageMimeTypes); i++)
                 {
                     aTransferable->GetTransferData(imageMimeTypes[i], getter_AddRefs(clip), &len);
                     ptrPrimitive = do_QueryInterface(clip);
                 }
 
                 if (!ptrPrimitive)
@@ -318,28 +319,29 @@ nsClipboard::GetNativeClipboardData(nsIT
                 aTransferable->SetTransferData(foundFlavor.get(),
                                                genericDataWrapper,len);
                 // And thats all
                 break;
             }
 
             // Image?
             if ((  !strcmp(flavorStr.get(), kJPEGImageMime)
+                || !strcmp(flavorStr.get(), kJPGImageMime)
                 || !strcmp(flavorStr.get(), kPNGImageMime)
                 || !strcmp(flavorStr.get(), kGIFImageMime))
                 && mimeData->hasImage())
             {
                 // Try to retrieve an image from clipboard
                 QImage image = cb->image();
                 if(image.isNull())
                     continue;
 
                 // Lets set the image format
                 QByteArray imageFormat;
-                if (!strcmp(flavorStr.get(), kJPEGImageMime))
+                if (!strcmp(flavorStr.get(), kJPEGImageMime) || !strcmp(flavorStr.get(), kJPGImageMime)
                     imageFormat = "jpeg";
                 else if (!strcmp(flavorStr.get(), kPNGImageMime))
                     imageFormat = "png";
                 else if (!strcmp(flavorStr.get(), kGIFImageMime))
                     imageFormat = "gif";
                 else
                     continue;
 
--- a/widget/tests/test_bug444800.xul
+++ b/widget/tests/test_bug444800.xul
@@ -79,15 +79,16 @@ function initAndRunTests()
   // Work around a problem on Windows where clipboard is not ready after copy.
   setTimeout(function() { runTests(cbSvc); }, 0);
 }
 
 function runTests(aCBSvc)
 {
   runImageClipboardTests(aCBSvc, "image/png");
   runImageClipboardTests(aCBSvc, "image/jpg");
+  runImageClipboardTests(aCBSvc, "image/jpeg");
 
   SimpleTest.finish();
 }
 
 ]]>
 </script>
 </window>
--- a/widget/windows/nsClipboard.cpp
+++ b/widget/windows/nsClipboard.cpp
@@ -71,19 +71,20 @@ UINT nsClipboard::GetFormat(const char* 
 {
   UINT format;
 
   if (strcmp(aMimeStr, kTextMime) == 0)
     format = CF_TEXT;
   else if (strcmp(aMimeStr, kUnicodeMime) == 0)
     format = CF_UNICODETEXT;
   else if (strcmp(aMimeStr, kJPEGImageMime) == 0 ||
+           strcmp(aMimeStr, kJPGImageMime) == 0 ||
            strcmp(aMimeStr, kPNGImageMime) == 0)
     format = CF_DIB;
-  else if (strcmp(aMimeStr, kFileMime) == 0 || 
+  else if (strcmp(aMimeStr, kFileMime) == 0 ||
            strcmp(aMimeStr, kFilePromiseMime) == 0)
     format = CF_HDROP;
   else if (strcmp(aMimeStr, kNativeHTMLMime) == 0)
     format = CF_HTML;
   else
     format = ::RegisterClipboardFormatW(NS_ConvertASCIItoUTF16(aMimeStr).get());
 
   return format;
@@ -181,17 +182,18 @@ nsresult nsClipboard::SetupNativeDataObj
         SET_FORMATETC(shortcutFE, ::RegisterClipboardFormat(CFSTR_FILECONTENTS), 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
         dObj->AddDataFlavor(kURLMime, &shortcutFE);  
         SET_FORMATETC(shortcutFE, ::RegisterClipboardFormat(CFSTR_INETURLA), 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
         dObj->AddDataFlavor(kURLMime, &shortcutFE);      
         SET_FORMATETC(shortcutFE, ::RegisterClipboardFormat(CFSTR_INETURLW), 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
         dObj->AddDataFlavor(kURLMime, &shortcutFE);      
       }
       else if ( strcmp(flavorStr, kPNGImageMime) == 0 || strcmp(flavorStr, kJPEGImageMime) == 0 ||
-                  strcmp(flavorStr, kGIFImageMime) == 0 || strcmp(flavorStr, kNativeImageMime) == 0  ) {
+                strcmp(flavorStr, kJPGImageMime) == 0 || strcmp(flavorStr, kGIFImageMime) == 0 ||
+                strcmp(flavorStr, kNativeImageMime) == 0  ) {
         // if we're an image, register the native bitmap flavor
         FORMATETC imageFE;
         SET_FORMATETC(imageFE, CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
         dObj->AddDataFlavor(flavorStr, &imageFE);      
       }
       else if ( strcmp(flavorStr, kFilePromiseMime) == 0 ) {
          // if we're a file promise flavor, also register the 
          // CFSTR_PREFERREDDROPEFFECT format.  The data object
@@ -620,16 +622,17 @@ nsresult nsClipboard::GetDataFromDataObj
           else
           {
             nsMemory::Free(data);
             continue;     // something wrong with this flavor, keep looking for other data
           }
           nsMemory::Free(data);
         }
         else if ( strcmp(flavorStr, kJPEGImageMime) == 0 ||
+                  strcmp(flavorStr, kJPGImageMime) == 0 ||
                   strcmp(flavorStr, kPNGImageMime) == 0) {
           nsIInputStream * imageStream = reinterpret_cast<nsIInputStream*>(data);
           genericDataWrapper = do_QueryInterface(imageStream);
           NS_IF_RELEASE(imageStream);
         }
         else {
           // we probably have some form of text. The DOM only wants LF, so convert from Win32 line 
           // endings to DOM line endings.
--- a/widget/windows/nsImageClipboard.cpp
+++ b/widget/windows/nsImageClipboard.cpp
@@ -196,17 +196,17 @@ nsImageFromClipboard ::GetEncodedImageSt
     BYTE  * pGlobal = (BYTE *) aClipboardData;
     // Convert the clipboard image into RGB packed pixel data
     rv = ConvertColorBitMap((unsigned char *) (pGlobal + header->bmiHeader.biSize), header, rgbData);
     // if that succeeded, encode the bitmap as aMIMEFormat data. Don't return early or we risk leaking rgbData
     if (NS_SUCCEEDED(rv)) {
       nsCAutoString encoderCID(NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type="));
 
       // Map image/jpg to image/jpeg (which is how the encoder is registered).
-      if (strcmp(aMIMEFormat, kJPEGImageMime) == 0)
+      if (strcmp(aMIMEFormat, kJPGImageMime) == 0)
         encoderCID.Append("image/jpeg");
       else
         encoderCID.Append(aMIMEFormat);
       nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get(), &rv);
       if (NS_SUCCEEDED(rv)){
         rv = encoder->InitFromData(rgbData, 0, width, height, 3 * width /* RGB * # pixels in a row */, 
                                    imgIEncoder::INPUT_FORMAT_RGB, EmptyString());
         if (NS_SUCCEEDED(rv))