Title: [137934] trunk/Source/WebCore
Revision
137934
Author
[email protected]
Date
2012-12-17 13:28:15 -0800 (Mon, 17 Dec 2012)

Log Message

Dragging a .jpg to Finder saves it as .jpeg
https://bugs.webkit.org/show_bug.cgi?id=105140
https://code.google.com/p/chromium/issues/detail?id=35811

Patch by Avi Drissman <[email protected]> on 2012-12-17
Reviewed by Tony Chang.

If the filename's extension is already valid for the MIME type, we don't
need to rewrite it to the preferred extension.

No layout tests because it involves dragging items to the desktop.

* platform/chromium/ClipboardChromium.cpp:
(WebCore::writeImageToDataObject):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (137933 => 137934)


--- trunk/Source/WebCore/ChangeLog	2012-12-17 21:22:44 UTC (rev 137933)
+++ trunk/Source/WebCore/ChangeLog	2012-12-17 21:28:15 UTC (rev 137934)
@@ -1,3 +1,19 @@
+2012-12-17  Avi Drissman  <[email protected]>
+
+        Dragging a .jpg to Finder saves it as .jpeg
+        https://bugs.webkit.org/show_bug.cgi?id=105140
+        https://code.google.com/p/chromium/issues/detail?id=35811
+
+        Reviewed by Tony Chang.
+
+        If the filename's extension is already valid for the MIME type, we don't
+        need to rewrite it to the preferred extension.
+
+        No layout tests because it involves dragging items to the desktop.
+
+        * platform/chromium/ClipboardChromium.cpp:
+        (WebCore::writeImageToDataObject):
+
 2012-12-17  Bem Jones-Bey  <[email protected]>
 
         [CSS Exclusions] shape-outside on floats for rectangle shapes height/width

Modified: trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp (137933 => 137934)


--- trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp	2012-12-17 21:22:44 UTC (rev 137933)
+++ trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp	2012-12-17 21:28:15 UTC (rev 137934)
@@ -369,6 +369,7 @@
 
     // Determine the filename for the file contents of the image.
     String filename = cachedImage->response().suggestedFilename();
+    String extension;
     if (filename.isEmpty())
         filename = url.lastPathComponent();
     if (filename.isEmpty())
@@ -376,14 +377,19 @@
     else {
         // Strip any existing extension. Assume that alt text is usually not a filename.
         int extensionIndex = filename.reverseFind('.');
-        if (extensionIndex != -1)
+        if (extensionIndex != -1) {
+            extension = filename.substring(extensionIndex + 1);
             filename.truncate(extensionIndex);
+        }
     }
 
-    String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
-        cachedImage->response().mimeType());
+    String extensionMimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
+    if (extensionMimeType != cachedImage->response().mimeType()) {
+        extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
+            cachedImage->response().mimeType());
+    }
+
     extension = extension.isEmpty() ? emptyString() : "." + extension;
-
     ClipboardChromium::validateFilename(filename, extension);
 
     dataObject->addSharedBuffer(filename + extension, imageBuffer);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to