- Revision
- 149977
- Author
- [email protected]
- Date
- 2013-05-12 19:41:35 -0700 (Sun, 12 May 2013)
Log Message
[Mac] Move clearData from ClipboardMac to PasteboardMac
https://bugs.webkit.org/show_bug.cgi?id=116000
Reviewed by Andreas Kling.
* dom/Clipboard.cpp:
(WebCore::Clipboard::clearData): Added. Calls through to Pasteboard after
doing the canWriteData check, which is part of DOM rules, not the platform.
* dom/Clipboard.h: Made clearData non-virtual in non-legacy case.
* platform/Pasteboard.h: Added an overload of the clear function that takes
a single type and clears only that type. Also temporarily exported the
cocoaTypeFromHTMLClipboardType function as a static member so it can be used
in both ClipboardMac and PasteboardMac during the transition.
* platform/mac/ClipboardMac.h: Removed clearData.
* platform/mac/ClipboardMac.mm: Removed clearData.
(WebCore::ClipboardMac::getData): Changed to call cocoaTypeFromHTMLClipboardType
as a Pasteboard class static member function.
(WebCore::ClipboardMac::setData): Ditto.
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::cocoaTypeFromHTMLClipboardType): Moved here from
ClipboardMac.
(WebCore::Pasteboard::clear): Added. Moved here from ClipboardMac.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (149976 => 149977)
--- trunk/Source/WebCore/ChangeLog 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/ChangeLog 2013-05-13 02:41:35 UTC (rev 149977)
@@ -1,5 +1,34 @@
2013-05-12 Darin Adler <[email protected]>
+ [Mac] Move clearData from ClipboardMac to PasteboardMac
+ https://bugs.webkit.org/show_bug.cgi?id=116000
+
+ Reviewed by Andreas Kling.
+
+ * dom/Clipboard.cpp:
+ (WebCore::Clipboard::clearData): Added. Calls through to Pasteboard after
+ doing the canWriteData check, which is part of DOM rules, not the platform.
+
+ * dom/Clipboard.h: Made clearData non-virtual in non-legacy case.
+
+ * platform/Pasteboard.h: Added an overload of the clear function that takes
+ a single type and clears only that type. Also temporarily exported the
+ cocoaTypeFromHTMLClipboardType function as a static member so it can be used
+ in both ClipboardMac and PasteboardMac during the transition.
+
+ * platform/mac/ClipboardMac.h: Removed clearData.
+ * platform/mac/ClipboardMac.mm: Removed clearData.
+ (WebCore::ClipboardMac::getData): Changed to call cocoaTypeFromHTMLClipboardType
+ as a Pasteboard class static member function.
+ (WebCore::ClipboardMac::setData): Ditto.
+
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::cocoaTypeFromHTMLClipboardType): Moved here from
+ ClipboardMac.
+ (WebCore::Pasteboard::clear): Added. Moved here from ClipboardMac.
+
+2013-05-12 Darin Adler <[email protected]>
+
[Mac] Move hasData from ClipboardMac to PasteboardMac
https://bugs.webkit.org/show_bug.cgi?id=115999
Modified: trunk/Source/WebCore/dom/Clipboard.cpp (149976 => 149977)
--- trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/dom/Clipboard.cpp 2013-05-13 02:41:35 UTC (rev 149977)
@@ -258,6 +258,14 @@
return m_pasteboard->hasData();
}
+void Clipboard::clearData(const String& type)
+{
+ if (!canWriteData())
+ return;
+
+ m_pasteboard->clear(type);
+}
+
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Clipboard.h (149976 => 149977)
--- trunk/Source/WebCore/dom/Clipboard.h 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/dom/Clipboard.h 2013-05-13 02:41:35 UTC (rev 149977)
@@ -79,7 +79,7 @@
String effectAllowed() const { return m_effectAllowed; }
void setEffectAllowed(const String&);
- virtual void clearData(const String& type) = 0;
+ LEGACY_VIRTUAL void clearData(const String& type) LEGACY_PURE;
virtual void clearAllData() = 0;
virtual String getData(const String& type) const = 0;
virtual bool setData(const String& type, const String& data) = 0;
Modified: trunk/Source/WebCore/platform/Pasteboard.h (149976 => 149977)
--- trunk/Source/WebCore/platform/Pasteboard.h 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2013-05-13 02:41:35 UTC (rev 149977)
@@ -91,6 +91,9 @@
explicit Pasteboard(const String& pasteboardName);
static String getStringSelection(Frame*, ShouldSerializeSelectedTextForClipboard);
static PassRefPtr<SharedBuffer> getDataSelection(Frame*, const String& pasteboardType);
+
+ // Functions needed temporarily until all code from ClipboardMac is moved to PasteboardMac.
+ static String cocoaTypeFromHTMLClipboardType(const String& type);
#endif
static Pasteboard* generalPasteboard();
@@ -104,6 +107,7 @@
void writeClipboard(Clipboard*);
void clear();
+ void clear(const String& type);
bool canSmartReplace();
Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.h (149976 => 149977)
--- trunk/Source/WebCore/platform/mac/ClipboardMac.h 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.h 2013-05-13 02:41:35 UTC (rev 149977)
@@ -53,7 +53,6 @@
virtual ~ClipboardMac();
- void clearData(const String& type);
void clearAllData();
String getData(const String& type) const;
bool setData(const String& type, const String& data);
Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.mm (149976 => 149977)
--- trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.mm 2013-05-13 02:41:35 UTC (rev 149977)
@@ -70,39 +70,6 @@
m_dragImage->removeClient(this);
}
-static String cocoaTypeFromHTMLClipboardType(const String& type)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dom-datatransfer-setdata
- String qType = type.lower();
-
- if (qType == "text")
- qType = "text/plain";
- if (qType == "url")
- qType = "text/uri-list";
-
- // Ignore any trailing charset - JS strings are Unicode, which encapsulates the charset issue
- if (qType == "text/plain" || qType.startsWith("text/plain;"))
- return String(NSStringPboardType);
- if (qType == "text/uri-list")
- // special case because UTI doesn't work with Cocoa's URL type
- return String(NSURLPboardType); // note special case in getData to read NSFilenamesType
-
- // Blacklist types that might contain subframe information
- if (qType == "text/rtf" || qType == "public.rtf" || qType == "com.apple.traditional-mac-plain-text")
- return String();
-
- // Try UTI now
- String mimeType = qType;
- if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType.createCFString().get(), NULL))) {
- RetainPtr<CFStringRef> pbType = adoptCF(UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType));
- if (pbType)
- return pbType.get();
- }
-
- // No mapping, just pass the whole string though
- return qType;
-}
-
static String utiTypeFromCocoaType(const String& type)
{
if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, type.createCFString().get(), 0))) {
@@ -146,18 +113,6 @@
resultTypes.add(cocoaType);
}
-void ClipboardMac::clearData(const String& type)
-{
- if (!canWriteData())
- return;
-
- // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
-
- String cocoaType = cocoaTypeFromHTMLClipboardType(type);
- if (!cocoaType.isEmpty())
- platformStrategies()->pasteboardStrategy()->setStringForType("", cocoaType, m_pasteboardName);
-}
-
void ClipboardMac::clearAllData()
{
if (!canWriteData())
@@ -216,7 +171,7 @@
if (!canReadData() || m_clipboardContents == DragAndDropFiles)
return String();
- const String& cocoaType = cocoaTypeFromHTMLClipboardType(type);
+ const String& cocoaType = Pasteboard::cocoaTypeFromHTMLClipboardType(type);
String cocoaValue;
// Grab the value off the pasteboard corresponding to the cocoaType
@@ -246,7 +201,7 @@
return false;
// note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
- const String& cocoaType = cocoaTypeFromHTMLClipboardType(type);
+ const String& cocoaType = Pasteboard::cocoaTypeFromHTMLClipboardType(type);
String cocoaData = data;
if (cocoaType == String(NSURLPboardType) || cocoaType == String(kUTTypeFileURL)) {
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (149976 => 149977)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-13 02:28:16 UTC (rev 149976)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-05-13 02:41:35 UTC (rev 149977)
@@ -596,4 +596,44 @@
return !types.isEmpty();
}
+String Pasteboard::cocoaTypeFromHTMLClipboardType(const String& type)
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dom-datatransfer-setdata
+ String qType = type.lower();
+
+ if (qType == "text")
+ qType = "text/plain";
+ if (qType == "url")
+ qType = "text/uri-list";
+
+ // Ignore any trailing charset - JS strings are Unicode, which encapsulates the charset issue
+ if (qType == "text/plain" || qType.startsWith("text/plain;"))
+ return String(NSStringPboardType);
+ if (qType == "text/uri-list")
+ // special case because UTI doesn't work with Cocoa's URL type
+ return String(NSURLPboardType); // note special case in getData to read NSFilenamesType
+
+ // Blacklist types that might contain subframe information
+ if (qType == "text/rtf" || qType == "public.rtf" || qType == "com.apple.traditional-mac-plain-text")
+ return String();
+
+ // Try UTI now
+ String mimeType = qType;
+ if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType.createCFString().get(), NULL))) {
+ RetainPtr<CFStringRef> pbType = adoptCF(UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType));
+ if (pbType)
+ return pbType.get();
+ }
+
+ // No mapping, just pass the whole string though
+ return qType;
}
+
+void Pasteboard::clear(const String& type)
+{
+ String cocoaType = cocoaTypeFromHTMLClipboardType(type);
+ if (!cocoaType.isEmpty())
+ platformStrategies()->pasteboardStrategy()->setStringForType("", cocoaType, m_pasteboardName);
+}
+
+}