<attachment> icons are low-resolution when transformed or under page scale
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Mar 2015 01:43:07 +0000 (01:43 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Mar 2015 01:43:07 +0000 (01:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142262
<rdar://problem/20035480>

Reviewed by Dean Jackson.

We should use Icon::createIconForFiles, just like <input type="file"> does,
instead of directly talking to IconServices. This results both in less code
and in NSImage's multiresolution magic making the icons sharp even under
the influence of transforms and page scale.

* WebCore.xcodeproj/project.pbxproj:
* platform/spi/mac/IconServicesSPI.h: Removed.
* platform/spi/mac/LaunchServicesSPI.h: Removed.
Get rid of IconServicesSPI.h and LaunchServicesSPI.h.

* platform/graphics/Icon.h:
Include RetainPtr just once.
paint() should take a GraphicsContext reference (null is not an option)
and a FloatRect (after all, it just turns around and converts to NSRect).

* platform/graphics/ios/IconIOS.mm:
(WebCore::Icon::paint):
* platform/graphics/mac/IconMac.mm:
(WebCore::Icon::createIconForFiles):
(WebCore::Icon::paint):
* platform/graphics/efl/IconEfl.cpp:
(WebCore::Icon::paint):
* platform/graphics/gtk/IconGtk.cpp:
(WebCore::Icon::paint):
* platform/graphics/win/IconWin.cpp:
(WebCore::Icon::paint):
Adapt to the paint() signature changes, fix some style, etc.

* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::paintObject):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintFileUploadIconDecorations):
Adapt to the paint() signature changes.

* rendering/RenderThemeMac.mm:
(WebCore::paintAttachmentIcon):
Use Icon::createIconForFiles instead of IconServices.

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/Icon.h
Source/WebCore/platform/graphics/efl/IconEfl.cpp
Source/WebCore/platform/graphics/gtk/IconGtk.cpp
Source/WebCore/platform/graphics/ios/IconIOS.mm
Source/WebCore/platform/graphics/mac/IconMac.mm
Source/WebCore/platform/graphics/win/IconWin.cpp
Source/WebCore/platform/spi/mac/IconServicesSPI.h [deleted file]
Source/WebCore/platform/spi/mac/LaunchServicesSPI.h [deleted file]
Source/WebCore/rendering/RenderFileUploadControl.cpp
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.mm

index cd21caf..52061b6 100644 (file)
@@ -1,3 +1,49 @@
+2015-03-04  Timothy Horton  <timothy_horton@apple.com>
+
+        <attachment> icons are low-resolution when transformed or under page scale
+        https://bugs.webkit.org/show_bug.cgi?id=142262
+        <rdar://problem/20035480>
+
+        Reviewed by Dean Jackson.
+
+        We should use Icon::createIconForFiles, just like <input type="file"> does,
+        instead of directly talking to IconServices. This results both in less code
+        and in NSImage's multiresolution magic making the icons sharp even under
+        the influence of transforms and page scale.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/spi/mac/IconServicesSPI.h: Removed.
+        * platform/spi/mac/LaunchServicesSPI.h: Removed.
+        Get rid of IconServicesSPI.h and LaunchServicesSPI.h.
+
+        * platform/graphics/Icon.h:
+        Include RetainPtr just once.
+        paint() should take a GraphicsContext reference (null is not an option)
+        and a FloatRect (after all, it just turns around and converts to NSRect).
+
+        * platform/graphics/ios/IconIOS.mm:
+        (WebCore::Icon::paint):
+        * platform/graphics/mac/IconMac.mm:
+        (WebCore::Icon::createIconForFiles):
+        (WebCore::Icon::paint):
+        * platform/graphics/efl/IconEfl.cpp:
+        (WebCore::Icon::paint):
+        * platform/graphics/gtk/IconGtk.cpp:
+        (WebCore::Icon::paint):
+        * platform/graphics/win/IconWin.cpp:
+        (WebCore::Icon::paint):
+        Adapt to the paint() signature changes, fix some style, etc.
+
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::paintObject):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintFileUploadIconDecorations):
+        Adapt to the paint() signature changes.
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::paintAttachmentIcon):
+        Use Icon::createIconForFiles instead of IconServices.
+
 2015-03-04  Tim Horton  <timothy_horton@apple.com>
 
         <attachment> should not appear selected when the cursor is adjacent to it
index 3a500e5..9501433 100644 (file)
                2D6E468417D660F500ECF8BB /* PDFDocumentImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */; };
                2D70BA1318074DDF0001908A /* PlatformCALayerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D70BA1218074DDF0001908A /* PlatformCALayerMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D70BA1518074F860001908A /* PlatformCALayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D70BA1418074F850001908A /* PlatformCALayer.cpp */; };
