[Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events...
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 21:11:12 +0000 (21:11 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 21:11:12 +0000 (21:11 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=113094

        Reviewed by Darin Adler.

        Mac platform implementation has checks for pasteboard change count, but it
        didn't use to update the count when writing to pasteboad from JavaScript.

        * platform/PasteboardStrategy.h: Changed changeCount function to return a long
        instead of an int, as the underlying Mac type is NSInteger. Changed all methods
        that modify the pasteboard to return a new change count.

        * platform/PlatformPasteboard.h: Changed all methods that modify the pasteboard
        to return a new change count.

        * platform/mac/PasteboardMac.mm:
        (WebCore::Pasteboard::clear): Update m_changeCount.
        (WebCore::Pasteboard::writeSelectionForTypes): Ditto.
        (WebCore::Pasteboard::writePlainText): Ditto.
        (WebCore::writeURLForTypes): Ditto.
        (WebCore::Pasteboard::writeURL): Ditto.
        (WebCore::writeFileWrapperAsRTFDAttachment): Ditto.
        (WebCore::Pasteboard::writeImage): Ditto.
        (WebCore::Pasteboard::writePasteboard): Ditto.
        (WebCore::addHTMLClipboardTypesForCocoaType): Ditto.
        (WebCore::Pasteboard::writeString): Ditto.

        * platform/mac/PlatformPasteboardMac.mm:
        (WebCore::PlatformPasteboard::changeCount): Changed returned type to long to avoid
        data loss.
        (WebCore::PlatformPasteboard::copy): Return new change count.
        (WebCore::PlatformPasteboard::addTypes): Ditto.
        (WebCore::PlatformPasteboard::setTypes): Ditto.
        (WebCore::PlatformPasteboard::setBufferForType): Ditto.
        (WebCore::PlatformPasteboard::setPathnamesForType): Ditto.
        (WebCore::PlatformPasteboard::setStringForType): Ditto. Replaced -[NSURL writeToPasteboard:]
        with an equivalent implemnentation that tells use whether writing was successful.
        There is difference with invalid URL string handling - we used to silently ignore
        such requets, but set pasteboard content to empty URL now.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154639 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/PasteboardStrategy.h
Source/WebCore/platform/PlatformPasteboard.h
Source/WebCore/platform/mac/PasteboardMac.mm
Source/WebCore/platform/mac/PlatformPasteboardMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebContext.messages.in
Source/WebKit2/UIProcess/mac/WebContextMac.mm
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h

index 3f7c3ea..b80d9c5 100644 (file)
@@ -1,3 +1,45 @@
+2013-08-26  Alexey Proskuryakov  <ap@apple.com>
+
+        [Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail
+        https://bugs.webkit.org/show_bug.cgi?id=113094
+
+        Reviewed by Darin Adler.
+
+        Mac platform implementation has checks for pasteboard change count, but it
+        didn't use to update the count when writing to pasteboad from JavaScript.
+
+        * platform/PasteboardStrategy.h: Changed changeCount function to return a long
+        instead of an int, as the underlying Mac type is NSInteger. Changed all methods
+        that modify the pasteboard to return a new change count.
+
+        * platform/PlatformPasteboard.h: Changed all methods that modify the pasteboard
+        to return a new change count.
+
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::clear): Update m_changeCount.
+        (WebCore::Pasteboard::writeSelectionForTypes): Ditto.
+        (WebCore::Pasteboard::writePlainText): Ditto.
+        (WebCore::writeURLForTypes): Ditto.
+        (WebCore::Pasteboard::writeURL): Ditto.
+        (WebCore::writeFileWrapperAsRTFDAttachment): Ditto.
+        (WebCore::Pasteboard::writeImage): Ditto.
+        (WebCore::Pasteboard::writePasteboard): Ditto.
+        (WebCore::addHTMLClipboardTypesForCocoaType): Ditto.
+        (WebCore::Pasteboard::writeString): Ditto.
+
+        * platform/mac/PlatformPasteboardMac.mm:
+        (WebCore::PlatformPasteboard::changeCount): Changed returned type to long to avoid
+        data loss.
+        (WebCore::PlatformPasteboard::copy): Return new change count.
+        (WebCore::PlatformPasteboard::addTypes): Ditto.
+        (WebCore::PlatformPasteboard::setTypes): Ditto.
+        (WebCore::PlatformPasteboard::setBufferForType): Ditto.
+        (WebCore::PlatformPasteboard::setPathnamesForType): Ditto.
+        (WebCore::PlatformPasteboard::setStringForType): Ditto. Replaced -[NSURL writeToPasteboard:]
+        with an equivalent implemnentation that tells use whether writing was successful.
+        There is difference with invalid URL string handling - we used to silently ignore
+        such requets, but set pasteboard content to empty URL now.
+
 2013-08-24  Sam Weinig  <sam@webkit.org>
 
         Add support for Promises
index 785fcdd..187264c 100644 (file)
@@ -43,17 +43,17 @@ public:
     virtual PassRefPtr<SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) = 0;
     virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) = 0;
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) = 0;
-    virtual int changeCount(const String& pasteboardName) = 0;
+    virtual long changeCount(const String& pasteboardName) = 0;
     virtual String uniqueName() = 0;
     virtual Color color(const String& pasteboardName) = 0;
     virtual KURL url(const String& pasteboardName) = 0;
     
