1 : /* ***** BEGIN LICENSE BLOCK *****
2 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Original Code is Mozilla Communicator.
15 : *
16 : * The Initial Developer of the Original Code is
17 : * Netscape Communications.
18 : * Portions created by the Initial Developer are Copyright (C) 2002
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Mike Pinkerton <pinkerton@netscape.com>
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 :
39 : #ifndef nsContentAreaDragDrop_h__
40 : #define nsContentAreaDragDrop_h__
41 :
42 :
43 : #include "nsCOMPtr.h"
44 :
45 : #include "nsIDOMEventTarget.h"
46 : #include "nsIDOMEventListener.h"
47 : #include "nsITransferable.h"
48 :
49 : class nsIDOMNode;
50 : class nsIDOMWindow;
51 : class nsIDOMDocument;
52 : class nsIDOMDragEvent;
53 : class nsISelection;
54 : class nsITransferable;
55 : class nsIContent;
56 : class nsIURI;
57 : class nsIFile;
58 : class nsISimpleEnumerator;
59 : class nsDOMDataTransfer;
60 :
61 : //
62 : // class nsContentAreaDragDrop, used to generate the dragdata
63 : //
64 : class nsContentAreaDragDrop
65 : {
66 : public:
67 :
68 : /**
69 : * Determine what data in the content area, if any, is being dragged.
70 : *
71 : * aWindow - the window containing the target node
72 : * aTarget - the mousedown event target that started the drag
73 : * aSelectionTargetNode - the node where the drag event should be fired
74 : * aIsAltKeyPressed - true if the Alt key is pressed. In some cases, this
75 : * will prevent the drag from occuring. For example,
76 : * holding down Alt over a link should select the text,
77 : * not drag the link.
78 : * aDataTransfer - the dataTransfer for the drag event.
79 : * aCanDrag - [out] set to true if the drag may proceed, false to stop the
80 : * drag entirely
81 : * aSelection - [out] set to the selection being dragged, or null if no
82 : * selection is being dragged.
83 : * aDragNode - [out] the link, image or area being dragged, or null if the
84 : * drag occurred on another element.
85 : */
86 : static nsresult GetDragData(nsIDOMWindow* aWindow,
87 : nsIContent* aTarget,
88 : nsIContent* aSelectionTargetNode,
89 : bool aIsAltKeyPressed,
90 : nsDOMDataTransfer* aDataTransfer,
91 : bool* aCanDrag,
92 : nsISelection** aSelection,
93 : nsIContent** aDragNode);
94 : };
95 :
96 : // this is used to save images to disk lazily when the image data is asked for
97 : // during the drop instead of when it is added to the drag data transfer. This
98 : // ensures that the image data is only created when an image drop is allowed.
99 : class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider
100 0 : {
101 : public:
102 : NS_DECL_ISUPPORTS
103 : NS_DECL_NSIFLAVORDATAPROVIDER
104 :
105 0 : virtual ~nsContentAreaDragDropDataProvider() {}
106 :
107 : nsresult SaveURIToFile(nsAString& inSourceURIString,
108 : nsIFile* inDestFile);
109 : };
110 :
111 :
112 : #endif /* nsContentAreaDragDrop_h__ */
113 :
|