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

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@230847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index 9754a9d..b150dfa 100644
--- 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
index 99f7eaf..0000000
--- a/ManualTests/DragInlinePDFImageDocument.html
+++ /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
index 8f2eeaf..0000000
--- a/ManualTests/resources/simple.pdf
+++ /dev/null
Binary files differ
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b24ee02..29d0f71 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/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  Eric Carlson  <eric.carlson@apple.com>
 
         Pausing should clear m_waitingToEnterFullscreen
diff --git a/Source/WebCore/dom/DOMImplementation.cpp b/Source/WebCore/dom/DOMImplementation.cpp
index a7b5025..f5b8074 100644
--- a/Source/WebCore/dom/DOMImplementation.cpp
+++ b/Source/WebCore/dom/DOMImplementation.cpp
@@ -149,10 +149,8 @@
 #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;
diff --git a/Source/WebCore/platform/MIMETypeRegistry.cpp b/Source/WebCore/platform/MIMETypeRegistry.cpp
index 36a00b7..017bd99 100644
--- a/Source/WebCore/platform/MIMETypeRegistry.cpp
+++ b/Source/WebCore/platform/MIMETypeRegistry.cpp
@@ -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 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 @@
 
     // 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 @@
         "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 @@
         "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::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 @@
     return *supportedImageMIMETypes;
 }
 
+const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
+{
+    if (!supportedImageResourceMIMETypes)
+        initializeSupportedImageMIMETypes();
+    return *supportedImageResourceMIMETypes;
+}
+
 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedNonImageMIMETypes()
 {
     if (!supportedNonImageMIMETypes)
diff --git a/Source/WebCore/platform/MIMETypeRegistry.h b/Source/WebCore/platform/MIMETypeRegistry.h
index eb6dc52..9244973 100644
--- a/Source/WebCore/platform/MIMETypeRegistry.h
+++ b/Source/WebCore/platform/MIMETypeRegistry.h
@@ -109,6 +109,7 @@
     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();