Title: [260407] trunk/Source
Revision
260407
Author
[email protected]
Date
2020-04-20 17:27:46 -0700 (Mon, 20 Apr 2020)

Log Message

WK2 Quicklook for attachments
https://bugs.webkit.org/show_bug.cgi?id=208891

Reviewed by Darin Adler.

Source/WebCore:

Added to HTMLAttachmentElement to have member image representing
QuickLook thumbnail. Added code to render this image on both iOS and Mac.

No new tests. Test will be added after additions to test infrastructure.

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::updateThumbnailRepresentation):
Allow setting of thumbnail member.
* html/HTMLAttachmentElement.h:
* rendering/RenderThemeIOS.mm:
Added rendering of image member of attachment element.
(WebCore::RenderAttachmentInfo::RenderAttachmentInfo):
(WebCore::paintAttachmentIcon):
(WebCore::RenderThemeIOS::paintAttachment):
* rendering/RenderThemeMac.mm:
(WebCore::paintAttachmentIcon):

Source/WebKit:

Allow attachment elements to render QuickLook thumbnail generated
from contents of the file as its icon, rather than the default
icons associated with each mime type.

* Configurations/WebKit.xcconfig:
Link QuickLook thumbnailing framework.
* UIProcess/API/APIAttachment.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _insertAttachmentWithFileWrapper:contentType:completion:]):
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
Create thumbnail request and add to queue.
(WebKit::convertNSImageToBitmap):
(WebKit::convertUIImageToBitmap):
(WebKit::WebPageProxy::getQLThumbnailForGenerationRequestion):
(WebKit::WebPageProxy::getQLThumbnailForFileWrapper):
(WebKit::WebPageProxy::getQLThumbnailForAttachment):
* UIProcess/QLThumbnailLoad.h: Added.
* UIProcess/QLThumbnailLoad.mm: Added.
Add code to request thumbnail for file data.
(-[WKQLThumbnailQueueManager init]):
(+[WKQLThumbnailQueueManager sharedInstance]):
(-[WKQLThumbnailLoadOperation initWithAttachment:identifier:]):
(-[WKQLThumbnailLoadOperation initWithURL:identifier:]):
(-[WKQLThumbnailLoadOperation start]):
(-[WKQLThumbnailLoadOperation isAsynchronous]):
(-[WKQLThumbnailLoadOperation isExecuting]):
(-[WKQLThumbnailLoadOperation setExecuting:]):
(-[WKQLThumbnailLoadOperation isFinished]):
(-[WKQLThumbnailLoadOperation setFinished:]):
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateAttachmentIcon):
Set thumbnail of attachment element
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Thumbnail request message.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/wtf/PlatformHave.h (260406 => 260407)


--- trunk/Source/WTF/wtf/PlatformHave.h	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2020-04-21 00:27:46 UTC (rev 260407)
@@ -677,3 +677,7 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(MACCATALYST) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
 #define HAVE_MEDIA_USAGE_FRAMEWORK 1
 #endif
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || PLATFORM(IOS_FAMILY)
+#define HAVE_QUICKLOOK_THUMBNAILING 1
+#endif

Modified: trunk/Source/WebCore/ChangeLog (260406 => 260407)


--- trunk/Source/WebCore/ChangeLog	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebCore/ChangeLog	2020-04-21 00:27:46 UTC (rev 260407)
@@ -1,3 +1,27 @@
+2020-04-20  Nikos Mouchtaris  <[email protected]>
+
+        WK2 Quicklook for attachments
+        https://bugs.webkit.org/show_bug.cgi?id=208891
+
+        Reviewed by Darin Adler.
+
+        Added to HTMLAttachmentElement to have member image representing
+        QuickLook thumbnail. Added code to render this image on both iOS and Mac.
+
+        No new tests. Test will be added after additions to test infrastructure.
+
+        * html/HTMLAttachmentElement.cpp:
+        (WebCore::HTMLAttachmentElement::updateThumbnailRepresentation):
+        Allow setting of thumbnail member.
+        * html/HTMLAttachmentElement.h:
+        * rendering/RenderThemeIOS.mm:
+        Added rendering of image member of attachment element.
+        (WebCore::RenderAttachmentInfo::RenderAttachmentInfo):
+        (WebCore::paintAttachmentIcon):
+        (WebCore::RenderThemeIOS::paintAttachment):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::paintAttachmentIcon):
+
 2020-04-20  Yusuke Suzuki  <[email protected]>
 
         Add more structure-cloning tests for BigInt

Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.cpp (260406 => 260407)


