Diff
Modified: trunk/LayoutTests/ChangeLog (87847 => 87848)
--- trunk/LayoutTests/ChangeLog 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/LayoutTests/ChangeLog 2011-06-01 21:13:06 UTC (rev 87848)
@@ -1,3 +1,17 @@
+2011-06-01 Daniel Cheng <dch...@chromium.org>
+
+ Reviewed by Tony Chang.
+
+ [chromium] Use correct file name for dragging out images.
+ https://bugs.webkit.org/show_bug.cgi?id=24887
+
+ * fast/events/drag-image-filename-expected.txt: Added.
+ * fast/events/drag-image-filename.html: Added.
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2011-06-01 Levi Weintraub <le...@chromium.org>
Reviewed by Eric Seidel.
Added: trunk/LayoutTests/fast/events/drag-image-filename-expected.txt (0 => 87848)
--- trunk/LayoutTests/fast/events/drag-image-filename-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/drag-image-filename-expected.txt 2011-06-01 21:13:06 UTC (rev 87848)
@@ -0,0 +1,4 @@
+Filename being dragged: onload-image.png
+This test requires DumpRenderTree. To test manually, drag the image to the desktop. It should receive the name "onload-image.png".
+
+
Added: trunk/LayoutTests/fast/events/drag-image-filename.html (0 => 87848)
--- trunk/LayoutTests/fast/events/drag-image-filename.html (rev 0)
+++ trunk/LayoutTests/fast/events/drag-image-filename.html 2011-06-01 21:13:06 UTC (rev 87848)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function runTest() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ } else
+ return;
+
+ e = document.getElementById("source");
+ x = e.offsetLeft + e.offsetWidth / 2;
+ y = e.offsetTop + e.offsetHeight / 2;
+
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ e = document.getElementById("target");
+ x = e.offsetLeft + e.offsetWidth / 2;
+ y = e.offsetTop + e.offsetHeight / 2;
+
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseUp();
+}
+
+function dragEnterOrOver(event) {
+ event.dataTransfer.dropEffect = "copy";
+ event.preventDefault();
+}
+
+function drop(event) {
+ event.preventDefault();
+ eventSender.dumpFilenameBeingDragged();
+ layoutTestController.notifyDone();
+}
+</script>
+<style>
+#target {
+ height: 100px;
+ width: 100px;
+}
+</style>
+</head>
+
+<body _onload_="runTest()">
+
+<p>This test requires DumpRenderTree. To test manually, drag the image to the desktop. It should receive the name "onload-image.png".
+
+<div id="target" _ondragenter_="dragEnterOrOver(event)" _ondragover_="dragEnterOrOver(event)" _ondrop_="drop(event)"></div>
+<img id="source" src="" alt="Does it work?">
+
+</body>
+</html>
Modified: trunk/LayoutTests/platform/gtk/Skipped (87847 => 87848)
--- trunk/LayoutTests/platform/gtk/Skipped 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/LayoutTests/platform/gtk/Skipped 2011-06-01 21:13:06 UTC (rev 87848)
@@ -1148,6 +1148,10 @@
fast/css/user-drag-none.html
fast/events/5056619.html
+# EventSender::dumpFilenameBeingDragged not implemented.
+# https://bugs.webkit.org/show_bug.cgi?id=61826
+fast/events/drag-image-filename.html
+
# Tests that fail because they assume a certain number of mouse
# movements during drags or fail only in Xvfb
http/tests/local/drag-over-remote-content.html
Modified: trunk/LayoutTests/platform/mac/Skipped (87847 => 87848)
--- trunk/LayoutTests/platform/mac/Skipped 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/LayoutTests/platform/mac/Skipped 2011-06-01 21:13:06 UTC (rev 87848)
@@ -191,6 +191,10 @@
# Filenames aren't filtered out from edit drags yet, see https://bugs.wekit.org/show_bug.cgi?id=38826
editing/pasteboard/file-drag-to-editable.html
+# EventSender::dumpFilenameBeingDragged not implemented.
+# https://bugs.webkit.org/show_bug.cgi?id=61827
+fast/events/drag-image-filename.html
+
# Hits an assert in FrameLoader.cpp. https://bugs.webkit.org/show_bug.cgi?id=31387
http/tests/multipart/policy-ignore-crash.php
Modified: trunk/LayoutTests/platform/qt/Skipped (87847 => 87848)
--- trunk/LayoutTests/platform/qt/Skipped 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/LayoutTests/platform/qt/Skipped 2011-06-01 21:13:06 UTC (rev 87848)
@@ -172,6 +172,10 @@
svg/as-image/drag-svg-as-image.html
fast/forms/slider-delete-while-dragging-thumb.html
+# EventSender::dumpFilenameBeingDragged not implemented.
+# https://bugs.webkit.org/show_bug.cgi?id=61828
+fast/events/drag-image-filename.html
+
# ------- missing drag-and-drop support
# See bug https://bugs.webkit.org/show_bug.cgi?id=31332
fast/events/drag-parent-node.html
Modified: trunk/LayoutTests/platform/win/Skipped (87847 => 87848)
--- trunk/LayoutTests/platform/win/Skipped 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/LayoutTests/platform/win/Skipped 2011-06-01 21:13:06 UTC (rev 87848)
@@ -126,6 +126,10 @@
fast/events/standalone-image-drag-to-editable.html
http/tests/security/drag-drop-same-unique-origin.html
+# EventSender::dumpFilenameBeingDragged not implemented.
+# https://bugs.webkit.org/show_bug.cgi?id=61829
+fast/events/drag-image-filename.html
+
# <rdar://problem/5643675> window.scrollTo scrolls a window with no scrollbars
fast/events/attempt-scroll-with-no-scrollbars.html
Modified: trunk/Source/WebCore/ChangeLog (87847 => 87848)
--- trunk/Source/WebCore/ChangeLog 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/Source/WebCore/ChangeLog 2011-06-01 21:13:06 UTC (rev 87848)
@@ -1,3 +1,24 @@
+2011-06-01 Daniel Cheng <dch...@chromium.org>
+
+ Reviewed by Tony Chang.
+
+ [chromium] Use correct file name for dragging out images.
+ https://bugs.webkit.org/show_bug.cgi?id=24887
+
+ We try to guess an appropriate filename when dragging out images. In order, we try to use:
+ - The filename suggested in the HTTP header.
+ - The last path component of the source URL.
+ - The alt text.
+ This matches the behavior of the other WebKit ports.
+
+ Test: fast/events/drag-image-filename.html
+
+ * platform/chromium/ClipboardChromium.cpp:
+ (WebCore::writeImageToDataObject):
+ * platform/chromium/ClipboardChromiumMac.cpp:
+ (WebCore::isInvalidFileCharacter):
+ (WebCore::ClipboardChromium::validateFileName):
+
2011-06-01 Levi Weintraub <le...@chromium.org>
Reviewed by Eric Seidel.
@@ -649,7 +670,6 @@
* platform/graphics/gpu/LoopBlinnMathUtils.cpp:
* platform/graphics/gpu/TilingData.cpp:
-<<<<<<< .mine
2011-05-31 Justin Novosad <ju...@chromium.org>
Reviewed by Stephen White.
@@ -662,7 +682,6 @@
* platform/graphics/gpu/LoopBlinnMathUtils.cpp:
* platform/graphics/gpu/TilingData.cpp:
-=======
2011-05-31 Rob Buis <rb...@rim.com>
Reviewed by Dirk Schulze.
Modified: trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp (87847 => 87848)
--- trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp 2011-06-01 21:13:06 UTC (rev 87848)
@@ -224,19 +224,25 @@
dataObject->setFileContent(imageBuffer);
- // Determine the filename for the file contents of the image. We try to
- // use the alt tag if one exists, otherwise we fall back on the suggested
- // filename in the http header, and finally we resort to using the filename
- // in the URL.
+ // Determine the filename for the file contents of the image.
+ String filename = cachedImage->response().suggestedFilename();
+ if (filename.isEmpty())
+ filename = url.lastPathComponent();
+ if (filename.isEmpty())
+ filename = element->getAttribute(altAttr);
+ else {
+ // Strip any existing extension. Assume that alt text is usually not a filename.
+ int extensionIndex = filename.reverseFind('.');
+ if (extensionIndex != -1)
+ filename.truncate(extensionIndex);
+ }
+ filename = ClipboardChromium::validateFileName(filename, dataObject);
+
String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
cachedImage->response().mimeType());
dataObject->setFileExtension(extension.isEmpty() ? emptyString() : "." + extension);
- String title = element->getAttribute(altAttr);
- if (title.isEmpty())
- title = cachedImage->response().suggestedFilename();
- title = ClipboardChromium::validateFileName(title, dataObject);
- dataObject->setFileContentFilename(title + dataObject->fileExtension());
+ dataObject->setFileContentFilename(filename + dataObject->fileExtension());
}
void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
Modified: trunk/Source/WebCore/platform/chromium/ClipboardChromiumMac.cpp (87847 => 87848)
--- trunk/Source/WebCore/platform/chromium/ClipboardChromiumMac.cpp 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/Source/WebCore/platform/chromium/ClipboardChromiumMac.cpp 2011-06-01 21:13:06 UTC (rev 87848)
@@ -28,14 +28,42 @@
#include "ClipboardChromium.h"
#include "ChromiumDataObject.h"
-#include "NotImplemented.h"
namespace WebCore {
+
+// Filename length and character-set limits vary by filesystem, and there's no
+// real way to tell what filesystem is in use. Since HFS+ is by far the most
+// common, we'll abide by its limits, which are 255 Unicode characters (slightly
+// simplified; really it uses Normalization Form D, but the differences aren't
+// really worth dealing with here.)
+static const unsigned MaxHFSFilenameLength = 255;
+
+
+static bool isInvalidFileCharacter(UChar c)
+{
+ // HFS+ basically allows anything but '/'. For sanity's sake we'll disallow
+ // control characters.
+ return c < ' ' || c == 0x7F || c == '/';
+}
+
String ClipboardChromium::validateFileName(const String& title, ChromiumDataObject* dataObject)
{
- notImplemented();
- return title;
+ // Remove any invalid file system characters, especially "/".
+ String result = title.removeCharacters(isInvalidFileCharacter);
+ String extension = dataObject->fileExtension().removeCharacters(&isInvalidFileCharacter);
+
+ // Remove a ridiculously-long extension.
+ if (extension.length() >= MaxHFSFilenameLength)
+ extension = "";
+
+ // Truncate an overly-long filename.
+ int overflow = result.length() + extension.length() - MaxHFSFilenameLength;
+ if (overflow > 0)
+ result.remove(result.length() - overflow, overflow);
+
+ dataObject->setFileExtension(extension);
+ return result;
}
} // namespace WebCore
Modified: trunk/Tools/ChangeLog (87847 => 87848)
--- trunk/Tools/ChangeLog 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/Tools/ChangeLog 2011-06-01 21:13:06 UTC (rev 87848)
@@ -1,3 +1,15 @@
+2011-06-01 Daniel Cheng <dch...@chromium.org>
+
+ Reviewed by Tony Chang.
+
+ [chromium] Use correct file name for dragging out images.
+ https://bugs.webkit.org/show_bug.cgi?id=24887
+
+ * DumpRenderTree/chromium/EventSender.cpp:
+ (EventSender::EventSender):
+ (EventSender::dumpFilenameBeingDragged):
+ * DumpRenderTree/chromium/EventSender.h:
+
2011-06-01 Dirk Pranke <dpra...@chromium.org>
Reviewed by Tony Chang.
Modified: trunk/Tools/DumpRenderTree/chromium/EventSender.cpp (87847 => 87848)
--- trunk/Tools/DumpRenderTree/chromium/EventSender.cpp 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/Tools/DumpRenderTree/chromium/EventSender.cpp 2011-06-01 21:13:06 UTC (rev 87848)
@@ -259,6 +259,7 @@
bindMethod("contextClick", &EventSender::contextClick);
bindMethod("continuousMouseScrollBy", &EventSender::continuousMouseScrollBy);
bindMethod("dispatchMessage", &EventSender::dispatchMessage);
+ bindMethod("dumpFilenameBeingDragged", &EventSender::dumpFilenameBeingDragged);
bindMethod("enableDOMUIEventLogging", &EventSender::enableDOMUIEventLogging);
bindMethod("fireKeyboardEventsToElement", &EventSender::fireKeyboardEventsToElement);
bindMethod("keyDown", &EventSender::keyDown);
@@ -344,6 +345,11 @@
replaySavedEvents();
}
+void EventSender::dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*)
+{
+ printf("Filename being dragged: %s\n", currentDragData.fileContentFilename().utf8().data());
+}
+
WebMouseEvent::Button EventSender::getButtonTypeFromButtonNumber(int buttonCode)
{
if (!buttonCode)
Modified: trunk/Tools/DumpRenderTree/chromium/EventSender.h (87847 => 87848)
--- trunk/Tools/DumpRenderTree/chromium/EventSender.h 2011-06-01 21:09:05 UTC (rev 87847)
+++ trunk/Tools/DumpRenderTree/chromium/EventSender.h 2011-06-01 21:13:06 UTC (rev 87848)
@@ -62,6 +62,9 @@
// Simulate drag&drop system call.
void doDragDrop(const WebKit::WebDragData&, WebKit::WebDragOperationsMask);
+ // Test helper for dragging out images.
+ void dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*);
+
// JS callback methods.
void mouseDown(const CppArgumentList&, CppVariant*);
void mouseUp(const CppArgumentList&, CppVariant*);