Backed out 4 changesets (bug 1825722) for causing reftest failures CLOSED TREE
[gecko.git] / dom / base / nsContentAreaDragDrop.h
blob27ef90f272c213a54bf5bbbb0662bc90983a32bb
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/. */
7 #ifndef nsContentAreaDragDrop_h__
8 #define nsContentAreaDragDrop_h__
10 #include "nsCOMPtr.h"
12 #include "nsITransferable.h"
13 #include "nsIContentSecurityPolicy.h"
15 class nsICookieJarSettings;
16 class nsPIDOMWindowOuter;
17 class nsITransferable;
18 class nsIContent;
19 class nsIFile;
21 namespace mozilla::dom {
22 class DataTransfer;
23 class Selection;
24 } // namespace mozilla::dom
27 // class nsContentAreaDragDrop, used to generate the dragdata
29 class nsContentAreaDragDrop {
30 public:
31 /**
32 * Determine what data in the content area, if any, is being dragged.
34 * aWindow - the window containing the target node
35 * aTarget - the mousedown event target that started the drag
36 * aSelectionTargetNode - the node where the drag event should be fired
37 * aIsAltKeyPressed - true if the Alt key is pressed. In some cases, this
38 * will prevent the drag from occuring. For example,
39 * holding down Alt over a link should select the text,
40 * not drag the link.
41 * aDataTransfer - the dataTransfer for the drag event.
42 * aCanDrag - [out] set to true if the drag may proceed, false to stop the
43 * drag entirely
44 * aSelection - [out] set to the selection being dragged, or null if no
45 * selection is being dragged.
46 * aDragNode - [out] the link, image or area being dragged, or null if the
47 * drag occurred on another element.
48 * aCSP - [out] set to the CSP of the Drag, or null if
49 * it's from browser chrome or OS
50 * aCookieJarSettings - [out] set to the cookieJarSetting of the Drag, or null
51 * if it's from browser chrome or OS
53 static nsresult GetDragData(nsPIDOMWindowOuter* aWindow, nsIContent* aTarget,
54 nsIContent* aSelectionTargetNode,
55 bool aIsAltKeyPressed,
56 mozilla::dom::DataTransfer* aDataTransfer,
57 bool* aCanDrag,
58 mozilla::dom::Selection** aSelection,
59 nsIContent** aDragNode,
60 nsIContentSecurityPolicy** aCsp,
61 nsICookieJarSettings** aCookieJarSettings);
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 class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider {
68 virtual ~nsContentAreaDragDropDataProvider() = default;
70 public:
71 NS_DECL_ISUPPORTS
72 NS_DECL_NSIFLAVORDATAPROVIDER
74 nsresult SaveURIToFile(nsIURI* inSourceURI,
75 nsIPrincipal* inTriggeringPrincipal,
76 nsICookieJarSettings* inCookieJarSettings,
77 nsIFile* inDestFile, nsContentPolicyType inPolicyType,
78 bool isPrivate);
81 #endif /* nsContentAreaDragDrop_h__ */