-    virtual void copy(const String& fromPasteboard, const String& toPasteboard) = 0;
-    virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
-    virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
-    virtual void setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType, const String& pasteboardName) = 0;
-    virtual void setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0;
-    virtual void setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0;
+    virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
+    virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
+    virtual long copy(const String& fromPasteboard, const String& toPasteboard) = 0;
+    virtual long setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType, const String& pasteboardName) = 0;
+    virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0;
+    virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0;
 #endif
 protected:
     virtual ~PasteboardStrategy()
index 2fdd77b..3721119 100644 (file)
@@ -49,16 +49,19 @@ public:
     PassRefPtr<SharedBuffer> bufferForType(const String& pasteboardType);
     void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType);
     String stringForType(const String& pasteboardType);
-    int changeCount() const;
+    long changeCount() const;
     Color color();
     KURL url();
-    
-    void copy(const String& fromPasteboard);
-    void addTypes(const Vector<String>& pasteboardTypes);
-    void setTypes(const Vector<String>& pasteboardTypes);
-    void setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType);
-    void setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType);
-    void setStringForType(const String&, const String& pasteboardType);
+
+    // Take ownership of the pasteboard, and return new change count.
+    long addTypes(const Vector<String>& pasteboardTypes);
+    long setTypes(const Vector<String>& pasteboardTypes);
+
+    // These methods will return 0 if pasteboard ownership has been taken from us.
+    long copy(const String& fromPasteboard);
+    long setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType);
+    long setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType);
+    long setStringForType(const String&, const String& pasteboardType);
 
 private:
 #if PLATFORM(MAC)
index ef984d6..2221928 100644 (file)
@@ -155,7 +155,7 @@ PassOwnPtr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData
 
 void Pasteboard::clear()
 {
-    platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName);
+    m_changeCount = platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName);
 }
 
 PassRefPtr<SharedBuffer> Pasteboard::getDataSelection(Frame* frame, const String& pasteboardType)
@@ -205,33 +205,33 @@ void Pasteboard::writeSelectionForTypes(const Vector<String>& pasteboardTypes, b
     frame->editor().client()->getClientPasteboardDataForRange(frame->editor().selectedRange().get(), clientTypes, clientData);
     types.appendVector(clientTypes);
 
-    platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName);
+    m_changeCount = platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName);
     frame->editor().client()->didSetSelectionTypesForPasteboard();
 
     for (size_t i = 0; i < clientTypes.size(); ++i)
-        platformStrategies()->pasteboardStrategy()->setBufferForType(clientData[i], clientTypes[i], m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(clientData[i], clientTypes[i], m_pasteboardName);
 
     // Put HTML on the pasteboard.
     if (types.contains(WebArchivePboardType))
-        platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, WebArchivePboardType), WebArchivePboardType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, WebArchivePboardType), WebArchivePboardType, m_pasteboardName);
     
     // Put the attributed string on the pasteboard (RTF/RTFD format).
     if (types.contains(String(NSRTFDPboardType)))
-        platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFDPboardType), NSRTFDPboardType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFDPboardType), NSRTFDPboardType, m_pasteboardName);
 
     if (types.contains(String(NSRTFPboardType)))
