Diff
Modified: trunk/Source/WebCore/ChangeLog (149971 => 149972)
--- trunk/Source/WebCore/ChangeLog 2013-05-12 23:16:30 UTC (rev 149971)
+++ trunk/Source/WebCore/ChangeLog 2013-05-13 01:25:46 UTC (rev 149972)
@@ -1,3 +1,33 @@
+2013-05-11 Darin Adler <[email protected]>
+
+ [Mac] Give every Clipboard an underlying Pasteboard
+ https://bugs.webkit.org/show_bug.cgi?id=115979
+
+ Reviewed by Andreas Kling.
+
+ This is the first step in Clipboard and Pasteboard refactoring
+ to fix the overlap and many layering violations.
+
+ * dom/Clipboard.cpp:
+ (WebCore::Clipboard::Clipboard): Add an m_pasteboard data member,
+ Mac-only for now, but eventually for all platforms.
+ (WebCore::Clipboard::~Clipboard): No longer inline the destructor.
+
+ * dom/Clipboard.h: Add WTF_USE_LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS
+ flag, currently true for all non-Mac platforms. Make the constructor
+ no longer inline. Added a PassOwnPtr<Pasteboard> argument to the
+ constructor and an OwnPtr<Pasteboard> data member.
+
+ * platform/Pasteboard.h: Added a create function to make it easy
+ to create a pasteboard given a pasteboard name.
+
+ * platform/mac/ClipboardMac.mm:
+ (WebCore::ClipboardMac::ClipboardMac): Create a pasteboard and pass
+ it to the Clipboard constructor.
+
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::create): Added.
+
2013-05-12 Andreas Kling <[email protected]>
Unload event listeners should prevent Safari from insta-killing the web process on last tab close.
Modified: trunk/Source/WebCore/dom/Clipboard.cpp (149971 => 149972)
--- trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-12 23:16:30 UTC (rev 149971)
+++ trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-13 01:25:46 UTC (rev 149972)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,17 +30,29 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "Image.h"
+#include "Pasteboard.h"
namespace WebCore {
-Clipboard::Clipboard(ClipboardAccessPolicy policy, ClipboardType clipboardType)
+Clipboard::Clipboard(ClipboardAccessPolicy policy, ClipboardType clipboardType
+#if !USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
+ , PassOwnPtr<Pasteboard> pasteboard
+#endif
+)
: m_policy(policy)
, m_dropEffect("uninitialized")
, m_effectAllowed("uninitialized")
, m_dragStarted(false)
, m_clipboardType(clipboardType)
+#if !USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
+ , m_pasteboard(pasteboard)
+#endif
{
}
+
+Clipboard::~Clipboard()
+{
+}
void Clipboard::setAccessPolicy(ClipboardAccessPolicy policy)
{
Modified: trunk/Source/WebCore/dom/Clipboard.h (149971 => 149972)
--- trunk/Source/WebCore/dom/Clipboard.h 2013-05-12 23:16:30 UTC (rev 149971)
+++ trunk/Source/WebCore/dom/Clipboard.h 2013-05-13 01:25:46 UTC (rev 149972)
@@ -2,7 +2,7 @@
* Copyright (C) 2001 Peter Kelly ([email protected])
* Copyright (C) 2001 Tobias Anton ([email protected])
* Copyright (C) 2006 Samuel Weinig ([email protected])
- * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2013 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -31,6 +31,11 @@
#include "IntPoint.h"
#include "Node.h"
+// This DOM object now works by calling through to classes in the platform layer.
+// Specifically, the class currently named Pasteboard. The legacy style instead
+// uses this as an abstract base class.
+#define WTF_USE_LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS !PLATFORM(MAC)
+
namespace WebCore {
class CachedImage;
@@ -38,6 +43,7 @@
class DragData;
class FileList;
class Frame;
+ class Pasteboard;
// State available during IE's events for drag and drop and copy/paste
class Clipboard : public RefCounted<Clipboard> {
@@ -50,7 +56,7 @@
static PassRefPtr<Clipboard> create(ClipboardAccessPolicy, DragData*, Frame*);
- virtual ~Clipboard() { }
+ virtual ~Clipboard();
bool isForCopyAndPaste() const { return m_clipboardType == CopyAndPaste; }
bool isForDragAndDrop() const { return m_clipboardType == DragAndDrop; }
@@ -110,7 +116,11 @@
#endif
protected:
+#if !USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
+ Clipboard(ClipboardAccessPolicy, ClipboardType, PassOwnPtr<Pasteboard>);
+#else
Clipboard(ClipboardAccessPolicy, ClipboardType);
+#endif
bool dragStarted() const { return m_dragStarted; }
@@ -129,6 +139,11 @@
IntPoint m_dragLoc;
CachedResourceHandle<CachedImage> m_dragImage;
RefPtr<Node> m_dragImageElement;
+
+#if !USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
+ private:
+ OwnPtr<Pasteboard> m_pasteboard;
+#endif
};
DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation);
Modified: trunk/Source/WebCore/platform/Pasteboard.h (149971 => 149972)
--- trunk/Source/WebCore/platform/Pasteboard.h 2013-05-12 23:16:30 UTC (rev 149971)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2013-05-13 01:25:46 UTC (rev 149972)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -84,6 +84,8 @@
};
#if PLATFORM(MAC)
+ static PassOwnPtr<Pasteboard> create(const String& pasteboardName);
+
// This is required to support OS X services.
void writeSelectionForTypes(const Vector<String>& pasteboardTypes, bool canSmartCopyOrDelete, Frame*, ShouldSerializeSelectedTextForClipboard);
explicit Pasteboard(const String& pasteboardName);
Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.mm (149971 => 149972)
--- trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-12 23:16:30 UTC (rev 149971)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-13 01:25:46 UTC (rev 149972)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2010, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -56,7 +56,7 @@
#endif
ClipboardMac::ClipboardMac(ClipboardType clipboardType, const String& pasteboardName, ClipboardAccessPolicy policy, ClipboardContents clipboardContents, Frame *frame)
- : Clipboard(policy, clipboardType)
+ : Clipboard(policy, clipboardType, Pasteboard::create(pasteboardName))
, m_pasteboardName(pasteboardName)
, m_clipboardContents(clipboardContents)
, m_frame(frame)
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (149971 => 149972)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-12 23:16:30 UTC (rev 149971)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-13 01:25:46 UTC (rev 149972)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -130,6 +130,11 @@
ASSERT(pasteboardName);
}
+PassOwnPtr<Pasteboard> Pasteboard::create(const String& pasteboardName)
+{
+ return adoptPtr(new Pasteboard(pasteboardName));
+}
+
void Pasteboard::clear()
{
platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName);