⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267305 in webkit


Ignore:
Timestamp:
Sep 18, 2020, 6:34:43 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[macOS] REGRESSION (r265702): System Services receive 0 bytes when extracting selected content as rich text data
https://bugs.webkit.org/show_bug.cgi?id=216718
<rdar://problem/69150358>

Reviewed by Tim Horton.

Source/WebKit:

Test: CopyHTML.WriteRichTextSelectionToPasteboard

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::dataSelectionForPasteboard):

After r265702, the IPCHandle received in the UI process was always being converted into a buffer of size 0,
due to using the size local variable (which is no longer set as an outparam of the sync IPC message). Instead,
use ipcHandle.dataSize.

Tools:

Add a new API test to verify that we get non-empty web archive data when using
-writeSelectionToPasteboard:types: to grab selected content as rich text data.

  • TestWebKitAPI/Tests/WebKitCocoa/CopyHTML.mm:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r267298 r267305  
     12020-09-18  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] REGRESSION (r265702): System Services receive 0 bytes when extracting selected content as rich text data
     4        https://bugs.webkit.org/show_bug.cgi?id=216718
     5        <rdar://problem/69150358>
     6
     7        Reviewed by Tim Horton.
     8
     9        Test: CopyHTML.WriteRichTextSelectionToPasteboard
     10
     11        * UIProcess/mac/WebPageProxyMac.mm:
     12        (WebKit::WebPageProxy::dataSelectionForPasteboard):
     13
     14        After r265702, the `IPCHandle` received in the UI process was always being converted into a buffer of size 0,
     15        due to using the `size` local variable (which is no longer set as an outparam of the sync IPC message). Instead,
     16        use `ipcHandle.dataSize`.
     17
    1182020-09-18  Megan Gardner  <megan_gardner@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r266654 r267305  
    257257
    258258    SharedMemory::IPCHandle ipcHandle;
    259     uint64_t size = 0;
    260259    const Seconds messageTimeout(20);
    261260    sendSync(Messages::WebPage::GetDataSelectionForPasteboard(pasteboardType), Messages::WebPage::GetDataSelectionForPasteboard::Reply(ipcHandle), messageTimeout);
     
    265264    if (!sharedMemoryBuffer)
    266265        return nullptr;
    267     return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(size));
     266    return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize);
    268267}
    269268
  • trunk/Tools/ChangeLog

    r267284 r267305  
     12020-09-18  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] REGRESSION (r265702): System Services receive 0 bytes when extracting selected content as rich text data
     4        https://bugs.webkit.org/show_bug.cgi?id=216718
     5        <rdar://problem/69150358>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a new API test to verify that we get non-empty web archive data when using
     10        `-writeSelectionToPasteboard:types:` to grab selected content as rich text data.
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/CopyHTML.mm:
     13
    1142020-09-18  Sihui Liu  <sihui_liu@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/CopyHTML.mm

    r261395 r267305  
    4747#if PLATFORM(MAC)
    4848
     49@interface WKWebView () <NSServicesMenuRequestor>
     50@end
     51
    4952NSData *readHTMLDataFromPasteboard()
    5053{
     
    194197}
    195198
     199TEST(CopyHTML, WriteRichTextSelectionToPasteboard)
     200{
     201    auto webView = createWebViewWithCustomPasteboardDataEnabled();
     202    [webView synchronouslyLoadHTMLString:@"<strong style='color: rgb(255, 0, 0);'>This is some text to copy.</strong>"];
     203    [webView stringByEvaluatingJavaScript:@"getSelection().selectAllChildren(document.body)"];
     204
     205    auto pasteboard = [NSPasteboard pasteboardWithUniqueName];
     206    [webView writeSelectionToPasteboard:pasteboard types:@[ (__bridge NSString *)kUTTypeWebArchive ]];
     207
     208    EXPECT_GT([pasteboard dataForType:(__bridge NSString *)kUTTypeWebArchive].length, 0U);
     209}
     210
    196211#endif // PLATFORM(MAC)
    197212
Note: See TracChangeset for help on using the changeset viewer.