From 62b4183f4d0ce4e8d37230d5f3eace39d37c2b88 Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.plus.com" Date: Tue, 20 Nov 2007 19:06:32 +0000 Subject: [PATCH] Bug 374347 nsIClipboard uses the deprecated nsISupportsArray interface. r=roc,Neil,sspitzer,sr=roc,a=mtschrep git-svn-id: svn://10.0.0.236/trunk@239735 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/places/content/controller.js | 2 +- .../components/places/content/utils.js | 20 ++---- .../libeditor/html/nsHTMLDataTransfer.cpp | 64 ++++++------------- .../text/nsPlaintextDataTransfer.cpp | 24 ++----- mozilla/suite/common/bookmarks/bookmarks.js | 18 ++---- mozilla/widget/public/nsIClipboard.idl | 11 ++-- mozilla/widget/src/cocoa/nsClipboard.h | 3 +- mozilla/widget/src/cocoa/nsClipboard.mm | 59 ++++++----------- mozilla/widget/src/gtk2/nsClipboard.cpp | 48 ++++++-------- mozilla/widget/src/os2/nsClipboard.cpp | 47 ++++++-------- mozilla/widget/src/os2/nsClipboard.h | 3 +- mozilla/widget/src/photon/nsClipboard.cpp | 40 ++++-------- mozilla/widget/src/windows/nsClipboard.cpp | 51 ++++++--------- mozilla/widget/src/windows/nsClipboard.h | 3 +- .../widget/src/xpwidgets/nsBaseClipboard.cpp | 4 +- 15 files changed, 140 insertions(+), 257 deletions(-) diff --git a/mozilla/browser/components/places/content/controller.js b/mozilla/browser/components/places/content/controller.js index 3e234c179ec..2efb40fe4cc 100755 --- a/mozilla/browser/components/places/content/controller.js +++ b/mozilla/browser/components/places/content/controller.js @@ -342,7 +342,7 @@ PlacesController.prototype = { var flavors = PlacesUtils.placesFlavors; var clipboard = PlacesUtils.clipboard; var hasPlacesData = - clipboard.hasDataMatchingFlavors(flavors, + clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard); if (hasPlacesData) return this._view.insertionPoint != null; diff --git a/mozilla/browser/components/places/content/utils.js b/mozilla/browser/components/places/content/utils.js index ca9453a91fb..738659ebd1f 100644 --- a/mozilla/browser/components/places/content/utils.js +++ b/mozilla/browser/components/places/content/utils.js @@ -1637,22 +1637,6 @@ var PlacesUtils = { this._openTabset(urlsToOpen, aEvent); }, - get placesFlavors() { - delete this.placesFlavors; - var placeTypes = [PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER, - PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR, - PlacesUtils.TYPE_X_MOZ_PLACE]; - this.placesFlavors = Cc["@mozilla.org/supports-array;1"]. - createInstance(Ci.nsISupportsArray); - for (var i = 0; i < placeTypes.length; ++i) { - var cstring = Cc["@mozilla.org/supports-cstring;1"]. - createInstance(Ci.nsISupportsCString); - cstring.data = placeTypes[i]; - this.placesFlavors.AppendElement(cstring); - } - return this.placesFlavors; - }, - /** * Helper for the toolbar and menu views */ @@ -1793,6 +1777,10 @@ var PlacesUtils = { } }; +PlacesUtils.placesFlavors = [PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER, + PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR, + PlacesUtils.TYPE_X_MOZ_PLACE]; + PlacesUtils.GENERIC_VIEW_DROP_TYPES = [PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER, PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR, PlacesUtils.TYPE_X_MOZ_PLACE, diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 8fb93f49957..ca1e4023335 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -75,7 +75,6 @@ #include "nsIContentIterator.h" #include "nsIDOMRange.h" #include "nsIDOMNSRange.h" -#include "nsISupportsArray.h" #include "nsCOMArray.h" #include "nsVoidArray.h" #include "nsIFile.h" @@ -1801,19 +1800,12 @@ PRBool nsHTMLEditor::HavePrivateHTMLFlavor(nsIClipboard *aClipboard) if (!aClipboard) return PR_FALSE; PRBool bHavePrivateHTMLFlavor = PR_FALSE; - nsCOMPtr flavArray; - nsresult res = NS_NewISupportsArray(getter_AddRefs(flavArray)); - if (NS_FAILED(res)) return PR_FALSE; + const char* flavArray[] = { kHTMLContext }; - nsCOMPtr contextString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID); - if (!contextString) return PR_FALSE; - - contextString->SetData(NS_LITERAL_CSTRING(kHTMLContext)); - - flavArray->AppendElement(contextString); - - if (NS_SUCCEEDED(aClipboard->HasDataMatchingFlavors (flavArray, nsIClipboard::kGlobalClipboard, &bHavePrivateHTMLFlavor ))) + if (NS_SUCCEEDED(aClipboard->HasDataMatchingFlavors(flavArray, + NS_ARRAY_LENGTH(flavArray), nsIClipboard::kGlobalClipboard, + &bHavePrivateHTMLFlavor ))) return bHavePrivateHTMLFlavor; return PR_FALSE; @@ -1952,45 +1944,25 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) if (NS_FAILED(rv)) return rv; // the flavors that we can deal with - const char* const textEditorFlavors[] = { kUnicodeMime, nsnull }; - const char* const htmlEditorFlavors[] = { kHTMLMime, kJPEGImageMime, nsnull }; + const char* textEditorFlavors[] = { kUnicodeMime }; + const char* textHtmlEditorFlavors[] = { kUnicodeMime, kHTMLMime, + kJPEGImageMime }; - nsCOMPtr flavorsList = - do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; - PRUint32 editorFlags; GetFlags(&editorFlags); - // add the flavors for all editors - for (const char* const* flavor = textEditorFlavors; *flavor; flavor++) - { - nsCOMPtr flavorString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID); - if (flavorString) - { - flavorString->SetData(nsDependentCString(*flavor)); - flavorsList->AppendElement(flavorString); - } - } - - // add the HTML-editor only flavors - if ((editorFlags & eEditorPlaintextMask) == 0) - { - for (const char* const* htmlFlavor = htmlEditorFlavors; - *htmlFlavor; - htmlFlavor++) - { - nsCOMPtr flavorString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID); - if (flavorString) - { - flavorString->SetData(nsDependentCString(*htmlFlavor)); - flavorsList->AppendElement(flavorString); - } - } - } - PRBool haveFlavors; - rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); + + // Use the flavors depending on the current editor mask + if ((editorFlags & eEditorPlaintextMask)) + rv = clipboard->HasDataMatchingFlavors(textEditorFlavors, + NS_ARRAY_LENGTH(textEditorFlavors), + aSelectionType, &haveFlavors); + else + rv = clipboard->HasDataMatchingFlavors(textHtmlEditorFlavors, + NS_ARRAY_LENGTH(textHtmlEditorFlavors), + aSelectionType, &haveFlavors); + if (NS_FAILED(rv)) return rv; *aCanPaste = haveFlavors; diff --git a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 31370e32fdf..ed04d307871 100644 --- a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -51,7 +51,6 @@ #include "nsIDOMRange.h" #include "nsIDOMNSRange.h" -#include "nsISupportsArray.h" #include "nsIDocumentEncoder.h" #include "nsISupportsPrimitives.h" @@ -476,27 +475,12 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPa if (NS_FAILED(rv)) return rv; // the flavors that we can deal with - const char* const textEditorFlavors[] = { kUnicodeMime, nsnull }; + const char* textEditorFlavors[] = { kUnicodeMime }; - nsCOMPtr flavorsList = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); - - PRUint32 editorFlags; - GetFlags(&editorFlags); - - // add the flavors for text editors - for (const char* const* flavor = textEditorFlavors; *flavor; flavor++) - { - nsCOMPtr flavorString = - do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID); - if (flavorString) - { - flavorString->SetData(nsDependentCString(*flavor)); - flavorsList->AppendElement(flavorString); - } - } - PRBool haveFlavors; - rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); + rv = clipboard->HasDataMatchingFlavors(textEditorFlavors, + NS_ARRAY_LENGTH(textEditorFlavors), + aSelectionType, &haveFlavors); if (NS_FAILED(rv)) return rv; *aCanPaste = haveFlavors; diff --git a/mozilla/suite/common/bookmarks/bookmarks.js b/mozilla/suite/common/bookmarks/bookmarks.js index bee5103418d..c22b36b1c04 100644 --- a/mozilla/suite/common/bookmarks/bookmarks.js +++ b/mozilla/suite/common/bookmarks/bookmarks.js @@ -863,19 +863,11 @@ var BookmarksController = { const kClipboardContractID = "@mozilla.org/widget/clipboard;1"; const kClipboardIID = Components.interfaces.nsIClipboard; var clipboard = Components.classes[kClipboardContractID].getService(kClipboardIID); - const kSuppArrayContractID = "@mozilla.org/supports-array;1"; - const kSuppArrayIID = Components.interfaces.nsISupportsArray; - var flavourArray = Components.classes[kSuppArrayContractID].createInstance(kSuppArrayIID); - const kSuppStringContractID = "@mozilla.org/supports-cstring;1"; - const kSuppStringIID = Components.interfaces.nsISupportsCString; - - var flavours = ["moz/bookmarkclipboarditem", "text/x-moz-url"]; - for (i = 0; i < flavours.length; ++i) { - const kSuppString = Components.classes[kSuppStringContractID].createInstance(kSuppStringIID); - kSuppString.data = flavours[i]; - flavourArray.AppendElement(kSuppString); - } - var hasFlavours = clipboard.hasDataMatchingFlavors(flavourArray, kClipboardIID.kGlobalClipboard); + var flavorArray = ["moz/bookmarkclipboarditem", "text/x-moz-url"]; + var hasFlavours = + clipboard.hasDataMatchingFlavors(flavorArray, + flavorArray.length, + kClipboardIID.kGlobalClipboard); return hasFlavours; case "cmd_bm_copy": return length > 0; diff --git a/mozilla/widget/public/nsIClipboard.idl b/mozilla/widget/public/nsIClipboard.idl index e505703c9e4..cfe39258ac6 100644 --- a/mozilla/widget/public/nsIClipboard.idl +++ b/mozilla/widget/public/nsIClipboard.idl @@ -39,12 +39,12 @@ #include "nsISupports.idl" -#include "nsISupportsArray.idl" #include "nsITransferable.idl" #include "nsIClipboardOwner.idl" +interface nsIArray; -[scriptable, uuid(8B5314BA-DB01-11d2-96CE-0060B0FB9956)] +[scriptable, uuid(38984945-8674-4d04-b786-5c0ca9434457)] interface nsIClipboard : nsISupports { const long kSelectionClipboard = 0; @@ -88,12 +88,15 @@ interface nsIClipboard : nsISupports * inexpensive call. All it does is check if there is data on the clipboard matching * any of the flavors in the given list. * - * @aFlavorList - nsISupportsCString's in a nsISupportsArray (for JavaScript). + * @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 ( in nsISupportsArray aFlavorList, in long aWhichClipboard ) ; + boolean hasDataMatchingFlavors ( [array, size_is(aLength)] in string aFlavorList, + in unsigned long aLength, + in long aWhichClipboard ) ; /** * Allows clients to determine if the implementation supports the concept of a diff --git a/mozilla/widget/src/cocoa/nsClipboard.h b/mozilla/widget/src/cocoa/nsClipboard.h index 356be844818..04edd63df2d 100644 --- a/mozilla/widget/src/cocoa/nsClipboard.h +++ b/mozilla/widget/src/cocoa/nsClipboard.h @@ -54,7 +54,8 @@ public: virtual ~nsClipboard(); // nsIClipboard - NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, PRBool *_retval); + NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, + PRInt32 aWhichClipboard, PRBool *_retval); // Helper methods, used also by nsDragService static NSDictionary* PasteboardDictFromTransferable(nsITransferable *aTransferable); diff --git a/mozilla/widget/src/cocoa/nsClipboard.mm b/mozilla/widget/src/cocoa/nsClipboard.mm index c9f1682e62b..db4fed54ec6 100644 --- a/mozilla/widget/src/cocoa/nsClipboard.mm +++ b/mozilla/widget/src/cocoa/nsClipboard.mm @@ -322,7 +322,8 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, PRInt32 aWhi // returns true if we have *any* of the passed in flavors available for pasting NS_IMETHODIMP -nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, PRInt32 aWhichClipboard, PRBool* outResult) +nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, + PRInt32 aWhichClipboard, PRBool* outResult) { *outResult = PR_FALSE; @@ -344,18 +345,9 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, PRInt32 aWhic continue; nsXPIDLCString transferableFlavorStr; currentTransferableFlavor->ToString(getter_Copies(transferableFlavorStr)); - - PRUint32 passedFlavorCount; - aFlavorList->Count(&passedFlavorCount); - for (PRUint32 k = 0; k < passedFlavorCount; k++) { - nsCOMPtr passedFlavorSupports; - aFlavorList->GetElementAt(k, getter_AddRefs(passedFlavorSupports)); - nsCOMPtr currentPassedFlavor(do_QueryInterface(passedFlavorSupports)); - if (!currentPassedFlavor) - continue; - nsXPIDLCString passedFlavorStr; - currentPassedFlavor->ToString(getter_Copies(passedFlavorStr)); - if (passedFlavorStr.Equals(transferableFlavorStr)) { + + for (PRUint32 k = 0; k < aLength; k++) { + if (transferableFlavorStr.Equals(aFlavorList[k])) { *outResult = PR_TRUE; return NS_OK; } @@ -366,32 +358,23 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, PRInt32 aWhic NSPasteboard* generalPBoard = [NSPasteboard generalPasteboard]; - PRUint32 passedFlavorCount; - aFlavorList->Count(&passedFlavorCount); - for (PRUint32 i = 0; i < passedFlavorCount; i++) { - nsCOMPtr passedFlavorSupports; - aFlavorList->GetElementAt(i, getter_AddRefs(passedFlavorSupports)); - nsCOMPtr flavorWrapper(do_QueryInterface(passedFlavorSupports)); - if (flavorWrapper) { - nsXPIDLCString flavorStr; - flavorWrapper->ToString(getter_Copies(flavorStr)); - if (flavorStr.EqualsLiteral(kUnicodeMime)) { - NSString* availableType = [generalPBoard availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]]; - if (availableType && [availableType isEqualToString:NSStringPboardType]) { - *outResult = PR_TRUE; - break; - } - } else if (flavorStr.EqualsLiteral(kJPEGImageMime) || - flavorStr.EqualsLiteral(kPNGImageMime) || - flavorStr.EqualsLiteral(kGIFImageMime)) { - NSString* availableType = [generalPBoard availableTypeFromArray: - [NSArray arrayWithObjects:IMAGE_PASTEBOARD_TYPES]]; - if (availableType) { - *outResult = PR_TRUE; - break; - } + for (PRUint32 i = 0; i < aLength; i++) { + if (!strcmp(aFlavorList[i], kUnicodeMime)) { + NSString* availableType = [generalPBoard availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]]; + if (availableType && [availableType isEqualToString:NSStringPboardType]) { + *outResult = PR_TRUE; + break; } - } + } else if (!strcmp(aFlavorList[i], kJPEGImageMime) || + !strcmp(aFlavorList[i], kPNGImageMime) || + !strcmp(aFlavorList[i], kGIFImageMime)) { + NSString* availableType = [generalPBoard availableTypeFromArray: + [NSArray arrayWithObjects:IMAGE_PASTEBOARD_TYPES]]; + if (availableType) { + *outResult = PR_TRUE; + break; + } + } } return NS_OK; diff --git a/mozilla/widget/src/gtk2/nsClipboard.cpp b/mozilla/widget/src/gtk2/nsClipboard.cpp index 3e2156ec07a..81aad4ffa18 100644 --- a/mozilla/widget/src/gtk2/nsClipboard.cpp +++ b/mozilla/widget/src/gtk2/nsClipboard.cpp @@ -349,15 +349,13 @@ nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard) } NS_IMETHODIMP -nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList, +nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, PRInt32 aWhichClipboard, PRBool *_retval) { - *_retval = PR_FALSE; + if (!aFlavorList || !_retval) + return NS_ERROR_NULL_POINTER; - PRUint32 length = 0; - aFlavorList->Count(&length); - if (!length) - return NS_OK; + *_retval = PR_FALSE; GtkSelectionData *selection_data = GetTargets(GetSelectionAtom(aWhichClipboard)); @@ -374,33 +372,23 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList, // Walk through the provided types and try to match it to a // provided type. - for (PRUint32 i = 0; i < length && !*_retval; i++) { - nsCOMPtr genericFlavor; - aFlavorList->GetElementAt(i, getter_AddRefs(genericFlavor)); - nsCOMPtr flavorWrapper; - flavorWrapper = do_QueryInterface(genericFlavor); + for (PRUint32 i = 0; i < aLength && !*_retval; i++) { + // We special case text/unicode here. + if (!strcmp(aFlavorList[i], kUnicodeMime) && + gtk_selection_data_targets_include_text(selection_data)) { + *_retval = PR_TRUE; + break; + } - if (flavorWrapper) { - nsXPIDLCString myStr; - flavorWrapper->ToString(getter_Copies(myStr)); - - // We special case text/unicode here. - if (!strcmp(myStr, kUnicodeMime) && - gtk_selection_data_targets_include_text(selection_data)) { + for (PRInt32 j = 0; j < n_targets; j++) { + gchar *atom_name = gdk_atom_name(targets[j]); + if (!strcmp(atom_name, aFlavorList[i])) *_retval = PR_TRUE; + + g_free(atom_name); + + if (*_retval) break; - } - - for (PRInt32 j = 0; j < n_targets; j++) { - gchar *atom_name = gdk_atom_name(targets[j]); - if (!strcmp(atom_name, (const char *)myStr)) - *_retval = PR_TRUE; - - g_free(atom_name); - - if (*_retval) - break; - } } } gtk_selection_data_free(selection_data); diff --git a/mozilla/widget/src/os2/nsClipboard.cpp b/mozilla/widget/src/os2/nsClipboard.cpp index 596fadf43d5..a06816a785d 100644 --- a/mozilla/widget/src/os2/nsClipboard.cpp +++ b/mozilla/widget/src/os2/nsClipboard.cpp @@ -456,48 +456,41 @@ nsClipboard::Observe(nsISupports *aSubject, const char *aTopic, return NS_OK; } -NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, +NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, + PRUint32 aLength, + PRInt32 aWhichClipboard, PRBool *_retval) { *_retval = PR_FALSE; - if (aWhichClipboard != kGlobalClipboard) + if (aWhichClipboard != kGlobalClipboard || !aFlavorList) return NS_OK; - PRUint32 cnt; - aFlavorList->Count(&cnt); - for (PRUint32 i = 0; i < cnt; ++i) { - nsCOMPtr genericFlavor; - aFlavorList->GetElementAt(i, getter_AddRefs(genericFlavor)); - nsCOMPtr currentFlavor(do_QueryInterface(genericFlavor)); - if (currentFlavor) { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - ULONG fmtInfo = 0; - ULONG format = GetFormatID(flavorStr); + for (PRUint32 i = 0; i < aLength; ++i) { + ULONG fmtInfo = 0; + ULONG format = GetFormatID(aFlavorList[i]); - if (WinQueryClipbrdFmtInfo(0/*hab*/, format, &fmtInfo)) { + if (WinQueryClipbrdFmtInfo(0/*hab*/, format, &fmtInfo)) { + *_retval = PR_TRUE; + break; + } + + // if the client asked for unicode and it wasn't present, check if we have CF_TEXT. + if (!strcmp(aFlavorList[i], kUnicodeMime)) { + if (WinQueryClipbrdFmtInfo(0/*hab*/, CF_TEXT, &fmtInfo)) { *_retval = PR_TRUE; break; } - - // if the client asked for unicode and it wasn't present, check if we have CF_TEXT. - if (!strcmp( flavorStr, kUnicodeMime )) { - if (WinQueryClipbrdFmtInfo( 0/*hab*/, CF_TEXT, &fmtInfo )) { - *_retval = PR_TRUE; - break; - } - } + } // OS2TODO - Support for Images - // if the client asked for image/.. and it wasn't present, check if we have CF_BITMAP. - if (strstr (flavorStr, "image/")) { - if (WinQueryClipbrdFmtInfo (0, CF_BITMAP, &fmtInfo)) { + // if the client asked for image/.. and it wasn't present, check if we have CF_BITMAP. + if (strstr(aFlavorList[i], "image/")) { + if (WinQueryClipbrdFmtInfo (0, CF_BITMAP, &fmtInfo)) { #ifdef DEBUG - printf( "nsClipboard:: Image present on clipboard; need to add BMP conversion!\n" ); + printf("nsClipboard:: Image present on clipboard; need to add BMP conversion!\n"); #endif // *_retval = PR_TRUE; // break; - } } } } diff --git a/mozilla/widget/src/os2/nsClipboard.h b/mozilla/widget/src/os2/nsClipboard.h index 625f2dea406..15b9e3c4b99 100644 --- a/mozilla/widget/src/os2/nsClipboard.h +++ b/mozilla/widget/src/os2/nsClipboard.h @@ -68,7 +68,8 @@ public: NS_DECL_NSIOBSERVER // nsIClipboard - NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, PRBool *_retval); + NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, + PRInt32 aWhichClipboard, PRBool *_retval); protected: NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard); diff --git a/mozilla/widget/src/photon/nsClipboard.cpp b/mozilla/widget/src/photon/nsClipboard.cpp index 563ed1ba1c1..1a6a291c3be 100644 --- a/mozilla/widget/src/photon/nsClipboard.cpp +++ b/mozilla/widget/src/photon/nsClipboard.cpp @@ -482,8 +482,9 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable, } NS_IMETHODIMP -nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, - PRInt32 aWhichClipboard, +nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, + PRUint32 aLength, + PRInt32 aWhichClipboard, PRBool * outResult) { if (aWhichClipboard == kSelectionClipboard) @@ -504,11 +505,8 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, * outResult = PR_FALSE; // Walk through flavors and see which flavor matches the one being pasted: - PRUint32 cnt; - - aFlavorList->Count(&cnt); nsCAutoString foundFlavor; - if (cnt > 0) { + if (aLength > 0) { void *clipPtr; char type[8]; PhClipHeader *cliphdr; @@ -517,30 +515,18 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, if(nsnull == clipPtr) return res; - for ( PRUint32 i = 0; i < cnt; ++i ) { - nsCOMPtr genericFlavor; - aFlavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); - nsCOMPtr currentFlavor ( do_QueryInterface(genericFlavor) ); + for ( PRUint32 i = 0; i < aLength; ++i ) { + nsresult err = GetFormat( aFlavorList[i], type ); + if (err != NS_OK) continue; - if ( currentFlavor ) { - - nsXPIDLCString flavorStr; - currentFlavor->ToString ( getter_Copies(flavorStr) ); - - nsresult err = GetFormat( flavorStr, type ); - if (err != NS_OK) continue; - - cliphdr = PhClipboardPasteType( clipPtr, type ); - if (cliphdr) - { - - res = NS_OK; - *outResult = PR_TRUE; - break; - } + cliphdr = PhClipboardPasteType( clipPtr, type ); + if (cliphdr) + { + res = NS_OK; + *outResult = PR_TRUE; + break; } } - PhClipboardPasteFinish( clipPtr ); } diff --git a/mozilla/widget/src/windows/nsClipboard.cpp b/mozilla/widget/src/windows/nsClipboard.cpp index c4d13e0b95d..8c54fc79a41 100644 --- a/mozilla/widget/src/windows/nsClipboard.cpp +++ b/mozilla/widget/src/windows/nsClipboard.cpp @@ -64,7 +64,6 @@ #include "nsIComponentManager.h" #include "nsWidgetsCID.h" #include "nsCRT.h" - #include "nsNetUtil.h" #include "nsIImage.h" @@ -880,42 +879,34 @@ nsClipboard::GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32 a //------------------------------------------------------------------------- -NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, - PRBool *_retval) +NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, + PRUint32 aLength, + PRInt32 aWhichClipboard, + PRBool *_retval) { *_retval = PR_FALSE; - if ( aWhichClipboard != kGlobalClipboard ) + if (aWhichClipboard != kGlobalClipboard || !aFlavorList) return NS_OK; - PRUint32 cnt; - aFlavorList->Count(&cnt); - for ( PRUint32 i = 0;i < cnt; ++i ) { - nsCOMPtr genericFlavor; - aFlavorList->GetElementAt (i, getter_AddRefs(genericFlavor)); - nsCOMPtr currentFlavor (do_QueryInterface(genericFlavor)); - if (currentFlavor) { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - + for (PRUint32 i = 0;i < aLength; ++i) { #ifdef NS_DEBUG - if ( strcmp(flavorStr, kTextMime) == 0 ) - NS_WARNING ( "DO NOT USE THE text/plain DATA FLAVOR ANY MORE. USE text/unicode INSTEAD" ); + if (strcmp(aFlavorList[i], kTextMime) == 0) + NS_WARNING ( "DO NOT USE THE text/plain DATA FLAVOR ANY MORE. USE text/unicode INSTEAD" ); #endif - UINT format = GetFormat(flavorStr); - if (IsClipboardFormatAvailable(format)) { - *_retval = PR_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(flavorStr, kUnicodeMime) == 0 ) { - // 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 = PR_TRUE; - } + UINT format = GetFormat(aFlavorList[i]); + if (IsClipboardFormatAvailable(format)) { + *_retval = PR_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) { + // 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 = PR_TRUE; } } } diff --git a/mozilla/widget/src/windows/nsClipboard.h b/mozilla/widget/src/windows/nsClipboard.h index cd6710c481d..fea17a37fe6 100644 --- a/mozilla/widget/src/windows/nsClipboard.h +++ b/mozilla/widget/src/windows/nsClipboard.h @@ -60,7 +60,8 @@ public: virtual ~nsClipboard(); // nsIClipboard - NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, PRBool *_retval); + NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, + PRInt32 aWhichClipboard, PRBool *_retval); // Internal Native Routines static nsresult CreateNativeDataObject(nsITransferable * aTransferable, diff --git a/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp b/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp index c937dd4cf67..dbf30591545 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp @@ -42,7 +42,6 @@ #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" - nsBaseClipboard::nsBaseClipboard() { mClipboardOwner = nsnull; @@ -133,7 +132,8 @@ NS_IMETHODIMP nsBaseClipboard::EmptyClipboard(PRInt32 aWhichClipboard) } NS_IMETHODIMP -nsBaseClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, +nsBaseClipboard::HasDataMatchingFlavors(const char** aFlavorList, + PRUint32 aLength, PRInt32 aWhichClipboard, PRBool* outResult) {