Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 :
8 : #ifndef nsContentAreaDragDrop_h__
9 : #define nsContentAreaDragDrop_h__
10 :
11 :
12 : #include "nsCOMPtr.h"
13 :
14 : #include "nsIDOMEventListener.h"
15 : #include "nsITransferable.h"
16 :
17 : class nsPIDOMWindowOuter;
18 : class nsISelection;
19 : class nsITransferable;
20 : class nsIContent;
21 : class nsIFile;
22 :
23 : namespace mozilla {
24 : namespace dom {
25 : class DataTransfer;
26 : } // namespace dom
27 : } // namespace mozilla
28 :
29 : //
30 : // class nsContentAreaDragDrop, used to generate the dragdata
31 : //
32 : class nsContentAreaDragDrop
33 : {
34 : public:
35 :
36 : /**
37 : * Determine what data in the content area, if any, is being dragged.
38 : *
39 : * aWindow - the window containing the target node
40 : * aTarget - the mousedown event target that started the drag
41 : * aSelectionTargetNode - the node where the drag event should be fired
42 : * aIsAltKeyPressed - true if the Alt key is pressed. In some cases, this
43 : * will prevent the drag from occuring. For example,
44 : * holding down Alt over a link should select the text,
45 : * not drag the link.
46 : * aDataTransfer - the dataTransfer for the drag event.
47 : * aCanDrag - [out] set to true if the drag may proceed, false to stop the
48 : * drag entirely
49 : * aSelection - [out] set to the selection being dragged, or null if no
50 : * selection is being dragged.
51 : * aDragNode - [out] the link, image or area being dragged, or null if the
52 : * drag occurred on another element.
53 : */
54 : static nsresult GetDragData(nsPIDOMWindowOuter* aWindow,
55 : nsIContent* aTarget,
56 : nsIContent* aSelectionTargetNode,
57 : bool aIsAltKeyPressed,
58 : mozilla::dom::DataTransfer* aDataTransfer,
59 : bool* aCanDrag,
60 : nsISelection** aSelection,
61 : nsIContent** aDragNode);
62 : };
63 :
64 : // this is used to save images to disk lazily when the image data is asked for
65 : // during the drop instead of when it is added to the drag data transfer. This
66 : // ensures that the image data is only created when an image drop is allowed.
67 0 : class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider
68 : {
69 0 : virtual ~nsContentAreaDragDropDataProvider() {}
70 :
71 : public:
72 : NS_DECL_ISUPPORTS
73 : NS_DECL_NSIFLAVORDATAPROVIDER
74 :
75 : nsresult SaveURIToFile(nsAString& inSourceURIString,
76 : nsIFile* inDestFile, bool isPrivate);
77 : };
78 :
79 :
80 : #endif /* nsContentAreaDragDrop_h__ */
81 :
|