-        platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFPboardType), NSRTFPboardType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFPboardType), NSRTFPboardType, m_pasteboardName);
     
     // Put plain string on the pasteboard.
     if (types.contains(String(NSStringPboardType))) {
         String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard
             ? frame->editor().stringSelectionForPasteboardWithImageAltText()
             : frame->editor().stringSelectionForPasteboard();
-        platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);
     }
     
     if (types.contains(WebSmartPastePboardType))
-        platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);
 }
 
 void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
@@ -242,9 +242,9 @@ void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartRepl
         types.append(WebSmartPastePboardType);
 
     platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName);
-    platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);
+    m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);
     if (smartReplaceOption == CanSmartReplace)
-        platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);
 }
     
 void Pasteboard::writeSelection(Range*, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
@@ -252,9 +252,9 @@ void Pasteboard::writeSelection(Range*, bool canSmartCopyOrDelete, Frame* frame,
     writeSelectionForTypes(Vector<String>(), canSmartCopyOrDelete, frame, shouldSerializeSelectedTextForClipboard);
 }
 
-static void writeURLForTypes(const Vector<String>& types, const String& pasteboardName, const KURL& url, const String& titleStr, Frame* frame)
+static long writeURLForTypes(const Vector<String>& types, const String& pasteboardName, const KURL& url, const String& titleStr, Frame* frame)
 {
-    platformStrategies()->pasteboardStrategy()->setTypes(types, pasteboardName);
+    long newChangeCount = platformStrategies()->pasteboardStrategy()->setTypes(types, pasteboardName);
     
     ASSERT(!url.isEmpty());
     
@@ -271,21 +271,23 @@ static void writeURLForTypes(const Vector<String>& types, const String& pasteboa
         Vector<String> paths;
         paths.append([cocoaURL absoluteString]);
         paths.append(titleStr.stripWhiteSpace());
-        platformStrategies()->pasteboardStrategy()->setPathnamesForType(paths, WebURLsWithTitlesPboardType, pasteboardName);
+        newChangeCount = platformStrategies()->pasteboardStrategy()->setPathnamesForType(paths, WebURLsWithTitlesPboardType, pasteboardName);
     }
     if (types.contains(String(NSURLPboardType)))
-        platformStrategies()->pasteboardStrategy()->setStringForType([cocoaURL absoluteString], NSURLPboardType, pasteboardName);
+        newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType([cocoaURL absoluteString], NSURLPboardType, pasteboardName);
     if (types.contains(WebURLPboardType))
-        platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, WebURLPboardType, pasteboardName);
+        newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, WebURLPboardType, pasteboardName);
     if (types.contains(WebURLNamePboardType))
-        platformStrategies()->pasteboardStrategy()->setStringForType(title, WebURLNamePboardType, pasteboardName);
+        newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType(title, WebURLNamePboardType, pasteboardName);
     if (types.contains(String(NSStringPboardType)))
-        platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, NSStringPboardType, pasteboardName);
+        newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, NSStringPboardType, pasteboardName);
+
+    return newChangeCount;
 }
     
 void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
 {
-    writeURLForTypes(writableTypesForURL(), m_pasteboardName, url, titleStr, frame);
+    m_changeCount = writeURLForTypes(writableTypesForURL(), m_pasteboardName, url, titleStr, frame);
 }
 
 static NSFileWrapper* fileWrapperForImage(CachedResource* resource, NSURL *url)
@@ -301,7 +303,7 @@ static NSFileWrapper* fileWrapperForImage(CachedResource* resource, NSURL *url)
     return wrapper;
 }
 
-static void writeFileWrapperAsRTFDAttachment(NSFileWrapper* wrapper, const String& pasteboardName)
+static void writeFileWrapperAsRTFDAttachment(NSFileWrapper* wrapper, const String& pasteboardName, long& newChangeCount)
 {
     NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:wrapper];
     
@@ -310,7 +312,7 @@ static void writeFileWrapperAsRTFDAttachment(NSFileWrapper* wrapper, const Strin
     
     NSData *RTFDData = [string RTFDFromRange:NSMakeRange(0, [string length]) documentAttributes:nil];
     if (RTFDData)
-        platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(RTFDData).get(), NSRTFDPboardType, pasteboardName);
+        newChangeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(RTFDData).get(), NSRTFDPboardType, pasteboardName);
 }
 
 void Pasteboard::writeImage(Node* node, const KURL& url, const String& title)
@@ -328,7 +330,7 @@ void Pasteboard::writeImage(Node* node, const KURL& url, const String& title)
     if (!cachedImage || cachedImage->errorOccurred())
         return;
 
