Title: [211158] trunk/Source
Revision
211158
Author
wenson_hs...@apple.com
Date
2017-01-25 12:16:17 -0800 (Wed, 25 Jan 2017)

Log Message

Add support for named pasteboards, pasteboard strategies and platform pasteboards
https://bugs.webkit.org/show_bug.cgi?id=167404

Reviewed by Enrica Casucci.

Source/WebCore:

Refactors some pasteboard-related code to plumb the name of the pasteboard across from WebCore to the client
layer. No new tests, because there should be no change in behavior.

* platform/DragData.h:
* platform/Pasteboard.h:
* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::write):
(WebCore::Pasteboard::writePlainText):
(WebCore::Pasteboard::read):
(WebCore::Pasteboard::hasData):
(WebCore::Pasteboard::clear):
(WebCore::Pasteboard::readString):
(WebCore::Pasteboard::writeString):
(WebCore::Pasteboard::types):

Source/WebKit/mac:

Adds pasteboard name as an argument to pasteboard-related WebPlatformStrategy methods.

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::writeToPasteboard):
(WebPlatformStrategies::getPasteboardItemsCount):
(WebPlatformStrategies::readBufferFromPasteboard):
(WebPlatformStrategies::readURLFromPasteboard):
(WebPlatformStrategies::readStringFromPasteboard):

Source/WebKit2:

Adds support for delivering the pasteboard name to the UI process when writing to or reading from the pasteboard.

* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::writeWebContentToPasteboard):
(WebKit::WebPasteboardProxy::writeImageToPasteboard):
(WebKit::WebPasteboardProxy::writeStringToPasteboard):
(WebKit::WebPasteboardProxy::readStringFromPasteboard):
(WebKit::WebPasteboardProxy::readURLFromPasteboard):
(WebKit::WebPasteboardProxy::readBufferFromPasteboard):
(WebKit::WebPasteboardProxy::getPasteboardItemsCount):
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.messages.in:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::writeToPasteboard):
(WebKit::WebPlatformStrategies::getPasteboardItemsCount):
(WebKit::WebPlatformStrategies::readBufferFromPasteboard):
(WebKit::WebPlatformStrategies::readURLFromPasteboard):
(WebKit::WebPlatformStrategies::readStringFromPasteboard):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211157 => 211158)


--- trunk/Source/WebCore/ChangeLog	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebCore/ChangeLog	2017-01-25 20:16:17 UTC (rev 211158)
@@ -1,3 +1,28 @@
+2017-01-25  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add support for named pasteboards, pasteboard strategies and platform pasteboards
+        https://bugs.webkit.org/show_bug.cgi?id=167404
+
+        Reviewed by Enrica Casucci.
+
+        Refactors some pasteboard-related code to plumb the name of the pasteboard across from WebCore to the client
+        layer. No new tests, because there should be no change in behavior.
+
+        * platform/DragData.h:
+        * platform/Pasteboard.h:
+        * platform/PasteboardStrategy.h:
+        * platform/PlatformPasteboard.h:
+        * platform/ios/PasteboardIOS.mm:
+        (WebCore::Pasteboard::Pasteboard):
+        (WebCore::Pasteboard::write):
+        (WebCore::Pasteboard::writePlainText):
+        (WebCore::Pasteboard::read):
+        (WebCore::Pasteboard::hasData):
+        (WebCore::Pasteboard::clear):
+        (WebCore::Pasteboard::readString):
+        (WebCore::Pasteboard::writeString):
+        (WebCore::Pasteboard::types):
+
 2017-01-25  Antoine Quint  <grao...@apple.com>
 
         LayoutTest media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles.html is flaky

Modified: trunk/Source/WebCore/platform/DragData.h (211157 => 211158)


--- trunk/Source/WebCore/platform/DragData.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebCore/platform/DragData.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -107,7 +107,7 @@
     unsigned numberOfFiles() const;
     void setFileNames(Vector<String>& fileNames) { m_fileNames = WTFMove(fileNames); }
     const Vector<String>& fileNames() const { return m_fileNames; }
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     const String& pasteboardName() const { return m_pasteboardName; }
     bool containsPromise() const;
 #endif
