Changeset 239511 in webkit


Ignore:
Timestamp:
Dec 21, 2018 11:40:41 AM (5 years ago)
Author:
Wenson Hsieh
Message:

Setting the file wrapper and content type of an attachment to a PDF should update its image
https://bugs.webkit.org/show_bug.cgi?id=192984
<rdar://problem/46798028>

Reviewed by Tim Horton.

Source/WebCore:

Allow PDF data to be used to update enclosing image elements when setting the file wrapper for an attachment.
Covered by a new API test: WKAttachmentTests.SetFileWrapperForPDFImageAttachment.

  • html/HTMLAttachmentElement.cpp:

(WebCore::mimeTypeIsSuitableForInlineImageAttachment):
(WebCore::HTMLAttachmentElement::updateEnclosingImageWithData):

Tools:

Add an API test to verify that setting the file wrapper for a _WKAttachment with an enclosing image element with
PDF data correctly updates the image element.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239504 r239511  
     12018-12-21  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Setting the file wrapper and content type of an attachment to a PDF should update its image
     4        https://bugs.webkit.org/show_bug.cgi?id=192984
     5        <rdar://problem/46798028>
     6
     7        Reviewed by Tim Horton.
     8
     9        Allow PDF data to be used to update enclosing image elements when setting the file wrapper for an attachment.
     10        Covered by a new API test: WKAttachmentTests.SetFileWrapperForPDFImageAttachment.
     11
     12        * html/HTMLAttachmentElement.cpp:
     13        (WebCore::mimeTypeIsSuitableForInlineImageAttachment):
     14        (WebCore::HTMLAttachmentElement::updateEnclosingImageWithData):
     15
    1162018-12-21  Justin Michaud  <justin_michaud@apple.com>
    217
  • trunk/Source/WebCore/html/HTMLAttachmentElement.cpp

    r239427 r239511  
    227227}
    228228
     229static bool mimeTypeIsSuitableForInlineImageAttachment(const String& mimeType)
     230{
     231    return MIMETypeRegistry::isSupportedImageMIMEType(mimeType) || MIMETypeRegistry::isPDFMIMEType(mimeType);
     232}
     233
    229234void HTMLAttachmentElement::updateEnclosingImageWithData(const String& contentType, Ref<SharedBuffer>&& data)
    230235{
     
    239244#endif
    240245
    241     if (!MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
     246    if (!mimeTypeIsSuitableForInlineImageAttachment(mimeType))
    242247        return;
    243248
  • trunk/Tools/ChangeLog

    r239507 r239511  
     12018-12-21  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Setting the file wrapper and content type of an attachment to a PDF should update its image
     4        https://bugs.webkit.org/show_bug.cgi?id=192984
     5        <rdar://problem/46798028>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add an API test to verify that setting the file wrapper for a _WKAttachment with an enclosing image element with
     10        PDF data correctly updates the image element.
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
     13
    1142018-12-21  Michael Catanzaro  <mcatanzaro@igalia.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm

    r239184 r239511  
    15061506}
    15071507
     1508TEST(WKAttachmentTests, SetFileWrapperForPDFImageAttachment)
     1509{
     1510    auto webView = webViewForTestingAttachments();
     1511    [webView evaluateJavaScript:@"document.body.appendChild()" completionHandler:nil];
     1512    NSString *identifier = [webView stringByEvaluatingJavaScript:@"const i = document.createElement('img'); document.body.appendChild(i); HTMLAttachmentElement.getAttachmentIdentifier(i)"];
     1513    _WKAttachment *attachment = [webView _attachmentForIdentifier:identifier];
     1514
     1515    auto pdfFile = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:testPDFData()]);
     1516    [attachment setFileWrapper:pdfFile.get() contentType:(__bridge NSString *)kUTTypePDF completion:nil];
     1517    [webView waitForImageElementSizeToBecome:CGSizeMake(130, 29)];
     1518}
     1519
    15081520#pragma mark - Platform-specific tests
    15091521
Note: See TracChangeset for help on using the changeset viewer.