• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3  * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5  * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #ifndef Clipboard_h
25 #define Clipboard_h
26 
27 #include "CachedResourceHandle.h"
28 #include "ClipboardAccessPolicy.h"
29 #include "DragActions.h"
30 #include "DragImage.h"
31 #include "IntPoint.h"
32 #include "Node.h"
33 
34 namespace WebCore {
35 
36     class FileList;
37 
38     // State available during IE's events for drag and drop and copy/paste
39     class Clipboard : public RefCounted<Clipboard> {
40     public:
~Clipboard()41         virtual ~Clipboard() { }
42 
43         // Is this operation a drag-drop or a copy-paste?
isForDragging()44         bool isForDragging() const { return m_forDragging; }
45 
dropEffect()46         String dropEffect() const { return m_dropEffect; }
47         void setDropEffect(const String&);
effectAllowed()48         String effectAllowed() const { return m_effectAllowed; }
49         void setEffectAllowed(const String&);
50 
51         virtual void clearData(const String& type) = 0;
52         virtual void clearAllData() = 0;
53         virtual String getData(const String& type, bool& success) const = 0;
54         virtual bool setData(const String& type, const String& data) = 0;
55 
56         // extensions beyond IE's API
57         virtual HashSet<String> types() const = 0;
58         virtual PassRefPtr<FileList> files() const = 0;
59 
dragLocation()60         IntPoint dragLocation() const { return m_dragLoc; }
dragImage()61         CachedImage* dragImage() const { return m_dragImage.get(); }
62         virtual void setDragImage(CachedImage*, const IntPoint&) = 0;
dragImageElement()63         Node* dragImageElement() const { return m_dragImageElement.get(); }
64         virtual void setDragImageElement(Node*, const IntPoint&) = 0;
65 
66         virtual DragImageRef createDragImage(IntPoint& dragLocation) const = 0;
67 #if ENABLE(DRAG_SUPPORT)
68         virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0;
69 #endif
70         virtual void writeURL(const KURL&, const String&, Frame*) = 0;
71         virtual void writeRange(Range*, Frame*) = 0;
72         virtual void writePlainText(const String&) = 0;
73 
74         virtual bool hasData() = 0;
75 
76         void setAccessPolicy(ClipboardAccessPolicy);
77 
78         DragOperation sourceOperation() const;
79         DragOperation destinationOperation() const;
80         void setSourceOperation(DragOperation);
81         void setDestinationOperation(DragOperation);
82 
setDragHasStarted()83         void setDragHasStarted() { m_dragStarted = true; }
84 
85     protected:
86         Clipboard(ClipboardAccessPolicy, bool isForDragging);
87 
policy()88         ClipboardAccessPolicy policy() const { return m_policy; }
dragStarted()89         bool dragStarted() const { return m_dragStarted; }
90 
91     private:
92         ClipboardAccessPolicy m_policy;
93         String m_dropEffect;
94         String m_effectAllowed;
95         bool m_dragStarted;
96 
97     protected:
98         bool m_forDragging;
99         IntPoint m_dragLoc;
100         CachedResourceHandle<CachedImage> m_dragImage;
101         RefPtr<Node> m_dragImageElement;
102     };
103 
104 } // namespace WebCore
105 
106 #endif // Clipboard_h
107