Diff
Modified: trunk/LayoutTests/ChangeLog (101827 => 101828)
--- trunk/LayoutTests/ChangeLog 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/ChangeLog 2011-12-02 18:52:52 UTC (rev 101828)
@@ -1,3 +1,21 @@
+2011-12-02 Daniel Cheng <dch...@chromium.org>
+
+ [chromium] Add plumbing for supporting custom MIME types in DataTransfer.
+ https://bugs.webkit.org/show_bug.cgi?id=73594
+
+ Reviewed by David Levin.
+
+ * editing/pasteboard/clipboard-customData-expected.txt: Added.
+ * editing/pasteboard/clipboard-customData.html: Added.
+ * fast/events/drag-customData-expected.txt: Added.
+ * fast/events/drag-customData.html: Added.
+ * platform/chromium/test_expectations.txt:
+ * platform/efl/Skipped:
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2011-12-02 Joshua Bell <jsb...@chromium.org>
IndexedDB: Rename "multientry" to "multiEntry" per spec change
Added: trunk/LayoutTests/editing/pasteboard/clipboard-customData-expected.txt (0 => 101828)
--- trunk/LayoutTests/editing/pasteboard/clipboard-customData-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/clipboard-customData-expected.txt 2011-12-02 18:52:52 UTC (rev 101828)
@@ -0,0 +1,3 @@
+Simple test that custom clipboard MIME types can be set during copy events and retrieved during paste events. The test can be manually run by copying any text on this page and then pasting anywhere. On success, the word SUCCESS will appear below.
+
+SUCCESS
Property changes on: trunk/LayoutTests/editing/pasteboard/clipboard-customData-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/editing/pasteboard/clipboard-customData.html (0 => 101828)
--- trunk/LayoutTests/editing/pasteboard/clipboard-customData.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/clipboard-customData.html 2011-12-02 18:52:52 UTC (rev 101828)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<p>Simple test that custom clipboard MIME types can be set during copy events
+and retrieved during paste events. The test can be manually run by copying
+any text on this page and then pasting anywhere. On success, the word SUCCESS
+will appear below.
+<div id="log"></div>
+<script>
+function copy(event) {
+ event.clipboardData.setData('text', 'sample');
+ event.clipboardData.setData('custom-data', 'hello world');
+ event.preventDefault();
+}
+
+function paste(event) {
+ var failed = false;
+ if (event.clipboardData.types.indexOf('text/plain') < 0
+ || event.clipboardData.types.indexOf('custom-data') < 0)
+ failed = true;
+ if (event.clipboardData.getData('text') != 'sample'
+ || event.clipboardData.getData('custom-data') != 'hello world')
+ failed = true;
+ document.getElementById('log').innerText = failed ? 'FAILURE' : 'SUCCESS';
+ event.preventDefault();
+}
+document.body.addEventListener('copy', copy);
+document.body.addEventListener('paste', paste);
+
+function runTest() {
+ if (!window.layoutTestController)
+ return;
+
+ layoutTestController.dumpAsText();
+ document.execCommand('copy');
+ document.execCommand('paste');
+}
+runTest();
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/editing/pasteboard/clipboard-customData.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/drag-customData-expected.txt (0 => 101828)
--- trunk/LayoutTests/fast/events/drag-customData-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/drag-customData-expected.txt 2011-12-02 18:52:52 UTC (rev 101828)
@@ -0,0 +1,6 @@
+To manually test, drag 'Drag Me' to 'Drop Here' and drop. The word 'SUCCESS' should appear.
+
+Drag Me
+Drop Here
+SUCCESS
+
Property changes on: trunk/LayoutTests/fast/events/drag-customData-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/drag-customData.html (0 => 101828)
--- trunk/LayoutTests/fast/events/drag-customData.html (rev 0)
+++ trunk/LayoutTests/fast/events/drag-customData.html 2011-12-02 18:52:52 UTC (rev 101828)
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#drag {
+ border: 1px solid black;
+ height: 200px;
+ width: 200px;
+}
+#drop {
+ border: 1px solid black;
+ height: 200px;
+ width: 200px;
+}
+</style>
+<script>
+function log(str)
+{
+ var result = document.getElementById('result');
+ result.appendChild(document.createTextNode(str));
+ result.appendChild(document.createElement('br'));
+}
+function dragstart(event) {
+ event.dataTransfer.setData('text', 'sample');
+ event.dataTransfer.setData('custom-data', 'hello world');
+}
+function dragenter(event) {
+ event.preventDefault();
+}
+function dragover(event) {
+ event.preventDefault();
+}
+function drop(event) {
+ var failed = false;
+ if (event.dataTransfer.types.indexOf('text/plain') < 0
+ || event.dataTransfer.types.indexOf('custom-data') < 0)
+ failed = true;
+ if (event.dataTransfer.getData('text') != 'sample'
+ || event.dataTransfer.getData('custom-data') != 'hello world')
+ failed = true;
+ log(failed ? 'FAILURE' : 'SUCCESS');
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+window._onload_ = function()
+{
+ if (!window.layoutTestController)
+ return;
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+
+ var dragElement = document.getElementById('drag');
+ eventSender.mouseMoveTo(dragElement.offsetLeft + dragElement.offsetWidth / 2,
+ dragElement.offsetTop + dragElement.offsetHeight / 2);
+ eventSender.mouseDown();
+ eventSender.leapForward(100);
+ var dropElement = document.getElementById('drop');
+ eventSender.mouseMoveTo(dropElement.offsetLeft + dropElement.offsetWidth / 2,
+ dropElement.offsetTop + dropElement.offsetHeight / 2);
+ eventSender.mouseUp();
+}
+</script>
+</head>
+<body>
+<p>To manually test, drag 'Drag Me' to 'Drop Here' and drop. The word 'SUCCESS' should appear.
+<div draggable="true" id="drag" _ondragstart_="dragstart(event)">Drag Me</div>
+<div id="drop" _ondragenter_="dragenter(event)" _ondragover_="dragover(event)" _ondrop_="drop(event)">Drop Here</div>
+</div>
+<div id="result"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/drag-customData.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (101827 => 101828)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-02 18:52:52 UTC (rev 101828)
@@ -3701,6 +3701,9 @@
BUGWK66953 : transitions/default-timing-function.html = PASS FAIL
+// Depends on Chromium follow up change before they will pass.
+BUGCR31037 : editing/pasteboard/clipboard-customData.html = FAIL
+
// Need to rebaseline on win and mac.
BUG_TONY MAC : css3/flexbox/repaint.html = PASS FAIL
BUG_TONY MAC : css3/flexbox/repaint-rtl-column.html = PASS FAIL
Modified: trunk/LayoutTests/platform/efl/Skipped (101827 => 101828)
--- trunk/LayoutTests/platform/efl/Skipped 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/platform/efl/Skipped 2011-12-02 18:52:52 UTC (rev 101828)
@@ -134,6 +134,7 @@
fast/events/drag-and-drop-dataTransfer-types-nocrash.html
fast/events/drag-and-drop-fire-drag-dragover.html
fast/events/drag-and-drop.html
+fast/events/drag-customData.html
fast/events/drag-selects-image.html
fast/events/dropzone-001.html
fast/events/dropzone-002.html
Modified: trunk/LayoutTests/platform/gtk/Skipped (101827 => 101828)
--- trunk/LayoutTests/platform/gtk/Skipped 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/platform/gtk/Skipped 2011-12-02 18:52:52 UTC (rev 101828)
@@ -300,6 +300,10 @@
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-image-png.html
+# Custom MIME type support in DataTransfer is not yet implemented.
+editing/pasteboard/clipboard-customData.html
+fast/events/drag-customData.html
+
# Needs grammar checking.
editing/spelling/markers.html
Modified: trunk/LayoutTests/platform/mac/Skipped (101827 => 101828)
--- trunk/LayoutTests/platform/mac/Skipped 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/platform/mac/Skipped 2011-12-02 18:52:52 UTC (rev 101828)
@@ -349,6 +349,10 @@
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-image-png.html
+# Custom MIME type support in DataTransfer is not yet implemented.
+editing/pasteboard/clipboard-customData.html
+fast/events/drag-customData.html
+
# Need to implement WebGeolocationRequest::cancelPermissionRequest on mac.
# https://bugs.webkit.org/show_bug.cgi?id=55944
fast/dom/Geolocation/page-reload-cancel-permission-requests.html
Modified: trunk/LayoutTests/platform/qt/Skipped (101827 => 101828)
--- trunk/LayoutTests/platform/qt/Skipped 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/platform/qt/Skipped 2011-12-02 18:52:52 UTC (rev 101828)
@@ -334,6 +334,10 @@
fast/forms/range/slider-delete-while-dragging-thumb.html
fast/forms/select-multiple-elements-with-mouse-drag-with-options-less-than-size.html
+# Custom MIME type support in DataTransfer not yet implemented.
+editing/pasteboard/clipboard-customData.html
+fast/events/drag-customData.html
+
# EventSender::dumpFilenameBeingDragged not implemented.
# https://bugs.webkit.org/show_bug.cgi?id=61828
fast/events/drag-image-filename.html
Modified: trunk/LayoutTests/platform/win/Skipped (101827 => 101828)
--- trunk/LayoutTests/platform/win/Skipped 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/LayoutTests/platform/win/Skipped 2011-12-02 18:52:52 UTC (rev 101828)
@@ -1279,6 +1279,10 @@
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-image-png.html
+# Custom MIME type support in DataTransfer not yet implemented.
+editing/pasteboard/clipboard-customData.html
+fast/events/drag-customData.html
+
# Needs expectation update
fast/dom/HTMLMeterElement/meter-element.html
fast/dom/HTMLMeterElement/meter-boundary-values.html
Modified: trunk/Source/WebCore/ChangeLog (101827 => 101828)
--- trunk/Source/WebCore/ChangeLog 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebCore/ChangeLog 2011-12-02 18:52:52 UTC (rev 101828)
@@ -1,3 +1,21 @@
+2011-12-02 Daniel Cheng <dch...@chromium.org>
+
+ [chromium] Add plumbing for supporting custom MIME types in DataTransfer.
+ https://bugs.webkit.org/show_bug.cgi?id=73594
+
+ Reviewed by David Levin.
+
+ Tests: editing/pasteboard/clipboard-customData.html
+ fast/events/drag-customData.html
+
+ * platform/chromium/ChromiumDataObject.cpp:
+ (WebCore::ChromiumDataObject::types):
+ (WebCore::ChromiumDataObject::getData):
+ (WebCore::ChromiumDataObject::setData):
+ * platform/chromium/ChromiumDataObject.h:
+ (WebCore::ChromiumDataObject::customData):
+ * platform/chromium/PlatformSupport.h:
+
2011-12-02 Darin Adler <da...@apple.com>
[Mac] Form stream data structures still not threadsafe
Modified: trunk/Source/WebCore/platform/chromium/ChromiumDataObject.cpp (101827 => 101828)
--- trunk/Source/WebCore/platform/chromium/ChromiumDataObject.cpp 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebCore/platform/chromium/ChromiumDataObject.cpp 2011-12-02 18:52:52 UTC (rev 101828)
@@ -124,10 +124,15 @@
if (!m_textHtml.isEmpty())
results.add(mimeTypeTextHTML);
+ for (HashMap<String, String>::const_iterator::Keys it = m_customData.begin().keys();
+ it != m_customData.end().keys(); ++it) {
+ results.add(*it);
+ }
+
return results;
}
-String ChromiumDataObject::getData(const String& type, bool& success)
+String ChromiumDataObject::getData(const String& type, bool& success) const
{
if (type == mimeTypeTextPlain) {
if (m_storageMode == Pasteboard) {
@@ -167,6 +172,18 @@
return m_downloadMetadata;
}
+ if (m_storageMode == Pasteboard) {
+ String data = "" type);
+ success = !data.isEmpty();
+ return data;
+ }
+
+ HashMap<String, String>::const_iterator it = m_customData.find(type);
+ if (it != m_customData.end()) {
+ success = true;
+ return it->second;
+ }
+
success = false;
return String();
}
@@ -217,7 +234,11 @@
return true;
}
- return false;
+ if (type.isEmpty())
+ return false;
+
+ m_customData.set(type, data);
+ return true;
}
bool ChromiumDataObject::containsFilenames() const
@@ -256,4 +277,3 @@
}
} // namespace WebCore
-
Modified: trunk/Source/WebCore/platform/chromium/ChromiumDataObject.h (101827 => 101828)
--- trunk/Source/WebCore/platform/chromium/ChromiumDataObject.h 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebCore/platform/chromium/ChromiumDataObject.h 2011-12-02 18:52:52 UTC (rev 101828)
@@ -34,6 +34,7 @@
#include "KURL.h"
#include "PlatformString.h"
#include "SharedBuffer.h"
+#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
@@ -75,7 +76,7 @@
bool hasData() const;
HashSet<String> types() const;
- String getData(const String& type, bool& success);
+ String getData(const String& type, bool& success) const;
bool setData(const String& type, const String& data);
// Special handlers for URL/HTML metadata.
@@ -96,6 +97,8 @@
void setFileContentFilename(const String& fileContentFilename) { m_fileContentFilename = fileContentFilename; }
PassRefPtr<SharedBuffer> fileContent() const { return m_fileContent; }
void setFileContent(PassRefPtr<SharedBuffer> fileContent) { m_fileContent = fileContent; }
+ const HashMap<String, String>& customData() const { return m_customData; }
+ HashMap<String, String>& customData() { return m_customData; }
private:
explicit ChromiumDataObject(StorageMode);
@@ -118,6 +121,8 @@
String m_fileContentFilename;
RefPtr<SharedBuffer> m_fileContent;
+ HashMap<String, String> m_customData;
+
// These two are linked. Setting m_url will set m_uriList to the same
// string value; setting m_uriList will cause its contents to be parsed
// according to RFC 2483 and the first URL found will be set in m_url.
@@ -128,4 +133,3 @@
} // namespace WebCore
#endif
-
Modified: trunk/Source/WebCore/platform/chromium/PlatformSupport.h (101827 => 101828)
--- trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2011-12-02 18:52:52 UTC (rev 101828)
@@ -105,6 +105,7 @@
static String clipboardReadPlainText(PasteboardPrivate::ClipboardBuffer);
static void clipboardReadHTML(PasteboardPrivate::ClipboardBuffer, String*, KURL*, unsigned* fragmentStart, unsigned* fragmentEnd);
static PassRefPtr<SharedBuffer> clipboardReadImage(PasteboardPrivate::ClipboardBuffer);
+ static String clipboardReadCustomData(PasteboardPrivate::ClipboardBuffer, const String& type);
// Only the clipboardRead functions take a buffer argument because
// Chromium currently uses a different technique to write to alternate
Modified: trunk/Source/WebKit/chromium/ChangeLog (101827 => 101828)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-12-02 18:52:52 UTC (rev 101828)
@@ -1,3 +1,19 @@
+2011-12-02 Daniel Cheng <dch...@chromium.org>
+
+ [chromium] Add plumbing for supporting custom MIME types in DataTransfer.
+ https://bugs.webkit.org/show_bug.cgi?id=73594
+
+ Reviewed by David Levin.
+
+ * public/platform/WebClipboard.h:
+ (WebKit::WebClipboard::readCustomData):
+ * public/platform/WebDragData.h:
+ * src/PlatformSupport.cpp:
+ (WebCore::PlatformSupport::clipboardReadCustomData):
+ * src/WebDragData.cpp:
+ (WebKit::WebDragData::customData):
+ (WebKit::WebDragData::setCustomData):
+
2011-12-02 Joshua Bell <jsb...@chromium.org>
IndexedDB: Rename "multientry" to "multiEntry" per spec change
Modified: trunk/Source/WebKit/chromium/public/platform/WebClipboard.h (101827 => 101828)
--- trunk/Source/WebKit/chromium/public/platform/WebClipboard.h 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebKit/chromium/public/platform/WebClipboard.h 2011-12-02 18:52:52 UTC (rev 101828)
@@ -78,6 +78,8 @@
Buffer buffer, WebURL* pageURL, unsigned* fragmentStart,
unsigned* fragmentEnd) { return WebString(); }
virtual WebData readImage(Buffer) { return WebData(); }
+ virtual WebString readCustomData(
+ Buffer, const WebString& type) { return WebString(); }
virtual void writePlainText(const WebString&) { }
virtual void writeHTML(
Modified: trunk/Source/WebKit/chromium/public/platform/WebDragData.h (101827 => 101828)
--- trunk/Source/WebKit/chromium/public/platform/WebDragData.h 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebKit/chromium/public/platform/WebDragData.h 2011-12-02 18:52:52 UTC (rev 101828)
@@ -32,6 +32,7 @@
#define WebDragData_h
#include "WebCommon.h"
+#include "WebString.h"
#if WEBKIT_IMPLEMENTATION
namespace WebCore { class ChromiumDataObject; }
@@ -42,7 +43,6 @@
class WebData;
class WebDragDataPrivate;
-class WebString;
class WebURL;
template <typename T> class WebVector;
@@ -98,6 +98,13 @@
WEBKIT_EXPORT WebData fileContent() const;
WEBKIT_EXPORT void setFileContent(const WebData&);
+ struct CustomData {
+ WebString type;
+ WebString data;
+ };
+ WEBKIT_EXPORT WebVector<CustomData> customData() const;
+ WEBKIT_EXPORT void setCustomData(const WebVector<CustomData>&);
+
#if WEBKIT_IMPLEMENTATION
WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&);
WebDragData& operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&);
Modified: trunk/Source/WebKit/chromium/src/PlatformSupport.cpp (101827 => 101828)
--- trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2011-12-02 18:52:52 UTC (rev 101828)
@@ -202,6 +202,12 @@
return webKitPlatformSupport()->clipboard()->readImage(static_cast<WebClipboard::Buffer>(buffer));
}
+String PlatformSupport::clipboardReadCustomData(
+ PasteboardPrivate::ClipboardBuffer buffer, const String& type)
+{
+ return webKitPlatformSupport()->clipboard()->readCustomData(static_cast<WebClipboard::Buffer>(buffer), type);
+}
+
void PlatformSupport::clipboardWriteSelection(const String& htmlText,
const KURL& sourceURL,
const String& plainText,
Modified: trunk/Source/WebKit/chromium/src/WebDragData.cpp (101827 => 101828)
--- trunk/Source/WebKit/chromium/src/WebDragData.cpp 2011-12-02 18:47:17 UTC (rev 101827)
+++ trunk/Source/WebKit/chromium/src/WebDragData.cpp 2011-12-02 18:52:52 UTC (rev 101828)
@@ -38,6 +38,7 @@
#include "WebURL.h"
#include "WebVector.h"
+#include <wtf/HashMap.h>
#include <wtf/PassRefPtr.h>
using namespace WebCore;
@@ -205,6 +206,28 @@
m_private->setFileContent(fileContent);
}
+WebVector<WebDragData::CustomData> WebDragData::customData() const
+{
+ ASSERT(!isNull());
+ WebVector<CustomData> customData(static_cast<size_t>(m_private->customData().size()));
+ HashMap<String, String>::const_iterator begin = m_private->customData().begin();
+ HashMap<String, String>::const_iterator end = m_private->customData().end();
+ size_t i = 0;
+ for (HashMap<String, String>::const_iterator it = begin; it != end; ++it) {
+ CustomData data = "" it->second};
+ customData[i++] = data;
+ }
+ return customData;
+}
+
+void WebDragData::setCustomData(const WebVector<WebDragData::CustomData>& customData)
+{
+ ensureMutable();
+ HashMap<String, String>& customDataMap = m_private->customData();
+ for (size_t i = 0; i < customData.size(); ++i)
+ customDataMap.set(customData[i].type, customData[i].data);
+}
+
WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data)
: m_private(static_cast<WebDragDataPrivate*>(data.leakRef()))
{