Bug 1309698 - Remove usage of nsISupportsArray from nsIDragService. r=smaug

This commit is contained in:
Eric Rahm 2016-10-18 11:56:20 -07:00
parent 940c54d37b
commit 1eb4ae7e0d
18 changed files with 94 additions and 144 deletions

View File

@ -7544,7 +7544,7 @@ nsContentUtils::IPCTransferableToTransferable(const IPCDataTransfer& aDataTransf
}
void
nsContentUtils::TransferablesToIPCTransferables(nsISupportsArray* aTransferables,
nsContentUtils::TransferablesToIPCTransferables(nsIArray* aTransferables,
nsTArray<IPCDataTransfer>& aIPC,
bool aInSyncMessage,
mozilla::dom::nsIContentChild* aChild,
@ -7553,12 +7553,10 @@ nsContentUtils::TransferablesToIPCTransferables(nsISupportsArray* aTransferables
aIPC.Clear();
if (aTransferables) {
uint32_t transferableCount = 0;
aTransferables->Count(&transferableCount);
aTransferables->GetLength(&transferableCount);
for (uint32_t i = 0; i < transferableCount; ++i) {
IPCDataTransfer* dt = aIPC.AppendElement();
nsCOMPtr<nsISupports> genericItem;
aTransferables->GetElementAt(i, getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> transferable(do_QueryInterface(genericItem));
nsCOMPtr<nsITransferable> transferable = do_QueryElementAt(aTransferables, i);
TransferableToIPCTransferable(transferable, dt, aInSyncMessage, aChild, aParent);
}
}

View File

@ -2500,7 +2500,7 @@ public:
mozilla::dom::nsIContentParent* aContentParent,
mozilla::dom::TabChild* aTabChild);
static void TransferablesToIPCTransferables(nsISupportsArray* aTransferables,
static void TransferablesToIPCTransferables(nsIArray* aTransferables,
nsTArray<mozilla::dom::IPCDataTransfer>& aIPC,
bool aInSyncMessage,
mozilla::dom::nsIContentChild* aChild,

View File

@ -13,6 +13,7 @@
#include "nsISupportsPrimitives.h"
#include "nsIScriptSecurityManager.h"
#include "mozilla/dom/DOMStringList.h"
#include "nsArray.h"
#include "nsError.h"
#include "nsIDragService.h"
#include "nsIClipboard.h"
@ -876,7 +877,7 @@ DataTransfer::Clone(nsISupports* aParent, EventMessage aEventMessage,
return NS_OK;
}
already_AddRefed<nsISupportsArray>
already_AddRefed<nsIArray>
DataTransfer::GetTransferables(nsIDOMNode* aDragTarget)
{
MOZ_ASSERT(aDragTarget);
@ -894,12 +895,10 @@ DataTransfer::GetTransferables(nsIDOMNode* aDragTarget)
return GetTransferables(doc->GetLoadContext());
}
already_AddRefed<nsISupportsArray>
already_AddRefed<nsIArray>
DataTransfer::GetTransferables(nsILoadContext* aLoadContext)
{
nsCOMPtr<nsISupportsArray> transArray =
do_CreateInstance("@mozilla.org/supports-array;1");
nsCOMPtr<nsIMutableArray> transArray = nsArray::Create();
if (!transArray) {
return nullptr;
}
@ -908,7 +907,7 @@ DataTransfer::GetTransferables(nsILoadContext* aLoadContext)
for (uint32_t i = 0; i < count; i++) {
nsCOMPtr<nsITransferable> transferable = GetTransferable(i, aLoadContext);
if (transferable) {
transArray->AppendElement(transferable);
transArray->AppendElement(transferable, /*weak =*/ false);
}
}

View File

@ -235,9 +235,9 @@ public:
// converts the data into an array of nsITransferable objects to be used for
// drag and drop or clipboard operations.
already_AddRefed<nsISupportsArray> GetTransferables(nsIDOMNode* aDragTarget);
already_AddRefed<nsIArray> GetTransferables(nsIDOMNode* aDragTarget);
already_AddRefed<nsISupportsArray>
already_AddRefed<nsIArray>
GetTransferables(nsILoadContext* aLoadContext);
// converts the data for a single item at aIndex into an nsITransferable

View File

@ -1975,7 +1975,7 @@ EventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
int32_t imageX, imageY;
Element* dragImage = aDataTransfer->GetDragImage(&imageX, &imageY);
nsCOMPtr<nsISupportsArray> transArray =
nsCOMPtr<nsIArray> transArray =
aDataTransfer->GetTransferables(dragTarget->AsDOMNode());
if (!transArray)
return false;

View File

@ -4692,7 +4692,7 @@ ContentParent::MaybeInvokeDragSession(TabParent* aParent)
transfer->FillAllExternalData();
nsCOMPtr<nsILoadContext> lc = aParent ?
aParent->GetLoadContext() : nullptr;
nsCOMPtr<nsISupportsArray> transferables =
nsCOMPtr<nsIArray> transferables =
transfer->GetTransferables(lc);
nsContentUtils::TransferablesToIPCTransferables(transferables,
dataTransfers,

View File

@ -22,7 +22,7 @@ public:
nsDragService();
// nsBaseDragService
virtual nsresult InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType);
// nsIDragService
@ -47,7 +47,7 @@ private:
NSString* GetTitleForURL(NSPasteboardItem* item);
NSString* GetFilePath(NSPasteboardItem* item);
nsCOMPtr<nsISupportsArray> mDataItems; // only valid for a drag started within gecko
nsCOMPtr<nsIArray> mDataItems; // only valid for a drag started within gecko
NSView* mNativeDragView;
NSEvent* mNativeDragEvent;
};

View File

@ -5,6 +5,7 @@
#include "mozilla/Logging.h"
#include "nsArrayUtils.h"
#include "nsDragService.h"
#include "nsArrayUtils.h"
#include "nsObjCExceptions.h"
@ -43,7 +44,7 @@ extern bool gUserCancelledDrag;
// This global makes the transferable array available to Cocoa's promised
// file destination callback.
nsISupportsArray *gDraggedTransferables = nullptr;
nsIArray *gDraggedTransferables = nullptr;
NSString* const kWildcardPboardType = @"MozillaWildcard";
NSString* const kCorePboardType_url = @"CorePasteboardFlavorType 0x75726C20"; // 'url ' url
@ -64,7 +65,7 @@ nsDragService::~nsDragService()
{
}
static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray)
static nsresult SetUpDragClipboard(nsIArray* aTransferableArray)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -72,17 +73,12 @@ static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray)
return NS_ERROR_FAILURE;
uint32_t count = 0;
aTransferableArray->Count(&count);
aTransferableArray->GetLength(&count);
NSPasteboard* dragPBoard = [NSPasteboard pasteboardWithName:NSDragPboard];
for (uint32_t j = 0; j < count; j++) {
nsCOMPtr<nsISupports> currentTransferableSupports;
aTransferableArray->GetElementAt(j, getter_AddRefs(currentTransferableSupports));
if (!currentTransferableSupports)
return NS_ERROR_FAILURE;
nsCOMPtr<nsITransferable> currentTransferable(do_QueryInterface(currentTransferableSupports));
nsCOMPtr<nsITransferable> currentTransferable = do_QueryElementAt(aTransferableArray, j);
if (!currentTransferable)
return NS_ERROR_FAILURE;
@ -310,7 +306,7 @@ nsDragService::GetFilePath(NSPasteboardItem* item)
// within NSView's 'mouseDown:' or 'mouseDragged:'. Luckily 'mouseDragged' is always on the
// stack when InvokeDragSession gets called.
nsresult
nsDragService::InvokeDragSessionImpl(nsISupportsArray* aTransferableArray,
nsDragService::InvokeDragSessionImpl(nsIArray* aTransferableArray,
nsIScriptableRegion* aDragRgn,
uint32_t aActionType)
{
@ -399,25 +395,21 @@ nsDragService::GetData(nsITransferable* aTransferable, uint32_t aItemIndex)
// if this drag originated within Mozilla we should just use the cached data from
// when the drag started if possible
if (mDataItems) {
nsCOMPtr<nsISupports> currentTransferableSupports;
mDataItems->GetElementAt(aItemIndex, getter_AddRefs(currentTransferableSupports));
if (currentTransferableSupports) {
nsCOMPtr<nsITransferable> currentTransferable(do_QueryInterface(currentTransferableSupports));
if (currentTransferable) {
for (uint32_t i = 0; i < acceptableFlavorCount; i++) {
nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryElementAt(flavorList, i);
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
nsCOMPtr<nsITransferable> currentTransferable = do_QueryElementAt(mDataItems, aItemIndex);
if (currentTransferable) {
for (uint32_t i = 0; i < acceptableFlavorCount; i++) {
nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryElementAt(flavorList, i);
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
nsCOMPtr<nsISupports> dataSupports;
uint32_t dataSize = 0;
rv = currentTransferable->GetTransferData(flavorStr, getter_AddRefs(dataSupports), &dataSize);
if (NS_SUCCEEDED(rv)) {
aTransferable->SetTransferData(flavorStr, dataSupports, dataSize);
return NS_OK; // maybe try to fill in more types? Is there a point?
}
nsCOMPtr<nsISupports> dataSupports;
uint32_t dataSize = 0;
rv = currentTransferable->GetTransferData(flavorStr, getter_AddRefs(dataSupports), &dataSize);
if (NS_SUCCEEDED(rv)) {
aTransferable->SetTransferData(flavorStr, dataSupports, dataSize);
return NS_OK; // maybe try to fill in more types? Is there a point?
}
}
}
@ -583,14 +575,9 @@ nsDragService::IsDataFlavorSupported(const char *aDataFlavor, bool *_retval)
// first see if we have data for this in our cached transferable
if (mDataItems) {
uint32_t dataItemsCount;
mDataItems->Count(&dataItemsCount);
mDataItems->GetLength(&dataItemsCount);
for (unsigned int i = 0; i < dataItemsCount; i++) {
nsCOMPtr<nsISupports> currentTransferableSupports;
mDataItems->GetElementAt(i, getter_AddRefs(currentTransferableSupports));
if (!currentTransferableSupports)
continue;
nsCOMPtr<nsITransferable> currentTransferable(do_QueryInterface(currentTransferableSupports));
nsCOMPtr<nsITransferable> currentTransferable = do_QueryElementAt(mDataItems, i);
if (!currentTransferable)
continue;
@ -654,7 +641,7 @@ nsDragService::GetNumDropItems(uint32_t* aNumItems)
// first check to see if we have a number of items cached
if (mDataItems) {
mDataItems->Count(aNumItems);
mDataItems->GetLength(aNumItems);
return NS_OK;
}

View File

@ -40,6 +40,7 @@
#include "mozilla/gfx/2D.h"
#include "gfxPlatform.h"
#include "nsScreenGtk.h"
#include "nsArrayUtils.h"
using namespace mozilla;
using namespace mozilla::gfx;
@ -301,7 +302,7 @@ GetGtkWindow(nsIDOMDocument *aDocument)
NS_IMETHODIMP
nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
nsISupportsArray * aArrayTransferables,
nsIArray * aArrayTransferables,
nsIScriptableRegion * aRegion,
uint32_t aActionType,
nsContentPolicyType aContentPolicyType =
@ -323,7 +324,7 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
// nsBaseDragService
nsresult
nsDragService::InvokeDragSessionImpl(nsISupportsArray* aArrayTransferables,
nsDragService::InvokeDragSessionImpl(nsIArray* aArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType)
{
@ -669,7 +670,7 @@ nsDragService::GetNumDropItems(uint32_t * aNumItems)
bool isList = IsTargetContextList();
if (isList)
mSourceDataItems->Count(aNumItems);
mSourceDataItems->GetLength(aNumItems);
else {
GdkAtom gdkFlavor = gdk_atom_intern(gTextUriListType, FALSE);
GetTargetDragData(gdkFlavor);
@ -733,10 +734,8 @@ nsDragService::GetData(nsITransferable * aTransferable,
LogLevel::Debug,
("flavor is %s\n", (const char *)flavorStr));
// get the item with the right index
nsCOMPtr<nsISupports> genericItem;
mSourceDataItems->GetElementAt(aItemIndex,
getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> item(do_QueryInterface(genericItem));
nsCOMPtr<nsITransferable> item =
do_QueryElementAt(mSourceDataItems, aItemIndex);
if (!item)
continue;
@ -1023,12 +1022,10 @@ nsDragService::IsDataFlavorSupported(const char *aDataFlavor,
// an external client trying to fool us.
if (!mSourceDataItems)
return NS_OK;
mSourceDataItems->Count(&numDragItems);
mSourceDataItems->GetLength(&numDragItems);
for (uint32_t itemIndex = 0; itemIndex < numDragItems; ++itemIndex) {
nsCOMPtr<nsISupports> genericItem;
mSourceDataItems->GetElementAt(itemIndex,
getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> currItem(do_QueryInterface(genericItem));
nsCOMPtr<nsITransferable> currItem =
do_QueryElementAt(mSourceDataItems, itemIndex);
if (currItem) {
nsCOMPtr <nsIArray> flavorList;
currItem->FlavorsTransferableCanExport(
@ -1243,7 +1240,7 @@ nsDragService::GetSourceList(void)
uint32_t targetCount = 0;
unsigned int numDragItems = 0;
mSourceDataItems->Count(&numDragItems);
mSourceDataItems->GetLength(&numDragItems);
// Check to see if we're dragging > 1 item.
if (numDragItems > 1) {
@ -1263,9 +1260,8 @@ nsDragService::GetSourceList(void)
// check what flavours are supported so we can decide what other
// targets to advertise.
nsCOMPtr<nsISupports> genericItem;
mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> currItem(do_QueryInterface(genericItem));
nsCOMPtr<nsITransferable> currItem =
do_QueryElementAt(mSourceDataItems, 0);
if (currItem) {
nsCOMPtr <nsIArray> flavorList;
@ -1300,9 +1296,8 @@ nsDragService::GetSourceList(void)
} // if valid flavor list
} // if item is a transferable
} else if (numDragItems == 1) {
nsCOMPtr<nsISupports> genericItem;
mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> currItem(do_QueryInterface(genericItem));
nsCOMPtr<nsITransferable> currItem =
do_QueryElementAt(mSourceDataItems, 0);
if (currItem) {
nsCOMPtr <nsIArray> flavorList;
currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
@ -1463,17 +1458,15 @@ nsDragService::SourceEndDragSession(GdkDragContext *aContext,
}
static void
CreateUriList(nsISupportsArray *items, gchar **text, gint *length)
CreateUriList(nsIArray *items, gchar **text, gint *length)
{
uint32_t i, count;
GString *uriList = g_string_new(nullptr);
items->Count(&count);
items->GetLength(&count);
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> genericItem;
items->GetElementAt(i, getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> item;
item = do_QueryInterface(genericItem);
item = do_QueryElementAt(items, i);
if (item) {
uint32_t tmpDataLen = 0;
@ -1552,10 +1545,8 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
return;
}
nsCOMPtr<nsISupports> genericItem;
mSourceDataItems->GetElementAt(0, getter_AddRefs(genericItem));
nsCOMPtr<nsITransferable> item;
item = do_QueryInterface(genericItem);
item = do_QueryElementAt(mSourceDataItems, 0);
if (item) {
// if someone was asking for text/plain, lookup unicode instead so
// we can convert it.

View File

@ -59,12 +59,12 @@ public:
NS_DECL_NSIOBSERVER
// nsBaseDragService
virtual nsresult InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType) override;
// nsIDragService
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode,
nsISupportsArray * anArrayTransferables,
nsIArray * anArrayTransferables,
nsIScriptableRegion * aRegion,
uint32_t aActionType,
nsContentPolicyType aContentPolicyType) override;
@ -194,7 +194,7 @@ private:
// the source of our drags
GtkWidget *mHiddenWidget;
// our source data items
nsCOMPtr<nsISupportsArray> mSourceDataItems;
nsCOMPtr<nsIArray> mSourceDataItems;
nsCOMPtr<nsIScriptableRegion> mSourceRegion;

View File

@ -207,7 +207,7 @@ nsBaseDragService::SetDataTransfer(nsIDOMDataTransfer* aDataTransfer)
//-------------------------------------------------------------------------
NS_IMETHODIMP
nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
nsISupportsArray* aTransferableArray,
nsIArray* aTransferableArray,
nsIScriptableRegion* aDragRgn,
uint32_t aActionType,
nsContentPolicyType aContentPolicyType =
@ -243,7 +243,7 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
NS_IMETHODIMP
nsBaseDragService::InvokeDragSessionWithImage(nsIDOMNode* aDOMNode,
nsISupportsArray* aTransferableArray,
nsIArray* aTransferableArray,
nsIScriptableRegion* aRegion,
uint32_t aActionType,
nsIDOMNode* aImage,
@ -281,7 +281,7 @@ nsBaseDragService::InvokeDragSessionWithImage(nsIDOMNode* aDOMNode,
NS_IMETHODIMP
nsBaseDragService::InvokeDragSessionWithSelection(nsISelection* aSelection,
nsISupportsArray* aTransferableArray,
nsIArray* aTransferableArray,
uint32_t aActionType,
nsIDOMDragEvent* aDragEvent,
nsIDOMDataTransfer* aDataTransfer)

View File

@ -75,7 +75,7 @@ protected:
* in this process. This is expected to ensure that StartDragSession() and
* EndDragSession() get called if the platform drag is successfully invoked.
*/
virtual nsresult InvokeDragSessionImpl(nsISupportsArray* aTransferableArray,
virtual nsresult InvokeDragSessionImpl(nsIArray* aTransferableArray,
nsIScriptableRegion* aDragRgn,
uint32_t aActionType) = 0;

View File

@ -28,7 +28,7 @@ nsDragServiceProxy::~nsDragServiceProxy()
}
nsresult
nsDragServiceProxy::InvokeDragSessionImpl(nsISupportsArray* aArrayTransferables,
nsDragServiceProxy::InvokeDragSessionImpl(nsIArray* aArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType)
{

View File

@ -16,7 +16,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsBaseDragService
virtual nsresult InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType) override;
private:

View File

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIArray.idl"
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
#include "nsIDragSession.idl"
#include "nsIScriptableRegion.idl"
#include "nsIContentPolicyBase.idl"
@ -38,7 +38,9 @@ interface nsIDragService : nsISupports
const long DRAGDROP_ACTION_UNINITIALIZED = 64;
/**
* Starts a modal drag session with an array of transaferables
* Starts a modal drag session with an array of transaferables.
*
* Note: This method is deprecated for non-native code.
*
* @param aTransferables - an array of transferables to be dragged
* @param aRegion - a region containing rectangles for cursor feedback,
@ -49,7 +51,7 @@ interface nsIDragService : nsISupports
* (defaults to TYPE_OTHER)
*/
void invokeDragSession (in nsIDOMNode aDOMNode,
in nsISupportsArray aTransferables,
in nsIArray aTransferables,
in nsIScriptableRegion aRegion,
in unsigned long aActionType,
[optional] in nsContentPolicyType aContentPolicyType);
@ -58,6 +60,8 @@ interface nsIDragService : nsISupports
* Starts a modal drag session using an image. The first four arguments are
* the same as invokeDragSession.
*
* Note: This method is deprecated for non-native code.
*
* A custom image may be specified using the aImage argument. If this is
* supplied, the aImageX and aImageY arguments specify the offset within
* the image where the cursor would be positioned. That is, when the image
@ -80,7 +84,7 @@ interface nsIDragService : nsISupports
* event are needed to calculate the image location.
*/
void invokeDragSessionWithImage(in nsIDOMNode aDOMNode,
in nsISupportsArray aTransferableArray,
in nsIArray aTransferableArray,
in nsIScriptableRegion aRegion,
in unsigned long aActionType,
in nsIDOMNode aImage,
@ -93,9 +97,11 @@ interface nsIDragService : nsISupports
* Start a modal drag session using the selection as the drag image.
* The aDragEvent must be supplied as the current screen coordinates of the
* event are needed to calculate the image location.
*
* Note: This method is deprecated for non-native code.
*/
void invokeDragSessionWithSelection(in nsISelection aSelection,
in nsISupportsArray aTransferableArray,
in nsIArray aTransferableArray,
in unsigned long aActionType,
in nsIDOMDragEvent aDragEvent,
in nsIDOMDataTransfer aDataTransfer);

View File

@ -20,10 +20,10 @@
#include "nsNativeDragTarget.h"
#include "nsNativeDragSource.h"
#include "nsClipboard.h"
#include "nsISupportsArray.h"
#include "nsIDocument.h"
#include "nsDataObjCollection.h"
#include "nsArrayUtils.h"
#include "nsString.h"
#include "nsEscape.h"
#include "nsIScreenManager.h"
@ -171,7 +171,7 @@ nsDragService::CreateDragImage(nsIDOMNode *aDOMNode,
//-------------------------------------------------------------------------
nsresult
nsDragService::InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
nsDragService::InvokeDragSessionImpl(nsIArray* anArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType)
{
@ -184,7 +184,7 @@ nsDragService::InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
}
uint32_t numItemsToDrag = 0;
nsresult rv = anArrayTransferables->Count(&numItemsToDrag);
nsresult rv = anArrayTransferables->GetLength(&numItemsToDrag);
if (!numItemsToDrag)
return NS_ERROR_FAILURE;
@ -202,9 +202,8 @@ nsDragService::InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
return NS_ERROR_OUT_OF_MEMORY;
itemToDrag = dataObjCollection;
for (uint32_t i=0; i<numItemsToDrag; ++i) {
nsCOMPtr<nsISupports> supports;
anArrayTransferables->GetElementAt(i, getter_AddRefs(supports));
nsCOMPtr<nsITransferable> trans(do_QueryInterface(supports));
nsCOMPtr<nsITransferable> trans =
do_QueryElementAt(anArrayTransferables, i);
if (trans) {
// set the requestingPrincipal on the transferable
nsCOMPtr<nsINode> node = do_QueryInterface(mSourceNode);
@ -223,9 +222,8 @@ nsDragService::InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
}
} // if dragging multiple items
else {
nsCOMPtr<nsISupports> supports;
anArrayTransferables->GetElementAt(0, getter_AddRefs(supports));
nsCOMPtr<nsITransferable> trans(do_QueryInterface(supports));
nsCOMPtr<nsITransferable> trans =
do_QueryElementAt(anArrayTransferables, 0);
if (trans) {
// set the requestingPrincipal on the transferable
nsCOMPtr<nsINode> node = do_QueryInterface(mSourceNode);

View File

@ -24,7 +24,7 @@ public:
virtual ~nsDragService();
// nsBaseDragService
virtual nsresult InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
virtual nsresult InvokeDragSessionImpl(nsIArray* anArrayTransferables,
nsIScriptableRegion* aRegion,
uint32_t aActionType);

View File

@ -8,7 +8,7 @@
#include <shlobj.h>
#include "TestHarness.h"
#include "nsIArray.h"
#include "nsArray.h"
#include "nsIFile.h"
#include "nsNetUtil.h"
#include "nsISupportsPrimitives.h"
@ -226,7 +226,7 @@ nsresult GetTransferableURI(nsCOMPtr<nsITransferable>& pTransferable)
return rv;
}
nsresult MakeDataObject(nsISupportsArray* transferableArray,
nsresult MakeDataObject(nsIArray* transferableArray,
RefPtr<IDataObject>& itemToDrag)
{
nsresult rv;
@ -236,7 +236,7 @@ nsresult MakeDataObject(nsISupportsArray* transferableArray,
rv = NS_NewURI(getter_AddRefs(uri), "http://www.mozilla.org");
NS_ENSURE_SUCCESS(rv, rv);
rv = transferableArray->Count(&itemCount);
rv = transferableArray->GetLength(&itemCount);
NS_ENSURE_SUCCESS(rv, rv);
// Copied more or less exactly from nsDragService::InvokeDragSession
@ -247,9 +247,7 @@ nsresult MakeDataObject(nsISupportsArray* transferableArray,
return NS_ERROR_OUT_OF_MEMORY;
itemToDrag = dataObjCollection;
for (uint32_t i=0; i<itemCount; ++i) {
nsCOMPtr<nsISupports> supports;
transferableArray->GetElementAt(i, getter_AddRefs(supports));
nsCOMPtr<nsITransferable> trans(do_QueryInterface(supports));
nsCOMPtr<nsITransferable> trans = do_QueryElementAt(transferableArray, i);
if (trans) {
RefPtr<IDataObject> dataObj;
rv = nsClipboard::CreateNativeDataObject(trans,
@ -264,9 +262,7 @@ nsresult MakeDataObject(nsISupportsArray* transferableArray,
}
} // if dragging multiple items
else {
nsCOMPtr<nsISupports> supports;
transferableArray->GetElementAt(0, getter_AddRefs(supports));
nsCOMPtr<nsITransferable> trans(do_QueryInterface(supports));
nsCOMPtr<nsITransferable> trans = do_QueryElementAt(transferableArray, 0);
if (trans) {
rv = nsClipboard::CreateNativeDataObject(trans,
getter_AddRefs(itemToDrag),
@ -281,14 +277,9 @@ nsresult Do_CheckOneFile()
{
nsresult rv;
nsCOMPtr<nsITransferable> transferable;
nsCOMPtr<nsISupportsArray> transferableArray;
nsCOMPtr<nsIMutableArray> transferableArray = nsArray::Create();
nsCOMPtr<nsISupports> genericWrapper;
RefPtr<IDataObject> dataObj;
rv = NS_NewISupportsArray(getter_AddRefs(transferableArray));
if (NS_FAILED(rv)) {
fail("Could not create the necessary nsISupportsArray");
return rv;
}
rv = GetTransferableFile(transferable);
if (NS_FAILED(rv)) {
@ -337,14 +328,9 @@ nsresult Do_CheckTwoFiles()
{
nsresult rv;
nsCOMPtr<nsITransferable> transferable;
nsCOMPtr<nsISupportsArray> transferableArray;
nsCOMPtr<nsIMutableArray> transferableArray = nsArray::Create();
nsCOMPtr<nsISupports> genericWrapper;
RefPtr<IDataObject> dataObj;
rv = NS_NewISupportsArray(getter_AddRefs(transferableArray));
if (NS_FAILED(rv)) {
fail("Could not create the necessary nsISupportsArray");
return rv;
}
rv = GetTransferableFile(transferable);
if (NS_FAILED(rv)) {
@ -405,14 +391,9 @@ nsresult Do_CheckOneString()
{
nsresult rv;
nsCOMPtr<nsITransferable> transferable;
nsCOMPtr<nsISupportsArray> transferableArray;
nsCOMPtr<nsIMutableArray> transferableArray = nsArray::Create();
nsCOMPtr<nsISupports> genericWrapper;
RefPtr<IDataObject> dataObj;
rv = NS_NewISupportsArray(getter_AddRefs(transferableArray));
if (NS_FAILED(rv)) {
fail("Could not create the necessary nsISupportsArray");
return rv;
}
rv = GetTransferableText(transferable);
if (NS_FAILED(rv)) {
@ -478,14 +459,9 @@ nsresult Do_CheckTwoStrings()
{
nsresult rv;
nsCOMPtr<nsITransferable> transferable;
nsCOMPtr<nsISupportsArray> transferableArray;
nsCOMPtr<nsIMutableArray> transferableArray = nsArray::Create();
nsCOMPtr<nsISupports> genericWrapper;
RefPtr<IDataObject> dataObj;
rv = NS_NewISupportsArray(getter_AddRefs(transferableArray));
if (NS_FAILED(rv)) {
fail("Could not create the necessary nsISupportsArray");
return rv;
}
rv = GetTransferableText(transferable);
if (NS_FAILED(rv)) {
@ -563,14 +539,9 @@ nsresult Do_CheckSetArbitraryData(bool aMultiple)
{
nsresult rv;
nsCOMPtr<nsITransferable> transferable;
nsCOMPtr<nsISupportsArray> transferableArray;
nsCOMPtr<nsIMutableArray> transferableArray = nsArray::Create();
nsCOMPtr<nsISupports> genericWrapper;
RefPtr<IDataObject> dataObj;
rv = NS_NewISupportsArray(getter_AddRefs(transferableArray));
if (NS_FAILED(rv)) {
fail("Could not create the necessary nsISupportsArray");
return rv;
}
rv = GetTransferableText(transferable);
if (NS_FAILED(rv)) {