Title: [290384] trunk/Source
Revision
290384
Author
[email protected]
Date
2022-02-23 11:02:54 -0800 (Wed, 23 Feb 2022)

Log Message

Prevent use of PDFKit when using PDF.js
https://bugs.webkit.org/show_bug.cgi?id=237052
rdar://89251696

Reviewed by Tim Horton.

Source/WebCore:

Add WEBCORE_EXPORT in order to use isPDFMIMEType.

* platform/MIMETypeRegistry.h:

Source/WebKit:

PDFKit was still being used by embeds, this patch fixes that issue by treating
pdf embeds as frames if PDF.js is enabled and also prevents the loading of
the PDFKit plugin entirely by modifying shouldUsePDFPlugin.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::objectContentType):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::shouldUsePDFPlugin const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290383 => 290384)


--- trunk/Source/WebCore/ChangeLog	2022-02-23 18:36:23 UTC (rev 290383)
+++ trunk/Source/WebCore/ChangeLog	2022-02-23 19:02:54 UTC (rev 290384)
@@ -1,3 +1,15 @@
+2022-02-23  J Pascoe  <[email protected]>
+
+        Prevent use of PDFKit when using PDF.js
+        https://bugs.webkit.org/show_bug.cgi?id=237052
+        rdar://89251696
+
+        Reviewed by Tim Horton.
+
+        Add WEBCORE_EXPORT in order to use isPDFMIMEType.
+
+        * platform/MIMETypeRegistry.h:
+
 2022-02-23  Alan Bujtas  <[email protected]>
 
         [IFC][Integration] LineLayout::firstInlineBoxRect should flip the rect coordinates for vertical-rl

Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (290383 => 290384)


--- trunk/Source/WebCore/platform/MIMETypeRegistry.h	2022-02-23 18:36:23 UTC (rev 290383)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h	2022-02-23 19:02:54 UTC (rev 290384)
@@ -105,7 +105,7 @@
     static bool isApplicationPluginMIMEType(const String& mimeType);
 
     // Check to see if a MIME type is one of the common PDF/PS types.
-    static bool isPDFMIMEType(const String& mimeType);
+    WEBCORE_EXPORT static bool isPDFMIMEType(const String& mimeType);
     static bool isPostScriptMIMEType(const String& mimeType);
     WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType);
 

Modified: trunk/Source/WebKit/ChangeLog (290383 => 290384)


--- trunk/Source/WebKit/ChangeLog	2022-02-23 18:36:23 UTC (rev 290383)
+++ trunk/Source/WebKit/ChangeLog	2022-02-23 19:02:54 UTC (rev 290384)
@@ -1,5 +1,22 @@
 2022-02-23  J Pascoe  <[email protected]>
 
+        Prevent use of PDFKit when using PDF.js
+        https://bugs.webkit.org/show_bug.cgi?id=237052
+        rdar://89251696
+
+        Reviewed by Tim Horton.
+
+        PDFKit was still being used by embeds, this patch fixes that issue by treating
+        pdf embeds as frames if PDF.js is enabled and also prevents the loading of
+        the PDFKit plugin entirely by modifying shouldUsePDFPlugin.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::objectContentType):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::shouldUsePDFPlugin const):
+
+2022-02-23  J Pascoe  <[email protected]>
+
         [WebAuthn] userHandle not marked nullable in _WKWebAuthenticationAssertionResponse
         https://bugs.webkit.org/show_bug.cgi?id=237043
         rdar://89317740

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (290383 => 290384)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2022-02-23 18:36:23 UTC (rev 290383)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2022-02-23 19:02:54 UTC (rev 290384)
@@ -1704,6 +1704,10 @@
             return ObjectContentType::Frame;
         }
     }
+    if (auto* webPage = m_frame->page()) {
+        if (webPage->corePage()->settings().pdfJSViewerEnabled() && MIMETypeRegistry::isPDFMIMEType(mimeType))
+            return ObjectContentType::Frame;
+    }
 
     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
         return ObjectContentType::Image;

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (290383 => 290384)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2022-02-23 18:36:23 UTC (rev 290383)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2022-02-23 19:02:54 UTC (rev 290384)
@@ -206,6 +206,7 @@
 bool WebPage::shouldUsePDFPlugin(const String& contentType, StringView path) const
 {
     return pdfPluginEnabled()
+        && !corePage()->settings().pdfJSViewerEnabled()
         && getPDFLayerControllerClass()
         && (MIMETypeRegistry::isPDFOrPostScriptMIMEType(contentType)
             || (contentType.isEmpty()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to