• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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.
24  */
25 
26 #ifndef DragController_h
27 #define DragController_h
28 
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"
34 
35 namespace blink {
36 
37 class DataTransfer;
38 class Document;
39 class DragClient;
40 class DragData;
41 class DragImage;
42 struct DragSession;
43 class DragState;
44 class LocalFrame;
45 class FrameSelection;
46 class HTMLInputElement;
47 class Node;
48 class Page;
49 class PlatformMouseEvent;
50 
51 class DragController FINAL : public NoBaseWillBeGarbageCollectedFinalized<DragController> {
52     WTF_MAKE_NONCOPYABLE(DragController);
53     WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
54 public:
55     ~DragController();
56 
57     static PassOwnPtrWillBeRawPtr<DragController> create(Page*, DragClient*);
58 
59     DragSession dragEntered(DragData*);
60     void dragExited(DragData*);
61     DragSession dragUpdated(DragData*);
62     bool performDrag(DragData*);
63 
64     enum SelectionDragPolicy {
65         ImmediateSelectionDragResolution,
66         DelayedSelectionDragResolution,
67     };
68     Node* draggableNode(const LocalFrame*, Node*, const IntPoint&, SelectionDragPolicy, DragSourceAction&) const;
69     void dragEnded();
70 
71     bool populateDragDataTransfer(LocalFrame* src, const DragState&, const IntPoint& dragOrigin);
72     bool startDrag(LocalFrame* src, const DragState&, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin);
73 
74     void trace(Visitor*);
75 
76     static const int DragIconRightInset;
77     static const int DragIconBottomInset;
78 
79 private:
80     DragController(Page*, DragClient*);
81 
82     bool dispatchTextInputEventFor(LocalFrame*, DragData*);
83     bool canProcessDrag(DragData*);
84     bool concludeEditDrag(DragData*);
85     DragSession dragEnteredOrUpdated(DragData*);
86     DragOperation operationForLoad(DragData*);
87     bool tryDocumentDrag(DragData*, DragDestinationAction, DragSession&);
88     bool tryDHTMLDrag(DragData*, DragOperation&);
89     DragOperation dragOperation(DragData*);
90     void cancelDrag();
91     bool dragIsMove(FrameSelection&, DragData*);
92     bool isCopyKeyDown(DragData*);
93 
94     void mouseMovedIntoDocument(Document*);
95 
96     void doSystemDrag(DragImage*, const IntPoint& dragLocation, const IntPoint& dragOrigin, DataTransfer*, LocalFrame*, bool forLink);
97     void cleanupAfterSystemDrag();
98 
99     RawPtrWillBeMember<Page> m_page;
100     DragClient* m_client;
101 
102     RefPtrWillBeMember<Document> m_documentUnderMouse; // The document the mouse was last dragged over.
103     RefPtrWillBeMember<Document> m_dragInitiator; // The Document (if any) that initiated the drag.
104     RefPtrWillBeMember<HTMLInputElement> m_fileInputElementUnderMouse;
105     bool m_documentIsHandlingDrag;
106 
107     DragDestinationAction m_dragDestinationAction;
108     bool m_didInitiateDrag;
109 };
110 
111 } // namespace blink
112 
113 #endif // DragController_h
114