@@ -132,7 +132,7 @@
     DragOperation m_draggingSourceOperationMask;
     DragApplicationFlags m_applicationFlags;
     Vector<String> m_fileNames;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     String m_pasteboardName;
 #endif
 #if PLATFORM(WIN)

Modified: trunk/Source/WebCore/platform/Pasteboard.h (211157 => 211158)


--- trunk/Source/WebCore/platform/Pasteboard.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebCore/platform/Pasteboard.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -201,7 +201,7 @@
     static String resourceMIMEType(const NSString *mimeType);
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     explicit Pasteboard(const String& pasteboardName);
 
     const String& name() const { return m_pasteboardName; }
@@ -231,11 +231,7 @@
     String m_name;
 #endif
 
-#if PLATFORM(IOS)
-    long m_changeCount;
-#endif
-
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     String m_pasteboardName;
     long m_changeCount;
 #endif

Modified: trunk/Source/WebCore/platform/PasteboardStrategy.h (211157 => 211158)


--- trunk/Source/WebCore/platform/PasteboardStrategy.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebCore/platform/PasteboardStrategy.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -42,15 +42,13 @@
 class PasteboardStrategy {
 public:
 #if PLATFORM(IOS)
-    // FIXME: We should move Mac to this.
-    virtual void writeToPasteboard(const PasteboardWebContent&) = 0;
-    virtual void writeToPasteboard(const PasteboardImage&) = 0;
-    virtual void writeToPasteboard(const String& pasteboardType, const String&) = 0;
-    virtual int getPasteboardItemsCount() = 0;
-    virtual String readStringFromPasteboard(int index, const String& pasteboardType) = 0;
-    virtual RefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) = 0;
-    virtual URL readURLFromPasteboard(int index, const String& pasteboardType) = 0;
-    virtual long changeCount() = 0;
+    virtual void writeToPasteboard(const PasteboardWebContent&, const String& pasteboardName) = 0;
+    virtual void writeToPasteboard(const PasteboardImage&, const String& pasteboardName) = 0;
+    virtual void writeToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName) = 0;
+    virtual int getPasteboardItemsCount(const String& pasteboardName) = 0;
+    virtual String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0;
+    virtual RefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0;
+    virtual URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0;
 #endif // PLATFORM(IOS)
 #if PLATFORM(COCOA)
     virtual void getTypes(Vector<String>& types, const String& pasteboardName) = 0;

Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (211157 => 211158)


--- trunk/Source/WebCore/platform/PlatformPasteboard.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -51,7 +51,6 @@
 
 class PlatformPasteboard {
 public:
-    // FIXME: probably we don't need a constructor that takes a pasteboard name for iOS.
     WEBCORE_EXPORT explicit PlatformPasteboard(const String& pasteboardName);
 #if PLATFORM(IOS)
     WEBCORE_EXPORT PlatformPasteboard();

Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (211157 => 211158)


--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm	2017-01-25 20:16:17 UTC (rev 211158)
@@ -82,7 +82,7 @@
 }
 
 Pasteboard::Pasteboard()
