Title: [261700] trunk/Source
Revision
261700
Author
[email protected]
Date
2020-05-14 11:06:05 -0700 (Thu, 14 May 2020)

Log Message

[macOS] Update the placeholder icon image for attachment elements with progress="0"
https://bugs.webkit.org/show_bug.cgi?id=211898
<rdar://problem/63203900>

Reviewed by Timothy Hatcher.

Source/WebCore:

Refactor logic for creating an attachment placeholder image into a separate helper method, with a
WebKitAdditions implementation when HAVE(SYSTEM_ATTACHMENT_PLACEHOLDER_ICON) is defined.

* rendering/RenderThemeMac.mm:
(WebCore::createAttachmentPlaceholderImage):
(WebCore::paintAttachmentIconPlaceholder):

Source/WTF:

Add a new flag for HAVE(SYSTEM_ATTACHMENT_PLACEHOLDER_ICON).

* wtf/PlatformHave.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (261699 => 261700)


--- trunk/Source/WTF/ChangeLog	2020-05-14 18:05:06 UTC (rev 261699)
+++ trunk/Source/WTF/ChangeLog	2020-05-14 18:06:05 UTC (rev 261700)
@@ -1,3 +1,15 @@
+2020-05-14  Wenson Hsieh  <[email protected]>
+
+        [macOS] Update the placeholder icon image for attachment elements with progress="0"
+        https://bugs.webkit.org/show_bug.cgi?id=211898
+        <rdar://problem/63203900>
+
+        Reviewed by Timothy Hatcher.
+
+        Add a new flag for HAVE(SYSTEM_ATTACHMENT_PLACEHOLDER_ICON).
+
+        * wtf/PlatformHave.h:
+
 2020-05-14  Chris Dumez  <[email protected]>
 
         Regression(r254856) Family Health iOS app is broken due to lack for WebSQL support

Modified: trunk/Source/WTF/wtf/PlatformHave.h (261699 => 261700)


--- trunk/Source/WTF/wtf/PlatformHave.h	2020-05-14 18:05:06 UTC (rev 261699)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2020-05-14 18:06:05 UTC (rev 261700)
@@ -560,6 +560,10 @@
 #define HAVE_INCREMENTAL_PDF_APIS 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600)
+#define HAVE_SYSTEM_ATTACHMENT_PLACEHOLDER_ICON 1
+#endif
+
 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
 #define HAVE_UICONTEXTMENU_LOCATION 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (261699 => 261700)


--- trunk/Source/WebCore/ChangeLog	2020-05-14 18:05:06 UTC (rev 261699)
+++ trunk/Source/WebCore/ChangeLog	2020-05-14 18:06:05 UTC (rev 261700)
@@ -1,3 +1,18 @@
+2020-05-14  Wenson Hsieh  <[email protected]>
+
+        [macOS] Update the placeholder icon image for attachment elements with progress="0"
+        https://bugs.webkit.org/show_bug.cgi?id=211898
+        <rdar://problem/63203900>
+
+        Reviewed by Timothy Hatcher.
+
+        Refactor logic for creating an attachment placeholder image into a separate helper method, with a
+        WebKitAdditions implementation when HAVE(SYSTEM_ATTACHMENT_PLACEHOLDER_ICON) is defined.
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::createAttachmentPlaceholderImage):
+        (WebCore::paintAttachmentIconPlaceholder):
+
 2020-05-14  Chris Dumez  <[email protected]>
 
         Regression(r254856) Family Health iOS app is broken due to lack for WebSQL support

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (261699 => 261700)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-05-14 18:05:06 UTC (rev 261699)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-05-14 18:06:05 UTC (rev 261700)
@@ -73,6 +73,7 @@
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/cocoa/NSColorSPI.h>
 #import <pal/spi/mac/NSCellSPI.h>
+#import <pal/spi/mac/NSImageSPI.h>
 #import <pal/spi/mac/NSSharingServicePickerSPI.h>
 #import <wtf/MathExtras.h>
 #import <wtf/ObjCRuntimeExtras.h>
@@ -2784,15 +2785,23 @@
     icon->paint(context, layout.iconRect);
 }
 
+#if HAVE(SYSTEM_ATTACHMENT_PLACEHOLDER_ICON) && USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/RenderThemeMacAdditions.mm>
+#else
+
+static std::pair<RefPtr<Image>, float> createAttachmentPlaceholderImage(float deviceScaleFactor, const AttachmentLayout&)
+{
+    if (deviceScaleFactor >= 2)
+        return { Image::loadPlatformResource("AttachmentPlaceholder@2x"), 2 };
+
+    return { Image::loadPlatformResource("AttachmentPlaceholder"), 1 };
+}
+
+#endif
+
 static void paintAttachmentIconPlaceholder(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
 {
-    RefPtr<Image> placeholderImage;
-    float imageScale = 1;
-    if (attachment.document().deviceScaleFactor() >= 2) {
-        placeholderImage = Image::loadPlatformResource("AttachmentPlaceholder@2x");
-        imageScale = 2;
-    } else
-        placeholderImage = Image::loadPlatformResource("AttachmentPlaceholder");
+    auto [placeholderImage, imageScale] = createAttachmentPlaceholderImage(attachment.document().deviceScaleFactor(), layout);
 
     // Center the placeholder image where the icon would usually be.
     FloatRect placeholderRect(0, 0, placeholderImage->width() / imageScale, placeholderImage->height() / imageScale);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to