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