<attachment> icon should be a folder for the custom MIME type multipart/x-folder
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Feb 2016 21:31:36 +0000 (21:31 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Feb 2016 21:31:36 +0000 (21:31 +0000)
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.

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

LayoutTests/ChangeLog
LayoutTests/fast/attachment/attachment-folder-icon-expected.html [new file with mode: 0644]
LayoutTests/fast/attachment/attachment-folder-icon.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderThemeMac.mm

index 99d3e29..d0704ef 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-02  Tim Horton  <timothy_horton@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.noronha@collabora.co.uk>
 
         [GTK] Layout Test fast/images/animated-gif-no-layout.html is failing
diff --git a/LayoutTests/fast/attachment/attachment-folder-icon-expected.html b/LayoutTests/fast/attachment/attachment-folder-icon-expected.html
new file mode 100644 (file)
index 0000000..efd122d
--- /dev/null
@@ -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>
diff --git a/LayoutTests/fast/attachment/attachment-folder-icon.html b/LayoutTests/fast/attachment/attachment-folder-icon.html
new file mode 100644 (file)
index 0000000..c57c9bf
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<attachment type="multipart/x-folder"></attachment>
+</body>
+</html>
index 5946845..cde09c0 100644 (file)
@@ -1,3 +1,19 @@
+2016-02-02  Tim Horton  <timothy_horton@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  <beidson@apple.com>
 
         Modern IDB: storage/indexeddb/cursor-continue-validity.html fails.
index dea9269..1d96427 100644 (file)
@@ -2337,22 +2337,28 @@ static void paintAttachmentIconBackground(const RenderAttachment&, GraphicsConte
     }
 }
 
-static void paintAttachmentIcon(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout)
-{
-    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);
+static RefPtr<Icon> iconForAttachment(const RenderAttachment& attachment)
+{
+    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);