-    : m_changeCount(platformStrategies()->pasteboardStrategy()->changeCount())
+    : m_changeCount(platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
 {
 }
 
@@ -102,7 +102,7 @@
 
 void Pasteboard::write(const PasteboardWebContent& content)
 {
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(content);
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(content, m_pasteboardName);
 }
 
 String Pasteboard::resourceMIMEType(const NSString *mimeType)
@@ -112,17 +112,17 @@
 
 void Pasteboard::write(const PasteboardImage& pasteboardImage)
 {
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(pasteboardImage);
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(pasteboardImage, m_pasteboardName);
 }
 
 void Pasteboard::writePlainText(const String& text, SmartReplaceOption)
 {
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(kUTTypeText, text);
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(kUTTypeText, text, m_pasteboardName);
 }
 
 void Pasteboard::write(const PasteboardURL& pasteboardURL)
 {
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(kUTTypeURL, pasteboardURL.url.string());
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(kUTTypeURL, pasteboardURL.url.string(), m_pasteboardName);
 }
 
 void Pasteboard::writeTrustworthyWebURLsPboardType(const PasteboardURL&)
@@ -146,9 +146,9 @@
 void Pasteboard::read(PasteboardPlainText& text)
 {
     PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy();
-    text.text = strategy.readStringFromPasteboard(0, kUTTypeText);
+    text.text = strategy.readStringFromPasteboard(0, kUTTypeText, m_pasteboardName);
     if (text.text.isEmpty())
-        text.text = strategy.readStringFromPasteboard(0, kUTTypeURL);
+        text.text = strategy.readStringFromPasteboard(0, kUTTypeURL, m_pasteboardName);
 }
 
 static NSArray* supportedImageTypes()
@@ -160,7 +160,7 @@
 {
     PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy();
 
-    int numberOfItems = strategy.getPasteboardItemsCount();
+    int numberOfItems = strategy.getPasteboardItemsCount(m_pasteboardName);
 
     if (!numberOfItems)
         return;
@@ -173,7 +173,7 @@
             NSString *type = [types objectAtIndex:typeIndex];
 
             if ([type isEqualToString:WebArchivePboardType]) {
-                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, WebArchivePboardType)) {
+                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, WebArchivePboardType, m_pasteboardName)) {
                     if (reader.readWebArchive(buffer.get()))
                         break;
                 }
@@ -180,13 +180,13 @@
             }
 
             if ([type isEqualToString:(NSString *)kUTTypeHTML]) {
-                String htmlString = strategy.readStringFromPasteboard(i, kUTTypeHTML);
+                String htmlString = strategy.readStringFromPasteboard(i, kUTTypeHTML, m_pasteboardName);
                 if (!htmlString.isNull() && reader.readHTML(htmlString))
                     break;
             }
 
             if ([type isEqualToString:(NSString *)kUTTypeFlatRTFD]) {
-                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeFlatRTFD)) {
+                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeFlatRTFD, m_pasteboardName)) {
                     if (reader.readRTFD(*buffer))
                         break;
                 }
@@ -193,7 +193,7 @@
             }
 
             if ([type isEqualToString:(NSString *)kUTTypeRTF]) {
-                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeRTF)) {
+                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeRTF, m_pasteboardName)) {
                     if (reader.readRTF(*buffer))
                         break;
                 }
@@ -200,7 +200,7 @@
             }
 
             if ([supportedImageTypes() containsObject:type]) {
-                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, type)) {
+                if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, type, m_pasteboardName)) {
                     if (reader.readImage(buffer.releaseNonNull(), type))
                         break;
                 }
@@ -207,13 +207,13 @@
         }
 
             if ([type isEqualToString:(NSString *)kUTTypeURL]) {
-                URL url = "" kUTTypeURL);
+                URL url = "" kUTTypeURL, m_pasteboardName);
                 if (!url.isNull() && reader.readURL(url, String()))
                     break;
             }
             
             if ([type isEqualToString:(NSString *)kUTTypeText]) {
-                String string = strategy.readStringFromPasteboard(i, kUTTypeText);
+                String string = strategy.readStringFromPasteboard(i, kUTTypeText, m_pasteboardName);
                 if (!string.isNull() && reader.readPlainText(string))
                     break;
             }
@@ -229,7 +229,7 @@
 
 bool Pasteboard::hasData()
 {
-    return platformStrategies()->pasteboardStrategy()->getPasteboardItemsCount() != 0;
+    return !!platformStrategies()->pasteboardStrategy()->getPasteboardItemsCount(m_pasteboardName);
 }
 
 static String utiTypeFromCocoaType(NSString *type)
@@ -273,12 +273,12 @@
     if (!cocoaType)
         return;
 
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(cocoaType.get(), String());
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(cocoaType.get(), String(), m_pasteboardName);
 }
 
 void Pasteboard::clear()
 {
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(String(), String());
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(String(), String(), m_pasteboardName);
 }
 
 String Pasteboard::readString(const String& type)