-    writeURLForTypes(writableTypesForImage(), m_pasteboardName, cocoaURL, nsStringNilIfEmpty(title), node->document()->frame());
+    m_changeCount = writeURLForTypes(writableTypesForImage(), m_pasteboardName, cocoaURL, nsStringNilIfEmpty(title), node->document()->frame());
     
     Image* image = cachedImage->imageForRenderer(renderer);
     if (!image)
@@ -336,17 +338,17 @@ void Pasteboard::writeImage(Node* node, const KURL& url, const String& title)
     NSData *imageData = (NSData *)[image->getNSImage() TIFFRepresentation];
     if (!imageData)
         return;
-    platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(imageData), NSTIFFPboardType, m_pasteboardName);
+    m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(imageData), NSTIFFPboardType, m_pasteboardName);
 
     String MIMEType = cachedImage->response().mimeType();
     ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(MIMEType));
 
-    writeFileWrapperAsRTFDAttachment(fileWrapperForImage(cachedImage, cocoaURL), m_pasteboardName);
+    writeFileWrapperAsRTFDAttachment(fileWrapperForImage(cachedImage, cocoaURL), m_pasteboardName, m_changeCount);
 }
 
 void Pasteboard::writePasteboard(const Pasteboard& pasteboard)
 {
-    platformStrategies()->pasteboardStrategy()->copy(pasteboard.m_pasteboardName, m_pasteboardName);
+    m_changeCount = platformStrategies()->pasteboardStrategy()->copy(pasteboard.m_pasteboardName, m_pasteboardName);
 }
 
 bool Pasteboard::canSmartReplace()
@@ -652,7 +654,7 @@ void Pasteboard::clear(const String& type)
     String cocoaType = cocoaTypeFromHTMLClipboardType(type);
     if (cocoaType.isEmpty())
         return;
-    platformStrategies()->pasteboardStrategy()->setStringForType(emptyString(), cocoaType, m_pasteboardName);
+    m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(emptyString(), cocoaType, m_pasteboardName);
 }
 
 static Vector<String> absoluteURLsFromPasteboardFilenames(const String& pasteboardName, bool onlyFirstURL = false)
@@ -761,7 +763,7 @@ static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes,
         resultTypes.add(utiType);
         return;
     }
-    // No mapping, just pass the whole string though
+    // No mapping, just pass the whole string through.
     resultTypes.add(cocoaType);
 }
 
@@ -778,7 +780,7 @@ bool Pasteboard::writeString(const String& type, const String& data)
         Vector<String> types;
         types.append(cocoaType);
         platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName);
-        platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName);
 
         return true;
     }
@@ -788,7 +790,7 @@ bool Pasteboard::writeString(const String& type, const String& data)
         Vector<String> types;
         types.append(cocoaType);
         platformStrategies()->pasteboardStrategy()->addTypes(types, m_pasteboardName);
-        platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName);
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName);
         return true;
     }
 
index 4058826..53a40aa 100644 (file)
@@ -71,7 +71,7 @@ String PlatformPasteboard::stringForType(const String& pasteboardType)
     return [m_pasteboard.get() stringForType:pasteboardType];
 }
 
-int PlatformPasteboard::changeCount() const
+long PlatformPasteboard::changeCount() const
 {
     return [m_pasteboard.get() changeCount];
 }
@@ -99,7 +99,7 @@ KURL PlatformPasteboard::url()
     return [NSURL URLFromPasteboard:m_pasteboard.get()];
 }
 
-void PlatformPasteboard::copy(const String& fromPasteboard)
+long PlatformPasteboard::copy(const String& fromPasteboard)
 {
     NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:fromPasteboard];
     NSArray* types = [pasteboard types];
@@ -107,52 +107,91 @@ void PlatformPasteboard::copy(const String& fromPasteboard)
     [m_pasteboard.get() addTypes:types owner:nil];
     for (NSUInteger i = 0; i < [types count]; i++) {
         NSString* type = [types objectAtIndex:i];
-        [m_pasteboard.get() setData:[pasteboard dataForType:type] forType:type];
+        if (![m_pasteboard.get() setData:[pasteboard dataForType:type] forType:type])
+            return 0;
     }    
+    return changeCount();
 }
 
