Changeset 231061 in webkit


Ignore:
Timestamp:
Apr 26, 2018 11:46:42 AM (6 years ago)
Author:
dbates@webkit.org
Message:
ASSERTION FAILED: ASSERT(!containsImage
MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType])) in -[NSPasteboard(WebExtras) _web_writePromisedRTFDFromArchive:containsImage:]

https://bugs.webkit.org/show_bug.cgi?id=184161
<rdar://problem/39051645>

Reviewed by Dan Bernstein.

.:

  • ManualTests/DragInlinePDFImageDocument.html: Added.
  • ManualTests/resources/simple.pdf: Added.

Source/WebKitLegacy/mac:

Fixes an assertion failure when quitting an app that uses a Legacy WebKit web view after dragging-and-
dropping a PDF embedded using an HTML image element into the same web view.

When performing a drag-and-drop of a PDF document image (WebCore::PDFDocumentImage) we create a WebArchive
from the main frame's WebHTMLView and promise AppKit that we will provide a Rich Text Format (RTF) document
from this archive if needed. For some reason, on app termination AppKit requests that the WebHTMLView
fulfill its RTF document promise for the WebArchive created at the start of the drag operation. To do this,
we need to extract the image resource from the Web Archive. Currently we query MIMETypeRegistry::isSupportedImageResourceMIMEType()
to see if the contained image is one that we can handle. However MIMETypeRegistry::isSupportedImageResourceMIMEType()
only returns true if WebKit supports creating an image document for the specified MIME type. Disregarding
the iOS motivated setting Settings::useImageDocumentForSubframePDF, PDFs and PostScripts do not create an
image document when navigated to directly. Since we can support dragging PDF document images we need to
query if MIMETypeRegistry::isPDFOrPostScriptMIMEType() in addition to querying MIMETypeRegistry::isSupportedImageResourceMIMEType().
We need to do both such queries before falling back to using the main resource of the Web Archive as
the image. Otherwise, we will cause an assertion failure if the main resource of the Web Archive is
not an image document.

  • Misc/WebNSPasteboardExtras.mm:

(-[NSPasteboard _web_writePromisedRTFDFromArchive:containsImage:]):

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r231047 r231061  
     12018-04-26  Daniel Bates  <dabates@apple.com>
     2
     3        ASSERTION FAILED: ASSERT(!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType])) in -[NSPasteboard(WebExtras) _web_writePromisedRTFDFromArchive:containsImage:]
     4        https://bugs.webkit.org/show_bug.cgi?id=184161
     5        <rdar://problem/39051645>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        * ManualTests/DragInlinePDFImageDocument.html: Added.
     10        * ManualTests/resources/simple.pdf: Added.
     11
    1122018-04-26  Andy VanWagoner  <thetalecrafter@gmail.com>
    213
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r231051 r231061  
     12018-04-26  Daniel Bates  <dabates@apple.com>
     2
     3        ASSERTION FAILED: ASSERT(!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType])) in -[NSPasteboard(WebExtras) _web_writePromisedRTFDFromArchive:containsImage:]
     4        https://bugs.webkit.org/show_bug.cgi?id=184161
     5        <rdar://problem/39051645>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        Fixes an assertion failure when quitting an app that uses a Legacy WebKit web view after dragging-and-
     10        dropping a PDF embedded using an HTML image element into the same web view.
     11
     12        When performing a drag-and-drop of a PDF document image (WebCore::PDFDocumentImage) we create a WebArchive
     13        from the main frame's WebHTMLView and promise AppKit that we will provide a Rich Text Format (RTF) document
     14        from this archive if needed. For some reason, on app termination AppKit requests that the WebHTMLView
     15        fulfill its RTF document promise for the WebArchive created at the start of the drag operation. To do this,
     16        we need to extract the image resource from the Web Archive. Currently we query MIMETypeRegistry::isSupportedImageResourceMIMEType()
     17        to see if the contained image is one that we can handle. However MIMETypeRegistry::isSupportedImageResourceMIMEType()
     18        only returns true if WebKit supports creating an image document for the specified MIME type. Disregarding
     19        the iOS motivated setting Settings::useImageDocumentForSubframePDF, PDFs and PostScripts do not create an
     20        image document when navigated to directly. Since we can support dragging PDF document images we need to
     21        query if MIMETypeRegistry::isPDFOrPostScriptMIMEType() in addition to querying MIMETypeRegistry::isSupportedImageResourceMIMEType().
     22        We need to do both such queries before falling back to using the main resource of the Web Archive as
     23        the image. Otherwise, we will cause an assertion failure if the main resource of the Web Archive is
     24        not an image document.
     25
     26        * Misc/WebNSPasteboardExtras.mm:
     27        (-[NSPasteboard _web_writePromisedRTFDFromArchive:containsImage:]):
     28
    1292018-04-26  Per Arne Vollan  <pvollan@apple.com>
    230
  • trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm

    r226277 r231061  
    213213    NSArray *subresources = [archive subresources];
    214214    WebResource *resource = [archive mainResource];
    215     if (containsImage && [subresources count] > 0
    216         && MIMETypeRegistry::isSupportedImageResourceMIMEType([[subresources objectAtIndex:0] MIMEType]))
    217         resource = (WebResource *)[subresources objectAtIndex:0];
     215    if (containsImage && [subresources count] > 0) {
     216        WebResource *subresource = [subresources objectAtIndex:0];
     217        NSString *subresourceMIMEType = [subresource MIMEType];
     218        if (MIMETypeRegistry::isSupportedImageResourceMIMEType(subresourceMIMEType) || MIMETypeRegistry::isPDFOrPostScriptMIMEType(subresourceMIMEType))
     219            resource = subresource;
     220    }
    218221    ASSERT(resource != nil);
    219222   
    220     ASSERT(!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType]));
    221     if (!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType]))
     223    ASSERT(!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType]) || MIMETypeRegistry::isPDFOrPostScriptMIMEType([resource MIMEType]));
     224    if (!containsImage || MIMETypeRegistry::isSupportedImageResourceMIMEType([resource MIMEType]) || MIMETypeRegistry::isPDFOrPostScriptMIMEType([resource MIMEType]))
    222225        [self _web_writeFileWrapperAsRTFDAttachment:[resource _fileWrapperRepresentation]];
    223226   
Note: See TracChangeset for help on using the changeset viewer.