@@ -285,7 +285,7 @@
 {
     PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy();
 
-    int numberOfItems = strategy.getPasteboardItemsCount();
+    int numberOfItems = strategy.getPasteboardItemsCount(m_pasteboardName);
 
     if (!numberOfItems)
         return String();
@@ -296,21 +296,21 @@
     NSString *cocoaValue = nil;
 
     if ([cocoaType isEqualToString:(NSString *)kUTTypeURL]) {
-        URL url = "" kUTTypeURL);
+        URL url = "" kUTTypeURL, m_pasteboardName);
         if (!url.isNull())
             cocoaValue = [(NSURL *)url absoluteString];
     } else if ([cocoaType isEqualToString:(NSString *)kUTTypeText]) {
-        String value = strategy.readStringFromPasteboard(0, kUTTypeText);
+        String value = strategy.readStringFromPasteboard(0, kUTTypeText, m_pasteboardName);
         if (!value.isNull())
             cocoaValue = [(NSString *)value precomposedStringWithCanonicalMapping];
     } else if (cocoaType) {
-        if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(0, cocoaType.get()))
+        if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(0, cocoaType.get(), m_pasteboardName))
             cocoaValue = [[[NSString alloc] initWithData:buffer->createNSData().get() encoding:NSUTF8StringEncoding] autorelease];
     }
 
     // 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 (cocoaValue && m_changeCount == platformStrategies()->pasteboardStrategy()->changeCount())
+    if (cocoaValue && m_changeCount == platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
         return cocoaValue;
 
     return String();
@@ -342,7 +342,7 @@
     if (!cocoaType)
         return;
 
-    platformStrategies()->pasteboardStrategy()->writeToPasteboard(type, data);
+    platformStrategies()->pasteboardStrategy()->writeToPasteboard(type, data, m_pasteboardName);
 }
 
 Vector<String> Pasteboard::types()
@@ -351,7 +351,7 @@
 
     // 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())
+    if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
         return Vector<String>();
 
     ListHashSet<String> result;

Modified: trunk/Source/WebKit/mac/ChangeLog (211157 => 211158)


--- trunk/Source/WebKit/mac/ChangeLog	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-01-25 20:16:17 UTC (rev 211158)
@@ -1,3 +1,20 @@
+2017-01-25  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add support for named pasteboards, pasteboard strategies and platform pasteboards
+        https://bugs.webkit.org/show_bug.cgi?id=167404
+
+        Reviewed by Enrica Casucci.
+
+        Adds pasteboard name as an argument to pasteboard-related WebPlatformStrategy methods.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::writeToPasteboard):
+        (WebPlatformStrategies::getPasteboardItemsCount):
+        (WebPlatformStrategies::readBufferFromPasteboard):
+        (WebPlatformStrategies::readURLFromPasteboard):
+        (WebPlatformStrategies::readStringFromPasteboard):
+
 2017-01-25  Aakash Jain  <aakash_j...@apple.com>
 
         LoadWebLocalizedStrings method should be moved in correct file

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h (211157 => 211158)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -59,14 +59,13 @@
 
     // WebCore::PasteboardStrategy
 #if PLATFORM(IOS)
-    void writeToPasteboard(const WebCore::PasteboardWebContent&) override;
-    void writeToPasteboard(const WebCore::PasteboardImage&) override;
-    void writeToPasteboard(const String& pasteboardType, const String&) override;
-    int getPasteboardItemsCount() override;
-    String readStringFromPasteboard(int index, const String& pasteboardType) override;
-    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) override;
-    WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType) override;
-    long changeCount() override;
+    void writeToPasteboard(const WebCore::PasteboardWebContent&, const String& pasteboardName) override;
+    void writeToPasteboard(const WebCore::PasteboardImage&, const String& pasteboardName) override;
+    void writeToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName) override;
+    int getPasteboardItemsCount(const String& pasteboardName) override;
+    String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
+    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
+    WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
 #endif
     void getTypes(Vector<String>& types, const String& pasteboardName) override;
     RefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm (211157 => 211158)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2017-01-25 20:16:17 UTC (rev 211158)
@@ -186,43 +186,38 @@
 }
 
 #if PLATFORM(IOS)
-void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content)
+void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
 {
-    PlatformPasteboard().write(content);
+    PlatformPasteboard(pasteboardName).write(content);
 }
 
-void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardImage& image)
+void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardImage& image, const String& pasteboardName)
 {
-    PlatformPasteboard().write(image);
+    PlatformPasteboard(pasteboardName).write(image);
 }
 
