Bug 1689992: part 0) Factor `nsClipboard::IsImageType` out. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D105277
This commit is contained in:
Mirko Brodesser 2021-02-19 09:04:34 +00:00
Родитель 2d8d6edee2
Коммит 373e080995
2 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -34,6 +34,7 @@ class nsClipboard : public nsIClipboard {
static NSDictionary* PasteboardDictFromTransferable(nsITransferable* aTransferable);
// aPasteboardType is being retained and needs to be released by the caller.
static bool IsStringType(const nsCString& aMIMEType, NSString** aPasteboardType);
static bool IsImageType(const nsACString& aMIMEType);
static NSString* WrapHtmlForSystemPasteboard(NSString* aString);
static nsresult TransferableFromPasteboard(nsITransferable* aTransferable, NSPasteboard* pboard);

Просмотреть файл

@ -505,9 +505,7 @@ NSDictionary* nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTran
}
[pasteboardOutputDict setObject:nativeData forKey:customType];
}
} else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) ||
flavorStr.EqualsLiteral(kNativeImageMime)) {
} else if (nsClipboard::IsImageType(flavorStr)) {
nsCOMPtr<nsISupports> transferSupports;
rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(transferSupports));
if (NS_FAILED(rv)) {
@ -656,6 +654,13 @@ bool nsClipboard::IsStringType(const nsCString& aMIMEType, NSString** aPasteboar
}
}
// static
bool nsClipboard::IsImageType(const nsACString& aMIMEType) {
return aMIMEType.EqualsLiteral(kPNGImageMime) || aMIMEType.EqualsLiteral(kJPEGImageMime) ||
aMIMEType.EqualsLiteral(kJPGImageMime) || aMIMEType.EqualsLiteral(kGIFImageMime) ||
aMIMEType.EqualsLiteral(kNativeImageMime);
}
NSString* nsClipboard::WrapHtmlForSystemPasteboard(NSString* aString) {
NSString* wrapped = [NSString
stringWithFormat:@"<html>"