зеркало из https://github.com/mozilla/gecko-dev.git
back out patch for bug 400028, it caused 407020 which is more serious. b=400028 r=josh sr=roc
This commit is contained in:
Родитель
7810776cd0
Коммит
7496007653
|
@ -91,37 +91,6 @@ GetDataFromPasteboard(NSPasteboard* aPasteboard, NSString* aType)
|
|||
}
|
||||
|
||||
|
||||
// This function converts the image referenced by aSourceImageRef to the
|
||||
// specified type and adds it to the Pasteboard dictionary aDict.
|
||||
static PRBool
|
||||
AddImageDataToPasteboardDict(NSMutableDictionary *aDict,
|
||||
CGImageRef aSourceImageRef,
|
||||
CFStringRef aImageType,
|
||||
NSString *aPasteboardType)
|
||||
{
|
||||
if (!aDict || !aSourceImageRef || !aImageType || !aPasteboardType)
|
||||
return PR_FALSE;
|
||||
|
||||
CFMutableDataRef imageData = CFDataCreateMutable(kCFAllocatorDefault, 0);
|
||||
CGImageDestinationRef destRef = CGImageDestinationCreateWithData(imageData,
|
||||
aImageType,
|
||||
1,
|
||||
NULL);
|
||||
CGImageDestinationAddImage(destRef, aSourceImageRef, NULL);
|
||||
PRBool imageConverted = CGImageDestinationFinalize(destRef);
|
||||
if (destRef)
|
||||
CFRelease(destRef);
|
||||
|
||||
if (imageConverted)
|
||||
[aDict setObject:(NSMutableData*)imageData forKey:aPasteboardType];
|
||||
|
||||
if (imageData)
|
||||
CFRelease(imageData);
|
||||
|
||||
return imageConverted;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
|
||||
{
|
||||
|
@ -474,18 +443,28 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
|
|||
CGColorSpaceRelease(colorSpace);
|
||||
CGDataProviderRelease(dataProvider);
|
||||
|
||||
// Convert the CGImageRef to TIFF and PICT data and add to dictionary.
|
||||
// We include PICT in order to work around a problem with a system
|
||||
// component that places invalid PICT data on the clipboard when it sees
|
||||
// TIFF data (this seems to happen when the user quits the application
|
||||
// immediately after copying an image). See bug 400028.
|
||||
AddImageDataToPasteboardDict(pasteboardOutputDict, imageRef,
|
||||
CFSTR("public.tiff"), NSTIFFPboardType);
|
||||
AddImageDataToPasteboardDict(pasteboardOutputDict, imageRef,
|
||||
CFSTR("com.apple.pict"), NSPICTPboardType);
|
||||
CGImageRelease(imageRef);
|
||||
// Convert the CGImageRef to TIFF data.
|
||||
CFMutableDataRef tiffData = CFDataCreateMutable(kCFAllocatorDefault, 0);
|
||||
CGImageDestinationRef destRef = CGImageDestinationCreateWithData(tiffData,
|
||||
CFSTR("public.tiff"),
|
||||
1,
|
||||
NULL);
|
||||
CGImageDestinationAddImage(destRef, imageRef, NULL);
|
||||
PRBool successfullyConverted = CGImageDestinationFinalize(destRef);
|
||||
|
||||
image->UnlockImagePixels(PR_FALSE);
|
||||
CGImageRelease(imageRef);
|
||||
if (destRef)
|
||||
CFRelease(destRef);
|
||||
|
||||
if (NS_FAILED(image->UnlockImagePixels(PR_FALSE)) || !successfullyConverted) {
|
||||
if (tiffData)
|
||||
CFRelease(tiffData);
|
||||
continue;
|
||||
}
|
||||
|
||||
[pasteboardOutputDict setObject:(NSMutableData*)tiffData forKey:NSTIFFPboardType];
|
||||
if (tiffData)
|
||||
CFRelease(tiffData);
|
||||
}
|
||||
else if (flavorStr.EqualsLiteral(kFilePromiseMime)) {
|
||||
[pasteboardOutputDict setObject:[NSArray arrayWithObject:@""] forKey:NSFilesPromisePboardType];
|
||||
|
|
Загрузка…
Ссылка в новой задаче