Home | History | Annotate | Download | only in page
      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/weborigin/KURL.h"
     32 #include "wtf/Forward.h"
     33 
     34 namespace WebCore {
     35 
     36     class Clipboard;
     37     class Document;
     38     class DragClient;
     39     class DragData;
     40     class DragImage;
     41     struct DragSession;
     42     struct DragState;
     43     class Element;
     44     class Frame;
     45     class FrameSelection;
     46     class HTMLInputElement;
     47     class Image;
     48     class IntRect;
     49     class Node;
     50     class Page;
     51     class PlatformMouseEvent;
     52     class Range;
     53 
     54     class DragController {
     55         WTF_MAKE_NONCOPYABLE(DragController); WTF_MAKE_FAST_ALLOCATED;
     56     public:
     57         ~DragController();
     58 
     59         static PassOwnPtr<DragController> create(Page*, DragClient*);
     60 
     61         DragSession dragEntered(DragData*);
     62         void dragExited(DragData*);
     63         DragSession dragUpdated(DragData*);
     64         bool performDrag(DragData*);
     65 
     66         enum SelectionDragPolicy {
     67             ImmediateSelectionDragResolution,
     68             DelayedSelectionDragResolution,
     69         };
     70         Node* draggableNode(const Frame*, Node*, const IntPoint&, SelectionDragPolicy, DragSourceAction&) const;
     71         void dragEnded();
     72 
     73         bool populateDragClipboard(Frame* src, const DragState&, const IntPoint& dragOrigin);
     74         bool startDrag(Frame* src, const DragState&, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin);
     75 
     76         static const int DragIconRightInset;
     77         static const int DragIconBottomInset;
     78 
     79     private:
     80         DragController(Page*, DragClient*);
     81 
     82         bool dispatchTextInputEventFor(Frame*, 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, Clipboard*, Frame*, bool forLink);
     97         void cleanupAfterSystemDrag();
     98 
     99         Page* m_page;
    100         DragClient* m_client;
    101 
    102         RefPtr<Document> m_documentUnderMouse; // The document the mouse was last dragged over.
    103         RefPtr<Document> m_dragInitiator; // The Document (if any) that initiated the drag.
    104         RefPtr<HTMLInputElement> m_fileInputElementUnderMouse;
    105         bool m_documentIsHandlingDrag;
    106 
    107         DragDestinationAction m_dragDestinationAction;
    108         bool m_didInitiateDrag;
    109     };
    110 
    111 }
    112 
    113 #endif
    114