Title: [107846] trunk/Source/WebKit/chromium
- Revision
- 107846
- Author
- [email protected]
- Date
- 2012-02-15 15:14:24 -0800 (Wed, 15 Feb 2012)
Log Message
[chromium] Add setter/getter to expose drag data as a list of items
https://bugs.webkit.org/show_bug.cgi?id=77125
This change supports the unification of the data store backing ChromiumDataObject and
DataTransferItemListChromium. ChromiumDataObject will represent dragging and clipboard data
as a list of data nodes to make it more straightforward to implement the HTML spec for
DataTransferItemList. Thus, we extend the abstraction to the webkit glue layer to
simplify the serialization/deserialization between platform-specific data and WebDragData.
The other setter/getter methods are deprecated and will be removed once the dependencies in
Chromium code are gone.
Reviewed by Darin Fisher.
* public/platform/WebDragData.h:
(WebKit):
(WebDragData):
* src/WebDragData.cpp:
(WebKit::WebDragData::items):
(WebKit):
(WebKit::WebDragData::setItems):
(WebKit::WebDragData::addItem):
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (107845 => 107846)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-02-15 23:10:26 UTC (rev 107845)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-02-15 23:14:24 UTC (rev 107846)
@@ -1,3 +1,27 @@
+2012-02-01 Daniel Cheng <[email protected]>
+
+ [chromium] Add setter/getter to expose drag data as a list of items
+ https://bugs.webkit.org/show_bug.cgi?id=77125
+
+ This change supports the unification of the data store backing ChromiumDataObject and
+ DataTransferItemListChromium. ChromiumDataObject will represent dragging and clipboard data
+ as a list of data nodes to make it more straightforward to implement the HTML spec for
+ DataTransferItemList. Thus, we extend the abstraction to the webkit glue layer to
+ simplify the serialization/deserialization between platform-specific data and WebDragData.
+ The other setter/getter methods are deprecated and will be removed once the dependencies in
+ Chromium code are gone.
+
+ Reviewed by Darin Fisher.
+
+ * public/platform/WebDragData.h:
+ (WebKit):
+ (WebDragData):
+ * src/WebDragData.cpp:
+ (WebKit::WebDragData::items):
+ (WebKit):
+ (WebKit::WebDragData::setItems):
+ (WebKit::WebDragData::addItem):
+
2012-02-15 Sadrul Habib Chowdhury <[email protected]>
Notify ChromeClient when touch-event handlers are installed/removed.
Modified: trunk/Source/WebKit/chromium/public/platform/WebDragData.h (107845 => 107846)
--- trunk/Source/WebKit/chromium/public/platform/WebDragData.h 2012-02-15 23:10:26 UTC (rev 107845)
+++ trunk/Source/WebKit/chromium/public/platform/WebDragData.h 2012-02-15 23:14:24 UTC (rev 107846)
@@ -32,7 +32,9 @@
#define WebDragData_h
#include "WebCommon.h"
+#include "WebData.h"
#include "WebString.h"
+#include "WebURL.h"
#if WEBKIT_IMPLEMENTATION
namespace WebCore { class ChromiumDataObject; }
@@ -41,15 +43,45 @@
namespace WebKit {
-class WebData;
class WebDragDataPrivate;
-class WebURL;
template <typename T> class WebVector;
// Holds data that may be exchanged through a drag-n-drop operation. It is
// inexpensive to copy a WebDragData object.
class WebDragData {
public:
+ struct Item {
+ enum StorageType {
+ // String data with an associated MIME type. Depending on the MIME type, there may be
+ // optional metadata attributes as well.
+ StorageTypeString,
+ // Stores the name of one file being dragged into the renderer.
+ StorageTypeFilename,
+ // An image being dragged out of the renderer. Contains a buffer holding the image data
+ // as well as the suggested name for saving the image to.
+ StorageTypeBinaryData,
+ };
+
+ StorageType storageType;
+
+ // Only valid when storageType == StorageTypeString.
+ WebString stringType;
+ WebString stringData;
+
+ // Only valid when storageType == StorageTypeFilename.
+ WebString filenameData;
+
+ // Only valid when storageType == StorageTypeBinaryData.
+ WebData binaryData;
+
+ // Title associated with a link when stringType == "text/uri-list".
+ // Filename when storageType == StorageTypeBinaryData.
+ WebString title;
+
+ // Only valid when stringType == "text/html".
+ WebURL baseURL;
+ };
+
~WebDragData() { reset(); }
WebDragData() : m_private(0) { }
@@ -66,6 +98,9 @@
bool isNull() const { return !m_private; }
+ WebVector<Item> items() const;
+ void setItems(const WebVector<Item>&);
+
WEBKIT_EXPORT WebString url() const;
WEBKIT_EXPORT void setURL(const WebURL&);
@@ -104,6 +139,7 @@
};
WEBKIT_EXPORT WebVector<CustomData> customData() const;
WEBKIT_EXPORT void setCustomData(const WebVector<CustomData>&);
+ void addItem(const Item&);
#if WEBKIT_IMPLEMENTATION
WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&);
Modified: trunk/Source/WebKit/chromium/src/WebDragData.cpp (107845 => 107846)
--- trunk/Source/WebKit/chromium/src/WebDragData.cpp 2012-02-15 23:10:26 UTC (rev 107845)
+++ trunk/Source/WebKit/chromium/src/WebDragData.cpp 2012-02-15 23:14:24 UTC (rev 107846)
@@ -66,6 +66,88 @@
assign(p);
}
+WebVector<WebDragData::Item> WebDragData::items() const
+{
+ Vector<Item> itemList;
+ const HashSet<String>& types = m_private->types();
+ if (types.contains(mimeTypeTextPlain)) {
+ Item item;
+ item.storageType = Item::StorageTypeString;
+ item.stringType = String(mimeTypeTextPlain);
+ bool ignored;
+ item.stringData = m_private->getData(mimeTypeTextPlain, ignored);
+ itemList.append(item);
+ }
+ if (types.contains(mimeTypeTextURIList)) {
+ Item item;
+ item.storageType = Item::StorageTypeString;
+ item.stringType = String(mimeTypeTextURIList);
+ bool ignored;
+ item.stringData = m_private->getData(mimeTypeURL, ignored);
+ item.title = m_private->urlTitle();
+ itemList.append(item);
+ }
+ if (types.contains(mimeTypeTextHTML)) {
+ Item item;
+ item.storageType = Item::StorageTypeString;
+ item.stringType = String(mimeTypeTextHTML);
+ bool ignored;
+ item.stringData = m_private->getData(mimeTypeTextHTML, ignored);
+ item.baseURL = m_private->htmlBaseUrl();
+ itemList.append(item);
+ }
+ if (types.contains(mimeTypeDownloadURL)) {
+ Item item;
+ item.storageType = Item::StorageTypeString;
+ item.stringType = String(mimeTypeDownloadURL);
+ bool ignored;
+ item.stringData = m_private->getData(mimeTypeDownloadURL, ignored);
+ itemList.append(item);
+ }
+ const HashMap<String, String>& customData = m_private->customData();
+ for (HashMap<String, String>::const_iterator it = customData.begin(); it != customData.end(); ++it) {
+ Item item;
+ item.storageType = Item::StorageTypeString;
+ item.stringType = it->first;
+ item.stringData = it->second;
+ itemList.append(item);
+ }
+ if (m_private->fileContent()) {
+ Item item;
+ item.storageType = Item::StorageTypeBinaryData;
+ item.binaryData = m_private->fileContent();
+ item.title = m_private->fileContentFilename();
+ }
+ // We don't handle filenames here, since they are never used for dragging out.
+ return itemList;
+}
+
+void WebDragData::setItems(const WebVector<Item>& itemList)
+{
+ m_private->clearAll();
+ for (size_t i = 0; i < itemList.size(); ++i)
+ addItem(itemList[i]);
+}
+
+void WebDragData::addItem(const Item& item)
+{
+ switch (item.storageType) {
+ case Item::StorageTypeString:
+ m_private->setData(item.stringType, item.stringData);
+ if (String(item.stringType) == mimeTypeTextURIList)
+ m_private->setUrlTitle(item.title);
+ else if (String(item.stringType) == mimeTypeTextHTML)
+ m_private->setHtmlBaseUrl(item.baseURL);
+ return;
+ case Item::StorageTypeFilename:
+ m_private->addFilename(item.filenameData);
+ return;
+ case Item::StorageTypeBinaryData:
+ // This should never happen when dragging in.
+ ASSERT_NOT_REACHED();
+ }
+}
+
WebString WebDragData::url() const
{
ASSERT(!isNull());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes