Unreviewed, rolling out r230117.
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Apr 2018 19:39:52 +0000 (19:39 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Apr 2018 19:39:52 +0000 (19:39 +0000)
Broke find-in-page for PDFs

Reverted changeset:

"ASSERTION FAILED: ASSERT(!containsImage ||
MIMETypeRegistry::isSupportedImageResourceMIMEType([resource
MIMEType])) in -[NSPasteboard(WebExtras)
_web_writePromisedRTFDFromArchive:containsImage:]"
https://bugs.webkit.org/show_bug.cgi?id=184161
https://trac.webkit.org/changeset/230117

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

ChangeLog
ManualTests/DragInlinePDFImageDocument.html [deleted file]
ManualTests/resources/simple.pdf [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/platform/MIMETypeRegistry.cpp
Source/WebCore/platform/MIMETypeRegistry.h

index 9754a9d..b150dfa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2018-04-20  Daniel Bates  <dabates@apple.com>
+
+        Unreviewed, rolling out r230117.
+
+        Broke find-in-page for PDFs
+
+        Reverted changeset:
+
+        "ASSERTION FAILED: ASSERT(!containsImage ||
+        MIMETypeRegistry::isSupportedImageResourceMIMEType([resource
+        MIMEType])) in -[NSPasteboard(WebExtras)
+        _web_writePromisedRTFDFromArchive:containsImage:]"
+        https://bugs.webkit.org/show_bug.cgi?id=184161
+        https://trac.webkit.org/changeset/230117
+
 2018-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Local cross references are broken in API documentation
diff --git a/ManualTests/DragInlinePDFImageDocument.html b/ManualTests/DragInlinePDFImageDocument.html
deleted file mode 100644 (file)
index 99f7eaf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<p>This is a test for <a href="https://bugs.webkit.org/show_bug.cgi?id=184161">Bug 184161</a>. Perform the following using a debug build of Legacy WebKit:</p>
-<ol>
-    <li>Drag and drop the PDF (the content demarcated with a black border on the page below) within the web view.</li>
-    <li>Quit this app.</li>
-</ol>
-<p>This test PASSED if this app does not crash with an assertion failure.</p>
-<img src="resources/simple.pdf" style="border:1px solid black">
-</body>
-</html>
diff --git a/ManualTests/resources/simple.pdf b/ManualTests/resources/simple.pdf
deleted file mode 100644 (file)
index 8f2eeaf..0000000
Binary files a/ManualTests/resources/simple.pdf and /dev/null differ
index b24ee02..29d0f71 100644 (file)
@@ -1,3 +1,18 @@
+2018-04-20  Daniel Bates  <dabates@apple.com>
+
+        Unreviewed, rolling out r230117.
+
+        Broke find-in-page for PDFs
+
+        Reverted changeset:
+
+        "ASSERTION FAILED: ASSERT(!containsImage ||
+        MIMETypeRegistry::isSupportedImageResourceMIMEType([resource
+        MIMEType])) in -[NSPasteboard(WebExtras)
+        _web_writePromisedRTFDFromArchive:containsImage:]"
+        https://bugs.webkit.org/show_bug.cgi?id=184161
+        https://trac.webkit.org/changeset/230117
+
 2018-04-20  Eric Carlson  <eric.carlson@apple.com>
 
         Pausing should clear m_waitingToEnterFullscreen
index a7b5025..f5b8074 100644 (file)
@@ -149,10 +149,8 @@ Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame
 #endif
 
     // If we want to useImageDocumentForSubframePDF, we'll let that override plugin support.
-    if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF()) {
-        ASSERT(Image::supportsType(type));
+    if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF())
         return ImageDocument::create(*frame, url);
-    }
 
     PluginData* pluginData = nullptr;
     auto allowedPluginTypes = PluginData::OnlyApplicationPlugins;
index 36a00b7..017bd99 100644 (file)
@@ -55,6 +55,7 @@
 
 namespace WebCore {
 
+static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageResourceMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypesForEncoding;
 static HashSet<String, ASCIICaseInsensitiveHash>* supportedJavaScriptMIMETypes;
@@ -65,19 +66,24 @@ static HashSet<String, ASCIICaseInsensitiveHash>* unsupportedTextMIMETypes;
 
 static void initializeSupportedImageMIMETypes()
 {
+    supportedImageResourceMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
     supportedImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
 
 #if USE(CG)
     // This represents the subset of allowed image UTIs for which CoreServices has a corresponding MIME type. Keep this in sync with allowedImageUTIs().
     static const char* const allowedImageMIMETypes[] = { "image/tiff", "image/gif", "image/jpeg", "image/vnd.microsoft.icon", "image/jp2", "image/png", "image/bmp" };
-    for (auto& mimeType : allowedImageMIMETypes)
+    for (auto& mimeType : allowedImageMIMETypes) {
         supportedImageMIMETypes->add(ASCIILiteral { mimeType });
+        supportedImageResourceMIMETypes->add(ASCIILiteral { mimeType });
+    }
 
 #ifndef NDEBUG
     for (auto& uti : allowedImageUTIs()) {
         auto mimeType = MIMETypeForImageSourceType(uti);
-        if (!mimeType.isEmpty())
+        if (!mimeType.isEmpty()) {
             ASSERT(supportedImageMIMETypes->contains(mimeType));
+            ASSERT(supportedImageResourceMIMETypes->contains(mimeType));
+        }
     }
 
 #if PLATFORM(COCOA)
@@ -88,9 +94,11 @@ static void initializeSupportedImageMIMETypes()
 
     // Favicons don't have a MIME type in the registry either.
     supportedImageMIMETypes->add("image/x-icon");
+    supportedImageResourceMIMETypes->add("image/x-icon");
 
     //  We only get one MIME type per UTI, hence our need to add these manually
     supportedImageMIMETypes->add("image/pjpeg");
+    supportedImageResourceMIMETypes->add("image/pjpeg");
 
 #if PLATFORM(IOS)
     // Add malformed image mimetype for compatibility with Mail and to handle malformed mimetypes from the net
@@ -114,8 +122,10 @@ static void initializeSupportedImageMIMETypes()
         "image/x-bmp", "image/x-win-bitmap", "image/x-windows-bmp", "image/ms-bmp", "image/x-ms-bmp",
         "application/bmp", "application/x-bmp", "application/x-win-bitmap",
     };
-    for (auto& type : malformedMIMETypes)
+    for (auto& type : malformedMIMETypes) {
         supportedImageMIMETypes->add(type);
+        supportedImageResourceMIMETypes->add(type);
+    }
 #endif
 
 #else
@@ -130,11 +140,14 @@ static void initializeSupportedImageMIMETypes()
         "image/x-icon",    // ico
         "image/x-xbitmap"  // xbm
     };
-    for (auto& type : types)
+    for (auto& type : types) {
         supportedImageMIMETypes->add(type);
+        supportedImageResourceMIMETypes->add(type);
+    }
 
 #if USE(WEBP)
     supportedImageMIMETypes->add("image/webp");
+    supportedImageResourceMIMETypes->add("image/webp");
 #endif
 
 #endif // USE(CG)
@@ -450,7 +463,11 @@ bool MIMETypeRegistry::isSupportedImageVideoOrSVGMIMEType(const String& mimeType
 
 bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType)
 {
-    return isSupportedImageMIMEType(mimeType) || isPDFOrPostScriptMIMEType(mimeType);
+    if (mimeType.isEmpty())
+        return false;
+    if (!supportedImageResourceMIMETypes)
+        initializeSupportedImageMIMETypes();
+    return supportedImageResourceMIMETypes->contains(getNormalizedMIMEType(mimeType));
 }
 
 bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType)
@@ -641,6 +658,13 @@ const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedI
     return *supportedImageMIMETypes;
 }
 
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
+{
+    if (!supportedImageResourceMIMETypes)
+        initializeSupportedImageMIMETypes();
+    return *supportedImageResourceMIMETypes;
+}
+
 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedNonImageMIMETypes()
 {
     if (!supportedNonImageMIMETypes)
index eb6dc52..9244973 100644 (file)
@@ -109,6 +109,7 @@ public:
     WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedNonImageMIMETypes();
 
     WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypes();
+    const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageResourceMIMETypes();
     WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedMediaMIMETypes();
     WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getPDFMIMETypes();
     WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& getUnsupportedTextMIMETypes();