-void PlatformPasteboard::addTypes(const Vector<String>& pasteboardTypes)
+long PlatformPasteboard::addTypes(const Vector<String>& pasteboardTypes)
 {
     RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] init]);
     for (size_t i = 0; i < pasteboardTypes.size(); ++i)
         [types.get() addObject:pasteboardTypes[i]];
 
-    [m_pasteboard.get() addTypes:types.get() owner:nil];
+    return [m_pasteboard.get() addTypes:types.get() owner:nil];
 }
 
-void PlatformPasteboard::setTypes(const Vector<String>& pasteboardTypes)
+long PlatformPasteboard::setTypes(const Vector<String>& pasteboardTypes)
 {
-    if (pasteboardTypes.isEmpty()) {
-        [m_pasteboard.get() declareTypes:nil owner:nil];
-        return;
-    }
+    if (pasteboardTypes.isEmpty())
+        return [m_pasteboard.get() declareTypes:nil owner:nil];
 
     RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] init]);
     for (size_t i = 0; i < pasteboardTypes.size(); ++i)
         [types.get() addObject:pasteboardTypes[i]];
 
-    [m_pasteboard.get() declareTypes:types.get() owner:nil];
+    return [m_pasteboard.get() declareTypes:types.get() owner:nil];
 }
 
-void PlatformPasteboard::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType)
+long PlatformPasteboard::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType)
 {
-    [m_pasteboard.get() setData:buffer ? [buffer->createNSData() autorelease] : nil forType:pasteboardType];
+    BOOL didWriteData = [m_pasteboard.get() setData:buffer ? [buffer->createNSData() autorelease] : nil forType:pasteboardType];
+    if (!didWriteData)
+        return 0;
+    return changeCount();
 }
 
-void PlatformPasteboard::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType)
+long PlatformPasteboard::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType)
 {
     RetainPtr<NSMutableArray> paths = adoptNS([[NSMutableArray alloc] init]);    
     for (size_t i = 0; i < pathnames.size(); ++i)
-        [paths.get() addObject: [NSArray arrayWithObject:pathnames[i]]];
-    [m_pasteboard.get() setPropertyList:paths.get() forType:pasteboardType];
+        [paths.get() addObject:[NSArray arrayWithObject:pathnames[i]]];
+    BOOL didWriteData = [m_pasteboard.get() setPropertyList:paths.get() forType:pasteboardType];
+    if (!didWriteData)
+        return 0;
+    return changeCount();
 }
 
-void PlatformPasteboard::setStringForType(const String& string, const String& pasteboardType)
+long PlatformPasteboard::setStringForType(const String& string, const String& pasteboardType)
 {
-    if (pasteboardType == String(NSURLPboardType))
-        [[NSURL URLWithString:string] writeToPasteboard:m_pasteboard.get()];
-    else
-        [m_pasteboard.get() setString:string forType:pasteboardType];
+    BOOL didWriteData;
+
+    if (pasteboardType == String(NSURLPboardType)) {
+        // We cannot just use -NSPasteboard writeObjects:], because -declareTypes has been already called, implicitly creating an item.
+        NSURL *url = [NSURL URLWithString:string];
+        if ([[m_pasteboard.get() types] containsObject:NSURLPboardType]) {
+            NSURL *base = [url baseURL];
+            if (base)
+                didWriteData = [m_pasteboard.get() setPropertyList:@[[url relativeString], [base absoluteString]] forType:NSURLPboardType];
+            else if (url)
+                didWriteData = [m_pasteboard.get() setPropertyList:@[[url absoluteString], @""] forType:NSURLPboardType];
+            else
+                didWriteData = [m_pasteboard.get() setPropertyList:@[@"", @""] forType:NSURLPboardType];
+
+            if (!didWriteData)
+                return 0;
+        }
+
+        if ([[m_pasteboard.get() types] containsObject:(NSString *)kUTTypeURL]) {
+            didWriteData = [m_pasteboard.get() setString:[url absoluteString] forType:(NSString *)kUTTypeURL];
+            if (!didWriteData)
+                return 0;
+        }
+
+        if ([[m_pasteboard.get() types] containsObject:(NSString *)kUTTypeFileURL] && [url isFileURL]) {
+            didWriteData = [m_pasteboard.get() setString:[url absoluteString] forType:(NSString *)kUTTypeFileURL];
+            if (!didWriteData)
+                return 0;
+        }
+
+    } else {
+        didWriteData = [m_pasteboard.get() setString:string forType:pasteboardType];
+        if (!didWriteData)
+            return 0;
+    }
+
+    return changeCount();
 }
 
 }
