- Revision
- 150183
- Author
- [email protected]
- Date
- 2013-05-16 08:44:09 -0700 (Thu, 16 May 2013)
Log Message
[Mac] Make Clipboard::create functions for Mac platform independent by moving Pasteboard creation to Pasteboard functions
https://bugs.webkit.org/show_bug.cgi?id=116179
Reviewed by Andreas Kling.
* dom/Clipboard.cpp:
(WebCore::Clipboard::createForCopyAndPaste): Moved the function here from
ClipboardMac, and have it use Pasteboard functions that are not Mac-specific.
(WebCore::Clipboard::create): Ditto.
(WebCore::Clipboard::createForDragAndDrop): Ditto.
* platform/DragData.h:
(WebCore::DragData::pasteboardName): Made this const.
* platform/Pasteboard.h: Added new create functions, used by the clipboard
create functions above.
* platform/mac/ClipboardMac.mm: Removed the functions that were moved to the
Clipboard.cpp file.
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::createForCopyAndPaste): Added.
(WebCore::Pasteboard::createPrivate): Added.
(WebCore::Pasteboard::createForDragAndDrop): Added.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (150182 => 150183)
--- trunk/Source/WebCore/ChangeLog 2013-05-16 15:19:05 UTC (rev 150182)
+++ trunk/Source/WebCore/ChangeLog 2013-05-16 15:44:09 UTC (rev 150183)
@@ -1,3 +1,30 @@
+2013-05-15 Darin Adler <[email protected]>
+
+ [Mac] Make Clipboard::create functions for Mac platform independent by moving Pasteboard creation to Pasteboard functions
+ https://bugs.webkit.org/show_bug.cgi?id=116179
+
+ Reviewed by Andreas Kling.
+
+ * dom/Clipboard.cpp:
+ (WebCore::Clipboard::createForCopyAndPaste): Moved the function here from
+ ClipboardMac, and have it use Pasteboard functions that are not Mac-specific.
+ (WebCore::Clipboard::create): Ditto.
+ (WebCore::Clipboard::createForDragAndDrop): Ditto.
+
+ * platform/DragData.h:
+ (WebCore::DragData::pasteboardName): Made this const.
+
+ * platform/Pasteboard.h: Added new create functions, used by the clipboard
+ create functions above.
+
+ * platform/mac/ClipboardMac.mm: Removed the functions that were moved to the
+ Clipboard.cpp file.
+
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::createForCopyAndPaste): Added.
+ (WebCore::Pasteboard::createPrivate): Added.
+ (WebCore::Pasteboard::createForDragAndDrop): Added.
+
2013-05-15 Anders Carlsson <[email protected]>
Fix a thinko.
Modified: trunk/Source/WebCore/dom/Clipboard.cpp (150182 => 150183)
--- trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-16 15:19:05 UTC (rev 150182)
+++ trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-16 15:44:09 UTC (rev 150183)
@@ -28,6 +28,7 @@
#include "CachedImage.h"
#include "CachedImageClient.h"
+#include "DragData.h"
#include "Editor.h"
#include "FileList.h"
#include "Frame.h"
@@ -278,6 +279,11 @@
#if !USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
+PassRefPtr<Clipboard> Clipboard::createForCopyAndPaste(ClipboardAccessPolicy policy)
+{
+ return adoptRef(new Clipboard(policy, CopyAndPaste, policy == ClipboardWritable ? Pasteboard::createPrivate() : Pasteboard::createForCopyAndPaste()));
+}
+
bool Clipboard::hasData()
{
return m_pasteboard->hasData();
@@ -350,6 +356,19 @@
#else
+// FIXME: Should be named createForDragAndDrop.
+// FIXME: Should take const DragData& instead of DragData*.
+// FIXME: Should not take Frame*.
+PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame*)
+{
+ return adoptRef(new Clipboard(policy, DragAndDrop, Pasteboard::createForDragAndDrop(*dragData), dragData->containsFiles()));
+}
+
+PassRefPtr<Clipboard> Clipboard::createForDragAndDrop()
+{
+ return adoptRef(new Clipboard(ClipboardWritable, DragAndDrop, Pasteboard::createForDragAndDrop()));
+}
+
void Clipboard::setDragImage(CachedImage* image, const IntPoint& location)
{
if (!canSetDragImage())
Modified: trunk/Source/WebCore/platform/DragData.h (150182 => 150183)
--- trunk/Source/WebCore/platform/DragData.h 2013-05-16 15:19:05 UTC (rev 150182)
+++ trunk/Source/WebCore/platform/DragData.h 2013-05-16 15:44:09 UTC (rev 150183)
@@ -116,7 +116,7 @@
unsigned numberOfFiles() const;
int modifierKeyState() const;
#if PLATFORM(MAC)
- const String& pasteboardName() { return m_pasteboardName; }
+ const String& pasteboardName() const { return m_pasteboardName; }
#endif
#if ENABLE(FILE_SYSTEM)
Modified: trunk/Source/WebCore/platform/Pasteboard.h (150182 => 150183)
--- trunk/Source/WebCore/platform/Pasteboard.h 2013-05-16 15:19:05 UTC (rev 150182)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2013-05-16 15:44:09 UTC (rev 150183)
@@ -63,6 +63,7 @@
class Clipboard;
class DocumentFragment;
+class DragData;
class Frame;
class HitTestResult;
class KURL;
@@ -84,7 +85,6 @@
static PassOwnPtr<Pasteboard> create(const String& pasteboardName);
String name() const { return m_pasteboardName; }
- // This is required to support OS X services.
void writeSelectionForTypes(const Vector<String>& pasteboardTypes, bool canSmartCopyOrDelete, Frame*, ShouldSerializeSelectedTextForClipboard);
explicit Pasteboard(const String& pasteboardName);
static PassRefPtr<SharedBuffer> getDataSelection(Frame*, const String& pasteboardType);
@@ -94,8 +94,17 @@
static String getStringSelection(Frame*, ShouldSerializeSelectedTextForClipboard);
#endif
+ // Deprecated. Use createForCopyAndPaste instead.
static Pasteboard* generalPasteboard();
+ static PassOwnPtr<Pasteboard> createForCopyAndPaste();
+ static PassOwnPtr<Pasteboard> createPrivate(); // Corresponds to the "unique pasteboard" concept on Mac. Used in editing, not sure exactly for what purpose.
+
+#if ENABLE(DRAG_SUPPORT)
+ static PassOwnPtr<Pasteboard> createForDragAndDrop();
+ static PassOwnPtr<Pasteboard> createForDragAndDrop(const DragData&);
+#endif
+
bool hasData();
ListHashSet<String> types();
Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.mm (150182 => 150183)
--- trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-16 15:19:05 UTC (rev 150182)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-16 15:44:09 UTC (rev 150183)
@@ -41,22 +41,6 @@
namespace WebCore {
-PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame*)
-{
- return adoptRef(new Clipboard(policy, DragAndDrop, Pasteboard::create(dragData->pasteboardName()), dragData->containsFiles()));
-}
-
-PassRefPtr<Clipboard> Clipboard::createForDragAndDrop()
-{
- return adoptRef(new Clipboard(ClipboardWritable, DragAndDrop, Pasteboard::create(NSDragPboard)));
-}
-
-PassRefPtr<Clipboard> Clipboard::createForCopyAndPaste(ClipboardAccessPolicy policy)
-{
- String pasteboardName = policy == ClipboardWritable ? platformStrategies()->pasteboardStrategy()->uniqueName() : String(NSGeneralPboard);
- return adoptRef(new Clipboard(policy, CopyAndPaste, Pasteboard::create(pasteboardName)));
-}
-
void Clipboard::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
{
ASSERT(frame);
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (150182 => 150183)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-16 15:19:05 UTC (rev 150182)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-16 15:44:09 UTC (rev 150183)
@@ -32,6 +32,7 @@
#import "Document.h"
#import "DocumentFragment.h"
#import "DocumentLoader.h"
+#import "DragData.h"
#import "Editor.h"
#import "EditorClient.h"
#import "ExceptionCodePlaceholder.h"
@@ -132,6 +133,26 @@
return adoptPtr(new Pasteboard(pasteboardName));
}
+PassOwnPtr<Pasteboard> Pasteboard::createForCopyAndPaste()
+{
+ return create(NSGeneralPboard);
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createPrivate()
+{
+ return create(platformStrategies()->pasteboardStrategy()->uniqueName());
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createForDragAndDrop()
+{
+ return create(NSDragPboard);
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData)
+{
+ return create(dragData.pasteboardName());
+}
+
void Pasteboard::clear()
{
platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName);