Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/base/nsContentAreaDragDrop.h
Line
Count
Source (jump to first uncovered line)
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 nsITransferable;
19
class nsIContent;
20
class nsIFile;
21
22
namespace mozilla {
23
namespace dom {
24
class DataTransfer;
25
class Selection;
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
   * aPrincipalURISpec - [out] set to the URI of the triggering principal of
54
   *                           the drag, or empty string if it's from
55
   *                           browser chrome or OS
56
   */
57
  static nsresult GetDragData(nsPIDOMWindowOuter* aWindow,
58
                              nsIContent* aTarget,
59
                              nsIContent* aSelectionTargetNode,
60
                              bool aIsAltKeyPressed,
61
                              mozilla::dom::DataTransfer* aDataTransfer,
62
                              bool* aCanDrag,
63
                              mozilla::dom::Selection** aSelection,
64
                              nsIContent** aDragNode,
65
                              nsACString& aPrincipalURISpec);
66
};
67
68
// this is used to save images to disk lazily when the image data is asked for
69
// during the drop instead of when it is added to the drag data transfer. This
70
// ensures that the image data is only created when an image drop is allowed.
71
class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider
72
{
73
0
  virtual ~nsContentAreaDragDropDataProvider() {}
74
75
public:
76
  NS_DECL_ISUPPORTS
77
  NS_DECL_NSIFLAVORDATAPROVIDER
78
79
  nsresult SaveURIToFile(nsIURI* inSourceURI,
80
                         nsIPrincipal* inTriggeringPrincipal,
81
                         nsIFile* inDestFile, bool isPrivate);
82
};
83
84
85
#endif /* nsContentAreaDragDrop_h__ */
86