content/base/src/nsContentAreaDragDrop.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/nsContentAreaDragDrop.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +
     1.9 +#ifndef nsContentAreaDragDrop_h__
    1.10 +#define nsContentAreaDragDrop_h__
    1.11 +
    1.12 +
    1.13 +#include "nsCOMPtr.h"
    1.14 +
    1.15 +#include "nsIDOMEventListener.h"
    1.16 +#include "nsITransferable.h"
    1.17 +
    1.18 +class nsIDOMNode;
    1.19 +class nsPIDOMWindow;
    1.20 +class nsIDOMDragEvent;
    1.21 +class nsISelection;
    1.22 +class nsITransferable;
    1.23 +class nsIContent;
    1.24 +class nsIURI;
    1.25 +class nsIFile;
    1.26 +class nsISimpleEnumerator;
    1.27 +
    1.28 +namespace mozilla {
    1.29 +namespace dom {
    1.30 +class DataTransfer;
    1.31 +}
    1.32 +}
    1.33 +
    1.34 +//
    1.35 +// class nsContentAreaDragDrop, used to generate the dragdata
    1.36 +//
    1.37 +class nsContentAreaDragDrop
    1.38 +{
    1.39 +public:
    1.40 +
    1.41 +  /**
    1.42 +   * Determine what data in the content area, if any, is being dragged.
    1.43 +   *
    1.44 +   * aWindow - the window containing the target node
    1.45 +   * aTarget - the mousedown event target that started the drag
    1.46 +   * aSelectionTargetNode - the node where the drag event should be fired
    1.47 +   * aIsAltKeyPressed - true if the Alt key is pressed. In some cases, this
    1.48 +   *                    will prevent the drag from occuring. For example,
    1.49 +   *                    holding down Alt over a link should select the text,
    1.50 +   *                    not drag the link.
    1.51 +   * aDataTransfer - the dataTransfer for the drag event.
    1.52 +   * aCanDrag - [out] set to true if the drag may proceed, false to stop the
    1.53 +   *            drag entirely
    1.54 +   * aSelection - [out] set to the selection being dragged, or null if no
    1.55 +   *                    selection is being dragged.
    1.56 +   * aDragNode - [out] the link, image or area being dragged, or null if the
    1.57 +   *             drag occurred on another element.
    1.58 +   */
    1.59 +  static nsresult GetDragData(nsPIDOMWindow* aWindow,
    1.60 +                              nsIContent* aTarget,
    1.61 +                              nsIContent* aSelectionTargetNode,
    1.62 +                              bool aIsAltKeyPressed,
    1.63 +                              mozilla::dom::DataTransfer* aDataTransfer,
    1.64 +                              bool* aCanDrag,
    1.65 +                              nsISelection** aSelection,
    1.66 +                              nsIContent** aDragNode);
    1.67 +};
    1.68 +
    1.69 +// this is used to save images to disk lazily when the image data is asked for
    1.70 +// during the drop instead of when it is added to the drag data transfer. This
    1.71 +// ensures that the image data is only created when an image drop is allowed.
    1.72 +class nsContentAreaDragDropDataProvider : public nsIFlavorDataProvider
    1.73 +{
    1.74 +public:
    1.75 +  NS_DECL_ISUPPORTS
    1.76 +  NS_DECL_NSIFLAVORDATAPROVIDER
    1.77 +
    1.78 +  virtual ~nsContentAreaDragDropDataProvider() {}
    1.79 +
    1.80 +  nsresult SaveURIToFile(nsAString& inSourceURIString,
    1.81 +                         nsIFile* inDestFile, bool isPrivate);
    1.82 +};
    1.83 +
    1.84 +
    1.85 +#endif /* nsContentAreaDragDrop_h__ */
    1.86 +

mercurial