Changeset 265720 in webkit
- Timestamp:
- Aug 14, 2020, 5:16:57 PM (5 years ago)
- Location:
- branches/safari-610.1-branch/Source/WebKit
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-610.1-branch/Source/WebKit/ChangeLog
r265717 r265720 1 2020-08-14 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r265702. rdar://problem/67106079 4 5 Convert SharedMemory::Handle to SharedMemory::IPCHandle WebPage image/pasteboard functions 6 https://bugs.webkit.org/show_bug.cgi?id=215478 7 <rdar://problem/67024582> 8 9 Reviewed by Chris Dumez. 10 11 Convert SharedMemory::Handle objects to SharedMemory::IPCHandle 12 objects which automatically verify the size of data being sent. 13 14 We can remove the additional size parameter being sent in many IPC 15 messages along with the handle, now that both are stored in the 16 IPCHandle struct. 17 18 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 19 (WebKit::WebPageProxy::setPromisedDataForImage): 20 * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: 21 (WebKit::WebPasteboardProxy::getPasteboardBufferForType): 22 No longer need size check, this is done in the IPCHandle::decode() 23 function. 24 (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 25 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 26 * UIProcess/WebPageProxy.h: 27 * UIProcess/WebPageProxy.messages.in: 28 * UIProcess/WebPasteboardProxy.cpp: 29 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 30 * UIProcess/WebPasteboardProxy.h: 31 * UIProcess/WebPasteboardProxy.messages.in: 32 * UIProcess/ios/WebPageProxyIOS.mm: 33 (WebKit::WebPageProxy::saveImageToLibrary): 34 * UIProcess/mac/WebPageProxyMac.mm: 35 (WebKit::WebPageProxy::dataSelectionForPasteboard): 36 No longer need size check, this is done in the IPCHandle::decode() 37 function. 38 (WebKit::WebPageProxy::setPromisedDataForImage): 39 * WebProcess/Plugins/PDF/PDFPlugin.mm: 40 (WebKit::PDFPlugin::writeItemsToPasteboard): 41 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 42 (WebKit::WebPlatformStrategies::bufferForType): 43 (WebKit::WebPlatformStrategies::setBufferForType): 44 (WebKit::WebPlatformStrategies::readBufferFromPasteboard): 45 No longer need size check, this is done in the IPCHandle::decode() 46 function. 47 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 48 (WebKit::WebDragClient::declareAndWriteDragImage): 49 * WebProcess/WebPage/WebPage.h: 50 * WebProcess/WebPage/WebPage.messages.in: 51 * WebProcess/WebPage/ios/WebPageIOS.mm: 52 (WebKit::WebPage::getDataSelectionForPasteboard): 53 (WebKit::WebPage::performActionOnElement): 54 * WebProcess/WebPage/mac/WebPageMac.mm: 55 (WebKit::WebPage::getDataSelectionForPasteboard): 56 57 58 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265702 268f45cc-cd09-0410-ab3c-d52691b4dbfc 59 60 2020-08-14 Kate Cheney <katherine_cheney@apple.com> 61 62 Convert SharedMemory::Handle to SharedMemory::IPCHandle WebPage image/pasteboard functions 63 https://bugs.webkit.org/show_bug.cgi?id=215478 64 <rdar://problem/67024582> 65 66 Reviewed by Chris Dumez. 67 68 Convert SharedMemory::Handle objects to SharedMemory::IPCHandle 69 objects which automatically verify the size of data being sent. 70 71 We can remove the additional size parameter being sent in many IPC 72 messages along with the handle, now that both are stored in the 73 IPCHandle struct. 74 75 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 76 (WebKit::WebPageProxy::setPromisedDataForImage): 77 * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: 78 (WebKit::WebPasteboardProxy::getPasteboardBufferForType): 79 No longer need size check, this is done in the IPCHandle::decode() 80 function. 81 (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 82 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 83 * UIProcess/WebPageProxy.h: 84 * UIProcess/WebPageProxy.messages.in: 85 * UIProcess/WebPasteboardProxy.cpp: 86 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 87 * UIProcess/WebPasteboardProxy.h: 88 * UIProcess/WebPasteboardProxy.messages.in: 89 * UIProcess/ios/WebPageProxyIOS.mm: 90 (WebKit::WebPageProxy::saveImageToLibrary): 91 * UIProcess/mac/WebPageProxyMac.mm: 92 (WebKit::WebPageProxy::dataSelectionForPasteboard): 93 No longer need size check, this is done in the IPCHandle::decode() 94 function. 95 (WebKit::WebPageProxy::setPromisedDataForImage): 96 * WebProcess/Plugins/PDF/PDFPlugin.mm: 97 (WebKit::PDFPlugin::writeItemsToPasteboard): 98 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 99 (WebKit::WebPlatformStrategies::bufferForType): 100 (WebKit::WebPlatformStrategies::setBufferForType): 101 (WebKit::WebPlatformStrategies::readBufferFromPasteboard): 102 No longer need size check, this is done in the IPCHandle::decode() 103 function. 104 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 105 (WebKit::WebDragClient::declareAndWriteDragImage): 106 * WebProcess/WebPage/WebPage.h: 107 * WebProcess/WebPage/WebPage.messages.in: 108 * WebProcess/WebPage/ios/WebPageIOS.mm: 109 (WebKit::WebPage::getDataSelectionForPasteboard): 110 (WebKit::WebPage::performActionOnElement): 111 * WebProcess/WebPage/mac/WebPageMac.mm: 112 (WebKit::WebPage::getDataSelectionForPasteboard): 113 1 114 2020-08-14 Alan Coon <alancoon@apple.com> 2 115 -
branches/safari-610.1-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r264283 r265720 218 218 #if PLATFORM(IOS_FAMILY) 219 219 220 void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory:: Handle&, uint64_t, const String&, const String&, const String&, const String&, const String&, const SharedMemory::Handle&, uint64_t)220 void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::IPCHandle&, const String&, const String&, const String&, const String&, const String&, const SharedMemory::IPCHandle&) 221 221 { 222 222 notImplemented(); -
branches/safari-610.1-branch/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
r261263 r265720 195 195 } 196 196 197 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t)>&& completionHandler)198 { 199 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ } , 0));200 201 if (!canAccessPasteboardData(connection, pasteboardName)) 202 return completionHandler({ } , 0);197 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 198 { 199 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ })); 200 201 if (!canAccessPasteboardData(connection, pasteboardName)) 202 return completionHandler({ }); 203 203 204 204 RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).bufferForType(pasteboardType); 205 205 if (!buffer) 206 return completionHandler({ } , 0);206 return completionHandler({ }); 207 207 uint64_t size = buffer->size(); 208 208 if (!size) 209 return completionHandler({ } , 0);209 return completionHandler({ }); 210 210 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size); 211 211 if (!sharedMemoryBuffer) 212 return completionHandler({ } , 0);212 return completionHandler({ }); 213 213 memcpy(sharedMemoryBuffer->data(), buffer->data(), size); 214 214 SharedMemory::Handle handle; 215 215 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 216 completionHandler( WTFMove(handle), size);216 completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size }); 217 217 } 218 218 … … 319 319 } 320 320 321 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory:: Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)321 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::IPCHandle& ipcHandle, CompletionHandler<void(int64_t)>&& completionHandler) 322 322 { 323 323 MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0)); … … 325 325 326 326 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 327 if ( handle.isNull()) {327 if (ipcHandle.handle.isNull()) { 328 328 auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType); 329 329 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); … … 331 331 } 332 332 333 // SharedMemory::Handle::size() is rounded up to the nearest page. 334 MESSAGE_CHECK_COMPLETION(size <= handle.size(), completionHandler(0)); 335 336 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 333 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly); 337 334 if (!sharedMemoryBuffer) 338 335 return completionHandler(0); 339 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>( size));336 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(ipcHandle.dataSize)); 340 337 auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType); 341 338 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); … … 415 412 } 416 413 417 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t size)>&& completionHandler)418 { 419 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ } , 0));420 421 if (!canAccessPasteboardData(connection, pasteboardName)) 422 return completionHandler({ } , 0);414 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 415 { 416 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ })); 417 418 if (!canAccessPasteboardData(connection, pasteboardName)) 419 return completionHandler({ }); 423 420 424 421 RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).readBuffer(index, pasteboardType); 425 422 if (!buffer) 426 return completionHandler({ } , 0);423 return completionHandler({ }); 427 424 uint64_t size = buffer->size(); 428 425 if (!size) 429 return completionHandler({ } , 0);426 return completionHandler({ }); 430 427 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size); 431 428 if (!sharedMemoryBuffer) 432 return completionHandler({ } , 0);429 return completionHandler({ }); 433 430 memcpy(sharedMemoryBuffer->data(), buffer->data(), size); 434 431 SharedMemory::Handle handle; 435 432 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 436 completionHandler( WTFMove(handle), size);433 completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size }); 437 434 } 438 435 -
branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPageProxy.h
r265717 r265720 792 792 void stopInteraction(); 793 793 void performActionOnElement(uint32_t action); 794 void saveImageToLibrary(const SharedMemory:: Handle& imageHandle, uint64_t imageSize);794 void saveImageToLibrary(const SharedMemory::IPCHandle& imageHandle); 795 795 void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& = [] { }); 796 796 void setFocusedElementValue(const String&); … … 1173 1173 #if PLATFORM(COCOA) 1174 1174 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& dragImageHandle); 1175 void setPromisedDataForImage(const String& pasteboardName, const SharedMemory:: Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,1176 const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize);1175 void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::IPCHandle& imageHandle, const String& filename, const String& extension, 1176 const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle); 1177 1177 #endif 1178 1178 #if PLATFORM(GTK) -
branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in
r264602 r265720 182 182 InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous 183 183 DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information) 184 SaveImageToLibrary(WebKit::SharedMemory:: Handle handle, uint64_t size)184 SaveImageToLibrary(WebKit::SharedMemory::IPCHandle handle) 185 185 ShowPlaybackTargetPicker(bool hasVideo, WebCore::IntRect elementRect, enum:uint8_t WebCore::RouteSharingPolicy policy, String routingContextUID) 186 186 CommitPotentialTapFailed() … … 314 314 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT) 315 315 StartDrag(struct WebCore::DragItem dragItem, WebKit::ShareableBitmap::Handle dragImage) 316 SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory:: Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)316 SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::IPCHandle imageHandle, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::IPCHandle archiveHandle) 317 317 #endif 318 318 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT) -
branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPasteboardProxy.cpp
r261792 r265720 112 112 } 113 113 114 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t size)>&& completionHandler)114 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 115 115 { 116 completionHandler({ } , 0);116 completionHandler({ }); 117 117 } 118 118 -
branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPasteboardProxy.h
r261802 r265720 98 98 void getPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&&); 99 99 void getPasteboardStringsForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&&); 100 void getPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t)>&&);100 void getPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::IPCHandle&&)>&&); 101 101 void getPasteboardChangeCount(const String& pasteboardName, CompletionHandler<void(int64_t)>&&); 102 102 void getPasteboardColor(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&&); … … 107 107 void setPasteboardColor(IPC::Connection&, const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&); 108 108 void setPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&); 109 void setPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const SharedMemory:: Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&);109 void setPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const SharedMemory::IPCHandle&, CompletionHandler<void(int64_t)>&&); 110 110 #endif 111 111 112 112 void readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&&); 113 113 void readURLFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&); 114 void readBufferFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t size)>&&);114 void readBufferFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::IPCHandle&&)>&&); 115 115 void getPasteboardItemsCount(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(uint64_t)>&&); 116 116 void informationForItemAtIndex(IPC::Connection&, size_t index, const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<WebCore::PasteboardItemInfo>&&)>&&); -
branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
r261802 r265720 37 37 ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) Synchronous WantsConnection 38 38 ReadURLFromPasteboard(uint64_t index, String pasteboardName) -> (String url, String title) Synchronous WantsConnection 39 ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory:: Handle handle, uint64_t size) Synchronous WantsConnection39 ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous WantsConnection 40 40 ContainsStringSafeForDOMToReadForType(String type, String pasteboardName) -> (bool result) Synchronous WantsConnection 41 41 … … 47 47 GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string) Synchronous WantsConnection 48 48 GetPasteboardStringsForType(String pasteboardName, String pasteboardType) -> (Vector<String> strings) Synchronous WantsConnection 49 GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory:: Handle handle, uint64_t size) Synchronous WantsConnection49 GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous WantsConnection 50 50 GetPasteboardChangeCount(String pasteboardName) -> (int64_t changeCount) Synchronous 51 51 GetPasteboardColor(String pasteboardName) -> (WebCore::Color color) Synchronous WantsConnection … … 56 56 SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous WantsConnection 57 57 SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous WantsConnection 58 SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory:: Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous WantsConnection58 SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::IPCHandle handle) -> (int64_t changeCount) Synchronous WantsConnection 59 59 ContainsURLStringSuitableForLoading(String pasteboardName) -> (bool result) Synchronous WantsConnection 60 60 URLStringSuitableForLoading(String pasteboardName) -> (String url, String title) Synchronous WantsConnection -
branches/safari-610.1-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r265163 r265720 667 667 } 668 668 669 void WebPageProxy::saveImageToLibrary(const SharedMemory::Handle& imageHandle, uint64_t imageSize) 670 { 671 MESSAGE_CHECK(!imageHandle.isNull()); 672 // SharedMemory::Handle::size() is rounded up to the nearest page. 673 MESSAGE_CHECK(imageSize && imageSize <= imageHandle.size()); 674 675 auto sharedMemoryBuffer = SharedMemory::map(imageHandle, SharedMemory::Protection::ReadOnly); 669 void WebPageProxy::saveImageToLibrary(const SharedMemory::IPCHandle& imageHandle) 670 { 671 MESSAGE_CHECK(!imageHandle.handle.isNull()); 672 673 auto sharedMemoryBuffer = SharedMemory::map(imageHandle.handle, SharedMemory::Protection::ReadOnly); 676 674 if (!sharedMemoryBuffer) 677 675 return; 678 676 679 auto buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), static_cast<size_t>(image Size));677 auto buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), static_cast<size_t>(imageHandle.dataSize)); 680 678 pageClient().saveImageToLibrary(WTFMove(buffer)); 681 679 } -
branches/safari-610.1-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r265158 r265720 250 250 if (!hasRunningProcess()) 251 251 return nullptr; 252 SharedMemory::Handle handle; 252 253 SharedMemory::IPCHandle ipcHandle; 253 254 uint64_t size = 0; 254 255 const Seconds messageTimeout(20); 255 sendSync(Messages::WebPage::GetDataSelectionForPasteboard(pasteboardType), Messages::WebPage::GetDataSelectionForPasteboard::Reply(handle, size), messageTimeout); 256 MESSAGE_CHECK_WITH_RETURN_VALUE(!handle.isNull(), nullptr); 257 // SharedMemory::Handle::size() is rounded up to the nearest page. 258 MESSAGE_CHECK_WITH_RETURN_VALUE(size <= handle.size(), nullptr); 259 260 auto sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 256 sendSync(Messages::WebPage::GetDataSelectionForPasteboard(pasteboardType), Messages::WebPage::GetDataSelectionForPasteboard::Reply(ipcHandle), messageTimeout); 257 MESSAGE_CHECK_WITH_RETURN_VALUE(!ipcHandle.handle.isNull(), nullptr); 258 259 auto sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly); 261 260 if (!sharedMemoryBuffer) 262 261 return nullptr; … … 284 283 #if ENABLE(DRAG_SUPPORT) 285 284 286 void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory:: Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,287 const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize)285 void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory::IPCHandle& imageHandle, const String& filename, const String& extension, 286 const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle) 288 287 { 289 288 MESSAGE_CHECK_URL(url); 290 289 MESSAGE_CHECK_URL(visibleURL); 291 MESSAGE_CHECK(!imageHandle.isNull()); 292 // SharedMemory::Handle::size() is rounded up to the nearest page. 293 MESSAGE_CHECK(imageSize && imageSize <= imageHandle.size()); 294 295 auto sharedMemoryImage = SharedMemory::map(imageHandle, SharedMemory::Protection::ReadOnly); 290 MESSAGE_CHECK(!imageHandle.handle.isNull()); 291 292 auto sharedMemoryImage = SharedMemory::map(imageHandle.handle, SharedMemory::Protection::ReadOnly); 296 293 if (!sharedMemoryImage) 297 294 return; 298 295 299 auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), static_cast<size_t>(image Size));296 auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), static_cast<size_t>(imageHandle.dataSize)); 300 297 RefPtr<SharedBuffer> archiveBuffer; 301 298 302 if (!archiveHandle.isNull()) { 303 // SharedMemory::Handle::size() is rounded up to the nearest page. 304 MESSAGE_CHECK(archiveSize && archiveSize <= archiveHandle.size()); 305 auto sharedMemoryArchive = SharedMemory::map(archiveHandle, SharedMemory::Protection::ReadOnly); 299 if (!archiveHandle.handle.isNull()) { 300 auto sharedMemoryArchive = SharedMemory::map(archiveHandle.handle, SharedMemory::Protection::ReadOnly); 306 301 if (!sharedMemoryArchive) 307 302 return; 308 archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archive Size));303 archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveHandle.dataSize)); 309 304 } 310 305 pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), ResourceResponseBase::sanitizeSuggestedFilename(filename), extension, title, url, visibleURL, WTFMove(archiveBuffer)); -
branches/safari-610.1-branch/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
r264990 r265720 2450 2450 memcpy(sharedMemory->data(), buffer->data(), buffer->size()); 2451 2451 sharedMemory->createHandle(handle, SharedMemory::Protection::ReadOnly); 2452 webProcess.parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, type, handle, buffer->size()), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0);2452 webProcess.parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, type, SharedMemory::IPCHandle { WTFMove(handle), buffer->size() }), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0); 2453 2453 } 2454 2454 } -
branches/safari-610.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r261802 r265720 133 133 134 134 // Fallback to messaging the UI process for native pasteboard content. 135 SharedMemory::Handle handle; 136 uint64_t size { 0 }; 137 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardBufferForType(pasteboardName, pasteboardType), Messages::WebPasteboardProxy::GetPasteboardBufferForType::Reply(handle, size), 0); 138 if (handle.isNull()) 135 SharedMemory::IPCHandle ipcHandle; 136 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardBufferForType(pasteboardName, pasteboardType), Messages::WebPasteboardProxy::GetPasteboardBufferForType::Reply(ipcHandle), 0); 137 if (ipcHandle.handle.isNull()) 139 138 return nullptr; 140 // SharedMemory::Handle::size() is rounded up to the nearest page. 141 if (!size || size > handle.size()) 142 return nullptr; 143 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 144 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size); 139 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly); 140 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize); 145 141 } 146 142 … … 216 212 } 217 213 int64_t newChangeCount { 0 }; 218 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0);214 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, pasteboardType, SharedMemory::IPCHandle { WTFMove(handle), buffer ? buffer->size() : 0 }), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0); 219 215 return newChangeCount; 220 216 } … … 400 396 RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName) 401 397 { 402 SharedMemory::Handle handle; 403 uint64_t size { 0 }; 404 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(handle, size), 0); 405 if (handle.isNull()) 398 SharedMemory::IPCHandle ipcHandle; 399 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(ipcHandle), 0); 400 if (ipcHandle.handle.isNull()) 406 401 return nullptr; 407 #if OS(DARWIN) || OS(WINDOWS) 408 // SharedMemory::Handle::size() is rounded up to the nearest page. 409 if (!size || size > handle.size()) 410 return nullptr; 411 #else 412 if (!size) 413 return nullptr; 414 #endif 415 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 416 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size); 402 403 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly); 404 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize); 417 405 } 418 406 -
branches/safari-610.1-branch/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r261442 r265720 182 182 } 183 183 184 m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, filename, extension, title, String([[response URL] absoluteString]), WTF::userVisibleString(url), archiveHandle, archiveSize));184 m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, SharedMemory::IPCHandle { WTFMove(imageHandle), imageSize }, filename, extension, title, String([[response URL] absoluteString]), WTF::userVisibleString(url), SharedMemory::IPCHandle { WTFMove(archiveHandle), archiveSize })); 185 185 } 186 186 -
branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h
r265717 r265720 863 863 void readSelectionFromPasteboard(const String& pasteboardName, CompletionHandler<void(bool&&)>&&); 864 864 void getStringSelectionForPasteboard(CompletionHandler<void(String&&)>&&); 865 void getDataSelectionForPasteboard(const String pasteboardType, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t)>&&);865 void getDataSelectionForPasteboard(const String pasteboardType, CompletionHandler<void(SharedMemory::IPCHandle&&)>&&); 866 866 void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, CompletionHandler<void(bool)>&&); 867 867 void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, CompletionHandler<void(bool)>&&); -
branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r265717 r265720 435 435 RegisterUIProcessAccessibilityTokens(IPC::DataReference elemenToken, IPC::DataReference windowToken) 436 436 GetStringSelectionForPasteboard() -> (String stringValue) Synchronous 437 GetDataSelectionForPasteboard(String pasteboardType) -> (WebKit::SharedMemory:: Handle handle, uint64_t size) Synchronous437 GetDataSelectionForPasteboard(String pasteboardType) -> (WebKit::SharedMemory::IPCHandle ipcHandle) Synchronous 438 438 ReadSelectionFromPasteboard(String pasteboardName) -> (bool result) Synchronous 439 439 -
branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r265595 r265720 590 590 } 591 591 592 void WebPage::getDataSelectionForPasteboard(const String, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t)>&& completionHandler)592 void WebPage::getDataSelectionForPasteboard(const String, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 593 593 { 594 594 notImplemented(); 595 completionHandler({ } , 0);595 completionHandler({ }); 596 596 } 597 597 … … 3007 3007 SharedMemory::Handle handle; 3008 3008 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 3009 send(Messages::WebPageProxy::SaveImageToLibrary( handle, bufferSize));3009 send(Messages::WebPageProxy::SaveImageToLibrary(SharedMemory::IPCHandle { WTFMove(handle), bufferSize })); 3010 3010 } 3011 3011 } -
branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r265176 r265720 557 557 } 558 558 559 void WebPage::getDataSelectionForPasteboard(const String pasteboardType, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t)>&& completionHandler)559 void WebPage::getDataSelectionForPasteboard(const String pasteboardType, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 560 560 { 561 561 auto& frame = m_page->focusController().focusedOrMainFrame(); 562 562 if (frame.selection().isNone()) 563 return completionHandler({ } , 0);563 return completionHandler({ }); 564 564 565 565 RefPtr<SharedBuffer> buffer = frame.editor().dataSelectionForPasteboard(pasteboardType); 566 566 if (!buffer) 567 return completionHandler({ } , 0);567 return completionHandler({ }); 568 568 uint64_t size = buffer->size(); 569 569 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size); … … 571 571 SharedMemory::Handle handle; 572 572 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 573 completionHandler( WTFMove(handle), size);573 completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size }); 574 574 } 575 575
Note:
See TracChangeset
for help on using the changeset viewer.