Title: [196028] trunk
Revision
196028
Author
timothy_hor...@apple.com
Date
2016-02-02 13:31:36 -0800 (Tue, 02 Feb 2016)

Log Message

<attachment> icon should be a folder for the custom MIME type multipart/x-folder
https://bugs.webkit.org/show_bug.cgi?id=153795
<rdar://problem/24416632>

Reviewed by Anders Carlsson.

Source/WebCore:

Test: fast/attachment/attachment-folder-icon.html

* rendering/RenderThemeMac.mm:
(WebCore::iconForAttachment):
(WebCore::paintAttachmentIcon):
Mail uses this special MIME type to indicate that something is a folder, which there
isn't a normal non-deprecated MIME type for.

LayoutTests:

* fast/attachment/attachment-folder-icon-expected.html: Added.
* fast/attachment/attachment-folder-icon.html: Added.
Make sure that the rendering of an attachment with multipart/x-folder
matches that of a file reference pointing at a folder.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (196027 => 196028)


--- trunk/LayoutTests/ChangeLog	2016-02-02 21:16:02 UTC (rev 196027)
+++ trunk/LayoutTests/ChangeLog	2016-02-02 21:31:36 UTC (rev 196028)
@@ -1,3 +1,16 @@
+2016-02-02  Tim Horton  <timothy_hor...@apple.com>
+
+        <attachment> icon should be a folder for the custom MIME type multipart/x-folder
+        https://bugs.webkit.org/show_bug.cgi?id=153795
+        <rdar://problem/24416632>
+
+        Reviewed by Anders Carlsson.
+
+        * fast/attachment/attachment-folder-icon-expected.html: Added.
+        * fast/attachment/attachment-folder-icon.html: Added.
+        Make sure that the rendering of an attachment with multipart/x-folder
+        matches that of a file reference pointing at a folder.
+
 2016-02-02  Gustavo Noronha Silva  <gustavo.noro...@collabora.co.uk>
 
         [GTK] Layout Test fast/images/animated-gif-no-layout.html is failing

Added: trunk/LayoutTests/fast/attachment/attachment-folder-icon-expected.html (0 => 196028)


--- trunk/LayoutTests/fast/attachment/attachment-folder-icon-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-folder-icon-expected.html	2016-02-02 21:31:36 UTC (rev 196028)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<body>
+<attachment title=" "></attachment>
+<script>
+if (window.internals)
+    file = window.internals.createFile("resources/");
+
+var attachments = document.getElementsByTagName("attachment");
+for (var i = 0; i < attachments.length; i++)
+    attachments[i].file = file;
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/attachment/attachment-folder-icon.html (0 => 196028)


--- trunk/LayoutTests/fast/attachment/attachment-folder-icon.html	                        (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-folder-icon.html	2016-02-02 21:31:36 UTC (rev 196028)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<attachment type="multipart/x-folder"></attachment>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (196027 => 196028)


--- trunk/Source/WebCore/ChangeLog	2016-02-02 21:16:02 UTC (rev 196027)
+++ trunk/Source/WebCore/ChangeLog	2016-02-02 21:31:36 UTC (rev 196028)
@@ -1,3 +1,19 @@
+2016-02-02  Tim Horton  <timothy_hor...@apple.com>
+
+        <attachment> icon should be a folder for the custom MIME type multipart/x-folder
+        https://bugs.webkit.org/show_bug.cgi?id=153795
+        <rdar://problem/24416632>
+
+        Reviewed by Anders Carlsson.
+
+        Test: fast/attachment/attachment-folder-icon.html
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::iconForAttachment):
+        (WebCore::paintAttachmentIcon):
+        Mail uses this special MIME type to indicate that something is a folder, which there
+        isn't a normal non-deprecated MIME type for.
+
 2016-02-02  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: storage/indexeddb/cursor-continue-validity.html fails.

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (196027 => 196028)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2016-02-02 21:16:02 UTC (rev 196027)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2016-02-02 21:31:36 UTC (rev 196028)
@@ -2337,22 +2337,28 @@
     }
 }
 
-static void paintAttachmentIcon(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
+static RefPtr<Icon> iconForAttachment(const RenderAttachment& attachment)
 {
-    RefPtr<Icon> icon;
-    String type = attachment.attachmentElement().attachmentType();
-    if (!type.isEmpty())
-        icon = Icon::createIconForMIMEType(type);
-    else {
-        Vector<String> filenames;
-        if (File* file = attachment.attachmentElement().file())
-            filenames.append(file->path());
-        icon = Icon::createIconForFiles(filenames);
+    String MIMEType = attachment.attachmentElement().attachmentType();
+    if (!MIMEType.isEmpty()) {
+        if (equalIgnoringASCIICase(MIMEType, "multipart/x-folder")) {
+            if (auto icon = Icon::createIconForUTI("public.directory"))
+                return icon;
+        } else if (auto icon = Icon::createIconForMIMEType(MIMEType))
+            return icon;
     }
 
-    if (!icon)
-        icon = Icon::createIconForUTI("public.data");
+    if (File* file = attachment.attachmentElement().file()) {
+        if (auto icon = Icon::createIconForFiles({ file->path() }))
+            return icon;
+    }
 
+    return Icon::createIconForUTI("public.data");
+}
+
+static void paintAttachmentIcon(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
+{
+    auto icon = iconForAttachment(attachment);
     if (!icon)
         return;
     icon->paint(context, layout.iconRect);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to