зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557847. Stop using [array] in nsIClipboard. r=NeilDeakin
Differential Revision: https://phabricator.services.mozilla.com/D34243 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
351d40e7c3
Коммит
5eb248348f
|
@ -329,7 +329,7 @@ PlacesController.prototype = {
|
|||
var flavors = PlacesUIUtils.PLACES_FLAVORS;
|
||||
var clipboard = this.clipboard;
|
||||
var hasPlacesData =
|
||||
clipboard.hasDataMatchingFlavors(flavors, flavors.length,
|
||||
clipboard.hasDataMatchingFlavors(flavors,
|
||||
Ci.nsIClipboard.kGlobalClipboard);
|
||||
if (hasPlacesData)
|
||||
return this._view.insertionPoint != null;
|
||||
|
|
|
@ -45,9 +45,9 @@ async function testCopyPaste (isXHTML) {
|
|||
await SimpleTest.promiseClipboardChange(() => true,
|
||||
() => { documentViewer.copySelection(); });
|
||||
if (!suppressUnicodeCheck)
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), "check text/unicode");
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1), "check text/unicode");
|
||||
if (!suppressHTMLCheck)
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), "check text/html");
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], 1), "check text/html");
|
||||
}
|
||||
function clear(node, suppressUnicodeCheck) {
|
||||
textarea.blur();
|
||||
|
|
|
@ -59,17 +59,17 @@ function hasExpectedFlavors() {
|
|||
var cb = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
|
||||
ok(cb.hasDataMatchingFlavors(["text/unicode"], 1, cb.kGlobalClipboard),
|
||||
ok(cb.hasDataMatchingFlavors(["text/unicode"], cb.kGlobalClipboard),
|
||||
"The clipboard has text/unicode");
|
||||
|
||||
// Android only supports plain text
|
||||
if (!navigator.appVersion.includes("Android")) {
|
||||
ok(cb.hasDataMatchingFlavors(["text/html"], 1, cb.kGlobalClipboard),
|
||||
ok(cb.hasDataMatchingFlavors(["text/html"], cb.kGlobalClipboard),
|
||||
"The clipboard has text/html");
|
||||
}
|
||||
|
||||
if (navigator.appVersion.includes("Win")) {
|
||||
ok(cb.hasDataMatchingFlavors(["application/x-moz-nativehtml"], 1, cb.kGlobalClipboard),
|
||||
ok(cb.hasDataMatchingFlavors(["application/x-moz-nativehtml"], cb.kGlobalClipboard),
|
||||
"The clipboard has application/x-moz-nativehtml");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=816298
|
|||
window.getSelection().selectAllChildren(document.getElementById(id));
|
||||
documentViewer.copySelection();
|
||||
|
||||
is(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), true);
|
||||
is(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), true);
|
||||
is(clipboard.hasDataMatchingFlavors(["text/unicode"], 1), true);
|
||||
is(clipboard.hasDataMatchingFlavors(["text/html"], 1), true);
|
||||
}
|
||||
function getClipboardData(mime) {
|
||||
var transferable = Cc['@mozilla.org/widget/transferable;1']
|
||||
|
|
|
@ -58,11 +58,11 @@ function testCopyImage () {
|
|||
//--------- Let's check the content of the clipboard now.
|
||||
|
||||
// Does the clipboard contain text/unicode data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard), "clipboard contains unicode text");
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], clipboard.kGlobalClipboard), "clipboard contains unicode text");
|
||||
// Does the clipboard contain text/html data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard), "clipboard contains html text");
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard), "clipboard contains html text");
|
||||
// Does the clipboard contain image data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["image/png"], 1, clipboard.kGlobalClipboard), "clipboard contains image");
|
||||
ok(clipboard.hasDataMatchingFlavors(["image/png"], clipboard.kGlobalClipboard), "clipboard contains image");
|
||||
|
||||
// Is the text/uncodie data correct ?
|
||||
testClipboardValue('text/unicode', 'about:logo');
|
||||
|
|
|
@ -676,10 +676,9 @@ void DataTransfer::GetExternalClipboardFormats(const int32_t& aWhichClipboard,
|
|||
|
||||
if (aPlainTextOnly) {
|
||||
bool hasType;
|
||||
static const char* unicodeMime[] = {kUnicodeMime};
|
||||
nsresult rv = clipboard->HasDataMatchingFlavors(
|
||||
unicodeMime,
|
||||
/* number of flavors to check */ 1, aWhichClipboard, &hasType);
|
||||
AutoTArray<nsCString, 1> unicodeMime = {nsDependentCString(kUnicodeMime)};
|
||||
nsresult rv = clipboard->HasDataMatchingFlavors(unicodeMime,
|
||||
aWhichClipboard, &hasType);
|
||||
NS_SUCCEEDED(rv);
|
||||
if (hasType) {
|
||||
aResult->AppendElement(kUnicodeMime);
|
||||
|
@ -694,9 +693,9 @@ void DataTransfer::GetExternalClipboardFormats(const int32_t& aWhichClipboard,
|
|||
|
||||
for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) {
|
||||
bool hasType;
|
||||
nsresult rv = clipboard->HasDataMatchingFlavors(
|
||||
&(formats[f]),
|
||||
/* number of flavors to check */ 1, aWhichClipboard, &hasType);
|
||||
AutoTArray<nsCString, 1> format = {nsDependentCString(formats[f])};
|
||||
nsresult rv =
|
||||
clipboard->HasDataMatchingFlavors(format, aWhichClipboard, &hasType);
|
||||
NS_SUCCEEDED(rv);
|
||||
if (hasType) {
|
||||
aResult->AppendElement(formats[f]);
|
||||
|
|
|
@ -27,10 +27,10 @@ SimpleTest.waitForFocus(() => {
|
|||
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(SpecialPowers.Ci.nsIClipboard);
|
||||
// does the clipboard contain text/unicode data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard),
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], clipboard.kGlobalClipboard),
|
||||
"clipboard contains unicode text");
|
||||
// does the clipboard contain text/html data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard),
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard),
|
||||
"clipboard contains html text");
|
||||
|
||||
window.addEventListener("paste", (e) => {
|
||||
|
|
|
@ -89,13 +89,13 @@
|
|||
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(SpecialPowers.Ci.nsIClipboard);
|
||||
// does the clipboard contain text/unicode data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard),
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], clipboard.kGlobalClipboard),
|
||||
"clipboard contains unicode text");
|
||||
// does the clipboard contain text/html data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard),
|
||||
ok(clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard),
|
||||
"clipboard contains html text");
|
||||
// does the clipboard contain image data ?
|
||||
ok(clipboard.hasDataMatchingFlavors(["image/png"], 1, clipboard.kGlobalClipboard),
|
||||
ok(clipboard.hasDataMatchingFlavors(["image/png"], clipboard.kGlobalClipboard),
|
||||
"clipboard contains image");
|
||||
|
||||
window.addEventListener("paste", onPaste);
|
||||
|
|
|
@ -2821,15 +2821,8 @@ mozilla::ipc::IPCResult ContentParent::RecvClipboardHasType(
|
|||
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
|
||||
const char** typesChrs = new const char*[aTypes.Length()];
|
||||
for (uint32_t t = 0; t < aTypes.Length(); t++) {
|
||||
typesChrs[t] = aTypes[t].get();
|
||||
}
|
||||
clipboard->HasDataMatchingFlavors(aTypes, aWhichClipboard, aHasType);
|
||||
|
||||
clipboard->HasDataMatchingFlavors(typesChrs, aTypes.Length(), aWhichClipboard,
|
||||
aHasType);
|
||||
|
||||
delete[] typesChrs;
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -1439,10 +1439,10 @@ bool HTMLEditor::HavePrivateHTMLFlavor(nsIClipboard* aClipboard) {
|
|||
NS_ENSURE_TRUE(aClipboard, false);
|
||||
bool bHavePrivateHTMLFlavor = false;
|
||||
|
||||
const char* flavArray[] = {kHTMLContext};
|
||||
AutoTArray<nsCString, 1> flavArray = {nsDependentCString(kHTMLContext)};
|
||||
|
||||
if (NS_SUCCEEDED(aClipboard->HasDataMatchingFlavors(
|
||||
flavArray, ArrayLength(flavArray), nsIClipboard::kGlobalClipboard,
|
||||
flavArray, nsIClipboard::kGlobalClipboard,
|
||||
&bHavePrivateHTMLFlavor))) {
|
||||
return bHavePrivateHTMLFlavor;
|
||||
}
|
||||
|
@ -1643,20 +1643,21 @@ bool HTMLEditor::CanPaste(int32_t aClipboardType) const {
|
|||
|
||||
// Use the flavors depending on the current editor mask
|
||||
if (IsPlaintextEditor()) {
|
||||
AutoTArray<nsCString, ArrayLength(textEditorFlavors)> flavors;
|
||||
flavors.AppendElements<const char*>(Span<const char*>(textEditorFlavors));
|
||||
bool haveFlavors;
|
||||
rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
|
||||
ArrayLength(textEditorFlavors),
|
||||
aClipboardType, &haveFlavors);
|
||||
rv = clipboard->HasDataMatchingFlavors(flavors, aClipboardType,
|
||||
&haveFlavors);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
return haveFlavors;
|
||||
}
|
||||
|
||||
AutoTArray<nsCString, ArrayLength(textHtmlEditorFlavors)> flavors;
|
||||
flavors.AppendElements<const char*>(Span<const char*>(textHtmlEditorFlavors));
|
||||
bool haveFlavors;
|
||||
rv = clipboard->HasDataMatchingFlavors(textHtmlEditorFlavors,
|
||||
ArrayLength(textHtmlEditorFlavors),
|
||||
aClipboardType, &haveFlavors);
|
||||
rv = clipboard->HasDataMatchingFlavors(flavors, aClipboardType, &haveFlavors);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -459,12 +459,12 @@ bool TextEditor::CanPaste(int32_t aClipboardType) const {
|
|||
}
|
||||
|
||||
// the flavors that we can deal with
|
||||
const char* textEditorFlavors[] = {kUnicodeMime};
|
||||
AutoTArray<nsCString, 1> textEditorFlavors = {
|
||||
nsDependentCString(kUnicodeMime)};
|
||||
|
||||
bool haveFlavors;
|
||||
rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
|
||||
ArrayLength(textEditorFlavors),
|
||||
aClipboardType, &haveFlavors);
|
||||
rv = clipboard->HasDataMatchingFlavors(textEditorFlavors, aClipboardType,
|
||||
&haveFlavors);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ function copyCF_HTML(cfhtml, success, failure) {
|
|||
}
|
||||
|
||||
var flavors = [CF_HTML];
|
||||
if (!cb.hasDataMatchingFlavors(flavors, flavors.length, cb.kGlobalClipboard)) {
|
||||
if (!cb.hasDataMatchingFlavors(flavors, cb.kGlobalClipboard)) {
|
||||
setTimeout(function() { copyCF_HTML_worker(successFn, failureFn); }, 100);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class GeckoViewSelectionActionChild extends GeckoViewChildModule {
|
|||
id: "org.mozilla.geckoview.PASTE",
|
||||
predicate: e => e.selectionEditable &&
|
||||
Services.clipboard.hasDataMatchingFlavors(
|
||||
["text/unicode"], 1, Ci.nsIClipboard.kGlobalClipboard),
|
||||
["text/unicode"], Ci.nsIClipboard.kGlobalClipboard),
|
||||
perform: _ => this._performPaste(),
|
||||
}, {
|
||||
id: "org.mozilla.geckoview.DELETE",
|
||||
|
|
|
@ -503,7 +503,7 @@ var ActionBarHandler = {
|
|||
}
|
||||
// Can't paste if Clipboard empty.
|
||||
let flavors = ["text/unicode"];
|
||||
return Services.clipboard.hasDataMatchingFlavors(flavors, flavors.length,
|
||||
return Services.clipboard.hasDataMatchingFlavors(flavors,
|
||||
Ci.nsIClipboard.kGlobalClipboard);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -292,7 +292,7 @@ add_task(async function testAccessibleCarets_designMode() {
|
|||
|
||||
let flavors = ["text/unicode"];
|
||||
let clipboardHasText = Services.clipboard.hasDataMatchingFlavors(
|
||||
flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard);
|
||||
flavors, Ci.nsIClipboard.kGlobalClipboard);
|
||||
is(clipboardHasText, true, "There should now be paste-able text in the clipboard.");
|
||||
|
||||
// Toggle designMode on/off/on, check UI expectations.
|
||||
|
|
|
@ -126,7 +126,7 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
||||
nsClipboard::HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
int32_t aWhichClipboard, bool* aHasText) {
|
||||
*aHasText = false;
|
||||
if (aWhichClipboard != kGlobalClipboard) return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -135,10 +135,10 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
for (uint32_t k = 0; k < aLength; k++) {
|
||||
for (auto& flavor : aFlavorList) {
|
||||
bool hasData =
|
||||
java::Clipboard::HasData(java::GeckoAppShell::GetApplicationContext(),
|
||||
NS_ConvertASCIItoUTF16(aFlavorList[k]));
|
||||
NS_ConvertASCIItoUTF16(flavor));
|
||||
if (hasData) {
|
||||
*aHasText = true;
|
||||
return NS_OK;
|
||||
|
|
|
@ -360,13 +360,13 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, int32_t aWhi
|
|||
|
||||
// returns true if we have *any* of the passed in flavors available for pasting
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
||||
int32_t aWhichClipboard, bool* outResult) {
|
||||
nsClipboard::HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList, int32_t aWhichClipboard,
|
||||
bool* outResult) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
*outResult = false;
|
||||
|
||||
if ((aWhichClipboard != kGlobalClipboard) || !aFlavorList) return NS_OK;
|
||||
if (aWhichClipboard != kGlobalClipboard) return NS_OK;
|
||||
|
||||
// first see if we have data for this in our cached transferable
|
||||
if (mTransferable) {
|
||||
|
@ -376,7 +376,7 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
for (uint32_t j = 0; j < flavors.Length(); j++) {
|
||||
const nsCString& transferableFlavorStr = flavors[j];
|
||||
|
||||
for (uint32_t k = 0; k < aLength; k++) {
|
||||
for (uint32_t k = 0; k < aFlavorList.Length(); k++) {
|
||||
if (transferableFlavorStr.Equals(aFlavorList[k])) {
|
||||
*outResult = true;
|
||||
return NS_OK;
|
||||
|
@ -388,8 +388,7 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
|
||||
NSPasteboard* generalPBoard = [NSPasteboard generalPasteboard];
|
||||
|
||||
for (uint32_t i = 0; i < aLength; i++) {
|
||||
nsDependentCString mimeType(aFlavorList[i]);
|
||||
for (auto& mimeType : aFlavorList) {
|
||||
NSString* pboardType = nil;
|
||||
|
||||
if (nsClipboard::IsStringType(mimeType, &pboardType)) {
|
||||
|
@ -399,7 +398,7 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
*outResult = true;
|
||||
break;
|
||||
}
|
||||
} else if (!strcmp(aFlavorList[i], kCustomTypesMime)) {
|
||||
} else if (mimeType.EqualsLiteral(kCustomTypesMime)) {
|
||||
NSString* availableType = [generalPBoard
|
||||
availableTypeFromArray:
|
||||
[NSArray arrayWithObject:[UTIHelper stringFromPboardType:kMozCustomTypesPboardType]]];
|
||||
|
@ -407,8 +406,8 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
*outResult = true;
|
||||
break;
|
||||
}
|
||||
} else if (!strcmp(aFlavorList[i], kJPEGImageMime) || !strcmp(aFlavorList[i], kJPGImageMime) ||
|
||||
!strcmp(aFlavorList[i], kPNGImageMime) || !strcmp(aFlavorList[i], kGIFImageMime)) {
|
||||
} else if (mimeType.EqualsLiteral(kJPEGImageMime) || mimeType.EqualsLiteral(kJPGImageMime) ||
|
||||
mimeType.EqualsLiteral(kPNGImageMime) || mimeType.EqualsLiteral(kGIFImageMime)) {
|
||||
NSString* availableType = [generalPBoard
|
||||
availableTypeFromArray:
|
||||
[NSArray arrayWithObjects:[UTIHelper stringFromPboardType:NSPasteboardTypeTIFF],
|
||||
|
|
|
@ -331,9 +331,11 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
||||
nsClipboard::HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
int32_t aWhichClipboard, bool* _retval) {
|
||||
if (!aFlavorList || !_retval) return NS_ERROR_NULL_POINTER;
|
||||
if (!_retval) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*_retval = false;
|
||||
|
||||
|
@ -343,9 +345,9 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
|
||||
// Walk through the provided types and try to match it to a
|
||||
// provided type.
|
||||
for (uint32_t i = 0; i < aLength && !*_retval; i++) {
|
||||
for (auto& flavor : aFlavorList) {
|
||||
// We special case text/unicode here.
|
||||
if (!strcmp(aFlavorList[i], kUnicodeMime) &&
|
||||
if (flavor.EqualsLiteral(kUnicodeMime) &&
|
||||
gtk_targets_include_text(targets, targetNums)) {
|
||||
*_retval = true;
|
||||
break;
|
||||
|
@ -355,12 +357,13 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
|||
gchar* atom_name = gdk_atom_name(targets[j]);
|
||||
if (!atom_name) continue;
|
||||
|
||||
if (!strcmp(atom_name, aFlavorList[i])) *_retval = true;
|
||||
|
||||
if (flavor.Equals(atom_name)) {
|
||||
*_retval = true;
|
||||
}
|
||||
// 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)) {
|
||||
else if (flavor.EqualsLiteral(kJPGImageMime) &&
|
||||
!strcmp(atom_name, kJPEGImageMime)) {
|
||||
*_retval = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,22 +77,18 @@ HeadlessClipboard::EmptyClipboard(int32_t aWhichClipboard) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HeadlessClipboard::HasDataMatchingFlavors(const char** aFlavorList,
|
||||
uint32_t aLength,
|
||||
int32_t aWhichClipboard,
|
||||
bool* aHasType) {
|
||||
HeadlessClipboard::HasDataMatchingFlavors(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aWhichClipboard,
|
||||
bool* aHasType) {
|
||||
*aHasType = false;
|
||||
if (aWhichClipboard != kGlobalClipboard) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
// Retrieve the union of all aHasType in aFlavorList
|
||||
for (uint32_t i = 0; i < aLength; ++i) {
|
||||
const char* flavor = aFlavorList[i];
|
||||
if (!flavor) {
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(flavor, kUnicodeMime) && mClipboard->HasText()) {
|
||||
for (auto& flavor : aFlavorList) {
|
||||
if (flavor.EqualsLiteral(kUnicodeMime) && mClipboard->HasText()) {
|
||||
*aHasType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -98,8 +98,7 @@ NS_IMETHODIMP nsBaseClipboard::EmptyClipboard(int32_t aWhichClipboard) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseClipboard::HasDataMatchingFlavors(const char** aFlavorList,
|
||||
uint32_t aLength,
|
||||
nsBaseClipboard::HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
int32_t aWhichClipboard,
|
||||
bool* outResult) {
|
||||
*outResult = true; // say we always do.
|
||||
|
|
|
@ -111,20 +111,13 @@ nsClipboardProxy::EmptyClipboard(int32_t aWhichClipboard) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboardProxy::HasDataMatchingFlavors(const char** aFlavorList,
|
||||
uint32_t aLength,
|
||||
nsClipboardProxy::HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
int32_t aWhichClipboard,
|
||||
bool* aHasType) {
|
||||
*aHasType = false;
|
||||
|
||||
nsTArray<nsCString> types;
|
||||
nsCString* t = types.AppendElements(aLength);
|
||||
for (uint32_t j = 0; j < aLength; ++j) {
|
||||
t[j].Rebind(aFlavorList[j], nsCharTraits<char>::length(aFlavorList[j]));
|
||||
}
|
||||
|
||||
ContentChild::GetSingleton()->SendClipboardHasType(types, aWhichClipboard,
|
||||
aHasType);
|
||||
ContentChild::GetSingleton()->SendClipboardHasType(aFlavorList,
|
||||
aWhichClipboard, aHasType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,13 +59,11 @@ interface nsIClipboard : nsISupports
|
|||
* any of the flavors in the given list.
|
||||
*
|
||||
* @param aFlavorList An array of ASCII strings.
|
||||
* @param aLength The length of the aFlavorList.
|
||||
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
|
||||
* @outResult - if data is present matching one of
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
boolean hasDataMatchingFlavors ( [array, size_is(aLength)] in string aFlavorList,
|
||||
in unsigned long aLength,
|
||||
boolean hasDataMatchingFlavors ( in Array<ACString> aFlavorList,
|
||||
in long aWhichClipboard ) ;
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ function runImageClipboardTests(aCBSvc, aImageType)
|
|||
{
|
||||
// Verify that hasDataMatchingFlavors() is working correctly.
|
||||
var typeArray = [ aImageType ];
|
||||
var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray, typeArray.length,
|
||||
var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray,
|
||||
knsIClipboard.kGlobalClipboard);
|
||||
ok(hasImage, aImageType + " - hasDataMatchingFlavors()");
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ var clipboard = Services.clipboard;
|
|||
}
|
||||
|
||||
setClipboardData(getTransferableFile(dir1));
|
||||
is(clipboard.hasDataMatchingFlavors(["application/x-moz-file"], 1, 1), true);
|
||||
is(clipboard.hasDataMatchingFlavors(["application/x-moz-file"], 1), true);
|
||||
var data = getClipboardData("application/x-moz-file");
|
||||
var file = data.value.QueryInterface(Ci.nsIFile);
|
||||
ok(file.isDirectory(), true);
|
||||
|
|
|
@ -1037,37 +1037,37 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard) {
|
|||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList,
|
||||
uint32_t aLength,
|
||||
int32_t aWhichClipboard,
|
||||
bool* _retval) {
|
||||
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aWhichClipboard,
|
||||
bool* _retval) {
|
||||
*_retval = false;
|
||||
if (aWhichClipboard != kGlobalClipboard || !aFlavorList) {
|
||||
if (aWhichClipboard != kGlobalClipboard) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < aLength; ++i) {
|
||||
for (auto& flavor : aFlavorList) {
|
||||
#ifdef DEBUG
|
||||
if (strcmp(aFlavorList[i], kTextMime) == 0) {
|
||||
if (flavor.EqualsLiteral(kTextMime)) {
|
||||
NS_WARNING(
|
||||
"DO NOT USE THE text/plain DATA FLAVOR ANY MORE. USE text/unicode "
|
||||
"INSTEAD");
|
||||
}
|
||||
#endif
|
||||
|
||||
UINT format = GetFormat(aFlavorList[i]);
|
||||
UINT format = GetFormat(flavor.get());
|
||||
if (IsClipboardFormatAvailable(format)) {
|
||||
*_retval = true;
|
||||
break;
|
||||
} else {
|
||||
// We haven't found the exact flavor the client asked for, but maybe we
|
||||
// can still find it from something else that's on the clipboard...
|
||||
if (strcmp(aFlavorList[i], kUnicodeMime) == 0) {
|
||||
if (flavor.EqualsLiteral(kUnicodeMime)) {
|
||||
// client asked for unicode and it wasn't present, check if we have
|
||||
// CF_TEXT. We'll handle the actual data substitution in the data
|
||||
// object.
|
||||
if (IsClipboardFormatAvailable(GetFormat(kTextMime))) {
|
||||
*_retval = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class nsClipboard : public nsBaseClipboard, public nsIObserver {
|
|||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// nsIClipboard
|
||||
NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
||||
NS_IMETHOD HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
int32_t aWhichClipboard,
|
||||
bool* _retval) override;
|
||||
NS_IMETHOD EmptyClipboard(int32_t aWhichClipboard) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче