mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fixing bug 503598. Adding support for drag n' drop funcitonality for local files. r=enndeakin@gmail.com, sr=mrbkap@gmail.com/jonas@sicking.cc
--HG-- extra : rebase_source : 66d93e71d30ea18e045f95f7f94951c02739edd9
This commit is contained in:
parent
9fcfc548de
commit
a6b371d7e0
@ -38,7 +38,6 @@
|
||||
#include "nsDOMDataTransfer.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIVariant.h"
|
||||
@ -219,6 +218,52 @@ nsDOMDataTransfer::GetMozUserCancelled(PRBool* aUserCancelled)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDataTransfer::GetFiles(nsIDOMFileList** aFileList)
|
||||
{
|
||||
*aFileList = nsnull;
|
||||
|
||||
if (mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP)
|
||||
return NS_OK;
|
||||
|
||||
if (!mFiles) {
|
||||
mFiles = new nsDOMFileList();
|
||||
NS_ENSURE_TRUE(mFiles, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRUint32 count = mItems.Length();
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIVariant> variant;
|
||||
nsresult rv = MozGetDataAt(NS_ConvertUTF8toUTF16(kFileMime), i, getter_AddRefs(variant));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!variant)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = variant->GetAsISupports(getter_AddRefs(supports));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
|
||||
|
||||
if (!file)
|
||||
continue;
|
||||
|
||||
nsRefPtr<nsDOMFile> domFile = new nsDOMFile(file);
|
||||
NS_ENSURE_TRUE(domFile, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (!mFiles->Append(domFile))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
*aFileList = mFiles;
|
||||
NS_ADDREF(*aFileList);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDataTransfer::GetTypes(nsIDOMDOMStringList** aTypes)
|
||||
{
|
||||
@ -407,7 +452,7 @@ nsDOMDataTransfer::MozSetDataAt(const nsAString& aFormat,
|
||||
// XXX perhaps this should also limit any non-string type as well
|
||||
if ((aFormat.EqualsLiteral("application/x-moz-file-promise") ||
|
||||
aFormat.EqualsLiteral("application/x-moz-file")) &&
|
||||
!nsContentUtils::IsCallerChrome()) {
|
||||
!nsContentUtils::IsCallerTrustedForCapability("UniversalXPConnect")) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,11 @@
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsDOMFile.h"
|
||||
|
||||
class nsITransferable;
|
||||
|
||||
/**
|
||||
@ -185,6 +190,9 @@ protected:
|
||||
// array of items, each containing an array of format->data pairs
|
||||
nsTArray<nsTArray<TransferItem> > mItems;
|
||||
|
||||
// array of files, containing only the files present in the dataTransfer
|
||||
nsRefPtr<nsDOMFileList> mFiles;
|
||||
|
||||
// the target of the drag. The drag and dragend events will fire at this.
|
||||
nsCOMPtr<nsIDOMElement> mDragTarget;
|
||||
|
||||
|
@ -38,8 +38,9 @@
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIVariant;
|
||||
interface nsIDOMFileList;
|
||||
|
||||
[scriptable, uuid(E4970BA1-9567-455C-8B4E-4607D7E741BB)]
|
||||
[scriptable, uuid(34042440-60A8-4992-AE5C-798E69148955)]
|
||||
interface nsIDOMDataTransfer : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -90,6 +91,13 @@ interface nsIDOMDataTransfer : nsISupports
|
||||
*/
|
||||
attribute DOMString effectAllowed;
|
||||
|
||||
/**
|
||||
* Holds a list of all the local files available on this data transfer.
|
||||
* A dataTransfer containing no files will return an empty list, and an
|
||||
* invalid index access on the resulting file list will return null.
|
||||
*/
|
||||
readonly attribute nsIDOMFileList files;
|
||||
|
||||
/**
|
||||
* Holds a list of the format types of the data that is stored for the first
|
||||
* item, in the same order the data was added. An empty list will be
|
||||
|
Loading…
Reference in New Issue
Block a user