2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef DragController_h
27 #define DragController_h
29 #include "core/page/DragActions.h"
30 #include "platform/geometry/IntPoint.h"
31 #include "platform/heap/Handle.h"
32 #include "platform/weborigin/KURL.h"
33 #include "wtf/Forward.h"
47 class HTMLInputElement;
52 class PlatformMouseEvent;
55 class DragController FINAL : public NoBaseWillBeGarbageCollectedFinalized<DragController> {
56 WTF_MAKE_NONCOPYABLE(DragController);
57 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
61 static PassOwnPtrWillBeRawPtr<DragController> create(Page*, DragClient*);
63 DragSession dragEntered(DragData*);
64 void dragExited(DragData*);
65 DragSession dragUpdated(DragData*);
66 bool performDrag(DragData*);
68 enum SelectionDragPolicy {
69 ImmediateSelectionDragResolution,
70 DelayedSelectionDragResolution,
72 Node* draggableNode(const LocalFrame*, Node*, const IntPoint&, SelectionDragPolicy, DragSourceAction&) const;
75 bool populateDragDataTransfer(LocalFrame* src, const DragState&, const IntPoint& dragOrigin);
76 bool startDrag(LocalFrame* src, const DragState&, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin);
80 static const int DragIconRightInset;
81 static const int DragIconBottomInset;
84 DragController(Page*, DragClient*);
86 bool dispatchTextInputEventFor(LocalFrame*, DragData*);
87 bool canProcessDrag(DragData*);
88 bool concludeEditDrag(DragData*);
89 DragSession dragEnteredOrUpdated(DragData*);
90 DragOperation operationForLoad(DragData*);
91 bool tryDocumentDrag(DragData*, DragDestinationAction, DragSession&);
92 bool tryDHTMLDrag(DragData*, DragOperation&);
93 DragOperation dragOperation(DragData*);
95 bool dragIsMove(FrameSelection&, DragData*);
96 bool isCopyKeyDown(DragData*);
98 void mouseMovedIntoDocument(Document*);
100 void doSystemDrag(DragImage*, const IntPoint& dragLocation, const IntPoint& dragOrigin, DataTransfer*, LocalFrame*, bool forLink);
101 void cleanupAfterSystemDrag();
103 RawPtrWillBeMember<Page> m_page;
104 DragClient* m_client;
106 RefPtrWillBeMember<Document> m_documentUnderMouse; // The document the mouse was last dragged over.
107 RefPtrWillBeMember<Document> m_dragInitiator; // The Document (if any) that initiated the drag.
108 RefPtrWillBeMember<HTMLInputElement> m_fileInputElementUnderMouse;
109 bool m_documentIsHandlingDrag;
111 DragDestinationAction m_dragDestinationAction;
112 bool m_didInitiateDrag;
117 #endif // DragController_h