-               2D74E99C1A9D3F3200DFB3D4 /* IconServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D74E99B1A9D3F3200DFB3D4 /* IconServicesSPI.h */; };
-               2D74E99E1A9D402900DFB3D4 /* LaunchServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D74E99D1A9D402900DFB3D4 /* LaunchServicesSPI.h */; };
                2D76BB821945632400CFD29A /* RunLoopObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D76BB801945632400CFD29A /* RunLoopObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D76BB8419456F8100CFD29A /* RunLoopObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D76BB8319456F8100CFD29A /* RunLoopObserver.cpp */; };
                2D8287F616E4A0380086BD00 /* HitTestLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */; };
                2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFDocumentImageMac.mm; sourceTree = "<group>"; };
                2D70BA1218074DDF0001908A /* PlatformCALayerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCALayerMac.h; path = ca/mac/PlatformCALayerMac.h; sourceTree = "<group>"; };
                2D70BA1418074F850001908A /* PlatformCALayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformCALayer.cpp; path = ca/PlatformCALayer.cpp; sourceTree = "<group>"; };
-               2D74E99B1A9D3F3200DFB3D4 /* IconServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconServicesSPI.h; sourceTree = "<group>"; };
-               2D74E99D1A9D402900DFB3D4 /* LaunchServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LaunchServicesSPI.h; sourceTree = "<group>"; };
                2D76BB801945632400CFD29A /* RunLoopObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoopObserver.h; sourceTree = "<group>"; };
                2D76BB8319456F8100CFD29A /* RunLoopObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopObserver.cpp; sourceTree = "<group>"; };
                2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestLocation.cpp; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */,
-                               2D74E99B1A9D3F3200DFB3D4 /* IconServicesSPI.h */,
-                               2D74E99D1A9D402900DFB3D4 /* LaunchServicesSPI.h */,
                                2D413F601A187A3F0041A521 /* LookupSPI.h */,
                                1C6466271A12C3F90094603C /* NSFontSPI.h */,
                                9321D58F1A3906FA008052BE /* NSImmediateActionGestureRecognizerSPI.h */,
                                2E37DFDB12DBAFB800A6B233 /* DOMURL.h in Headers */,
                                CD9DE18217AAD6A400EA386D /* DOMURLMediaSource.h in Headers */,
                                15C770A6100D41CD005BA267 /* DOMValidityState.h in Headers */,
-                               2D74E99C1A9D3F3200DFB3D4 /* IconServicesSPI.h in Headers */,
                                BC1A37C0097C715F0019F3D8 /* DOMViews.h in Headers */,
                                31C0FF490E4CEFDD007D6FE5 /* DOMWebKitAnimationEvent.h in Headers */,
                                31C0FF4B0E4CEFDD007D6FE5 /* DOMWebKitAnimationEventInternal.h in Headers */,
                                B2227A880D00BF220071B782 /* SVGPatternElement.h in Headers */,
                                B2227A8C0D00BF220071B782 /* SVGPointList.h in Headers */,
                                B2227A8F0D00BF220071B782 /* SVGPolyElement.h in Headers */,
-                               2D74E99E1A9D402900DFB3D4 /* LaunchServicesSPI.h in Headers */,
                                2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */,
                                B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */,
                                B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */,
index cf94ee8..aa395c5 100644 (file)
 #ifndef Icon_h
 #define Icon_h
 
+#include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
-#include <wtf/Forward.h>
+#include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 
 #if PLATFORM(IOS)
 #include "NativeImagePtr.h"
 #include <CoreGraphics/CoreGraphics.h>
-#include <wtf/RetainPtr.h>
 #elif PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
 OBJC_CLASS NSImage;
 #elif PLATFORM(WIN)
 typedef struct HICON__* HICON;
@@ -42,7 +41,7 @@ typedef struct _GdkPixbuf GdkPixbuf;
 namespace WebCore {
 
 class GraphicsContext;
-class IntRect;
+class FloatRect;
     
 class Icon : public RefCounted<Icon> {
 public:
@@ -50,7 +49,7 @@ public:
 
     WEBCORE_EXPORT ~Icon();
 
-    void paint(GraphicsContext*, const IntRect&);
+    void paint(GraphicsContext&, const FloatRect&);
 
 #if PLATFORM(WIN)
     static PassRefPtr<Icon> create(HICON hIcon) { return adoptRef(new Icon(hIcon)); }
index 40aea77..9c92c08 100644 (file)
@@ -57,7 +57,7 @@ PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
     return 0;
 }
 
-void Icon::paint(GraphicsContext*, const IntRect&)
+void Icon::paint(GraphicsContext&, const FloatRect&)
 {
     notImplemented();
 }
index 6c91f83..5945e1f 100644 (file)
@@ -113,13 +113,13 @@ PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
     return 0;
 }
 
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
+void Icon::paint(GraphicsContext& context, const FloatRect& rect)
 {
-    if (context->paintingDisabled())
+    if (context.paintingDisabled())
         return;
 
     // TODO: Scale/clip the image if necessary.
-    cairo_t* cr = context->platformContext()->cr();
+    cairo_t* cr = context.platformContext()->cr();
     cairo_save(cr);
     gdk_cairo_set_source_pixbuf(cr, m_icon, rect.x(), rect.y());
     cairo_paint(cr);
index 88bfca0..be35076 100644 (file)
@@ -55,21 +55,20 @@ PassRefPtr<Icon> Icon::createIconForImage(NativeImagePtr imageRef)
     return adoptRef(new Icon(imageRef));
 }
 
-void Icon::paint(GraphicsContext* context, const IntRect& destRect)
+void Icon::paint(GraphicsContext& context, const FloatRect& destRect)
 {
-    if (context->paintingDisabled())
+    if (context.paintingDisabled())
         return;
 
-    GraphicsContextStateSaver stateSaver(*context);
+    GraphicsContextStateSaver stateSaver(context);
 
     float width = CGImageGetWidth(m_cgImage.get());
     float height = CGImageGetHeight(m_cgImage.get());
     FloatSize size(width, height);
-    FloatRect srcRect(0, 0, width, height);
-    ColorSpace colorSpace = ColorSpaceDeviceRGB;
+    FloatRect srcRect(FloatPoint(), size);
 
-    context->setImageInterpolationQuality(InterpolationHigh);
-    context->drawNativeImage(m_cgImage.get(), size, colorSpace, destRect, srcRect);
+    context.setImageInterpolationQuality(InterpolationHigh);
+    context.drawNativeImage(m_cgImage.get(), size, ColorSpaceDeviceRGB, destRect, srcRect);
 }
 
 }
index 1fc094e..6841ee4 100644 (file)
@@ -49,7 +49,7 @@ Icon::~Icon()
 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
     if (filenames.isEmpty())
-        return 0;
+        return nullptr;
 
     bool useIconFromFirstFile;
     useIconFromFirstFile = filenames.size() == 1;
@@ -57,31 +57,29 @@ PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
         // Don't pass relative filenames -- we don't want a result that depends on the current directory.
         // Need 0U here to disambiguate String::operator[] from operator(NSString*, int)[]
         if (filenames[0].isEmpty() || filenames[0][0U] != '/')
-            return 0;
+            return nullptr;
 
-        NSImageimage = [[NSWorkspace sharedWorkspace] iconForFile:filenames[0]];
+        NSImage *image = [[NSWorkspace sharedWorkspace] iconForFile:filenames[0]];
         if (!image)
-            return 0;
+            return nullptr;
 
         return adoptRef(new Icon(image));
     }
-    NSImageimage = [NSImage imageNamed:NSImageNameMultipleDocuments];
+    NSImage *image = [NSImage imageNamed:NSImageNameMultipleDocuments];
     if (!image)
-        return 0;
+        return nullptr;
 
     return adoptRef(new Icon(image));
 }
 
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
+void Icon::paint(GraphicsContext& context, const FloatRect& rect)
 {
-    if (context->paintingDisabled())
+    if (context.paintingDisabled())
         return;
 
-    LocalCurrentGraphicsContext localCurrentGC(context);
+    LocalCurrentGraphicsContext localCurrentGC(&context);
 
-    [m_nsImage.get() drawInRect:rect
-        fromRect:NSMakeRect(0, 0, [m_nsImage.get() size].width, [m_nsImage.get() size].height)
-        operation:NSCompositeSourceOver fraction:1.0f];
+    [m_nsImage drawInRect:rect fromRect:NSMakeRect(0, 0, [m_nsImage size].width, [m_nsImage size].height) operation:NSCompositeSourceOver fraction:1.0f];
 }
 
 }
index f3b0d0b..ee88e20 100644 (file)
@@ -73,12 +73,12 @@ PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
     return adoptRef(new Icon(hIcon));
 }
 
-void Icon::paint(GraphicsContext* context, const IntRect& r)
+void Icon::paint(GraphicsContext& context, const FloatRect& r)
 {
-    if (context->paintingDisabled())
+    if (context.paintingDisabled())
         return;
 
-    LocalWindowsContext windowContext(context, r);
+    LocalWindowsContext windowContext(&context, enclosingIntRect(r));
     DrawIconEx(windowContext.hdc(), r.x(), r.y(), m_hIcon, r.width(), r.height(), 0, 0, DI_NORMAL);
 }
 