-void WebPlatformStrategies::writeToPasteboard(const String& pasteboardType, const String& text)
+void WebPlatformStrategies::writeToPasteboard(const String& pasteboardType, const String& text, const String& pasteboardName)
 {
-    PlatformPasteboard().write(pasteboardType, text);
+    PlatformPasteboard(pasteboardName).write(pasteboardType, text);
 }
 
-int WebPlatformStrategies::getPasteboardItemsCount()
+int WebPlatformStrategies::getPasteboardItemsCount(const String& pasteboardName)
 {
-    return PlatformPasteboard().count();
+    return PlatformPasteboard(pasteboardName).count();
 }
 
-RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& type)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& type, const String& pasteboardName)
 {
-    return PlatformPasteboard().readBuffer(index, type);
+    return PlatformPasteboard(pasteboardName).readBuffer(index, type);
 }
 
-WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& type)
+WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& type, const String& pasteboardName)
 {
-    return PlatformPasteboard().readURL(index, type);
+    return PlatformPasteboard(pasteboardName).readURL(index, type);
 }
 
-String WebPlatformStrategies::readStringFromPasteboard(int index, const String& type)
+String WebPlatformStrategies::readStringFromPasteboard(int index, const String& type, const String& pasteboardName)
 {
-    return PlatformPasteboard().readString(index, type);
+    return PlatformPasteboard(pasteboardName).readString(index, type);
 }
-
-long WebPlatformStrategies::changeCount()
-{
-    return PlatformPasteboard().changeCount();
-}
 #endif // PLATFORM(IOS)

Modified: trunk/Source/WebKit2/ChangeLog (211157 => 211158)


--- trunk/Source/WebKit2/ChangeLog	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-25 20:16:17 UTC (rev 211158)
@@ -1,3 +1,30 @@
+2017-01-25  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add support for named pasteboards, pasteboard strategies and platform pasteboards
+        https://bugs.webkit.org/show_bug.cgi?id=167404
+
+        Reviewed by Enrica Casucci.
+
+        Adds support for delivering the pasteboard name to the UI process when writing to or reading from the pasteboard.
+
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        (WebKit::WebPasteboardProxy::writeWebContentToPasteboard):
+        (WebKit::WebPasteboardProxy::writeImageToPasteboard):
+        (WebKit::WebPasteboardProxy::writeStringToPasteboard):
+        (WebKit::WebPasteboardProxy::readStringFromPasteboard):
+        (WebKit::WebPasteboardProxy::readURLFromPasteboard):
+        (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
+        (WebKit::WebPasteboardProxy::getPasteboardItemsCount):
+        * UIProcess/WebPasteboardProxy.h:
+        * UIProcess/WebPasteboardProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::writeToPasteboard):
+        (WebKit::WebPlatformStrategies::getPasteboardItemsCount):
+        (WebKit::WebPlatformStrategies::readBufferFromPasteboard):
+        (WebKit::WebPlatformStrategies::readURLFromPasteboard):
+        (WebKit::WebPlatformStrategies::readStringFromPasteboard):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2017-01-25  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Icon Database should be in private browsing mode for ephemeral web views

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (211157 => 211158)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2017-01-25 20:16:17 UTC (rev 211158)
@@ -135,34 +135,34 @@
 }
 
 #if PLATFORM(IOS)
-void WebPasteboardProxy::writeWebContentToPasteboard(const WebCore::PasteboardWebContent& content)
+void WebPasteboardProxy::writeWebContentToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
 {
-    PlatformPasteboard().write(content);
+    PlatformPasteboard(pasteboardName).write(content);
 }
 
-void WebPasteboardProxy::writeImageToPasteboard(const WebCore::PasteboardImage& pasteboardImage)
+void WebPasteboardProxy::writeImageToPasteboard(const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName)
 {
-    PlatformPasteboard().write(pasteboardImage);
+    PlatformPasteboard(pasteboardName).write(pasteboardImage);
 }
 