--- trunk/Source/WebCore/html/HTMLAttachmentElement.cpp	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.cpp	2020-04-21 00:27:46 UTC (rev 260407)
@@ -249,6 +249,14 @@
     hostElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document(), Blob::create(WTFMove(data), mimeType)));
 }
 
+void HTMLAttachmentElement::updateThumbnail(const RefPtr<Image>& thumbnail)
+{
+    m_thumbnail = thumbnail;
+    
+    if (auto* renderer = this->renderer())
+        renderer->invalidate();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)

Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.h (260406 => 260407)


--- trunk/Source/WebCore/html/HTMLAttachmentElement.h	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.h	2020-04-21 00:27:46 UTC (rev 260407)
@@ -33,7 +33,9 @@
 
 class File;
 class HTMLImageElement;
+class Image;
 class RenderAttachment;
+class ShareableBitmap;
 class SharedBuffer;
 
 class HTMLAttachmentElement final : public HTMLElement {
@@ -56,6 +58,7 @@
 
     WEBCORE_EXPORT void updateAttributes(Optional<uint64_t>&& newFileSize, const String& newContentType, const String& newFilename);
     WEBCORE_EXPORT void updateEnclosingImageWithData(const String& contentType, Ref<SharedBuffer>&& data);
+    WEBCORE_EXPORT void updateThumbnail(const RefPtr<Image>& thumbnail);
 
     InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
     void removedFromAncestor(RemovalType, ContainerNode&) final;
@@ -67,7 +70,7 @@
     String attachmentTitleForDisplay() const;
     String attachmentType() const;
     String attachmentPath() const;
-
+    RefPtr<Image> thumbnail() const { return m_thumbnail; }
     RenderAttachment* renderer() const;
 
 private:
@@ -87,6 +90,7 @@
     
     RefPtr<File> m_file;
     String m_uniqueIdentifier;
+    RefPtr<Image> m_thumbnail;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (260406 => 260407)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2020-04-21 00:27:46 UTC (rev 260407)
@@ -1619,6 +1619,7 @@
     float progress;
 
     RetainPtr<UIImage> icon;
+    RefPtr<Image> thumbnailIcon;
 
     int baseline { 0 };
 
@@ -1803,8 +1804,11 @@
     if (action.isEmpty() && !hasProgress) {
         FloatSize iconSize;
         icon = iconForAttachment(attachment, iconSize);
-        if (icon) {
-            iconRect = FloatRect(FloatPoint((attachmentRect.width() / 2) - (iconSize.width() / 2), 0), iconSize);
+        thumbnailIcon = attachment.attachmentElement().thumbnail();
+        
+        if (thumbnailIcon || icon) {
+            auto visibleIconSize = thumbnailIcon ? FloatSize(attachmentIconSize, attachmentIconSize) : iconSize;
+            iconRect = FloatRect(FloatPoint((attachmentRect.width() / 2) - (visibleIconSize.width() / 2), 0), visibleIconSize);
             yOffset += iconRect.height() + attachmentItemMargin;
         }
     } else
@@ -1839,11 +1843,13 @@
 
 static void paintAttachmentIcon(GraphicsContext& context, RenderAttachmentInfo& info)
 {
-    if (!info.icon)
-        return;
-
-    auto iconImage = BitmapImage::create([info.icon CGImage]);
-    context.drawImage(iconImage.get(), info.iconRect);
+    RefPtr<Image> iconImage;
+    if (info.thumbnailIcon)
+        iconImage = info.thumbnailIcon;
+    else if (info.icon)
+        iconImage = BitmapImage::create([info.icon CGImage]);
+    
+    context.drawImage(*iconImage, info.iconRect);
 }
 
 static void paintAttachmentText(GraphicsContext& context, RenderAttachmentInfo& info)
@@ -1919,7 +1925,7 @@
 
     if (info.hasProgress)
         paintAttachmentProgress(context, info);
-    else if (info.icon)
+    else if (info.icon || info.thumbnailIcon)
         paintAttachmentIcon(context, info);
 
     paintAttachmentText(context, info);

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (260406 => 260407)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-04-21 00:27:46 UTC (rev 260407)
@@ -2777,6 +2777,10 @@
 
 static void paintAttachmentIcon(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
 {
+    if (auto thumbnailIcon = attachment.attachmentElement().thumbnail()) {
+        context.drawImage(*thumbnailIcon, layout.iconRect);
+        return;
+    }
     auto icon = iconForAttachment(attachment);
     if (!icon)
         return;

Modified: trunk/Source/WebKit/ChangeLog (260406 => 260407)


--- trunk/Source/WebKit/ChangeLog	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/ChangeLog	2020-04-21 00:27:46 UTC (rev 260407)
@@ -1,3 +1,49 @@
+2020-04-20  Nikos Mouchtaris  <[email protected]>
+
+        WK2 Quicklook for attachments
+        https://bugs.webkit.org/show_bug.cgi?id=208891
+
+        Reviewed by Darin Adler.
+
+        Allow attachment elements to render QuickLook thumbnail generated
+        from contents of the file as its icon, rather than the default
+        icons associated with each mime type.
+
+        * Configurations/WebKit.xcconfig:
+        Link QuickLook thumbnailing framework.
+        * UIProcess/API/APIAttachment.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _insertAttachmentWithFileWrapper:contentType:completion:]):
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        Create thumbnail request and add to queue.
+        (WebKit::convertNSImageToBitmap):
+        (WebKit::convertUIImageToBitmap):
+        (WebKit::WebPageProxy::getQLThumbnailForGenerationRequestion):
+        (WebKit::WebPageProxy::getQLThumbnailForFileWrapper):
+        (WebKit::WebPageProxy::getQLThumbnailForAttachment):
+        * UIProcess/QLThumbnailLoad.h: Added.
+        * UIProcess/QLThumbnailLoad.mm: Added.
+        Add code to request thumbnail for file data.
+        (-[WKQLThumbnailQueueManager init]):
+        (+[WKQLThumbnailQueueManager sharedInstance]):
+        (-[WKQLThumbnailLoadOperation initWithAttachment:identifier:]):
+        (-[WKQLThumbnailLoadOperation initWithURL:identifier:]):
+        (-[WKQLThumbnailLoadOperation start]):
+        (-[WKQLThumbnailLoadOperation isAsynchronous]):
+        (-[WKQLThumbnailLoadOperation isExecuting]):
+        (-[WKQLThumbnailLoadOperation setExecuting:]):
+        (-[WKQLThumbnailLoadOperation isFinished]):
+        (-[WKQLThumbnailLoadOperation setFinished:]):
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updateAttachmentIcon):
+        Set thumbnail of attachment element
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Thumbnail request message.
+
 2020-04-20  Kate Cheney  <[email protected]>
 
         Unreviewed macCatalyst build fix.

Modified: trunk/Source/WebKit/Configurations/WebKit.xcconfig (260406 => 260407)


--- trunk/Source/WebKit/Configurations/WebKit.xcconfig	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/Configurations/WebKit.xcconfig	2020-04-21 00:27:46 UTC (rev 260407)
@@ -124,8 +124,14 @@
 WK_AUTHKIT_LDFLAGS_macosx = $(WK_AUTHKIT_LDFLAGS$(WK_MACOS_1015));
 WK_AUTHKIT_LDFLAGS_MACOS_SINCE_1015 = -framework AuthKit;
 
-FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS);
+WK_QUICKLOOK_THUMBNAILING_LDFLAGS = $(WK_QUICKLOOK_THUMBNAILING_LDFLAGS_$(WK_PLATFORM_NAME));
+WK_QUICKLOOK_THUMBNAILING_LDFLAGS_macosx = $(WK_QUICKLOOK_THUMBNAILING_LDFLAGS$(WK_MACOS_1015));
+WK_QUICKLOOK_THUMBNAILING_LDFLAGS_MACOS_SINCE_1015 = -framework QuickLookThumbnailing;
+WK_QUICKLOOK_THUMBNAILING_LDFLAGS_iphoneos = -framework QuickLookThumbnailing;
+WK_QUICKLOOK_THUMBNAILING_LDFLAGS_iphonesimulator = -framework QuickLookThumbnailing;
 
+FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -framework QuickLookThumbnailing -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS) $(WK_QUICKLOOK_THUMBNAILING_LDFLAGS);
+
 // Prevent C++ standard library basic_stringstream, operator new, delete and their related exception types from being exported as weak symbols.
 UNEXPORTED_SYMBOL_LDFLAGS = -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__Znwm -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2EOS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1EOS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSEDn -Wl,-unexported_symbol -Wl,__ZNKSt3__18functionIFvN7WebCore12PolicyActionEEEclES2_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEE4swapERS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1ERKS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2ERKS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEE
 ED1Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED2Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSERKS4_ -Wl,-unexported_symbol -Wl,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_14basic_iostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE16_NS_13basic_ostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTTNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEE
 NS_9allocatorIcEEEE8_NS_13basic_ostreamIcS2_EE;
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (260406 => 260407)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-04-21 00:27:46 UTC (rev 260407)
@@ -46,6 +46,7 @@
 #import "ObjCObjectGraph.h"
 #import "PageClient.h"
 #import "ProvisionalPageProxy.h"
+#import "QuickLookThumbnailLoader.h"
 #import "RemoteLayerTreeScrollingPerformanceData.h"
 #import "RemoteObjectRegistry.h"
 #import "RemoteObjectRegistryMessages.h"
@@ -2160,7 +2161,9 @@
         if (capturedHandler)
             capturedHandler(error == WebKit::CallbackBase::Error::None);
     });
-
+#if HAVE(QUICKLOOK_THUMBNAILING)
+    _page->requestThumbnailWithFileWrapper(fileWrapper, identifier);
+#endif
     return wrapper(attachment);
 #else
     return nil;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (260406 => 260407)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2020-04-21 00:27:46 UTC (rev 260407)
@@ -33,6 +33,7 @@
 #import "InsertTextOptions.h"
 #import "LoadParameters.h"
 #import "PageClient.h"
+#import "QuickLookThumbnailLoader.h"
 #import "SafeBrowsingSPI.h"
 #import "SafeBrowsingWarning.h"
 #import "SharedBufferDataReference.h"
@@ -387,6 +388,68 @@
 }
 #endif
 
+#if HAVE(QUICKLOOK_THUMBNAILING)
+#if PLATFORM(MAC)
+using PlatformImage = NSImage*;
+#elif PLATFORM(IOS_FAMILY)
+using PlatformImage = UIImage*;
+#endif
+
+static RefPtr<WebKit::ShareableBitmap> convertPlatformImageToBitmap(PlatformImage image, const WebCore::IntSize& size)
+{
+    WebKit::ShareableBitmap::Configuration bitmapConfiguration;
+    auto bitmap = WebKit::ShareableBitmap::createShareable(size, bitmapConfiguration);
+    if (!bitmap)
+        return nullptr;
+
+    auto graphicsContext = bitmap->createGraphicsContext();
+    if (!graphicsContext)
+        return nullptr;
+#if PLATFORM(IOS_FAMILY)
+    UIGraphicsPushContext(graphicsContext->platformContext());
+    [image drawInRect:CGRectMake(0, 0, bitmap->size().width(), bitmap->size().height())];
+    UIGraphicsPopContext();
+#elif PLATFORM(MAC)
+    auto savedContext = adoptNS([NSGraphicsContext currentContext]);
+
+    [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithCGContext:graphicsContext->platformContext() flipped:YES]];
+    [image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil];
+
+    [NSGraphicsContext setCurrentContext:savedContext.get()];
+#endif
+    return bitmap;
+}
+
+void WebPageProxy::requestThumbnailWithOperation(WKQLThumbnailLoadOperation *operation)
+{
+    [operation setCompletionBlock:^{
+        dispatch_async(dispatch_get_main_queue(), ^{
+            auto identifier = [operation identifier];
+            auto convertedImage = convertPlatformImageToBitmap([operation thumbnail], WebCore::IntSize(400, 400));
+            if (!convertedImage)
+                return;
+            this->updateAttachmentIcon(identifier, convertedImage);
+        });
+    }];
+        
+    [[WKQLThumbnailQueueManager sharedInstance].qlThumbnailGenerationQueue addOperation:operation];
+}
+
+
+void WebPageProxy::requestThumbnailWithFileWrapper(NSFileWrapper* fileWrapper, const String& identifier)
+{
+    auto operation = adoptNS([[WKQLThumbnailLoadOperation alloc] initWithAttachment:fileWrapper identifier:identifier]);
+    requestThumbnailWithOperation(operation.get());
+}
+
+void WebPageProxy::requestThumbnailWithPath(const String& identifier, const String& filePath)
+{
+    auto operation = adoptNS([[WKQLThumbnailLoadOperation alloc] initWithURL:filePath identifier:identifier]);
+    requestThumbnailWithOperation(operation.get());
+    
+}
+
+#endif
 } // namespace WebKit
 
 #undef MESSAGE_CHECK_COMPLETION

Added: trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.h (0 => 260407)


--- trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.h	2020-04-21 00:27:46 UTC (rev 260407)
@@ -0,0 +1,60 @@
+/*
+* Copyright (C) 2020 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#if HAVE(QUICKLOOK_THUMBNAILING)
+
+#if PLATFORM(IOS_FAMILY)
+@class UIImage;
+#endif
+
+@interface WKQLThumbnailQueueManager : NSObject
+
+@property (nonatomic, readwrite, retain) NSOperationQueue* qlThumbnailGenerationQueue;
+- (id)init;
++ (WKQLThumbnailQueueManager *)sharedInstance;
+@end
+
+@interface WKQLThumbnailLoadOperation : NSOperation
+
+@property (readonly, getter=isAsynchronous) BOOL asynchronous;
+@property (readonly, getter=isExecuting) BOOL executing;
+@property (readonly, getter=isFinished) BOOL finished;
+
+@property (nonatomic, copy) NSString *contentType;
+@property (nonatomic) BOOL shouldWrite;
+
+- (id)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier;
+- (id)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier;
+- (NSString *)identifier;
+#if PLATFORM(IOS_FAMILY)
+-(UIImage *)thumbnail;
+#endif
+#if PLATFORM(MAC)
+-(NSImage *)thumbnail;
+#endif
+
+@end
+
+#endif

Added: trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.mm (0 => 260407)


--- trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.mm	2020-04-21 00:27:46 UTC (rev 260407)
@@ -0,0 +1,190 @@
+/*
+* Copyright (C) 2020 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#import "config.h"
+#import "QuickLookThumbnailLoader.h"
+
+#if HAVE(QUICKLOOK_THUMBNAILING)
+
+#import <QuickLookThumbnailing/QLThumbnailGenerator.h>
+#import <wtf/FileSystem.h>
+
+@implementation WKQLThumbnailQueueManager 
+
+- (id)init
+{
+    self = [super init];
+    if (self)
+        _qlThumbnailGenerationQueue = [[NSOperationQueue alloc] init];
+    return self;
+}
+
++ (WKQLThumbnailQueueManager *)sharedInstance
+{
+    static WKQLThumbnailQueueManager *sharedInstance = [[WKQLThumbnailQueueManager alloc] init];
+    return sharedInstance;
+}
+
+@end
+
+@implementation WKQLThumbnailLoadOperation {
+    RetainPtr<NSURL> _filePath;
+    RetainPtr<NSMutableString> _identifier;
+    RetainPtr<NSFileWrapper> _fileWrapper;
+#if PLATFORM(MAC)
+    RetainPtr<NSImage> _thumbnail;
+#endif
+#if PLATFORM(IOS_FAMILY)
+    RetainPtr<UIImage> _thumbnail;
+#endif
+}
+
+- (id)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier
+{
+    if (self = [super init]) {
+        _fileWrapper = fileWrapper;
+        _identifier = adoptNS([identifier copy]);
+        _shouldWrite = YES;
+    }
+    return self;
+}
+
+- (id)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier
+{
+    if (self = [super init]) {
+        _identifier = adoptNS([identifier copy]);
+        _filePath = [NSURL fileURLWithPath:fileURL];
+    }
+    return self;
+}
+
+- (void)start
+{
+    self.executing = YES;
+    
+    if (_shouldWrite) {
+        NSString *temporaryDirectory = FileSystem::createTemporaryDirectory(@"QLTempFileData");
+    
+        NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:[_fileWrapper preferredFilename]];
+        NSFileWrapperWritingOptions options = 0;
+        NSError *error = nil;
+        
+        auto fileURLPath = adoptNS([NSURL fileURLWithPath:filePath]);
+
+        [_fileWrapper writeToURL:fileURLPath.get() options:options originalContentsURL:nil error:&error];
+        _filePath = WTFMove(fileURLPath);
+        if (error)
+            return;
+    }
+
+    QLThumbnailGenerationRequest *req = [[QLThumbnailGenerationRequest alloc] initWithFileAtURL:_filePath.get() size:CGSizeMake(400, 400) scale:1 representationTypes:QLThumbnailGenerationRequestRepresentationTypeAll];
+    req.iconMode = YES;
+    
+    [[QLThumbnailGenerator sharedGenerator] generateBestRepresentationForRequest:req completionHandler:^(QLThumbnailRepresentation *thumbnail, NSError *error) {
+        if (error)
+            return;
+        if (_thumbnail)
+            return;
+#if PLATFORM(MAC)
+        _thumbnail = thumbnail.NSImage;
+#endif
+#if PLATFORM(IOS_FAMILY)
+        _thumbnail = thumbnail.UIImage;
+#endif
+        if (_shouldWrite)
+            [[NSFileManager defaultManager] removeItemAtURL:_filePath.get() error:nullptr];
+
+        self.executing = NO;
+        self.finished = YES;
+    }];
+}
+
+#if PLATFORM(IOS_FAMILY)
+- (UIImage *)thumbnail
+{
+    return _thumbnail.get();
+}
+#endif
+
+#if PLATFORM(MAC)
+- (NSImage *)thumbnail
+{
+    return _thumbnail.get();
+}
+#endif
+
+- (NSString *)identifier
+{
+    return _identifier.get();
+}
+
+- (BOOL)isAsynchronous
+{
+    return YES;
+}
+
+@synthesize executing=_executing;
+
+- (BOOL)isExecuting
+{
+    @synchronized(self) {
+        return _executing;
+    }
+}
+
+- (void)setExecuting:(BOOL)executing
+{
+    @synchronized(self) {
+        if (executing != _executing) {
+            [self willChangeValueForKey:@"isExecuting"];
+            _executing = executing;
+            [self didChangeValueForKey:@"isExecuting"];
+        }
+    }
+}
+
+@synthesize finished=_finished;
+
+- (BOOL)isFinished
+{
+    @synchronized(self) {
+        return _finished;
+    }
+}
+
+- (void)setFinished:(BOOL)finished
+{
+    @synchronized(self) {
+        if (finished != _finished) {
+            [self willChangeValueForKey:@"isFinished"];
+            _finished = finished;
+            [self didChangeValueForKey:@"isFinished"];
+        }
+    }
+}
+
+@end
+
+#endif

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (260406 => 260407)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-21 00:27:46 UTC (rev 260407)
@@ -9495,6 +9495,20 @@
     send(Messages::WebPage::UpdateAttachmentAttributes(attachment.identifier(), attachment.fileSizeForDisplay(), attachment.contentType(), attachment.fileName(), WTFMove(dataReference), callbackID));
 }
 
+#if HAVE(QUICKLOOK_THUMBNAILING)
+void WebPageProxy::updateAttachmentIcon(const String& identifier, const RefPtr<ShareableBitmap>& bitmap)
+{
+    if (!hasRunningProcess())
+        return;
+    
+    ShareableBitmap::Handle handle;
+    if (bitmap)
+        bitmap->createHandle(handle);
+
+    send(Messages::WebPage::UpdateAttachmentIcon(identifier, handle));
+}
+#endif
+
 void WebPageProxy::registerAttachmentIdentifierFromData(const String& identifier, const String& contentType, const String& preferredFileName, const IPC::SharedBufferDataReference& data)
 {
     MESSAGE_CHECK(m_process, m_preferences->attachmentElementEnabled());
@@ -9522,8 +9536,10 @@
     attachment->setContentType(contentType);
     attachment->setFilePath(filePath);
     m_attachmentIdentifierToAttachmentMap.set(identifier, attachment.copyRef());
-
     platformRegisterAttachment(WTFMove(attachment), filePath);
+#if HAVE(QUICKLOOK_THUMBNAILING)
+    requestThumbnailWithPath(identifier, filePath);
+#endif
 }
 
 void WebPageProxy::registerAttachmentIdentifier(const String& identifier)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (260406 => 260407)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-04-21 00:27:46 UTC (rev 260407)
@@ -201,6 +201,8 @@
 class FormDataReference;
 class SharedBufferDataReference;
 }
+OBJC_CLASS NSFileWrapper;
+OBJC_CLASS WKQLThumbnailLoadOperation;
 
 namespace WebCore {
 class AuthenticationChallenge;
@@ -1596,7 +1598,12 @@
     void serializedAttachmentDataForIdentifiers(const Vector<String>&, CompletionHandler<void(Vector<WebCore::SerializedAttachmentData>&&)>&&);
     void registerAttachmentIdentifier(const String&);
     void didInvalidateDataForAttachment(API::Attachment&);
-
+#if HAVE(QUICKLOOK_THUMBNAILING)
+    void updateAttachmentIcon(const String&, const RefPtr<ShareableBitmap>&);
+    void requestThumbnailWithPath(const String&, const String&);
+    void requestThumbnailWithFileWrapper(NSFileWrapper*, const String&);
+    void requestThumbnailWithOperation(WKQLThumbnailLoadOperation*);
+#endif
     enum class ShouldUpdateAttachmentAttributes : bool { No, Yes };
     ShouldUpdateAttachmentAttributes willUpdateAttachmentAttributes(const API::Attachment&);
 #endif

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (260406 => 260407)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-04-21 00:27:46 UTC (rev 260407)
@@ -164,6 +164,7 @@
 		1A07D2F91919B3A900ECDA16 /* messages.py in Copy Message Generation Scripts */ = {isa = PBXBuildFile; fileRef = 0FC0856F187CE0A900780D86 /* messages.py */; };
 		1A07D2FA1919B3A900ECDA16 /* model.py in Copy Message Generation Scripts */ = {isa = PBXBuildFile; fileRef = 0FC08570187CE0A900780D86 /* model.py */; };
 		1A07D2FB1919B3A900ECDA16 /* parser.py in Copy Message Generation Scripts */ = {isa = PBXBuildFile; fileRef = 0FC08571187CE0A900780D86 /* parser.py */; };
+		1A0C225E243575CD00ED614D /* QuickLookThumbnailLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEE57242409F142002005D6 /* QuickLookThumbnailLoader.mm */; };
 		1A0EC603124A9F2C007EF4A5 /* PluginProcessManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC601124A9F2C007EF4A5 /* PluginProcessManager.h */; };
 		1A0EC6C0124BBD9B007EF4A5 /* PluginProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC6BE124BBD9B007EF4A5 /* PluginProcessMessages.h */; };
 		1A0EC75E124BC7B2007EF4A5 /* PluginProcessProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC75C124BC7B2007EF4A5 /* PluginProcessProxy.h */; };
@@ -379,6 +380,7 @@
 		1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE4987611FF7FAA0048B464 /* JSNPObject.h */; };
 		1AE49A4911FFA8CE0048B464 /* JSNPMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE49A4711FFA8CE0048B464 /* JSNPMethod.h */; };
 		1AE52F981920267200A1FA37 /* WKContextConfigurationRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE52F9419201F6B00A1FA37 /* WKContextConfigurationRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1AEE57252409F142002005D6 /* QuickLookThumbnailLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEE57232409F142002005D6 /* QuickLookThumbnailLoader.h */; };
 		1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */; };
 		1AEFD27911D16C81008219D3 /* ArgumentCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFD27811D16C81008219D3 /* ArgumentCoder.h */; };
 		1AEFD2F711D1807B008219D3 /* ArgumentCoders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFD2F611D1807B008219D3 /* ArgumentCoders.h */; };
@@ -2663,6 +2665,8 @@
 		1AE52F9319201F6B00A1FA37 /* WKContextConfigurationRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKContextConfigurationRef.cpp; sourceTree = "<group>"; };
 		1AE52F9419201F6B00A1FA37 /* WKContextConfigurationRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContextConfigurationRef.h; sourceTree = "<group>"; };
 		1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapePluginMac.mm; sourceTree = "<group>"; };
+		1AEE57232409F142002005D6 /* QuickLookThumbnailLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QuickLookThumbnailLoader.h; sourceTree = "<group>"; };
+		1AEE57242409F142002005D6 /* QuickLookThumbnailLoader.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = QuickLookThumbnailLoader.mm; sourceTree = "<group>"; };
 		1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInfoStore.h; sourceTree = "<group>"; };
 		1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginInfoStore.cpp; sourceTree = "<group>"; };
 		1AEFCCBC11D02C5E008219D3 /* PluginInfoStoreMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginInfoStoreMac.mm; sourceTree = "<group>"; };
@@ -8933,6 +8937,8 @@
 				83048AE51ACA45DC0082C832 /* ProcessThrottlerClient.h */,
 				4683569B21E81CC7006E27A3 /* ProvisionalPageProxy.cpp */,
 				4683569A21E81CC7006E27A3 /* ProvisionalPageProxy.h */,
+				1AEE57232409F142002005D6 /* QuickLookThumbnailLoader.h */,
+				1AEE57242409F142002005D6 /* QuickLookThumbnailLoader.mm */,
 				BC111B08112F5E3C00337BAB /* ResponsivenessTimer.cpp */,
 				1A30066C1110F4F70031937C /* ResponsivenessTimer.h */,
 				5CA98549210BEB5A0057EB6B /* SafeBrowsingWarning.h */,
@@ -10999,6 +11005,7 @@
 				86E67A251910B9D100004AB7 /* ProcessThrottler.h in Headers */,
 				83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */,
 				A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */,
+				1AEE57252409F142002005D6 /* QuickLookThumbnailLoader.h in Headers */,
 				57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */,
 				9B1229D223FF2BCC008CA751 /* RemoteAudioDestinationIdentifier.h in Headers */,
 				9B1229CD23FF25F2008CA751 /* RemoteAudioDestinationManager.h in Headers */,
@@ -11327,7 +11334,6 @@
 				BCEE7AD112817988009827DA /* WebProcessProxyMessages.h in Headers */,
 				BCE0E425168B7A280057E66A /* WebProcessSupplement.h in Headers */,
 				1A1E093418861D3800D2DC49 /* WebProgressTrackerClient.h in Headers */,
-				5109099723DACBF2003B1E4C /* WKScriptMessageHandlerWithReply.h in Headers */,
 				512F589D12A8838800629530 /* WebProtectionSpace.h in Headers */,
 				461CCCA6231485AA00B659B9 /* WebRemoteObjectRegistry.h in Headers */,
 				37948404150C350600E52CE9 /* WebRenderLayer.h in Headers */,
@@ -11681,6 +11687,7 @@
 				5CA26D81217ABD5B00F97A35 /* WKSafeBrowsingWarning.h in Headers */,
 				1A7E377918E4A4FE003D0FFF /* WKScriptMessage.h in Headers */,
 				1A7E377518E4A33A003D0FFF /* WKScriptMessageHandler.h in Headers */,
+				5109099723DACBF2003B1E4C /* WKScriptMessageHandlerWithReply.h in Headers */,
 				7CC99A3618EF7CBC0048C8B4 /* WKScriptMessageInternal.h in Headers */,
 				0FCB4E5418BBE044000FCFC9 /* WKScrollView.h in Headers */,
 				0F04159C23C7CC730060A3E2 /* WKScrollViewMac.h in Headers */,
@@ -12738,6 +12745,7 @@
 				C15CBB3723F37ECB00300CC7 /* PreferenceObserver.mm in Sources */,
 				2D54C31B212F4DA60049C174 /* ProcessLauncher.cpp in Sources */,
 				CD2865EF2255562000606AC7 /* ProcessTaskStateObserver.mm in Sources */,
+				1A0C225E243575CD00ED614D /* QuickLookThumbnailLoader.mm in Sources */,
 				9B1229CE23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp in Sources */,
 				CDAC20F723FC726C0021DEE3 /* RemoteCDMFactoryProxyMessageReceiver.cpp in Sources */,
 				CDAC20F823FC726C0021DEE3 /* RemoteCDMInstanceProxyMessageReceiver.cpp in Sources */,

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (260406 => 260407)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-04-21 00:27:46 UTC (rev 260407)
@@ -6841,6 +6841,14 @@
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
+void WebPage::updateAttachmentIcon(const String& identifier, const ShareableBitmap::Handle& qlThumbnailHandle)
+{
+    if (auto attachment = attachmentElementWithIdentifier(identifier)) {
+        if (RefPtr<ShareableBitmap> thumbnail = !qlThumbnailHandle.isNull() ? ShareableBitmap::create(qlThumbnailHandle) : nullptr)
+            attachment->updateThumbnail(thumbnail->createImage());
+    }
+}
+
 RefPtr<HTMLAttachmentElement> WebPage::attachmentElementWithIdentifier(const String& identifier) const
 {
     // FIXME: Handle attachment elements in subframes too as well.

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (260406 => 260407)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-04-21 00:27:46 UTC (rev 260407)
@@ -49,6 +49,7 @@
 #include "PolicyDecision.h"
 #include "SandboxExtension.h"
 #include "ShareSheetCallbackID.h"
+#include "ShareableBitmap.h"
 #include "SharedMemory.h"
 #include "StorageNamespaceIdentifier.h"
 #include "TransactionID.h"
@@ -1218,6 +1219,7 @@
 #if ENABLE(ATTACHMENT_ELEMENT)
     void insertAttachment(const String& identifier, Optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID);
     void updateAttachmentAttributes(const String& identifier, Optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, const IPC::SharedBufferDataReference& enclosingImageData, CallbackID);
+    void updateAttachmentIcon(const String& identifier, const ShareableBitmap::Handle& qlThumbnailHandle);
 #endif
 
 #if ENABLE(APPLICATION_MANIFEST)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (260406 => 260407)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-04-21 00:03:27 UTC (rev 260406)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-04-21 00:27:46 UTC (rev 260407)
@@ -560,6 +560,7 @@
 #if ENABLE(ATTACHMENT_ELEMENT)
     InsertAttachment(String identifier, Optional<uint64_t> fileSize, String fileName, String contentType, WebKit::CallbackID callbackID)
     UpdateAttachmentAttributes(String identifier, Optional<uint64_t> fileSize, String contentType, String fileName, IPC::SharedBufferDataReference enclosingImageData, WebKit::CallbackID callbackID)
+    UpdateAttachmentIcon(String identifier, WebKit::ShareableBitmap::Handle qlThumbnailHandle)
 #endif
 
 #if ENABLE(APPLICATION_MANIFEST)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to