- Revision
- 149983
- Author
- [email protected]
- Date
- 2013-05-12 22:26:39 -0700 (Sun, 12 May 2013)
Log Message
[Mac] Move types function from ClipboardMac to PasteboardMac
https://bugs.webkit.org/show_bug.cgi?id=116007
Reviewed by Anders Carlsson.
* dom/Clipboard.cpp:
(WebCore::Clipboard::types): Added. Calls through to Pasteboard
after doing checks needed at this level.
* dom/Clipboard.h: Made types function non-virtual in non-legacy case,
and removed non-helpful comment.
* platform/Pasteboard.h: Updated includes and comments at the top of
the file a bit. Removed static member function addHTMLClipboardTypesForCocoaType,
since it can now be private to PasteboardMac. Added member function types.
* platform/mac/ClipboardMac.h: Removed types function.
* platform/mac/ClipboardMac.mm: Ditto.
* platform/mac/PasteboardMac.mm:
(WebCore::addHTMLClipboardTypesForCocoaType): Made this a file-local
function instead of a static member function.
(WebCore::Pasteboard::types): Added. Moved from ClipboardMac.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (149982 => 149983)
--- trunk/Source/WebCore/ChangeLog 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/ChangeLog 2013-05-13 05:26:39 UTC (rev 149983)
@@ -1,5 +1,31 @@
2013-05-12 Darin Adler <[email protected]>
+ [Mac] Move types function from ClipboardMac to PasteboardMac
+ https://bugs.webkit.org/show_bug.cgi?id=116007
+
+ Reviewed by Anders Carlsson.
+
+ * dom/Clipboard.cpp:
+ (WebCore::Clipboard::types): Added. Calls through to Pasteboard
+ after doing checks needed at this level.
+
+ * dom/Clipboard.h: Made types function non-virtual in non-legacy case,
+ and removed non-helpful comment.
+
+ * platform/Pasteboard.h: Updated includes and comments at the top of
+ the file a bit. Removed static member function addHTMLClipboardTypesForCocoaType,
+ since it can now be private to PasteboardMac. Added member function types.
+
+ * platform/mac/ClipboardMac.h: Removed types function.
+ * platform/mac/ClipboardMac.mm: Ditto.
+
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::addHTMLClipboardTypesForCocoaType): Made this a file-local
+ function instead of a static member function.
+ (WebCore::Pasteboard::types): Added. Moved from ClipboardMac.
+
+2013-05-12 Darin Adler <[email protected]>
+
[Mac] Move setData from ClipboardMac to PasteboardMac
https://bugs.webkit.org/show_bug.cgi?id=116006
Modified: trunk/Source/WebCore/dom/Clipboard.cpp (149982 => 149983)
--- trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-13 05:26:39 UTC (rev 149983)
@@ -291,6 +291,14 @@
return m_pasteboard->writeString(type, data);
}
+ListHashSet<String> Clipboard::types() const
+{
+ if (!canReadTypes())
+ return ListHashSet<String>();
+
+ return m_pasteboard->types();
+}
+
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Clipboard.h (149982 => 149983)
--- trunk/Source/WebCore/dom/Clipboard.h 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/dom/Clipboard.h 2013-05-13 05:26:39 UTC (rev 149983)
@@ -84,8 +84,7 @@
LEGACY_VIRTUAL String getData(const String& type) const LEGACY_PURE;
LEGACY_VIRTUAL bool setData(const String& type, const String& data) LEGACY_PURE;
- // extensions beyond IE's API
- virtual ListHashSet<String> types() const = 0;
+ LEGACY_VIRTUAL ListHashSet<String> types() const LEGACY_PURE;
virtual PassRefPtr<FileList> files() const = 0;
IntPoint dragLocation() const { return m_dragLoc; }
Modified: trunk/Source/WebCore/platform/Pasteboard.h (149982 => 149983)
--- trunk/Source/WebCore/platform/Pasteboard.h 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2013-05-13 05:26:39 UTC (rev 149983)
@@ -27,29 +27,29 @@
#define Pasteboard_h
#include <wtf/Forward.h>
-#include <wtf/HashSet.h>
+#include <wtf/ListHashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(MAC)
-#include <wtf/ListHashSet.h>
#include <wtf/RetainPtr.h>
#endif
#if PLATFORM(GTK)
+// FIXME: Why does this include need to be in the header?
#include <PasteboardHelper.h>
#endif
-// FIXME: This class is too high-level to be in the platform directory, since it
-// uses the DOM and makes calls to Editor. It should either be divested of its
-// knowledge of the frame and editor or moved into the editing directory.
-
#if PLATFORM(WIN)
#include <windows.h>
typedef struct HWND__* HWND;
#endif
+// FIXME: This class is too high-level to be in the platform directory, since it
+// uses the DOM and makes calls to Editor. It should either be divested of its
+// knowledge of the frame and editor or moved into the editing directory.
+
namespace WebCore {
#if PLATFORM(MAC)
@@ -90,12 +90,12 @@
// Functions needed temporarily until all code from ClipboardMac is moved to PasteboardMac.
static Vector<String> absoluteURLsFromPasteboardFilenames(const String& pasteboardName, bool _onlyFirstURL_ = false);
- static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName);
#endif
static Pasteboard* generalPasteboard();
bool hasData();
+ ListHashSet<String> types();
String readString(const String& type);
Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.h (149982 => 149983)
--- trunk/Source/WebCore/platform/mac/ClipboardMac.h 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.h 2013-05-13 05:26:39 UTC (rev 149983)
@@ -52,9 +52,7 @@
}
virtual ~ClipboardMac();
-
- // extensions beyond IE's API
- virtual ListHashSet<String> types() const;
+
virtual PassRefPtr<FileList> files() const;
void setDragImage(CachedImage*, const IntPoint&);
Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.mm (149982 => 149983)
--- trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-13 05:26:39 UTC (rev 149983)
@@ -70,32 +70,6 @@
m_dragImage->removeClient(this);
}
-ListHashSet<String> ClipboardMac::types() const
-{
- if (!canReadTypes())
- return ListHashSet<String>();
-
- Vector<String> types;
- platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-
- // Enforce changeCount ourselves for security. We check after reading instead of before to be
- // sure it doesn't change between our testing the change count and accessing the data.
- if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
- return ListHashSet<String>();
-
- ListHashSet<String> result;
- // FIXME: This loop could be split into two stages. One which adds all the HTML5 specified types
- // and a second which adds all the extra types from the cocoa clipboard (which is Mac-only behavior).
- for (size_t i = 0; i < types.size(); i++) {
- if (types[i] == "NeXT plain ascii pasteboard type")
- continue; // skip this ancient type that gets auto-supplied by some system conversion
-
- Pasteboard::addHTMLClipboardTypesForCocoaType(result, types[i], m_pasteboardName);
- }
-
- return result;
-}
-
// FIXME: We could cache the computed fileList if necessary
// Currently each access gets a new copy, setData() modifications to the
// clipboard are not reflected in any FileList objects the page has accessed and stored
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (149982 => 149983)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-13 05:19:32 UTC (rev 149982)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-13 05:26:39 UTC (rev 149983)
@@ -711,7 +711,7 @@
return String();
}
-void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
+static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
{
// UTI may not do these right, so make sure we get the right, predictable result
if (cocoaType == String(NSStringPboardType)) {
@@ -775,4 +775,27 @@
return false;
}
+ListHashSet<String> Pasteboard::types()
+{
+ Vector<String> types;
+ platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+
+ // Enforce changeCount ourselves for security. We check after reading instead of before to be
+ // sure it doesn't change between our testing the change count and accessing the data.
+ if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
+ return ListHashSet<String>();
+
+ ListHashSet<String> result;
+ // FIXME: This loop could be split into two stages. One which adds all the HTML5 specified types
+ // and a second which adds all the extra types from the cocoa clipboard (which is Mac-only behavior).
+ for (size_t i = 0; i < types.size(); i++) {
+ if (types[i] == "NeXT plain ascii pasteboard type")
+ continue; // skip this ancient type that gets auto-supplied by some system conversion
+
+ addHTMLClipboardTypesForCocoaType(result, types[i], m_pasteboardName);
+ }
+
+ return result;
}
+
+}