nsContentAreaDragDrop.h (3392B)
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 #ifndef nsContentAreaDragDrop_h__ 8 #define nsContentAreaDragDrop_h__ 9 10 #include "nsCOMPtr.h" 11 #include "nsITransferable.h" 12 13 class nsIPolicyContainer; 14 class nsICookieJarSettings; 15 class nsPIDOMWindowOuter; 16 class nsITransferable; 17 class nsIContent; 18 class nsIFile; 19 20 namespace mozilla::dom { 21 class DataTransfer; 22 class Selection; 23 } // namespace mozilla::dom 24 25 // 26 // class nsContentAreaDragDrop, used to generate the dragdata 27 // 28 class nsContentAreaDragDrop { 29 public: 30 /** 31 * Determine what data in the content area, if any, is being dragged. 32 * 33 * aWindow - the window containing the target node 34 * aTarget - the mousedown event target that started the drag 35 * aSelectionTargetNode - the node where the drag event should be fired 36 * aIsAltKeyPressed - true if the Alt key is pressed. In some cases, this 37 * will prevent the drag from occuring. For example, 38 * holding down Alt over a link should select the text, 39 * not drag the link. 40 * aDataTransfer - the dataTransfer for the drag event. 41 * aCanDrag - [out] set to true if the drag may proceed, false to stop the 42 * drag entirely 43 * aSelection - [out] set to the selection being dragged, or null if no 44 * selection is being dragged. 45 * aDragNode - [out] the link, image or area being dragged, or null if the 46 * drag occurred on another element. 47 * aPolicyContainer - [out] set to the policyContainer of the Drag, or null if 48 * it's from browser chrome or OS 49 * aCookieJarSettings - [out] set to the cookieJarSetting of the Drag, or null 50 * if it's from browser chrome or OS 51 */ 52 static nsresult GetDragData(nsPIDOMWindowOuter* aWindow, nsIContent* aTarget, 53 nsIContent* aSelectionTargetNode, 54 bool aIsAltKeyPressed, 55 mozilla::dom::DataTransfer* aDataTransfer, 56 bool* aCanDrag, 57 mozilla::dom::Selection** aSelection, 58 nsIContent** aDragNode, 59 nsIPolicyContainer** aPolicyContainer, 60 nsICookieJarSettings** aCookieJarSettings); 61 }; 62 63 // this is used to save images to disk lazily when the image data is asked for 64 // during the drop instead of when it is added to the drag data transfer. This 65 // ensures that the image data is only created when an image drop is allowed. 66 class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider { 67 virtual ~nsContentAreaDragDropDataProvider() = default; 68 69 public: 70 NS_DECL_ISUPPORTS 71 NS_DECL_NSIFLAVORDATAPROVIDER 72 73 nsresult SaveURIToFile(nsIURI* inSourceURI, 74 nsIPrincipal* inTriggeringPrincipal, 75 nsICookieJarSettings* inCookieJarSettings, 76 nsIFile* inDestFile, nsContentPolicyType inPolicyType, 77 bool isPrivate); 78 }; 79 80 #endif /* nsContentAreaDragDrop_h__ */