Changeset 265720 in webkit


Ignore:
Timestamp:
Aug 14, 2020, 5:16:57 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r265702. rdar://problem/67106079

Convert SharedMemory::Handle to SharedMemory::IPCHandle WebPage image/pasteboard functions
https://bugs.webkit.org/show_bug.cgi?id=215478
<rdar://problem/67024582>

Reviewed by Chris Dumez.

Convert SharedMemory::Handle objects to SharedMemory::IPCHandle
objects which automatically verify the size of data being sent.

We can remove the additional size parameter being sent in many IPC
messages along with the handle, now that both are stored in the
IPCHandle struct.

  • UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::setPromisedDataForImage):
  • UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::getPasteboardBufferForType): No longer need size check, this is done in the IPCHandle::decode() function. (WebKit::WebPasteboardProxy::setPasteboardBufferForType): (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/WebPasteboardProxy.cpp: (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
  • UIProcess/WebPasteboardProxy.h:
  • UIProcess/WebPasteboardProxy.messages.in:
  • UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::saveImageToLibrary):
  • UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::dataSelectionForPasteboard): No longer need size check, this is done in the IPCHandle::decode() function. (WebKit::WebPageProxy::setPromisedDataForImage):
  • WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::writeItemsToPasteboard):
  • WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::bufferForType): (WebKit::WebPlatformStrategies::setBufferForType): (WebKit::WebPlatformStrategies::readBufferFromPasteboard): No longer need size check, this is done in the IPCHandle::decode() function.
  • WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: (WebKit::WebDragClient::declareAndWriteDragImage):
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getDataSelectionForPasteboard): (WebKit::WebPage::performActionOnElement):
  • WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::getDataSelectionForPasteboard):

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

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  
     12020-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
    11142020-08-14  Alan Coon  <alancoon@apple.com>
    2115
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r264283 r265720  
    218218#if PLATFORM(IOS_FAMILY)
    219219
    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)
     220void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::IPCHandle&, const String&, const String&, const String&, const String&, const String&, const SharedMemory::IPCHandle&)
    221221{
    222222    notImplemented();
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm

    r261263 r265720  
    195195}
    196196
    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);
     197void 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({ });
    203203
    204204    RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).bufferForType(pasteboardType);
    205205    if (!buffer)
    206         return completionHandler({ }, 0);
     206        return completionHandler({ });
    207207    uint64_t size = buffer->size();
    208208    if (!size)
    209         return completionHandler({ }, 0);
     209        return completionHandler({ });
    210210    RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size);
    211211    if (!sharedMemoryBuffer)
    212         return completionHandler({ }, 0);
     212        return completionHandler({ });
    213213    memcpy(sharedMemoryBuffer->data(), buffer->data(), size);
    214214    SharedMemory::Handle handle;
    215215    sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
    216     completionHandler(WTFMove(handle), size);
     216    completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size });
    217217}
    218218
     
    319319}
    320320
    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)
     321void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::IPCHandle& ipcHandle, CompletionHandler<void(int64_t)>&& completionHandler)
    322322{
    323323    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    325325
    326326    auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
    327     if (handle.isNull()) {
     327    if (ipcHandle.handle.isNull()) {
    328328        auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType);
    329329        didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
     
    331331    }
    332332
    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);
    337334    if (!sharedMemoryBuffer)
    338335        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));
    340337    auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType);
    341338    didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
     
    415412}
    416413
    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);
     414void 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({ });
    423420
    424421    RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).readBuffer(index, pasteboardType);
    425422    if (!buffer)
    426         return completionHandler({ }, 0);
     423        return completionHandler({ });
    427424    uint64_t size = buffer->size();
    428425    if (!size)
    429         return completionHandler({ }, 0);
     426        return completionHandler({ });
    430427    RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size);
    431428    if (!sharedMemoryBuffer)
    432         return completionHandler({ }, 0);
     429        return completionHandler({ });
    433430    memcpy(sharedMemoryBuffer->data(), buffer->data(), size);
    434431    SharedMemory::Handle handle;
    435432    sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
    436     completionHandler(WTFMove(handle), size);
     433    completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size });
    437434}
    438435
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPageProxy.h

    r265717 r265720  
    792792    void stopInteraction();
    793793    void performActionOnElement(uint32_t action);
    794     void saveImageToLibrary(const SharedMemory::Handle& imageHandle, uint64_t imageSize);
     794    void saveImageToLibrary(const SharedMemory::IPCHandle& imageHandle);
    795795    void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& = [] { });
    796796    void setFocusedElementValue(const String&);
     
    11731173#if PLATFORM(COCOA)
    11741174    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);
    11771177#endif
    11781178#if PLATFORM(GTK)
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r264602 r265720  
    182182    InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous
    183183    DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information)
    184     SaveImageToLibrary(WebKit::SharedMemory::Handle handle, uint64_t size)
     184    SaveImageToLibrary(WebKit::SharedMemory::IPCHandle handle)
    185185    ShowPlaybackTargetPicker(bool hasVideo, WebCore::IntRect elementRect, enum:uint8_t WebCore::RouteSharingPolicy policy, String routingContextUID)
    186186    CommitPotentialTapFailed()
     
    314314#if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
    315315    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)
    317317#endif
    318318#if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPasteboardProxy.cpp

    r261792 r265720  
    112112}
    113113
    114 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
     114void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
    115115{
    116     completionHandler({ }, 0);
     116    completionHandler({ });
    117117}
    118118
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/WebPasteboardProxy.h

    r261802 r265720  
    9898    void getPasteboardStringForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&&);
    9999    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&&)>&&);
    101101    void getPasteboardChangeCount(const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
    102102    void getPasteboardColor(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(WebCore::Color&&)>&&);
     
    107107    void setPasteboardColor(IPC::Connection&, const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&);
    108108    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)>&&);
    110110#endif
    111111
    112112    void readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&&);
    113113    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&&)>&&);
    115115    void getPasteboardItemsCount(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(uint64_t)>&&);
    116116    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  
    3737    ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) Synchronous WantsConnection
    3838    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 WantsConnection
     39    ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous WantsConnection
    4040    ContainsStringSafeForDOMToReadForType(String type, String pasteboardName) -> (bool result) Synchronous WantsConnection
    4141
     
    4747    GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string) Synchronous WantsConnection
    4848    GetPasteboardStringsForType(String pasteboardName, String pasteboardType) -> (Vector<String> strings) Synchronous WantsConnection
    49     GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous WantsConnection
     49    GetPasteboardBufferForType(String pasteboardName, String pasteboardType) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous WantsConnection
    5050    GetPasteboardChangeCount(String pasteboardName) -> (int64_t changeCount) Synchronous
    5151    GetPasteboardColor(String pasteboardName) -> (WebCore::Color color) Synchronous WantsConnection
     
    5656    SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous WantsConnection
    5757    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 WantsConnection
     58    SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::IPCHandle handle) -> (int64_t changeCount) Synchronous WantsConnection
    5959    ContainsURLStringSuitableForLoading(String pasteboardName) -> (bool result) Synchronous WantsConnection
    6060    URLStringSuitableForLoading(String pasteboardName) -> (String url, String title) Synchronous WantsConnection
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r265163 r265720  
    667667}
    668668
    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);
     669void WebPageProxy::saveImageToLibrary(const SharedMemory::IPCHandle& imageHandle)
     670{
     671    MESSAGE_CHECK(!imageHandle.handle.isNull());
     672
     673    auto sharedMemoryBuffer = SharedMemory::map(imageHandle.handle, SharedMemory::Protection::ReadOnly);
    676674    if (!sharedMemoryBuffer)
    677675        return;
    678676
    679     auto buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), static_cast<size_t>(imageSize));
     677    auto buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), static_cast<size_t>(imageHandle.dataSize));
    680678    pageClient().saveImageToLibrary(WTFMove(buffer));
    681679}
  • branches/safari-610.1-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r265158 r265720  
    250250    if (!hasRunningProcess())
    251251        return nullptr;
    252     SharedMemory::Handle handle;
     252
     253    SharedMemory::IPCHandle ipcHandle;
    253254    uint64_t size = 0;
    254255    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);
    261260    if (!sharedMemoryBuffer)
    262261        return nullptr;
     
    284283#if ENABLE(DRAG_SUPPORT)
    285284
    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)
     285void 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)
    288287{
    289288    MESSAGE_CHECK_URL(url);
    290289    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);
    296293    if (!sharedMemoryImage)
    297294        return;
    298295
    299     auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), static_cast<size_t>(imageSize));
     296    auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), static_cast<size_t>(imageHandle.dataSize));
    300297    RefPtr<SharedBuffer> archiveBuffer;
    301298
    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);
    306301        if (!sharedMemoryArchive)
    307302            return;
    308         archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveSize));
     303        archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveHandle.dataSize));
    309304    }
    310305    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  
    24502450            memcpy(sharedMemory->data(), buffer->data(), buffer->size());
    24512451            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);
    24532453        }
    24542454    }
  • branches/safari-610.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp

    r261802 r265720  
    133133
    134134    // 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())
    139138        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);
    145141}
    146142
     
    216212    }
    217213    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);
    219215    return newChangeCount;
    220216}
     
    400396RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName)
    401397{
    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())
    406401        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);
    417405}
    418406
  • branches/safari-610.1-branch/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm

    r261442 r265720  
    182182    }
    183183
    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 }));
    185185}
    186186
  • branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h

    r265717 r265720  
    863863    void readSelectionFromPasteboard(const String& pasteboardName, CompletionHandler<void(bool&&)>&&);
    864864    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&&)>&&);
    866866    void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, CompletionHandler<void(bool)>&&);
    867867    void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, CompletionHandler<void(bool)>&&);
  • branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r265717 r265720  
    435435    RegisterUIProcessAccessibilityTokens(IPC::DataReference elemenToken, IPC::DataReference windowToken)
    436436    GetStringSelectionForPasteboard() -> (String stringValue) Synchronous
    437     GetDataSelectionForPasteboard(String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) Synchronous
     437    GetDataSelectionForPasteboard(String pasteboardType) -> (WebKit::SharedMemory::IPCHandle ipcHandle) Synchronous
    438438    ReadSelectionFromPasteboard(String pasteboardName) -> (bool result) Synchronous
    439439
  • branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r265595 r265720  
    590590}
    591591
    592 void WebPage::getDataSelectionForPasteboard(const String, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler)
     592void WebPage::getDataSelectionForPasteboard(const String, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
    593593{
    594594    notImplemented();
    595     completionHandler({ }, 0);
     595    completionHandler({ });
    596596}
    597597
     
    30073007        SharedMemory::Handle handle;
    30083008        sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
    3009         send(Messages::WebPageProxy::SaveImageToLibrary(handle, bufferSize));
     3009        send(Messages::WebPageProxy::SaveImageToLibrary(SharedMemory::IPCHandle { WTFMove(handle), bufferSize }));
    30103010    }
    30113011}
  • branches/safari-610.1-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

    r265176 r265720  
    557557}
    558558
    559 void WebPage::getDataSelectionForPasteboard(const String pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler)
     559void WebPage::getDataSelectionForPasteboard(const String pasteboardType, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
    560560{
    561561    auto& frame = m_page->focusController().focusedOrMainFrame();
    562562    if (frame.selection().isNone())
    563         return completionHandler({ }, 0);
     563        return completionHandler({ });
    564564
    565565    RefPtr<SharedBuffer> buffer = frame.editor().dataSelectionForPasteboard(pasteboardType);
    566566    if (!buffer)
    567         return completionHandler({ }, 0);
     567        return completionHandler({ });
    568568    uint64_t size = buffer->size();
    569569    RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(size);
     
    571571    SharedMemory::Handle handle;
    572572    sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
    573     completionHandler(WTFMove(handle), size);
     573    completionHandler(SharedMemory::IPCHandle { WTFMove(handle), size });
    574574}
    575575
Note: See TracChangeset for help on using the changeset viewer.