Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / windows / nsNativeDragTarget.h
blob82edc7aae70e7e34bc2ce426a596f76d41367ede
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _nsNativeDragTarget_h_
6 #define _nsNativeDragTarget_h_
8 #include "nsCOMPtr.h"
9 #include <ole2.h>
10 #include <shlobj.h>
12 #ifndef IDropTargetHelper
13 # include <shobjidl.h> // Vista drag image interfaces
14 # undef LogSeverity // SetupAPI.h #defines this as DWORD
15 #endif
17 #include "mozilla/Attributes.h"
18 #include "mozilla/EventForwards.h"
20 class nsIDragService;
21 class nsIWidget;
24 * nsNativeDragTarget implements the IDropTarget interface and gets most of its
25 * behavior from the associated adapter (m_dragDrop).
28 class nsNativeDragTarget final : public IDropTarget {
29 public:
30 explicit nsNativeDragTarget(nsIWidget* aWidget);
31 ~nsNativeDragTarget();
33 // IUnknown members - see iunknown.h for documentation
34 STDMETHODIMP QueryInterface(REFIID, void**);
35 STDMETHODIMP_(ULONG) AddRef();
36 STDMETHODIMP_(ULONG) Release();
38 // IDataTarget members
40 // Set pEffect based on whether this object can support a drop based on
41 // the data available from pSource, the key and mouse states specified
42 // in grfKeyState, and the coordinates specified by point. This is
43 // called by OLE when a drag enters this object's window (as registered
44 // by Initialize).
45 STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState, POINTL point,
46 DWORD* pEffect);
48 // Similar to DragEnter except it is called frequently while the drag
49 // is over this object's window.
50 MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP DragOver(DWORD grfKeyState,
51 POINTL point,
52 DWORD* pEffect);
54 // Release the drag-drop source and put internal state back to the point
55 // before the call to DragEnter. This is called when the drag leaves
56 // without a drop occurring.
57 MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP DragLeave();
59 // If point is within our region of interest and pSource's data supports
60 // one of our formats, get the data and set pEffect according to
61 // grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
62 // DROPEFFECT_COPY if the control key was pressed). Otherwise return
63 // E_FAIL.
64 MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP Drop(LPDATAOBJECT pSource,
65 DWORD grfKeyState, POINTL point,
66 DWORD* pEffect);
67 /**
68 * Cancel the current drag session, if any.
70 MOZ_CAN_RUN_SCRIPT_BOUNDARY void DragCancel();
72 static void DragImageChanged() { gDragImageChanged = true; }
74 protected:
75 void GetGeckoDragAction(DWORD grfKeyState, LPDWORD pdwEffect,
76 uint32_t* aGeckoAction);
77 void ProcessDrag(mozilla::EventMessage aEventMessage, DWORD grfKeyState,
78 POINTL pt, DWORD* pdwEffect);
79 void DispatchDragDropEvent(mozilla::EventMessage aEventMessage,
80 const POINTL& aPT);
81 void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource);
83 // Native Stuff
84 ULONG m_cRef; // reference count
85 HWND mHWnd;
86 DWORD mEffectsAllowed;
87 DWORD mEffectsPreferred;
88 bool mTookOwnRef;
90 // Gecko Stuff
91 nsIWidget* mWidget;
92 nsCOMPtr<nsIDragService> mDragService;
93 // Drag target helper
94 IDropTargetHelper* GetDropTargetHelper();
96 private:
97 // Drag target helper
98 IDropTargetHelper* mDropTargetHelper;
100 static bool gDragImageChanged;
103 #endif // _nsNativeDragTarget_h_