diff --git a/Source/WebCore/platform/spi/mac/IconServicesSPI.h b/Source/WebCore/platform/spi/mac/IconServicesSPI.h
deleted file mode 100644 (file)
index 4c65924..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2015 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 "LaunchServicesSPI.h"
-#import "SoftLinking.h"
-#import <objc/runtime.h>
-
-SOFT_LINK_PRIVATE_FRAMEWORK(IconServices)
-
-typedef UInt32 ISScale;
-
-SOFT_LINK(IconServices, _ISCreateCGImageFromBindingWithSizeScaleAndOptions, CGImageRef, (LSBindingRef binding, CGSize size, ISScale scale, CFDictionaryRef options), (binding, size, scale, options))
diff --git a/Source/WebCore/platform/spi/mac/LaunchServicesSPI.h b/Source/WebCore/platform/spi/mac/LaunchServicesSPI.h
deleted file mode 100644 (file)
index 458e8ae..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2015 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 USE(APPLE_INTERNAL_SDK)
-
-#include <LaunchServices/LaunchServicesPriv.h>
-
-#else
-
-WTF_EXTERN_C_BEGIN
-typedef struct _LSBinding* LSBindingRef;
-LSBindingRef _LSBindingCreateWithURL(CFAllocatorRef, CFURLRef);
-WTF_EXTERN_C_END
-
-#endif
index b2a9990..cbb1a73 100644 (file)
@@ -186,7 +186,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
             }
 #else
             // Draw the file icon
-            inputElement().icon()->paint(paintInfo.context, IntRect(roundToInt(iconX), roundToInt(iconY), iconWidth, iconHeight));
+            inputElement().icon()->paint(*paintInfo.context, IntRect(roundToInt(iconX), roundToInt(iconY), iconWidth, iconHeight));
 #endif
         }
     }
index 8bf888d..7c94b72 100644 (file)
@@ -1054,7 +1054,7 @@ bool RenderThemeIOS::paintFileUploadIconDecorations(const RenderObject&, const R
 
     // Foreground picture frame and icon.
     paintInfo.context->fillRoundedRect(FloatRoundedRect(thumbnailPictureFrameRect, cornerSize, cornerSize, cornerSize, cornerSize), pictureFrameColor, ColorSpaceDeviceRGB);
-    icon->paint(paintInfo.context, thumbnailRect);
+    icon->paint(*paintInfo.context, thumbnailRect);
 
     return false;
 }
index e1b865d..a6e104f 100644 (file)
 #import "HTMLMediaElement.h"
 #import "HTMLNames.h"
 #import "HTMLPlugInImageElement.h"
-#import "IconServicesSPI.h"
+#import "Icon.h"
 #import "Image.h"
 #import "ImageBuffer.h"
-#import "LaunchServicesSPI.h"
 #import "LocalCurrentGraphicsContext.h"
 #import "LocalizedStrings.h"
 #import "MediaControlElements.h"
@@ -2322,20 +2321,13 @@ static void paintAttachmentIconBackground(const RenderAttachment&, GraphicsConte
 
 static void paintAttachmentIcon(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
 {
-    File* file = attachment.attachmentElement().file();
-    RetainPtr<LSBindingRef> lsBinding = adoptCF(_LSBindingCreateWithURL(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:file ? file->path() : String()]));
-    if (!lsBinding)
-        return;
-
-    // FIXME: This should take transforms and page scale into account, not just deviceScaleFactor.
-    FloatSize iconSizeInPoints(attachmentIconSize, attachmentIconSize);
-    iconSizeInPoints.scale(attachment.document().deviceScaleFactor());
-
-    RetainPtr<CGImageRef> icon = adoptCF(_ISCreateCGImageFromBindingWithSizeScaleAndOptions(lsBinding.get(), iconSizeInPoints, 1, nil));
+    Vector<String> filenames;
+    if (File* file = attachment.attachmentElement().file())
+        filenames.append(file->path());
+    RefPtr<Icon> icon = Icon::createIconForFiles(filenames);
     if (!icon)
         return;
-
-    context.drawNativeImage(icon.get(), iconSizeInPoints, ColorSpaceDeviceRGB, layout.iconRect, FloatRect(FloatPoint(), iconSizeInPoints));
+    icon->paint(context, layout.iconRect);
 }
 
 static void addAttachmentTitleBackgroundRightCorner(Path& path, const FloatRect* fromRect, const FloatRect* toRect)