Backout changeset 125438dda903 (bug 761051) because of Bq bustage

This commit is contained in:
Ehsan Akhgari 2012-06-07 19:49:37 -04:00
parent 97c0ab79ca
commit 3010661bb0
10 changed files with 21 additions and 45 deletions

View File

@ -1002,7 +1002,6 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransfera
{ {
case 0: // prefer JPEG over PNG over GIF encoding case 0: // prefer JPEG over PNG over GIF encoding
(*aTransferable)->AddDataFlavor(kJPEGImageMime); (*aTransferable)->AddDataFlavor(kJPEGImageMime);
(*aTransferable)->AddDataFlavor(kJPGImageMime);
(*aTransferable)->AddDataFlavor(kPNGImageMime); (*aTransferable)->AddDataFlavor(kPNGImageMime);
(*aTransferable)->AddDataFlavor(kGIFImageMime); (*aTransferable)->AddDataFlavor(kGIFImageMime);
break; break;
@ -1010,13 +1009,11 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransfera
default: default:
(*aTransferable)->AddDataFlavor(kPNGImageMime); (*aTransferable)->AddDataFlavor(kPNGImageMime);
(*aTransferable)->AddDataFlavor(kJPEGImageMime); (*aTransferable)->AddDataFlavor(kJPEGImageMime);
(*aTransferable)->AddDataFlavor(kJPGImageMime);
(*aTransferable)->AddDataFlavor(kGIFImageMime); (*aTransferable)->AddDataFlavor(kGIFImageMime);
break; break;
case 2: // prefer GIF over JPEG over PNG encoding case 2: // prefer GIF over JPEG over PNG encoding
(*aTransferable)->AddDataFlavor(kGIFImageMime); (*aTransferable)->AddDataFlavor(kGIFImageMime);
(*aTransferable)->AddDataFlavor(kJPEGImageMime); (*aTransferable)->AddDataFlavor(kJPEGImageMime);
(*aTransferable)->AddDataFlavor(kJPGImageMime);
(*aTransferable)->AddDataFlavor(kPNGImageMime); (*aTransferable)->AddDataFlavor(kPNGImageMime);
break; break;
} }
@ -1238,7 +1235,6 @@ nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, boo
} }
if (0 == nsCRT::strcmp(type, kJPEGImageMime) || if (0 == nsCRT::strcmp(type, kJPEGImageMime) ||
0 == nsCRT::strcmp(type, kJPGImageMime) ||
0 == nsCRT::strcmp(type, kPNGImageMime) || 0 == nsCRT::strcmp(type, kPNGImageMime) ||
0 == nsCRT::strcmp(type, kGIFImageMime) || 0 == nsCRT::strcmp(type, kGIFImageMime) ||
insertAsImage) insertAsImage)
@ -1308,7 +1304,6 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
if (0 == nsCRT::strcmp(bestFlavor, kFileMime) || if (0 == nsCRT::strcmp(bestFlavor, kFileMime) ||
0 == nsCRT::strcmp(bestFlavor, kJPEGImageMime) || 0 == nsCRT::strcmp(bestFlavor, kJPEGImageMime) ||
0 == nsCRT::strcmp(bestFlavor, kJPGImageMime) ||
0 == nsCRT::strcmp(bestFlavor, kPNGImageMime) || 0 == nsCRT::strcmp(bestFlavor, kPNGImageMime) ||
0 == nsCRT::strcmp(bestFlavor, kGIFImageMime)) { 0 == nsCRT::strcmp(bestFlavor, kGIFImageMime)) {
rv = InsertObject(bestFlavor, genericDataObj, isSafe, rv = InsertObject(bestFlavor, genericDataObj, isSafe,
@ -1408,7 +1403,6 @@ nsresult nsHTMLEditor::InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
if (!isText) { if (!isText) {
if (type.EqualsLiteral(kFileMime) || if (type.EqualsLiteral(kFileMime) ||
type.EqualsLiteral(kJPEGImageMime) || type.EqualsLiteral(kJPEGImageMime) ||
type.EqualsLiteral(kJPGImageMime) ||
type.EqualsLiteral(kPNGImageMime) || type.EqualsLiteral(kPNGImageMime) ||
type.EqualsLiteral(kGIFImageMime)) { type.EqualsLiteral(kGIFImageMime)) {
nsCOMPtr<nsIVariant> variant; nsCOMPtr<nsIVariant> variant;
@ -1630,8 +1624,8 @@ NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(PRInt32 aSelectionType)
static const char* textEditorFlavors[] = { kUnicodeMime }; static const char* textEditorFlavors[] = { kUnicodeMime };
static const char* textHtmlEditorFlavors[] = { kUnicodeMime, kHTMLMime, static const char* textHtmlEditorFlavors[] = { kUnicodeMime, kHTMLMime,
kJPEGImageMime, kJPGImageMime, kJPEGImageMime, kPNGImageMime,
kPNGImageMime, kGIFImageMime }; kGIFImageMime };
NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, bool *aCanPaste) NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, bool *aCanPaste)
{ {

View File

@ -165,7 +165,6 @@ nsClipboard::TransferableFromPasteboard(nsITransferable *aTransferable, NSPasteb
break; break;
} }
else if (flavorStr.EqualsLiteral(kJPEGImageMime) || else if (flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) ||
flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kPNGImageMime) ||
flavorStr.EqualsLiteral(kGIFImageMime)) { flavorStr.EqualsLiteral(kGIFImageMime)) {
// Figure out if there's data on the pasteboard we can grab (sanity check) // Figure out if there's data on the pasteboard we can grab (sanity check)
@ -180,8 +179,7 @@ nsClipboard::TransferableFromPasteboard(nsITransferable *aTransferable, NSPasteb
// Figure out what type we're converting to // Figure out what type we're converting to
CFStringRef outputType = NULL; CFStringRef outputType = NULL;
if (flavorStr.EqualsLiteral(kJPEGImageMime) || if (flavorStr.EqualsLiteral(kJPEGImageMime))
flavorStr.EqualsLiteral(kJPGImageMime))
outputType = CFSTR("public.jpeg"); outputType = CFSTR("public.jpeg");
else if (flavorStr.EqualsLiteral(kPNGImageMime)) else if (flavorStr.EqualsLiteral(kPNGImageMime))
outputType = CFSTR("public.png"); outputType = CFSTR("public.png");
@ -341,7 +339,6 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength,
break; break;
} }
} else if (!strcmp(aFlavorList[i], kJPEGImageMime) || } else if (!strcmp(aFlavorList[i], kJPEGImageMime) ||
!strcmp(aFlavorList[i], kJPGImageMime) ||
!strcmp(aFlavorList[i], kPNGImageMime) || !strcmp(aFlavorList[i], kPNGImageMime) ||
!strcmp(aFlavorList[i], kGIFImageMime)) { !strcmp(aFlavorList[i], kGIFImageMime)) {
NSString* availableType = [generalPBoard availableTypeFromArray: NSString* availableType = [generalPBoard availableTypeFromArray:
@ -413,8 +410,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
nsMemory::Free(data); nsMemory::Free(data);
} }
else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) || else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) || flavorStr.EqualsLiteral(kNativeImageMime)) {
flavorStr.EqualsLiteral(kNativeImageMime)) {
PRUint32 dataSize = 0; PRUint32 dataSize = 0;
nsCOMPtr<nsISupports> transferSupports; nsCOMPtr<nsISupports> transferSupports;
aTransferable->GetTransferData(flavorStr, getter_AddRefs(transferSupports), &dataSize); aTransferable->GetTransferData(flavorStr, getter_AddRefs(transferSupports), &dataSize);

View File

@ -426,7 +426,7 @@ nsDragService::GetData(nsITransferable* aTransferable, PRUint32 aItemIndex)
// in is accomplished with a file path drag instead of the image data itself. // in is accomplished with a file path drag instead of the image data itself.
/* /*
if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) || if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime)) { flavorStr.EqualsLiteral(kGIFImageMime)) {
} }
*/ */

View File

@ -207,7 +207,6 @@ nsClipboard::SetData(nsITransferable *aTransferable,
if (flavorStr.EqualsLiteral(kNativeImageMime) || if (flavorStr.EqualsLiteral(kNativeImageMime) ||
flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kPNGImageMime) ||
flavorStr.EqualsLiteral(kJPEGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) ||
flavorStr.EqualsLiteral(kGIFImageMime)) { flavorStr.EqualsLiteral(kGIFImageMime)) {
// don't bother adding image targets twice // don't bother adding image targets twice
if (!imagesAdded) { if (!imagesAdded) {
@ -315,16 +314,12 @@ nsClipboard::GetData(nsITransferable *aTransferable, PRInt32 aWhichClipboard)
// For images, we must wrap the data in an nsIInputStream then return instead of break, // For images, we must wrap the data in an nsIInputStream then return instead of break,
// because that code below won't help us. // because that code below won't help us.
if (!strcmp(flavorStr, kJPEGImageMime) || if (!strcmp(flavorStr, kJPEGImageMime) || !strcmp(flavorStr, kPNGImageMime) || !strcmp(flavorStr, kGIFImageMime)) {
!strcmp(flavorStr, kJPGImageMime) || GdkAtom atom;
!strcmp(flavorStr, kPNGImageMime) || if (!strcmp(flavorStr, kJPEGImageMime)) // This is image/jpg, but X only understands image/jpeg
!strcmp(flavorStr, kGIFImageMime)) { atom = gdk_atom_intern("image/jpeg", FALSE);
// Emulate support for image/jpg else
if (!strcmp(flavorStr, kJPGImageMime)) { atom = gdk_atom_intern(flavorStr, FALSE);
flavorStr.Assign(kJPEGImageMime);
}
GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
GtkSelectionData *selectionData = wait_for_contents(clipboard, atom); GtkSelectionData *selectionData = wait_for_contents(clipboard, atom);
if (!selectionData) if (!selectionData)
@ -446,9 +441,8 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength,
if (!strcmp(atom_name, aFlavorList[i])) if (!strcmp(atom_name, aFlavorList[i]))
*_retval = true; *_retval = true;
// X clipboard supports image/jpeg, but we want to emulate support // X clipboard wants image/jpeg, not image/jpg
// for image/jpg as well if (!strcmp(aFlavorList[i], kJPEGImageMime) && !strcmp(atom_name, "image/jpeg"))
if (!strcmp(aFlavorList[i], kJPGImageMime) && !strcmp(atom_name, kJPEGImageMime))
*_retval = true; *_retval = true;
g_free(atom_name); g_free(atom_name);
@ -570,7 +564,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
if (gtk_targets_include_image(&aSelectionData->target, 1, TRUE)) { if (gtk_targets_include_image(&aSelectionData->target, 1, TRUE)) {
// Look through our transfer data for the image // Look through our transfer data for the image
static const char* const imageMimeTypes[] = { static const char* const imageMimeTypes[] = {
kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime }; kNativeImageMime, kPNGImageMime, kJPEGImageMime, kGIFImageMime };
nsCOMPtr<nsISupports> item; nsCOMPtr<nsISupports> item;
PRUint32 len; PRUint32 len;
nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive; nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive;

View File

@ -19,8 +19,7 @@
#define kHTMLMime "text/html" #define kHTMLMime "text/html"
#define kAOLMailMime "AOLMAIL" #define kAOLMailMime "AOLMAIL"
#define kPNGImageMime "image/png" #define kPNGImageMime "image/png"
#define kJPEGImageMime "image/jpeg" #define kJPEGImageMime "image/jpg"
#define kJPGImageMime "image/jpg"
#define kGIFImageMime "image/gif" #define kGIFImageMime "image/gif"
#define kFileMime "application/x-moz-file" #define kFileMime "application/x-moz-file"

View File

@ -34,7 +34,6 @@ nsClipboard::nsClipboard() : nsBaseClipboard()
RegisterClipboardFormat(kAOLMailMime); RegisterClipboardFormat(kAOLMailMime);
RegisterClipboardFormat(kPNGImageMime); RegisterClipboardFormat(kPNGImageMime);
RegisterClipboardFormat(kJPEGImageMime); RegisterClipboardFormat(kJPEGImageMime);
RegisterClipboardFormat(kJPGImageMime);
RegisterClipboardFormat(kGIFImageMime); RegisterClipboardFormat(kGIFImageMime);
RegisterClipboardFormat(kFileMime); RegisterClipboardFormat(kFileMime);
RegisterClipboardFormat(kURLMime); RegisterClipboardFormat(kURLMime);
@ -139,7 +138,7 @@ bool nsClipboard::GetClipboardDataByID(PRUint32 aFormatID, const char *aFlavor)
{ {
if (aFormatID == CF_BITMAP) if (aFormatID == CF_BITMAP)
{ {
if (!strcmp( aFlavor, kJPEGImageMime ) || !strcmp( aFlavor, kJPGImageMime )) if (!strcmp( aFlavor, kJPEGImageMime ))
{ {
// OS2TODO Convert bitmap to jpg // OS2TODO Convert bitmap to jpg
#ifdef DEBUG #ifdef DEBUG

View File

@ -153,13 +153,12 @@ nsClipboard::SetNativeClipboardData( nsITransferable *aTransferable,
&& (!strcmp(flavorStr.get(), kNativeImageMime) && (!strcmp(flavorStr.get(), kNativeImageMime)
|| !strcmp(flavorStr.get(), kPNGImageMime) || !strcmp(flavorStr.get(), kPNGImageMime)
|| !strcmp(flavorStr.get(), kJPEGImageMime) || !strcmp(flavorStr.get(), kJPEGImageMime)
|| !strcmp(flavorStr.get(), kJPGImageMime)
|| !strcmp(flavorStr.get(), kGIFImageMime)) || !strcmp(flavorStr.get(), kGIFImageMime))
) )
{ {
// Look through our transfer data for the image // Look through our transfer data for the image
static const char* const imageMimeTypes[] = { static const char* const imageMimeTypes[] = {
kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime }; kNativeImageMime, kPNGImageMime, kJPEGImageMime, kGIFImageMime };
nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive; nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive;
for (PRUint32 i = 0; !ptrPrimitive && i < ArrayLength(imageMimeTypes); i++) for (PRUint32 i = 0; !ptrPrimitive && i < ArrayLength(imageMimeTypes); i++)
{ {
@ -324,7 +323,6 @@ nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable,
// Image? // Image?
if (( !strcmp(flavorStr.get(), kJPEGImageMime) if (( !strcmp(flavorStr.get(), kJPEGImageMime)
|| !strcmp(flavorStr.get(), kJPGImageMime)
|| !strcmp(flavorStr.get(), kPNGImageMime) || !strcmp(flavorStr.get(), kPNGImageMime)
|| !strcmp(flavorStr.get(), kGIFImageMime)) || !strcmp(flavorStr.get(), kGIFImageMime))
&& mimeData->hasImage()) && mimeData->hasImage())
@ -336,7 +334,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable,
// Lets set the image format // Lets set the image format
QByteArray imageFormat; QByteArray imageFormat;
if (!strcmp(flavorStr.get(), kJPEGImageMime) || !strcmp(flavorStr.get(), kJPGImageMime) if (!strcmp(flavorStr.get(), kJPEGImageMime))
imageFormat = "jpeg"; imageFormat = "jpeg";
else if (!strcmp(flavorStr.get(), kPNGImageMime)) else if (!strcmp(flavorStr.get(), kPNGImageMime))
imageFormat = "png"; imageFormat = "png";

View File

@ -84,7 +84,6 @@ function runTests(aCBSvc)
{ {
runImageClipboardTests(aCBSvc, "image/png"); runImageClipboardTests(aCBSvc, "image/png");
runImageClipboardTests(aCBSvc, "image/jpg"); runImageClipboardTests(aCBSvc, "image/jpg");
runImageClipboardTests(aCBSvc, "image/jpeg");
SimpleTest.finish(); SimpleTest.finish();
} }

View File

@ -76,10 +76,9 @@ UINT nsClipboard::GetFormat(const char* aMimeStr)
else if (strcmp(aMimeStr, kUnicodeMime) == 0) else if (strcmp(aMimeStr, kUnicodeMime) == 0)
format = CF_UNICODETEXT; format = CF_UNICODETEXT;
else if (strcmp(aMimeStr, kJPEGImageMime) == 0 || else if (strcmp(aMimeStr, kJPEGImageMime) == 0 ||
strcmp(aMimeStr, kJPGImageMime) == 0 ||
strcmp(aMimeStr, kPNGImageMime) == 0) strcmp(aMimeStr, kPNGImageMime) == 0)
format = CF_DIB; format = CF_DIB;
else if (strcmp(aMimeStr, kFileMime) == 0 || else if (strcmp(aMimeStr, kFileMime) == 0 ||
strcmp(aMimeStr, kFilePromiseMime) == 0) strcmp(aMimeStr, kFilePromiseMime) == 0)
format = CF_HDROP; format = CF_HDROP;
else if (strcmp(aMimeStr, kNativeHTMLMime) == 0) else if (strcmp(aMimeStr, kNativeHTMLMime) == 0)
@ -187,8 +186,7 @@ nsresult nsClipboard::SetupNativeDataObject(nsITransferable * aTransferable, IDa
dObj->AddDataFlavor(kURLMime, &shortcutFE); dObj->AddDataFlavor(kURLMime, &shortcutFE);
} }
else if ( strcmp(flavorStr, kPNGImageMime) == 0 || strcmp(flavorStr, kJPEGImageMime) == 0 || else if ( strcmp(flavorStr, kPNGImageMime) == 0 || strcmp(flavorStr, kJPEGImageMime) == 0 ||
strcmp(flavorStr, kJPGImageMime) == 0 || strcmp(flavorStr, kGIFImageMime) == 0 || strcmp(flavorStr, kGIFImageMime) == 0 || strcmp(flavorStr, kNativeImageMime) == 0 ) {
strcmp(flavorStr, kNativeImageMime) == 0 ) {
// if we're an image, register the native bitmap flavor // if we're an image, register the native bitmap flavor
FORMATETC imageFE; FORMATETC imageFE;
SET_FORMATETC(imageFE, CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL) SET_FORMATETC(imageFE, CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
@ -627,7 +625,6 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
nsMemory::Free(data); nsMemory::Free(data);
} }
else if ( strcmp(flavorStr, kJPEGImageMime) == 0 || else if ( strcmp(flavorStr, kJPEGImageMime) == 0 ||
strcmp(flavorStr, kJPGImageMime) == 0 ||
strcmp(flavorStr, kPNGImageMime) == 0) { strcmp(flavorStr, kPNGImageMime) == 0) {
nsIInputStream * imageStream = reinterpret_cast<nsIInputStream*>(data); nsIInputStream * imageStream = reinterpret_cast<nsIInputStream*>(data);
genericDataWrapper = do_QueryInterface(imageStream); genericDataWrapper = do_QueryInterface(imageStream);

View File

@ -201,7 +201,7 @@ nsImageFromClipboard ::GetEncodedImageStream (unsigned char * aClipboardData, co
nsCAutoString encoderCID(NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type=")); nsCAutoString encoderCID(NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type="));
// Map image/jpg to image/jpeg (which is how the encoder is registered). // Map image/jpg to image/jpeg (which is how the encoder is registered).
if (strcmp(aMIMEFormat, kJPGImageMime) == 0) if (strcmp(aMIMEFormat, kJPEGImageMime) == 0)
encoderCID.Append("image/jpeg"); encoderCID.Append("image/jpeg");
else else
encoderCID.Append(aMIMEFormat); encoderCID.Append(aMIMEFormat);