index f298dfb..95fe6e7 100644 (file)
@@ -1,3 +1,22 @@
+2013-08-26  Alexey Proskuryakov  <ap@apple.com>
+
+        [Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail
+        https://bugs.webkit.org/show_bug.cgi?id=113094
+
+        Reviewed by Darin Adler.
+
+        Return new pasteboard change count from all functions that change it.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::copy):
+        (WebPlatformStrategies::changeCount):
+        (WebPlatformStrategies::addTypes):
+        (WebPlatformStrategies::setTypes):
+        (WebPlatformStrategies::setBufferForType):
+        (WebPlatformStrategies::setPathnamesForType):
+        (WebPlatformStrategies::setStringForType):
+
 2013-08-26  Andreas Kling  <akling@apple.com>
 
         Unreviewed build fix.
index c401e03..acdbedb 100644 (file)
@@ -83,17 +83,17 @@ private:
     virtual PassRefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE;
     virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE;
-    virtual int changeCount(const String& pasteboardName) OVERRIDE;
+    virtual long changeCount(const String& pasteboardName) OVERRIDE;
     virtual String uniqueName() OVERRIDE;
     virtual WebCore::Color color(const String& pasteboardName) OVERRIDE;
     virtual WebCore::KURL url(const String& pasteboardName) OVERRIDE;
 
-    virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
-    virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
-    virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
-    virtual void setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
-    virtual void setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
-    virtual void setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
+    virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
+    virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
+    virtual long copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
+    virtual long setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
+    virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
+    virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
 };
 
 #endif // WebPlatformStrategies_h
index ad55729..5f2ad8c 100644 (file)
@@ -174,12 +174,12 @@ String WebPlatformStrategies::stringForType(const String& pasteboardType, const
     return PlatformPasteboard(pasteboardName).stringForType(pasteboardType);
 }
 
-void WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
+long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
 {
-    PlatformPasteboard(toPasteboard).copy(fromPasteboard);
+    return PlatformPasteboard(toPasteboard).copy(fromPasteboard);
 }
 
-int WebPlatformStrategies::changeCount(const String &pasteboardName)
+long WebPlatformStrategies::changeCount(const String &pasteboardName)
 {
     return PlatformPasteboard(pasteboardName).changeCount();
 }
@@ -199,27 +199,27 @@ KURL WebPlatformStrategies::url(const String& pasteboardName)
     return PlatformPasteboard(pasteboardName).url();
 }
 
-void WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
+long WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
 {
-    PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);
+    return PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);
 }
 
-void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
+long WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
 {
-    PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
+    return PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
 }
 
-void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)
+long WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);
+    return PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);
 }
 
-void WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
+long WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
+    return PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
 }
 
-void WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)
+long WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);    
+    return PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);
 }
index 3d9250a..b3e91bf 100644 (file)
@@ -1,3 +1,33 @@
+2013-08-26  Alexey Proskuryakov  <ap@apple.com>
+
+        [Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail
+        https://bugs.webkit.org/show_bug.cgi?id=113094
+
+        Reviewed by Darin Adler.
+
+        Return new pasteboard change count from all functions that change it.
+
+        * UIProcess/WebContext.h:
+        * UIProcess/WebContext.messages.in:
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::pasteboardCopy):
+        (WebKit::WebContext::addPasteboardTypes):
+        (WebKit::WebContext::setPasteboardTypes):
+        (WebKit::WebContext::setPasteboardPathnamesForType):
+        (WebKit::WebContext::setPasteboardStringForType):
+        (WebKit::WebContext::setPasteboardBufferForType):
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::writeItemsToPasteboard):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::copy):
+        (WebKit::WebPlatformStrategies::changeCount):
+        (WebKit::WebPlatformStrategies::addTypes):
+        (WebKit::WebPlatformStrategies::setTypes):
+        (WebKit::WebPlatformStrategies::setBufferForType):
+        (WebKit::WebPlatformStrategies::setPathnamesForType):
+        (WebKit::WebPlatformStrategies::setStringForType):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2013-08-26  Andreas Kling  <akling@apple.com>
 
         Unreviewed build fix.
index a9c7ee3..ac36722 100644 (file)
@@ -323,16 +323,16 @@ private:
     void getPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames);
     void getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, String&);
     void getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, SharedMemory::Handle&, uint64_t& size);
