Changeset 265702 in webkit
- Timestamp:
- Aug 14, 2020, 1:41:11 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 17 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/Cocoa/WebPageProxyCocoa.mm (modified) (1 diff)
-
UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (modified) (5 diffs)
-
UIProcess/WebPageProxy.h (modified) (2 diffs)
-
UIProcess/WebPageProxy.messages.in (modified) (2 diffs)
-
UIProcess/WebPasteboardProxy.cpp (modified) (1 diff)
-
UIProcess/WebPasteboardProxy.h (modified) (2 diffs)
-
UIProcess/WebPasteboardProxy.messages.in (modified) (3 diffs)
-
UIProcess/ios/WebPageProxyIOS.mm (modified) (1 diff)
-
UIProcess/mac/WebPageProxyMac.mm (modified) (2 diffs)
-
WebProcess/Plugins/PDF/PDFPlugin.mm (modified) (1 diff)
-
WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (modified) (3 diffs)
-
WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (modified) (1 diff)
-
WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
-
WebProcess/WebPage/ios/WebPageIOS.mm (modified) (2 diffs)
-
WebProcess/WebPage/mac/WebPageMac.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r265688 r265702 1 2020-08-14 Kate Cheney <katherine_cheney@apple.com> 2 3 Convert SharedMemory::Handle to SharedMemory::IPCHandle WebPage image/pasteboard functions 4 https://bugs.webkit.org/show_bug.cgi?id=215478 5 <rdar://problem/67024582> 6 7 Reviewed by Chris Dumez. 8 9 Convert SharedMemory::Handle objects to SharedMemory::IPCHandle 10 objects which automatically verify the size of data being sent. 11 12 We can remove the additional size parameter being sent in many IPC 13 messages along with the handle, now that both are stored in the 14 IPCHandle struct. 15 16 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 17 (WebKit::WebPageProxy::setPromisedDataForImage): 18 * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: 19 (WebKit::WebPasteboardProxy::getPasteboardBufferForType): 20 No longer need size check, this is done in the IPCHandle::decode() 21 function. 22 (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 23 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 24 * UIProcess/WebPageProxy.h: 25 * UIProcess/WebPageProxy.messages.in: 26 * UIProcess/WebPasteboardProxy.cpp: 27 (WebKit::WebPasteboardProxy::readBufferFromPasteboard): 28 * UIProcess/WebPasteboardProxy.h: 29 * UIProcess/WebPasteboardProxy.messages.in: 30 * UIProcess/ios/WebPageProxyIOS.mm: 31 (WebKit::WebPageProxy::saveImageToLibrary): 32 * UIProcess/mac/WebPageProxyMac.mm: 33 (WebKit::WebPageProxy::dataSelectionForPasteboard): 34 No longer need size check, this is done in the IPCHandle::decode() 35 function. 36 (WebKit::WebPageProxy::setPromisedDataForImage): 37 * WebProcess/Plugins/PDF/PDFPlugin.mm: 38 (WebKit::PDFPlugin::writeItemsToPasteboard): 39 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 40 (WebKit::WebPlatformStrategies::bufferForType): 41 (WebKit::WebPlatformStrategies::setBufferForType): 42 (WebKit::WebPlatformStrategies::readBufferFromPasteboard): 43 No longer need size check, this is done in the IPCHandle::decode() 44 function. 45 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 46 (WebKit::WebDragClient::declareAndWriteDragImage): 47 * WebProcess/WebPage/WebPage.h: 48 * WebProcess/WebPage/WebPage.messages.in: 49 * WebProcess/WebPage/ios/WebPageIOS.mm: 50 (WebKit::WebPage::getDataSelectionForPasteboard): 51 (WebKit::WebPage::performActionOnElement): 52 * WebProcess/WebPage/mac/WebPageMac.mm: 53 (WebKit::WebPage::getDataSelectionForPasteboard): 54 1 55 2020-08-14 Wenson Hsieh <wenson_hsieh@apple.com> 2 56 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r264283 r265702 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(); -
trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
r265410 r265702 196 196 } 197 197 198 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t)>&& completionHandler)199 { 200 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ } , 0));201 202 if (!canAccessPasteboardData(connection, pasteboardName)) 203 return completionHandler({ } , 0);198 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 199 { 200 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ })); 201 202 if (!canAccessPasteboardData(connection, pasteboardName)) 203 return completionHandler({ }); 204 204 205 205 RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).bufferForType(pasteboardType); 206 206 if (!buffer) 207 return completionHandler({ } , 0);207 return completionHandler({ }); 208 208 uint64_t size = buffer->size(); 209 209 if (!size) 210 return completionHandler({ } , 0);210 return completionHandler({ }); 211 211 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size); 212 212 if (!sharedMemoryBuffer) 213 return completionHandler({ } , 0);213 return completionHandler({ }); 214 214 memcpy(sharedMemoryBuffer->data(), buffer->data(), size); 215 215 SharedMemory::Handle handle; 216 216 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 217 completionHandler( WTFMove(handle), size);217 completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size }); 218 218 } 219 219 … … 320 320 } 321 321 322 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory:: Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)322 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::IPCHandle& ipcHandle, CompletionHandler<void(int64_t)>&& completionHandler) 323 323 { 324 324 MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0)); … … 326 326 327 327 auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount(); 328 if ( handle.isNull()) {328 if (ipcHandle.handle.isNull()) { 329 329 auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType); 330 330 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); … … 332 332 } 333 333 334 // SharedMemory::Handle::size() is rounded up to the nearest page. 335 MESSAGE_CHECK_COMPLETION(size <= handle.size(), completionHandler(0)); 336 337 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 334 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly); 338 335 if (!sharedMemoryBuffer) 339 336 return completionHandler(0); 340 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>( size));337 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(ipcHandle.dataSize)); 341 338 auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType); 342 339 didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount); … … 416 413 } 417 414 418 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory:: Handle&&, uint64_t size)>&& completionHandler)419 { 420 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ } , 0));421 422 if (!canAccessPasteboardData(connection, pasteboardName)) 423 return completionHandler({ } , 0);415 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler) 416 { 417 MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ })); 418 419 if (!canAccessPasteboardData(connection, pasteboardName)) 420 return completionHandler({ }); 424 421 425 422 RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).readBuffer(index, pasteboardType); 426 423 if (!buffer) 427 return completionHandler({ } , 0);424 return completionHandler({ }); 428 425 uint64_t size = buffer->size(); 429 426 if (!size) 430 return completionHandler({ } , 0);427 return completionHandler({ }); 431 428 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size); 432 429 if (!sharedMemoryBuffer) 433 return completionHandler({ } , 0);430 return completionHandler({ }); 434 431 memcpy(sharedMemoryBuffer->data(), buffer->data(), size); 435 432 SharedMemory::Handle handle; 436 433 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 437 completionHandler( WTFMove(handle), size);434 completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size }); 438 435 } 439 436 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r265623 r265702 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) -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r265228 r265702 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) -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp
r261792 r265702 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 -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h
r261802 r265702 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>&&)>&&); -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
r261802 r265702 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 -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r265228 r265702 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 } -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r265158 r265702 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)); -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
r264990 r265702 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 } -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r265410 r265702 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 … … 217 213 } 218 214 int64_t newChangeCount { 0 }; 219 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0);215 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, pasteboardType, SharedMemory::IPCHandle { WTFMove(handle), buffer ? buffer->size() : 0 }), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0); 220 216 return newChangeCount; 221 217 } … … 405 401 RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName) 406 402 { 407 SharedMemory::Handle handle; 408 uint64_t size { 0 }; 409 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(handle, size), 0); 410 if (handle.isNull()) 403 SharedMemory::IPCHandle ipcHandle; 404 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(ipcHandle), 0); 405 if (ipcHandle.handle.isNull()) 411 406 return nullptr; 412 #if OS(DARWIN) || OS(WINDOWS) 413 // SharedMemory::Handle::size() is rounded up to the nearest page. 414 if (!size || size > handle.size()) 415 return nullptr; 416 #else 417 if (!size) 418 return nullptr; 419 #endif 420 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 421 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size); 407 408 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly); 409 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize); 422 410 } 423 411 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r261442 r265702 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 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r265623 r265702 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)>&&); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r265623 r265702 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 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r265515 r265702 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 … … 3005 3005 SharedMemory::Handle handle; 3006 3006 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); 3007 send(Messages::WebPageProxy::SaveImageToLibrary( handle, bufferSize));3007 send(Messages::WebPageProxy::SaveImageToLibrary(SharedMemory::IPCHandle { WTFMove(handle), bufferSize })); 3008 3008 } 3009 3009 } -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r265176 r265702 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.