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 WebCore { 36 37 class Clipboard; 38 class Document; 39 class DragClient; 40 class DragData; 41 class DragImage; 42 struct DragSession; 43 class DragState; 44 class Element; 45 class LocalFrame; 46 class FrameSelection; 47 class HTMLInputElement; 48 class Image; 49 class IntRect; 50 class Node; 51 class Page; 52 class PlatformMouseEvent; 53 class Range; 54 55 class DragController FINAL : public NoBaseWillBeGarbageCollectedFinalized<DragController> { 56 WTF_MAKE_NONCOPYABLE(DragController); 57 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 58 public: 59 ~DragController(); 60 61 static PassOwnPtrWillBeRawPtr<DragController> create(Page*, DragClient*); 62 63 DragSession dragEntered(DragData*); 64 void dragExited(DragData*); 65 DragSession dragUpdated(DragData*); 66 bool performDrag(DragData*); 67 68 enum SelectionDragPolicy { 69 ImmediateSelectionDragResolution, 70 DelayedSelectionDragResolution, 71 }; 72 Node* draggableNode(const LocalFrame*, Node*, const IntPoint&, SelectionDragPolicy, DragSourceAction&) const; 73 void dragEnded(); 74 75 bool populateDragClipboard(LocalFrame* src, const DragState&, const IntPoint& dragOrigin); 76 bool startDrag(LocalFrame* src, const DragState&, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin); 77 78 void trace(Visitor*); 79 80 static const int DragIconRightInset; 81 static const int DragIconBottomInset; 82 83 private: 84 DragController(Page*, DragClient*); 85 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*); 94 void cancelDrag(); 95 bool dragIsMove(FrameSelection&, DragData*); 96 bool isCopyKeyDown(DragData*); 97 98 void mouseMovedIntoDocument(Document*); 99 100 void doSystemDrag(DragImage*, const IntPoint& dragLocation, const IntPoint& dragOrigin, Clipboard*, LocalFrame*, bool forLink); 101 void cleanupAfterSystemDrag(); 102 103 RawPtrWillBeMember<Page> m_page; 104 DragClient* m_client; 105 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; 110 111 DragDestinationAction m_dragDestinationAction; 112 bool m_didInitiateDrag; 113 }; 114 115 } 116 117 #endif 118