-void WebPasteboardProxy::writeStringToPasteboard(const String& pasteboardType, const String& text)
+void WebPasteboardProxy::writeStringToPasteboard(const String& pasteboardType, const String& text, const String& pasteboardName)
 {
-    PlatformPasteboard().write(pasteboardType, text);
+    PlatformPasteboard(pasteboardName).write(pasteboardType, text);
 }
 
-void WebPasteboardProxy::readStringFromPasteboard(uint64_t index, const String& pasteboardType, WTF::String& value)
+void WebPasteboardProxy::readStringFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, WTF::String& value)
 {
-    value = PlatformPasteboard().readString(index, pasteboardType);
+    value = PlatformPasteboard(pasteboardName).readString(index, pasteboardType);
 }
 
-void WebPasteboardProxy::readURLFromPasteboard(uint64_t index, const String& pasteboardType, String& url)
+void WebPasteboardProxy::readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& url)
 {
-    url = "" pasteboardType);
+    url = "" pasteboardType);
 }
 
-void WebPasteboardProxy::readBufferFromPasteboard(uint64_t index, const String& pasteboardType, SharedMemory::Handle& handle, uint64_t& size)
+void WebPasteboardProxy::readBufferFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, SharedMemory::Handle& handle, uint64_t& size)
 {
-    RefPtr<SharedBuffer> buffer = PlatformPasteboard().readBuffer(index, pasteboardType);
+    RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).readBuffer(index, pasteboardType);
     if (!buffer)
         return;
     size = buffer->size();
@@ -173,9 +173,9 @@
     sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
 }
 
-void WebPasteboardProxy::getPasteboardItemsCount(uint64_t& itemsCount)
+void WebPasteboardProxy::getPasteboardItemsCount(const String& pasteboardName, uint64_t& itemsCount)
 {
-    itemsCount = PlatformPasteboard().count();
+    itemsCount = PlatformPasteboard(pasteboardName).count();
 }
 
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h (211157 => 211158)


--- trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -68,13 +68,13 @@
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
 
 #if PLATFORM(IOS)
-    void writeWebContentToPasteboard(const WebCore::PasteboardWebContent&);
-    void writeImageToPasteboard(const WebCore::PasteboardImage&);
-    void writeStringToPasteboard(const String& pasteboardType, const String&);
-    void readStringFromPasteboard(uint64_t index, const String& pasteboardType, WTF::String&);
-    void readURLFromPasteboard(uint64_t index, const String& pasteboardType, String&);
-    void readBufferFromPasteboard(uint64_t index, const String& pasteboardType, SharedMemory::Handle&, uint64_t& size);
-    void getPasteboardItemsCount(uint64_t& itemsCount);
+    void writeWebContentToPasteboard(const WebCore::PasteboardWebContent&, const String& pasteboardName);
+    void writeImageToPasteboard(const WebCore::PasteboardImage&, const String& pasteboardName);
+    void writeStringToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName);
+    void readStringFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, WTF::String&);
+    void readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String&);
+    void readBufferFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, SharedMemory::Handle&, uint64_t& size);
+    void getPasteboardItemsCount(const String& pasteboardName, uint64_t& itemsCount);
 #endif
 #if PLATFORM(COCOA)
     void getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes);

Modified: trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in (211157 => 211158)


--- trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in	2017-01-25 20:16:17 UTC (rev 211158)
@@ -22,13 +22,13 @@
 
 messages -> WebPasteboardProxy {
 #if PLATFORM(IOS)
-    WriteWebContentToPasteboard(struct WebCore::PasteboardWebContent content)
-    WriteImageToPasteboard(struct WebCore::PasteboardImage pasteboardImage)
-    WriteStringToPasteboard(String pasteboardType, String text) 
-    ReadStringFromPasteboard(uint64_t index, String pasteboardType) -> (String string)
-    ReadURLFromPasteboard(uint64_t index, String pasteboardType) -> (String string)
-    ReadBufferFromPasteboard(uint64_t index, String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size)
-    GetPasteboardItemsCount() -> (uint64_t itemsCount)
+    WriteWebContentToPasteboard(struct WebCore::PasteboardWebContent content, String pasteboardName)
+    WriteImageToPasteboard(struct WebCore::PasteboardImage pasteboardImage, String pasteboardName)
+    WriteStringToPasteboard(String pasteboardType, String text, String pasteboardName)
+    ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string)
+    ReadURLFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string)
+    ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size)
+    GetPasteboardItemsCount(String pasteboardName) -> (uint64_t itemsCount)
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (211157 => 211158)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2017-01-25 20:16:17 UTC (rev 211158)
@@ -285,33 +285,33 @@
 }
 
 #if PLATFORM(IOS)
-void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content)
+void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
 {
-    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteWebContentToPasteboard(content), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteWebContentToPasteboard(content, pasteboardName), 0);
 }
 
-void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardImage& image)
+void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardImage& image, const String& pasteboardName)
 {
-    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteImageToPasteboard(image), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteImageToPasteboard(image, pasteboardName), 0);
 }
 
-void WebPlatformStrategies::writeToPasteboard(const String& pasteboardType, const String& text)
+void WebPlatformStrategies::writeToPasteboard(const String& pasteboardType, const String& text, const String& pasteboardName)
 {
-    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteStringToPasteboard(pasteboardType, text), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteStringToPasteboard(pasteboardType, text, pasteboardName), 0);
 }
 
-int WebPlatformStrategies::getPasteboardItemsCount()
+int WebPlatformStrategies::getPasteboardItemsCount(const String& pasteboardName)
 {
     uint64_t itemsCount;
-    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardItemsCount(), Messages::WebPasteboardProxy::GetPasteboardItemsCount::Reply(itemsCount), 0);
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardItemsCount(pasteboardName), Messages::WebPasteboardProxy::GetPasteboardItemsCount::Reply(itemsCount), 0);
     return itemsCount;
 }
 
-RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& pasteboardType)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName)
 {
     SharedMemory::Handle handle;
     uint64_t size = 0;
-    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(handle, size), 0);
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(handle, size), 0);
     if (handle.isNull())
         return nullptr;
     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
@@ -318,27 +318,19 @@
     return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size);
 }
 
-WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& pasteboardType)
+WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName)
 {
     String urlString;
-    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadURLFromPasteboard(index, pasteboardType), Messages::WebPasteboardProxy::ReadURLFromPasteboard::Reply(urlString), 0);
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadURLFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadURLFromPasteboard::Reply(urlString), 0);
     return URL(ParsedURLString, urlString);
 }
 
-String WebPlatformStrategies::readStringFromPasteboard(int index, const String& pasteboardType)
+String WebPlatformStrategies::readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName)
 {
     String value;
-    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadStringFromPasteboard(index, pasteboardType), Messages::WebPasteboardProxy::ReadStringFromPasteboard::Reply(value), 0);
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadStringFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadStringFromPasteboard::Reply(value), 0);
     return value;
 }
-
-long WebPlatformStrategies::changeCount()
-{
-    uint64_t changeCount;
-    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardChangeCount(String()), Messages::WebPasteboardProxy::GetPasteboardChangeCount::Reply(changeCount), 0);
-    return changeCount;
-}
-
 #endif // PLATFORM(IOS)
 
 #endif // PLATFORM(COCOA)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (211157 => 211158)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2017-01-25 20:04:30 UTC (rev 211157)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2017-01-25 20:16:17 UTC (rev 211158)
@@ -60,14 +60,13 @@
 
     // WebCore::PasteboardStrategy
 #if PLATFORM(IOS)
-    void writeToPasteboard(const WebCore::PasteboardWebContent&) override;
-    void writeToPasteboard(const WebCore::PasteboardImage&) override;
-    void writeToPasteboard(const String& pasteboardType, const String&) override;
-    int getPasteboardItemsCount() override;
-    String readStringFromPasteboard(int index, const String& pasteboardType) override;
-    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) override;
-    WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType) override;
-    long changeCount() override;
+    void writeToPasteboard(const WebCore::PasteboardWebContent&, const String& pasteboardName) override;
+    void writeToPasteboard(const WebCore::PasteboardImage&, const String& pasteboardName) override;
+    void writeToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName) override;
+    int getPasteboardItemsCount(const String& pasteboardName) override;
+    String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
+    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
+    WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
 #endif
 #if PLATFORM(COCOA)
     void getTypes(Vector<String>& types, const String& pasteboardName) override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to