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 Daniel Cheng <dcheng@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 Daniel Cheng <dcheng@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:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87848
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-06-01 Daniel Cheng <dcheng@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 <leviw@chromium.org>
Reviewed by Eric Seidel.
--- /dev/null
+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".
+
+
--- /dev/null
+<!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="resources/onload-image.png" alt="Does it work?">
+
+</body>
+</html>
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
# 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
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
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
+2011-06-01 Daniel Cheng <dcheng@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 <leviw@chromium.org>
Reviewed by Eric Seidel.
* platform/graphics/gpu/LoopBlinnMathUtils.cpp:
* platform/graphics/gpu/TilingData.cpp:
-<<<<<<< .mine
2011-05-31 Justin Novosad <junov@chromium.org>
Reviewed by Stephen White.
* platform/graphics/gpu/LoopBlinnMathUtils.cpp:
* platform/graphics/gpu/TilingData.cpp:
-=======
2011-05-31 Rob Buis <rbuis@rim.com>
Reviewed by Dirk Schulze.
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)
#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
+2011-06-01 Daniel Cheng <dcheng@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 <dpranke@chromium.org>
Reviewed by Tony Chang.
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);
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)
// 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*);