Changeset 154639 in webkit
- Timestamp:
- Aug 26, 2013 2:11:12 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154629 r154639 1 2013-08-26 Alexey Proskuryakov <ap@apple.com> 2 3 [Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail 4 https://bugs.webkit.org/show_bug.cgi?id=113094 5 6 Reviewed by Darin Adler. 7 8 Mac platform implementation has checks for pasteboard change count, but it 9 didn't use to update the count when writing to pasteboad from JavaScript. 10 11 * platform/PasteboardStrategy.h: Changed changeCount function to return a long 12 instead of an int, as the underlying Mac type is NSInteger. Changed all methods 13 that modify the pasteboard to return a new change count. 14 15 * platform/PlatformPasteboard.h: Changed all methods that modify the pasteboard 16 to return a new change count. 17 18 * platform/mac/PasteboardMac.mm: 19 (WebCore::Pasteboard::clear): Update m_changeCount. 20 (WebCore::Pasteboard::writeSelectionForTypes): Ditto. 21 (WebCore::Pasteboard::writePlainText): Ditto. 22 (WebCore::writeURLForTypes): Ditto. 23 (WebCore::Pasteboard::writeURL): Ditto. 24 (WebCore::writeFileWrapperAsRTFDAttachment): Ditto. 25 (WebCore::Pasteboard::writeImage): Ditto. 26 (WebCore::Pasteboard::writePasteboard): Ditto. 27 (WebCore::addHTMLClipboardTypesForCocoaType): Ditto. 28 (WebCore::Pasteboard::writeString): Ditto. 29 30 * platform/mac/PlatformPasteboardMac.mm: 31 (WebCore::PlatformPasteboard::changeCount): Changed returned type to long to avoid 32 data loss. 33 (WebCore::PlatformPasteboard::copy): Return new change count. 34 (WebCore::PlatformPasteboard::addTypes): Ditto. 35 (WebCore::PlatformPasteboard::setTypes): Ditto. 36 (WebCore::PlatformPasteboard::setBufferForType): Ditto. 37 (WebCore::PlatformPasteboard::setPathnamesForType): Ditto. 38 (WebCore::PlatformPasteboard::setStringForType): Ditto. Replaced -[NSURL writeToPasteboard:] 39 with an equivalent implemnentation that tells use whether writing was successful. 40 There is difference with invalid URL string handling - we used to silently ignore 41 such requets, but set pasteboard content to empty URL now. 42 1 43 2013-08-24 Sam Weinig <sam@webkit.org> 2 44 -
trunk/Source/WebCore/platform/PasteboardStrategy.h
r150104 r154639 44 44 virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) = 0; 45 45 virtual String stringForType(const String& pasteboardType, const String& pasteboardName) = 0; 46 virtual intchangeCount(const String& pasteboardName) = 0;46 virtual long changeCount(const String& pasteboardName) = 0; 47 47 virtual String uniqueName() = 0; 48 48 virtual Color color(const String& pasteboardName) = 0; 49 49 virtual KURL url(const String& pasteboardName) = 0; 50 50 51 virtual void copy(const String& fromPasteboard, const String& toPasteboard) = 0;52 virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;53 virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;54 virtual voidsetBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType, const String& pasteboardName) = 0;55 virtual voidsetPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0;56 virtual voidsetStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0;51 virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0; 52 virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0; 53 virtual long copy(const String& fromPasteboard, const String& toPasteboard) = 0; 54 virtual long setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType, const String& pasteboardName) = 0; 55 virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0; 56 virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0; 57 57 #endif 58 58 protected: -
trunk/Source/WebCore/platform/PlatformPasteboard.h
r123716 r154639 50 50 void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType); 51 51 String stringForType(const String& pasteboardType); 52 intchangeCount() const;52 long changeCount() const; 53 53 Color color(); 54 54 KURL url(); 55 56 void copy(const String& fromPasteboard); 57 void addTypes(const Vector<String>& pasteboardTypes); 58 void setTypes(const Vector<String>& pasteboardTypes); 59 void setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType); 60 void setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType); 61 void setStringForType(const String&, const String& pasteboardType); 55 56 // Take ownership of the pasteboard, and return new change count. 57 long addTypes(const Vector<String>& pasteboardTypes); 58 long setTypes(const Vector<String>& pasteboardTypes); 59 60 // These methods will return 0 if pasteboard ownership has been taken from us. 61 long copy(const String& fromPasteboard); 62 long setBufferForType(PassRefPtr<SharedBuffer>, const String& pasteboardType); 63 long setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType); 64 long setStringForType(const String&, const String& pasteboardType); 62 65 63 66 private: -
trunk/Source/WebCore/platform/mac/PasteboardMac.mm
r154578 r154639 156 156 void Pasteboard::clear() 157 157 { 158 platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName);158 m_changeCount = platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName); 159 159 } 160 160 … … 206 206 types.appendVector(clientTypes); 207 207 208 platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName);208 m_changeCount = platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName); 209 209 frame->editor().client()->didSetSelectionTypesForPasteboard(); 210 210 211 211 for (size_t i = 0; i < clientTypes.size(); ++i) 212 platformStrategies()->pasteboardStrategy()->setBufferForType(clientData[i], clientTypes[i], m_pasteboardName);212 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(clientData[i], clientTypes[i], m_pasteboardName); 213 213 214 214 // Put HTML on the pasteboard. 215 215 if (types.contains(WebArchivePboardType)) 216 platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, WebArchivePboardType), WebArchivePboardType, m_pasteboardName);216 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, WebArchivePboardType), WebArchivePboardType, m_pasteboardName); 217 217 218 218 // Put the attributed string on the pasteboard (RTF/RTFD format). 219 219 if (types.contains(String(NSRTFDPboardType))) 220 platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFDPboardType), NSRTFDPboardType, m_pasteboardName);220 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFDPboardType), NSRTFDPboardType, m_pasteboardName); 221 221 222 222 if (types.contains(String(NSRTFPboardType))) 223 platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFPboardType), NSRTFPboardType, m_pasteboardName);223 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFPboardType), NSRTFPboardType, m_pasteboardName); 224 224 225 225 // Put plain string on the pasteboard. … … 228 228 ? frame->editor().stringSelectionForPasteboardWithImageAltText() 229 229 : frame->editor().stringSelectionForPasteboard(); 230 platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);230 m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName); 231 231 } 232 232 233 233 if (types.contains(WebSmartPastePboardType)) 234 platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);234 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName); 235 235 } 236 236 … … 243 243 244 244 platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName); 245 platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);245 m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName); 246 246 if (smartReplaceOption == CanSmartReplace) 247 platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);247 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName); 248 248 } 249 249 … … 253 253 } 254 254 255 static voidwriteURLForTypes(const Vector<String>& types, const String& pasteboardName, const KURL& url, const String& titleStr, Frame* frame)256 { 257 platformStrategies()->pasteboardStrategy()->setTypes(types, pasteboardName);255 static long writeURLForTypes(const Vector<String>& types, const String& pasteboardName, const KURL& url, const String& titleStr, Frame* frame) 256 { 257 long newChangeCount = platformStrategies()->pasteboardStrategy()->setTypes(types, pasteboardName); 258 258 259 259 ASSERT(!url.isEmpty()); … … 272 272 paths.append([cocoaURL absoluteString]); 273 273 paths.append(titleStr.stripWhiteSpace()); 274 platformStrategies()->pasteboardStrategy()->setPathnamesForType(paths, WebURLsWithTitlesPboardType, pasteboardName);274 newChangeCount = platformStrategies()->pasteboardStrategy()->setPathnamesForType(paths, WebURLsWithTitlesPboardType, pasteboardName); 275 275 } 276 276 if (types.contains(String(NSURLPboardType))) 277 platformStrategies()->pasteboardStrategy()->setStringForType([cocoaURL absoluteString], NSURLPboardType, pasteboardName);277 newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType([cocoaURL absoluteString], NSURLPboardType, pasteboardName); 278 278 if (types.contains(WebURLPboardType)) 279 platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, WebURLPboardType, pasteboardName);279 newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, WebURLPboardType, pasteboardName); 280 280 if (types.contains(WebURLNamePboardType)) 281 platformStrategies()->pasteboardStrategy()->setStringForType(title, WebURLNamePboardType, pasteboardName);281 newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType(title, WebURLNamePboardType, pasteboardName); 282 282 if (types.contains(String(NSStringPboardType))) 283 platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, NSStringPboardType, pasteboardName); 283 newChangeCount = platformStrategies()->pasteboardStrategy()->setStringForType(userVisibleString, NSStringPboardType, pasteboardName); 284 285 return newChangeCount; 284 286 } 285 287 286 288 void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame) 287 289 { 288 writeURLForTypes(writableTypesForURL(), m_pasteboardName, url, titleStr, frame);290 m_changeCount = writeURLForTypes(writableTypesForURL(), m_pasteboardName, url, titleStr, frame); 289 291 } 290 292 … … 302 304 } 303 305 304 static void writeFileWrapperAsRTFDAttachment(NSFileWrapper* wrapper, const String& pasteboardName )306 static void writeFileWrapperAsRTFDAttachment(NSFileWrapper* wrapper, const String& pasteboardName, long& newChangeCount) 305 307 { 306 308 NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:wrapper]; … … 311 313 NSData *RTFDData = [string RTFDFromRange:NSMakeRange(0, [string length]) documentAttributes:nil]; 312 314 if (RTFDData) 313 platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(RTFDData).get(), NSRTFDPboardType, pasteboardName);315 newChangeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(RTFDData).get(), NSRTFDPboardType, pasteboardName); 314 316 } 315 317 … … 329 331 return; 330 332 331 writeURLForTypes(writableTypesForImage(), m_pasteboardName, cocoaURL, nsStringNilIfEmpty(title), node->document()->frame());333 m_changeCount = writeURLForTypes(writableTypesForImage(), m_pasteboardName, cocoaURL, nsStringNilIfEmpty(title), node->document()->frame()); 332 334 333 335 Image* image = cachedImage->imageForRenderer(renderer); … … 337 339 if (!imageData) 338 340 return; 339 platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(imageData), NSTIFFPboardType, m_pasteboardName);341 m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(imageData), NSTIFFPboardType, m_pasteboardName); 340 342 341 343 String MIMEType = cachedImage->response().mimeType(); 342 344 ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(MIMEType)); 343 345 344 writeFileWrapperAsRTFDAttachment(fileWrapperForImage(cachedImage, cocoaURL), m_pasteboardName );346 writeFileWrapperAsRTFDAttachment(fileWrapperForImage(cachedImage, cocoaURL), m_pasteboardName, m_changeCount); 345 347 } 346 348 347 349 void Pasteboard::writePasteboard(const Pasteboard& pasteboard) 348 350 { 349 platformStrategies()->pasteboardStrategy()->copy(pasteboard.m_pasteboardName, m_pasteboardName);351 m_changeCount = platformStrategies()->pasteboardStrategy()->copy(pasteboard.m_pasteboardName, m_pasteboardName); 350 352 } 351 353 … … 653 655 if (cocoaType.isEmpty()) 654 656 return; 655 platformStrategies()->pasteboardStrategy()->setStringForType(emptyString(), cocoaType, m_pasteboardName);657 m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(emptyString(), cocoaType, m_pasteboardName); 656 658 } 657 659 … … 762 764 return; 763 765 } 764 // No mapping, just pass the whole string th ough766 // No mapping, just pass the whole string through. 765 767 resultTypes.add(cocoaType); 766 768 } … … 779 781 types.append(cocoaType); 780 782 platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName); 781 platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName);783 m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName); 782 784 783 785 return true; … … 789 791 types.append(cocoaType); 790 792 platformStrategies()->pasteboardStrategy()->addTypes(types, m_pasteboardName); 791 platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName);793 m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(cocoaData, cocoaType, m_pasteboardName); 792 794 return true; 793 795 } -
trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm
r149255 r154639 72 72 } 73 73 74 intPlatformPasteboard::changeCount() const74 long PlatformPasteboard::changeCount() const 75 75 { 76 76 return [m_pasteboard.get() changeCount]; … … 100 100 } 101 101 102 voidPlatformPasteboard::copy(const String& fromPasteboard)102 long PlatformPasteboard::copy(const String& fromPasteboard) 103 103 { 104 104 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:fromPasteboard]; … … 108 108 for (NSUInteger i = 0; i < [types count]; i++) { 109 109 NSString* type = [types objectAtIndex:i]; 110 [m_pasteboard.get() setData:[pasteboard dataForType:type] forType:type]; 110 if (![m_pasteboard.get() setData:[pasteboard dataForType:type] forType:type]) 111 return 0; 111 112 } 113 return changeCount(); 112 114 } 113 115 114 voidPlatformPasteboard::addTypes(const Vector<String>& pasteboardTypes)116 long PlatformPasteboard::addTypes(const Vector<String>& pasteboardTypes) 115 117 { 116 118 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] init]); … … 118 120 [types.get() addObject:pasteboardTypes[i]]; 119 121 120 [m_pasteboard.get() addTypes:types.get() owner:nil];122 return [m_pasteboard.get() addTypes:types.get() owner:nil]; 121 123 } 122 124 123 voidPlatformPasteboard::setTypes(const Vector<String>& pasteboardTypes)125 long PlatformPasteboard::setTypes(const Vector<String>& pasteboardTypes) 124 126 { 125 if (pasteboardTypes.isEmpty()) { 126 [m_pasteboard.get() declareTypes:nil owner:nil]; 127 return; 128 } 127 if (pasteboardTypes.isEmpty()) 128 return [m_pasteboard.get() declareTypes:nil owner:nil]; 129 129 130 130 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] init]); … … 132 132 [types.get() addObject:pasteboardTypes[i]]; 133 133 134 [m_pasteboard.get() declareTypes:types.get() owner:nil];134 return [m_pasteboard.get() declareTypes:types.get() owner:nil]; 135 135 } 136 136 137 voidPlatformPasteboard::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType)137 long PlatformPasteboard::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType) 138 138 { 139 [m_pasteboard.get() setData:buffer ? [buffer->createNSData() autorelease] : nil forType:pasteboardType]; 139 BOOL didWriteData = [m_pasteboard.get() setData:buffer ? [buffer->createNSData() autorelease] : nil forType:pasteboardType]; 140 if (!didWriteData) 141 return 0; 142 return changeCount(); 140 143 } 141 144 142 voidPlatformPasteboard::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType)145 long PlatformPasteboard::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType) 143 146 { 144 147 RetainPtr<NSMutableArray> paths = adoptNS([[NSMutableArray alloc] init]); 145 148 for (size_t i = 0; i < pathnames.size(); ++i) 146 [paths.get() addObject: [NSArray arrayWithObject:pathnames[i]]]; 147 [m_pasteboard.get() setPropertyList:paths.get() forType:pasteboardType]; 149 [paths.get() addObject:[NSArray arrayWithObject:pathnames[i]]]; 150 BOOL didWriteData = [m_pasteboard.get() setPropertyList:paths.get() forType:pasteboardType]; 151 if (!didWriteData) 152 return 0; 153 return changeCount(); 148 154 } 149 155 150 voidPlatformPasteboard::setStringForType(const String& string, const String& pasteboardType)156 long PlatformPasteboard::setStringForType(const String& string, const String& pasteboardType) 151 157 { 152 if (pasteboardType == String(NSURLPboardType)) 153 [[NSURL URLWithString:string] writeToPasteboard:m_pasteboard.get()]; 154 else 155 [m_pasteboard.get() setString:string forType:pasteboardType]; 158 BOOL didWriteData; 159 160 if (pasteboardType == String(NSURLPboardType)) { 161 // We cannot just use -NSPasteboard writeObjects:], because -declareTypes has been already called, implicitly creating an item. 162 NSURL *url = [NSURL URLWithString:string]; 163 if ([[m_pasteboard.get() types] containsObject:NSURLPboardType]) { 164 NSURL *base = [url baseURL]; 165 if (base) 166 didWriteData = [m_pasteboard.get() setPropertyList:@[[url relativeString], [base absoluteString]] forType:NSURLPboardType]; 167 else if (url) 168 didWriteData = [m_pasteboard.get() setPropertyList:@[[url absoluteString], @""] forType:NSURLPboardType]; 169 else 170 didWriteData = [m_pasteboard.get() setPropertyList:@[@"", @""] forType:NSURLPboardType]; 171 172 if (!didWriteData) 173 return 0; 174 } 175 176 if ([[m_pasteboard.get() types] containsObject:(NSString *)kUTTypeURL]) { 177 didWriteData = [m_pasteboard.get() setString:[url absoluteString] forType:(NSString *)kUTTypeURL]; 178 if (!didWriteData) 179 return 0; 180 } 181 182 if ([[m_pasteboard.get() types] containsObject:(NSString *)kUTTypeFileURL] && [url isFileURL]) { 183 didWriteData = [m_pasteboard.get() setString:[url absoluteString] forType:(NSString *)kUTTypeFileURL]; 184 if (!didWriteData) 185 return 0; 186 } 187 188 } else { 189 didWriteData = [m_pasteboard.get() setString:string forType:pasteboardType]; 190 if (!didWriteData) 191 return 0; 192 } 193 194 return changeCount(); 156 195 } 157 196 -
trunk/Source/WebKit/mac/ChangeLog
r154620 r154639 1 2013-08-26 Alexey Proskuryakov <ap@apple.com> 2 3 [Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail 4 https://bugs.webkit.org/show_bug.cgi?id=113094 5 6 Reviewed by Darin Adler. 7 8 Return new pasteboard change count from all functions that change it. 9 10 * WebCoreSupport/WebPlatformStrategies.h: 11 * WebCoreSupport/WebPlatformStrategies.mm: 12 (WebPlatformStrategies::copy): 13 (WebPlatformStrategies::changeCount): 14 (WebPlatformStrategies::addTypes): 15 (WebPlatformStrategies::setTypes): 16 (WebPlatformStrategies::setBufferForType): 17 (WebPlatformStrategies::setPathnamesForType): 18 (WebPlatformStrategies::setStringForType): 19 1 20 2013-08-26 Andreas Kling <akling@apple.com> 2 21 -
trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
r149035 r154639 84 84 virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 85 85 virtual String stringForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE; 86 virtual intchangeCount(const String& pasteboardName) OVERRIDE;86 virtual long changeCount(const String& pasteboardName) OVERRIDE; 87 87 virtual String uniqueName() OVERRIDE; 88 88 virtual WebCore::Color color(const String& pasteboardName) OVERRIDE; 89 89 virtual WebCore::KURL url(const String& pasteboardName) OVERRIDE; 90 90 91 virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;92 virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;93 virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;94 virtual voidsetBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;95 virtual voidsetPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;96 virtual voidsetStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;91 virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE; 92 virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE; 93 virtual long copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE; 94 virtual long setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 95 virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 96 virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 97 97 }; 98 98 -
trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
r154142 r154639 175 175 } 176 176 177 voidWebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)178 { 179 PlatformPasteboard(toPasteboard).copy(fromPasteboard);180 } 181 182 intWebPlatformStrategies::changeCount(const String &pasteboardName)177 long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard) 178 { 179 return PlatformPasteboard(toPasteboard).copy(fromPasteboard); 180 } 181 182 long WebPlatformStrategies::changeCount(const String &pasteboardName) 183 183 { 184 184 return PlatformPasteboard(pasteboardName).changeCount(); … … 200 200 } 201 201 202 voidWebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)203 { 204 PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);205 } 206 207 voidWebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)208 { 209 PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);210 } 211 212 voidWebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)213 { 214 PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);215 } 216 217 voidWebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)218 { 219 PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);220 } 221 222 voidWebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)223 { 224 PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);225 } 202 long WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 203 { 204 return PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes); 205 } 206 207 long WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 208 { 209 return PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes); 210 } 211 212 long WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName) 213 { 214 return PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType); 215 } 216 217 long WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) 218 { 219 return PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType); 220 } 221 222 long WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName) 223 { 224 return PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType); 225 } -
trunk/Source/WebKit2/ChangeLog
r154620 r154639 1 2013-08-26 Alexey Proskuryakov <ap@apple.com> 2 3 [Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail 4 https://bugs.webkit.org/show_bug.cgi?id=113094 5 6 Reviewed by Darin Adler. 7 8 Return new pasteboard change count from all functions that change it. 9 10 * UIProcess/WebContext.h: 11 * UIProcess/WebContext.messages.in: 12 * UIProcess/mac/WebContextMac.mm: 13 (WebKit::WebContext::pasteboardCopy): 14 (WebKit::WebContext::addPasteboardTypes): 15 (WebKit::WebContext::setPasteboardTypes): 16 (WebKit::WebContext::setPasteboardPathnamesForType): 17 (WebKit::WebContext::setPasteboardStringForType): 18 (WebKit::WebContext::setPasteboardBufferForType): 19 * WebProcess/Plugins/PDF/PDFPlugin.mm: 20 (WebKit::PDFPlugin::writeItemsToPasteboard): 21 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 22 (WebKit::WebPlatformStrategies::copy): 23 (WebKit::WebPlatformStrategies::changeCount): 24 (WebKit::WebPlatformStrategies::addTypes): 25 (WebKit::WebPlatformStrategies::setTypes): 26 (WebKit::WebPlatformStrategies::setBufferForType): 27 (WebKit::WebPlatformStrategies::setPathnamesForType): 28 (WebKit::WebPlatformStrategies::setStringForType): 29 * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 30 1 31 2013-08-26 Andreas Kling <akling@apple.com> 2 32 -
trunk/Source/WebKit2/UIProcess/WebContext.h
r154144 r154639 324 324 void getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, String&); 325 325 void getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, SharedMemory::Handle&, uint64_t& size); 326 void pasteboardCopy(const String& fromPasteboard, const String& toPasteboard );326 void pasteboardCopy(const String& fromPasteboard, const String& toPasteboard, uint64_t& newChangeCount); 327 327 void getPasteboardChangeCount(const String& pasteboardName, uint64_t& changeCount); 328 328 void getPasteboardUniqueName(String& pasteboardName); 329 329 void getPasteboardColor(const String& pasteboardName, WebCore::Color&); 330 330 void getPasteboardURL(const String& pasteboardName, WTF::String&); 331 void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes );332 void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes );333 void setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames );334 void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& );335 void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size );331 void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount); 332 void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount); 333 void setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames, uint64_t& newChangeCount); 334 void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, uint64_t& newChangeCount); 335 void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount); 336 336 #endif 337 337 -
trunk/Source/WebKit2/UIProcess/WebContext.messages.in
r142651 r154639 35 35 GetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (WTF::String string) 36 36 GetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) 37 PasteboardCopy(WTF::String fromPasteboard, WTF::String toPasteboard) 37 PasteboardCopy(WTF::String fromPasteboard, WTF::String toPasteboard) -> (uint64_t changeCount) 38 38 GetPasteboardChangeCount(WTF::String pasteboardName) -> (uint64_t changeCount) 39 39 GetPasteboardUniqueName() -> (WTF::String pasteboardName) 40 40 GetPasteboardColor(WTF::String pasteboardName) -> (WebCore::Color color) 41 41 GetPasteboardURL(WTF::String pasteboardName) -> (WTF::String urlString) 42 AddPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) 43 SetPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) 44 SetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType, Vector<WTF::String> pathnames) 45 SetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType, WTF::String string) 46 SetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) 42 AddPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) -> (uint64_t changeCount) 43 SetPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) -> (uint64_t changeCount) 44 SetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType, Vector<WTF::String> pathnames) -> (uint64_t changeCount) 45 SetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType, WTF::String string) -> (uint64_t changeCount) 46 SetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (uint64_t changeCount) 47 47 #endif 48 48 -
trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm
r154302 r154639 404 404 } 405 405 406 void WebContext::pasteboardCopy(const String& fromPasteboard, const String& toPasteboard )407 { 408 PlatformPasteboard(toPasteboard).copy(fromPasteboard);406 void WebContext::pasteboardCopy(const String& fromPasteboard, const String& toPasteboard, uint64_t& newChangeCount) 407 { 408 newChangeCount = PlatformPasteboard(toPasteboard).copy(fromPasteboard); 409 409 } 410 410 … … 429 429 } 430 430 431 void WebContext::addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes )432 { 433 PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes);434 } 435 436 void WebContext::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes )437 { 438 PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);439 } 440 441 void WebContext::setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames )442 { 443 PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);444 } 445 446 void WebContext::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string )447 { 448 PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);449 } 450 451 void WebContext::setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size )431 void WebContext::addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount) 432 { 433 newChangeCount = PlatformPasteboard(pasteboardName).addTypes(pasteboardTypes); 434 } 435 436 void WebContext::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount) 437 { 438 newChangeCount = PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes); 439 } 440 441 void WebContext::setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames, uint64_t& newChangeCount) 442 { 443 newChangeCount = PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType); 444 } 445 446 void WebContext::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string, uint64_t& newChangeCount) 447 { 448 newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType); 449 } 450 451 void WebContext::setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, uint64_t& newChangeCount) 452 452 { 453 453 if (handle.isNull()) { 454 PlatformPasteboard(pasteboardName).setBufferForType(0, pasteboardType);454 newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(0, pasteboardType); 455 455 return; 456 456 } 457 457 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly); 458 458 RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size); 459 PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);459 newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType); 460 460 } 461 461 -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
r154142 r154639 1642 1642 pasteboardTypes.append(type); 1643 1643 1644 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes), 0); 1644 uint64_t newChangeCount; 1645 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes), 1646 Messages::WebContext::SetPasteboardTypes::Reply(newChangeCount), 0); 1645 1647 1646 1648 for (NSUInteger i = 0, count = items.count; i < count; ++i) { … … 1656 1658 if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) { 1657 1659 RetainPtr<NSString> plainTextString = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); 1658 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()), 0); 1660 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()), 1661 Messages::WebContext::SetPasteboardStringForType::Reply(newChangeCount), 0); 1659 1662 } else { 1660 1663 RefPtr<SharedBuffer> buffer = SharedBuffer::wrapNSData(data); … … 1667 1670 memcpy(sharedMemory->data(), buffer->data(), buffer->size()); 1668 1671 sharedMemory->createHandle(handle, SharedMemory::ReadOnly); 1669 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()), 0); 1672 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()), 1673 Messages::WebContext::SetPasteboardBufferForType::Reply(newChangeCount), 0); 1670 1674 } 1671 1675 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r154490 r154639 410 410 } 411 411 412 void WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard) 413 { 414 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::PasteboardCopy(fromPasteboard, toPasteboard), 0); 415 } 416 417 int WebPlatformStrategies::changeCount(const WTF::String &pasteboardName) 412 long WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard) 413 { 414 uint64_t newChangeCount; 415 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::PasteboardCopy(fromPasteboard, toPasteboard), 416 Messages::WebContext::PasteboardCopy::Reply(newChangeCount), 0); 417 return newChangeCount; 418 } 419 420 long WebPlatformStrategies::changeCount(const WTF::String &pasteboardName) 418 421 { 419 422 uint64_t changeCount; … … 447 450 } 448 451 449 void WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 450 { 451 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::AddPasteboardTypes(pasteboardName, pasteboardTypes), 0); 452 } 453 454 void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 455 { 456 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes), 0); 457 } 458 459 void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName) 452 long WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 453 { 454 uint64_t newChangeCount; 455 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::AddPasteboardTypes(pasteboardName, pasteboardTypes), 456 Messages::WebContext::AddPasteboardTypes::Reply(newChangeCount), 0); 457 return newChangeCount; 458 } 459 460 long WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 461 { 462 uint64_t newChangeCount; 463 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes), 464 Messages::WebContext::SetPasteboardTypes::Reply(newChangeCount), 0); 465 return newChangeCount; 466 } 467 468 long WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName) 460 469 { 461 470 SharedMemory::Handle handle; … … 465 474 sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly); 466 475 } 467 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0), 0); 468 } 469 470 void WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) 471 { 472 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardPathnamesForType(pasteboardName, pasteboardType, pathnames), 0); 473 } 474 475 void WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName) 476 { 477 WebProcess::shared().parentProcessConnection()->send(Messages::WebContext::SetPasteboardStringForType(pasteboardName, pasteboardType, string), 0); 476 uint64_t newChangeCount; 477 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0), 478 Messages::WebContext::SetPasteboardBufferForType::Reply(newChangeCount), 0); 479 return newChangeCount; 480 } 481 482 long WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) 483 { 484 uint64_t newChangeCount; 485 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardPathnamesForType(pasteboardName, pasteboardType, pathnames), 486 Messages::WebContext::SetPasteboardPathnamesForType::Reply(newChangeCount), 0); 487 return newChangeCount; 488 } 489 490 long WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName) 491 { 492 uint64_t newChangeCount; 493 WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(pasteboardName, pasteboardType, string), 494 Messages::WebContext::SetPasteboardStringForType::Reply(newChangeCount), 0); 495 return newChangeCount; 478 496 } 479 497 #endif -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
r153877 r154639 100 100 virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 101 101 virtual String stringForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE; 102 virtual intchangeCount(const String& pasteboardName) OVERRIDE;102 virtual long changeCount(const String& pasteboardName) OVERRIDE; 103 103 virtual String uniqueName() OVERRIDE; 104 104 virtual WebCore::Color color(const String& pasteboardName) OVERRIDE; 105 105 virtual WebCore::KURL url(const String& pasteboardName) OVERRIDE; 106 106 107 virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;108 virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;109 virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;110 virtual voidsetBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;111 virtual voidsetPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;112 virtual voidsetStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;107 virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE; 108 virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE; 109 virtual long copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE; 110 virtual long setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 111 virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 112 virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) OVERRIDE; 113 113 #endif 114 114
Note: See TracChangeset
for help on using the changeset viewer.