Changeset 230117 in webkit
- Timestamp:
- Mar 30, 2018 2:01:35 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r230048 r230117 1 2018-03-30 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 6 Reviewed by Per Arne Vollan. 7 8 * ManualTests/DragInlinePDFImageDocument.html: Added. 9 * ManualTests/resources/simple.pdf: Added. 10 1 11 2018-03-28 Tim Horton <timothy_horton@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r230112 r230117 1 2018-03-30 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 6 Reviewed by Per Arne Vollan. 7 8 Fixes an assertion failure when quiting an app that uses a Legacy WebKit web view 9 after dragging-and-dropping a PDF embedded using an HTML image element into the 10 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 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 fullfill its RTF document promise for the WebArchive created at the start of the drag operation. WebKit 16 expects that the created WebArchive is either for an inline image (e.g. <img>) or an image document that 17 has a supported image resource MIME type (by querying MIMETypeRegistry::isSupportedImageResourceMIMEType()) 18 and checks for these cases in this order. PDF/PostScript are not listed in the set of supported image 19 resource MIME types. So, the first check fails and WebKit assumes that the WebArchive was created from 20 an image document of a supported image resource MIME type. However, the WebArchive was created from a 21 WebHTMLView and has MIME type text/html. Therefore the assertion fails. We need to add PDF and PostScript 22 to the set of supported image resource MIME types so that WebKit does not fall back to the WebHTMLView 23 code path. Historically, PDF and PostScript were in the set supported image resource MIME types. Over time 24 the set of MIME types for image resouces (images loaded as a document) became identical to the set of MIME 25 types for images loaded inline (e.g. <img>) and this set omitted the MIME types for PDF and PostScript. 26 27 Additionally it is sufficient to implement MIMETypeRegistry::isSupportedImageResourceMIMEType() in terms 28 of MIMETypeRegistry::isSupportedImageMIMEType() and MIMETypeRegistry::isPDFOrPostScriptMIMEType() instead 29 of allocating a dedicated HashSet for the supported image resource MIME types (as we currently do). 30 31 * dom/DOMImplementation.cpp: 32 (WebCore::DOMImplementation::createDocument): Assert that PDF is a supported image MIME type before 33 instantiating an ImageDocument. 34 * platform/MIMETypeRegistry.cpp: 35 (WebCore::initializeSupportedImageMIMETypes): Remove unnecessary allocation of a HashSet for the support 36 image resource MIME types. 37 (WebCore::MIMETypeRegistry::isSupportedImageResourceMIMEType): Write in terms of MIMETypeRegistry::isSupportedImageMIMEType() 38 and MIMETypeRegistry::isPDFOrPostScriptMIMEType(). 39 (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Deleted. 40 * platform/MIMETypeRegistry.h: 41 1 42 2018-03-29 Antoine Quint <graouts@apple.com> 2 43 -
trunk/Source/WebCore/dom/DOMImplementation.cpp
r227439 r230117 151 151 152 152 // If we want to useImageDocumentForSubframePDF, we'll let that override plugin support. 153 if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF()) 153 if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF()) { 154 ASSERT(Image::supportsType(type)); 154 155 return ImageDocument::create(*frame, url); 156 } 155 157 156 158 PluginData* pluginData = nullptr; -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r230107 r230117 56 56 namespace WebCore { 57 57 58 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageResourceMIMETypes;59 58 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypes; 60 59 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypesForEncoding; … … 67 66 static void initializeSupportedImageMIMETypes() 68 67 { 69 supportedImageResourceMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;70 68 supportedImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 71 69 … … 73 71 // This represents the subset of allowed image UTIs for which CoreServices has a corresponding MIME type. Keep this in sync with allowedImageUTIs(). 74 72 static const char* const allowedImageMIMETypes[] = { "image/tiff", "image/gif", "image/jpeg", "image/vnd.microsoft.icon", "image/jp2", "image/png", "image/bmp" }; 75 for (auto& mimeType : allowedImageMIMETypes) {73 for (auto& mimeType : allowedImageMIMETypes) 76 74 supportedImageMIMETypes->add(ASCIILiteral { mimeType }); 77 supportedImageResourceMIMETypes->add(ASCIILiteral { mimeType });78 }79 75 80 76 #ifndef NDEBUG 81 77 for (auto& uti : allowedImageUTIs()) { 82 78 auto mimeType = MIMETypeForImageSourceType(uti); 83 if (!mimeType.isEmpty()) {79 if (!mimeType.isEmpty()) 84 80 ASSERT(supportedImageMIMETypes->contains(mimeType)); 85 ASSERT(supportedImageResourceMIMETypes->contains(mimeType));86 }87 81 } 88 82 … … 95 89 // Favicons don't have a MIME type in the registry either. 96 90 supportedImageMIMETypes->add("image/x-icon"); 97 supportedImageResourceMIMETypes->add("image/x-icon");98 91 99 92 // We only get one MIME type per UTI, hence our need to add these manually 100 93 supportedImageMIMETypes->add("image/pjpeg"); 101 supportedImageResourceMIMETypes->add("image/pjpeg");102 94 103 95 #if PLATFORM(IOS) … … 123 115 "application/bmp", "application/x-bmp", "application/x-win-bitmap", 124 116 }; 125 for (auto& type : malformedMIMETypes) {117 for (auto& type : malformedMIMETypes) 126 118 supportedImageMIMETypes->add(type); 127 supportedImageResourceMIMETypes->add(type);128 }129 119 #endif 130 120 … … 141 131 "image/x-xbitmap" // xbm 142 132 }; 143 for (auto& type : types) {133 for (auto& type : types) 144 134 supportedImageMIMETypes->add(type); 145 supportedImageResourceMIMETypes->add(type);146 }147 135 148 136 #if USE(WEBP) 149 137 supportedImageMIMETypes->add("image/webp"); 150 supportedImageResourceMIMETypes->add("image/webp");151 138 #endif 152 139 … … 464 451 bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType) 465 452 { 466 if (mimeType.isEmpty()) 467 return false; 468 if (!supportedImageResourceMIMETypes) 469 initializeSupportedImageMIMETypes(); 470 return supportedImageResourceMIMETypes->contains(getNormalizedMIMEType(mimeType)); 453 return isSupportedImageMIMEType(mimeType) || isPDFOrPostScriptMIMEType(mimeType); 471 454 } 472 455 … … 657 640 initializeSupportedImageMIMETypes(); 658 641 return *supportedImageMIMETypes; 659 }660 661 const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()662 {663 if (!supportedImageResourceMIMETypes)664 initializeSupportedImageMIMETypes();665 return *supportedImageResourceMIMETypes;666 642 } 667 643 -
trunk/Source/WebCore/platform/MIMETypeRegistry.h
r230107 r230117 110 110 111 111 WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypes(); 112 const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageResourceMIMETypes();113 112 WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedMediaMIMETypes(); 114 113 WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getPDFMIMETypes();
Note: See TracChangeset
for help on using the changeset viewer.