-    void pasteboardCopy(const String& fromPasteboard, const String& toPasteboard);
+    void pasteboardCopy(const String& fromPasteboard, const String& toPasteboard, uint64_t& newChangeCount);
     void getPasteboardChangeCount(const String& pasteboardName, uint64_t& changeCount);
     void getPasteboardUniqueName(String& pasteboardName);
     void getPasteboardColor(const String& pasteboardName, WebCore::Color&);
     void getPasteboardURL(const String& pasteboardName, WTF::String&);
-    void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes);
-    void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes);
-    void setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames);
-    void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&);
-    void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size);
+    void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount);
+    void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount);
+    void setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames, uint64_t& newChangeCount);
+    void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, uint64_t& newChangeCount);
+    void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount);
 #endif
 
 #if !PLATFORM(MAC)
index f3df087..471bde8 100644 (file)
@@ -34,16 +34,16 @@ messages -> WebContext LegacyReceiver {
     GetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (Vector<WTF::String> pathnames)
     GetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (WTF::String string)
     GetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size)
-    PasteboardCopy(WTF::String fromPasteboard, WTF::String toPasteboard)
+    PasteboardCopy(WTF::String fromPasteboard, WTF::String toPasteboard) -> (uint64_t changeCount)
     GetPasteboardChangeCount(WTF::String pasteboardName) -> (uint64_t changeCount)
     GetPasteboardUniqueName() -> (WTF::String pasteboardName)
     GetPasteboardColor(WTF::String pasteboardName) -> (WebCore::Color color)
     GetPasteboardURL(WTF::String pasteboardName) -> (WTF::String urlString)
-    AddPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes)
-    SetPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes)
-    SetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType, Vector<WTF::String> pathnames)
-    SetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType, WTF::String string)
-    SetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size)
+    AddPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) -> (uint64_t changeCount)
+    SetPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) -> (uint64_t changeCount)
+    SetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType, Vector<WTF::String> pathnames) -> (uint64_t changeCount)
+    SetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType, WTF::String string) -> (uint64_t changeCount)
+    SetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (uint64_t changeCount)
 #endif
 
 #if !PLATFORM(MAC)
index 4446c0d..dbd2cc7 100644 (file)
@@ -403,9 +403,9 @@ void WebContext::getPasteboardBufferForType(const String& pasteboardName, const
     sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly);
 }
 
-void WebContext::pasteboardCopy(const String& fromPasteboard, const String& toPasteboard)
+void WebContext::pasteboardCopy(const String& fromPasteboard, const String& toPasteboard, uint64_t& newChangeCount)
 {
-    PlatformPasteboard(toPasteboard).copy(fromPasteboard);
+    newChangeCount = PlatformPasteboard(toPasteboard).copy(fromPasteboard);
 }
 
 void WebContext::getPasteboardChangeCount(const String& pasteboardName, uint64_t& changeCount)
@@ -428,35 +428,35 @@ void WebContext::getPasteboardURL(const String& pasteboardName, WTF::String& url
     urlString = PlatformPasteboard(pasteboardName).url().string();
 }
 
-void WebContext::addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes)
+void WebContext::addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount)
 {
-    PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);
+    newChangeCount = PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);
 }
 
-void WebContext::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes)
+void WebContext::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount)
 {
-    PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
+    newChangeCount = PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
 }
 
-void WebContext::setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames)
+void WebContext::setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames, uint64_t& newChangeCount)
 {
-    PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
+    newChangeCount = PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
 }
 
-void WebContext::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string)
+void WebContext::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string, uint64_t& newChangeCount)
 {
-    PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);    
+    newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);
 }
 
-void WebContext::setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size)
+void WebContext::setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, uint64_t& newChangeCount)
 {
     if (handle.isNull()) {
-        PlatformPasteboard(pasteboardName).setBufferForType(0, pasteboardType);
+        newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(0, pasteboardType);
         return;
     }
     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly);
     RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size);
-    PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);
+    newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);
 }
 
 void WebContext::setProcessSuppressionEnabled(bool enabled)
