2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef nsContentAreaDragDrop_h__
|
|
|
|
#define nsContentAreaDragDrop_h__
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2008-10-17 13:04:55 -07:00
|
|
|
#include "nsIDOMEventListener.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsITransferable.h"
|
|
|
|
|
|
|
|
class nsIDOMNode;
|
2012-08-04 00:44:01 -07:00
|
|
|
class nsPIDOMWindow;
|
2008-10-17 13:04:55 -07:00
|
|
|
class nsIDOMDragEvent;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsISelection;
|
|
|
|
class nsITransferable;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIURI;
|
|
|
|
class nsIFile;
|
|
|
|
class nsISimpleEnumerator;
|
2013-08-12 07:45:33 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DataTransfer;
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//
|
2010-04-18 11:27:18 -07:00
|
|
|
// class nsContentAreaDragDrop, used to generate the dragdata
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
2010-04-18 11:27:18 -07:00
|
|
|
class nsContentAreaDragDrop
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-08-27 05:07:27 -07:00
|
|
|
/**
|
|
|
|
* Determine what data in the content area, if any, is being dragged.
|
|
|
|
*
|
|
|
|
* aWindow - the window containing the target node
|
|
|
|
* aTarget - the mousedown event target that started the drag
|
|
|
|
* aSelectionTargetNode - the node where the drag event should be fired
|
|
|
|
* aIsAltKeyPressed - true if the Alt key is pressed. In some cases, this
|
|
|
|
* will prevent the drag from occuring. For example,
|
|
|
|
* holding down Alt over a link should select the text,
|
|
|
|
* not drag the link.
|
|
|
|
* aDataTransfer - the dataTransfer for the drag event.
|
|
|
|
* aCanDrag - [out] set to true if the drag may proceed, false to stop the
|
|
|
|
* drag entirely
|
2012-02-17 06:16:59 -08:00
|
|
|
* aSelection - [out] set to the selection being dragged, or null if no
|
|
|
|
* selection is being dragged.
|
2008-08-27 05:07:27 -07:00
|
|
|
* aDragNode - [out] the link, image or area being dragged, or null if the
|
2010-05-13 05:19:50 -07:00
|
|
|
* drag occurred on another element.
|
2008-08-27 05:07:27 -07:00
|
|
|
*/
|
2012-08-04 00:44:01 -07:00
|
|
|
static nsresult GetDragData(nsPIDOMWindow* aWindow,
|
2008-08-27 05:07:27 -07:00
|
|
|
nsIContent* aTarget,
|
|
|
|
nsIContent* aSelectionTargetNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsAltKeyPressed,
|
2013-08-12 07:45:33 -07:00
|
|
|
mozilla::dom::DataTransfer* aDataTransfer,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aCanDrag,
|
2012-02-17 06:16:59 -08:00
|
|
|
nsISelection** aSelection,
|
2008-08-27 05:07:27 -07:00
|
|
|
nsIContent** aDragNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-27 05:07:27 -07:00
|
|
|
// this is used to save images to disk lazily when the image data is asked for
|
|
|
|
// during the drop instead of when it is added to the drag data transfer. This
|
|
|
|
// ensures that the image data is only created when an image drop is allowed.
|
|
|
|
class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider
|
|
|
|
{
|
2014-06-24 19:09:15 -07:00
|
|
|
virtual ~nsContentAreaDragDropDataProvider() {}
|
|
|
|
|
2008-08-27 05:07:27 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFLAVORDATAPROVIDER
|
|
|
|
|
|
|
|
nsresult SaveURIToFile(nsAString& inSourceURIString,
|
2012-10-04 12:07:51 -07:00
|
|
|
nsIFile* inDestFile, bool isPrivate);
|
2008-08-27 05:07:27 -07:00
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* nsContentAreaDragDrop_h__ */
|
|
|
|
|