index b1b5f81..7c3454b 100644 (file)
@@ -1641,7 +1641,9 @@ void PDFPlugin::writeItemsToPasteboard(NSArray *items, NSArray *types)
     for (NSString *type in types)
         pasteboardTypes.append(type);
 
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes),
+        Messages::WebContext::SetPasteboardTypes::Reply(newChangeCount), 0);
 
     for (NSUInteger i = 0, count = items.count; i < count; ++i) {
         NSString *type = [types objectAtIndex:i];
@@ -1655,7 +1657,8 @@ void PDFPlugin::writeItemsToPasteboard(NSArray *items, NSArray *types)
 
         if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) {
             RetainPtr<NSString> plainTextString = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
-            WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()), 0);
+            WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()),
+                Messages::WebContext::SetPasteboardStringForType::Reply(newChangeCount), 0);
         } else {
             RefPtr<SharedBuffer> buffer = SharedBuffer::wrapNSData(data);
 
@@ -1666,7 +1669,8 @@ void PDFPlugin::writeItemsToPasteboard(NSArray *items, NSArray *types)
             RefPtr<SharedMemory> sharedMemory = SharedMemory::create(buffer->size());
             memcpy(sharedMemory->data(), buffer->data(), buffer->size());
             sharedMemory->createHandle(handle, SharedMemory::ReadOnly);
-            WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()), 0);
+            WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()),
+                Messages::WebContext::SetPasteboardBufferForType::Reply(newChangeCount), 0);
         }
     }
 }
index 19ea6c8..26edb2a 100644 (file)
@@ -409,12 +409,15 @@ String WebPlatformStrategies::stringForType(const String& pasteboardType, const
     return value;
 }
 
-void WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
+long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
 {
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::PasteboardCopy(fromPasteboard, toPasteboard), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::PasteboardCopy(fromPasteboard, toPasteboard),
+        Messages::WebContext::PasteboardCopy::Reply(newChangeCount), 0);
+    return newChangeCount;
 }
 
-int WebPlatformStrategies::changeCount(const WTF::String &pasteboardName)
+long WebPlatformStrategies::changeCount(const WTF::String &pasteboardName)
 {
     uint64_t changeCount;
     WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::GetPasteboardChangeCount(pasteboardName),
@@ -446,17 +449,23 @@ KURL WebPlatformStrategies::url(const String& pasteboardName)
     return KURL(ParsedURLString, urlString);
 }
 
-void WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
+long WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
 {
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::AddPasteboardTypes(pasteboardName, pasteboardTypes), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::AddPasteboardTypes(pasteboardName, pasteboardTypes),
+        Messages::WebContext::AddPasteboardTypes::Reply(newChangeCount), 0);
+    return newChangeCount;
 }
 
-void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
+long WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
 {
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes),
+        Messages::WebContext::SetPasteboardTypes::Reply(newChangeCount), 0);
+    return newChangeCount;
 }
 
-void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)
+long WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)
 {
     SharedMemory::Handle handle;
     if (buffer) {
@@ -464,17 +473,26 @@ void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, co
         memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
         sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly);
     }
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0),
+        Messages::WebContext::SetPasteboardBufferForType::Reply(newChangeCount), 0);
+    return newChangeCount;
 }
 
-void WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
+long WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
 {
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardPathnamesForType(pasteboardName, pasteboardType, pathnames), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardPathnamesForType(pasteboardName, pasteboardType, pathnames),
+        Messages::WebContext::SetPasteboardPathnamesForType::Reply(newChangeCount), 0);
+    return newChangeCount;
 }
 
-void WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)
+long WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)
 {
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardStringForType(pasteboardName, pasteboardType, string), 0);
+    uint64_t newChangeCount;
+    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(pasteboardName, pasteboardType, string),
+        Messages::WebContext::SetPasteboardStringForType::Reply(newChangeCount), 0);
+    return newChangeCount;
 }
 #endif
 
index daedc4d..9a009b8 100644 (file)
@@ -99,17 +99,17 @@ private:
     virtual PassRefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE;
     virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE;
-    virtual int changeCount(const String& pasteboardName) OVERRIDE;
+    virtual long changeCount(const String& pasteboardName) OVERRIDE;
     virtual String uniqueName() OVERRIDE;
     virtual WebCore::Color color(const String& pasteboardName) OVERRIDE;
     virtual WebCore::KURL url(const String& pasteboardName) OVERRIDE;
 
-    virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
-    virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
-    virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
-    virtual void setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
-    virtual void setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
-    virtual void setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
+    virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
+    virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
+    virtual long copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
+    virtual long setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
+    virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
+    virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
 #endif
 
 #if ENABLE(NETSCAPE_PLUGIN_API)