[chromium] Merge ChromiumDataObject and DataTransferItemListChromium.
authordcheng@chromium.org <dcheng@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2012 22:03:41 +0000 (22:03 +0000)
committerdcheng@chromium.org <dcheng@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2012 22:03:41 +0000 (22:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82407

Reviewed by Tony Chang.

Source/WebCore:

Since ChromiumDataObject is just a very thin wrapper for DataTransferItemListChromium now,
combine the two and remove a layer of indirection.

No functionality change, should be covered by existing tests.

* WebCore.gypi:
* platform/chromium/ChromiumDataObject.cpp: Replacing DataTransferItemListChromium.
(WebCore::ChromiumDataObject::createFromPasteboard):
(WebCore::ChromiumDataObject::create):
(WebCore::ChromiumDataObject::length):
(WebCore):
(WebCore::ChromiumDataObject::item):
(WebCore::ChromiumDataObject::deleteItem):
(WebCore::ChromiumDataObject::clearAll):
(WebCore::ChromiumDataObject::add):
(WebCore::ChromiumDataObject::clearData):
(WebCore::ChromiumDataObject::clearAllExceptFiles):
(WebCore::ChromiumDataObject::types):
(WebCore::ChromiumDataObject::getData):
(WebCore::ChromiumDataObject::setData):
(WebCore::ChromiumDataObject::urlAndTitle):
(WebCore::ChromiumDataObject::setURLAndTitle):
(WebCore::ChromiumDataObject::htmlAndBaseURL):
(WebCore::ChromiumDataObject::setHTMLAndBaseURL):
(WebCore::ChromiumDataObject::containsFilenames):
(WebCore::ChromiumDataObject::filenames):
(WebCore::ChromiumDataObject::addFilename):
(WebCore::ChromiumDataObject::addSharedBuffer):
(WebCore::ChromiumDataObject::ChromiumDataObject):
(WebCore::ChromiumDataObject::findStringItem):
(WebCore::ChromiumDataObject::internalAddStringItem):
(WebCore::ChromiumDataObject::internalAddFileItem):
* platform/chromium/ChromiumDataObject.h:
(WebCore):
(ChromiumDataObject):
* platform/chromium/ChromiumDataObjectItem.cpp: Renamed from Source/WebCore/platform/chromium/DataTransferItemChromium.cpp.
(WebCore):
(WebCore::ChromiumDataObjectItem::createFromString):
(WebCore::ChromiumDataObjectItem::createFromFile):
(WebCore::ChromiumDataObjectItem::createFromURL):
(WebCore::ChromiumDataObjectItem::createFromHTML):
(WebCore::ChromiumDataObjectItem::createFromSharedBuffer):
(WebCore::ChromiumDataObjectItem::createFromPasteboard):
(WebCore::ChromiumDataObjectItem::ChromiumDataObjectItem):
(WebCore::ChromiumDataObjectItem::getAsString):
(WebCore::ChromiumDataObjectItem::getAsFile):
(WebCore::ChromiumDataObjectItem::internalGetAsString):
(WebCore::ChromiumDataObjectItem::isFilename):
* platform/chromium/ChromiumDataObjectItem.h: Renamed from Source/WebCore/platform/chromium/DataTransferItemChromium.h.
(WebCore):
(ChromiumDataObjectItem):
(WebCore::ChromiumDataObjectItem::kind):
(WebCore::ChromiumDataObjectItem::type):
(WebCore::ChromiumDataObjectItem::sharedBuffer):
(WebCore::ChromiumDataObjectItem::title):
(WebCore::ChromiumDataObjectItem::baseURL):
* platform/chromium/ClipboardChromium.cpp:
(WebCore::ClipboardChromium::files):
(WebCore::ClipboardChromium::hasData):
(WebCore::ClipboardChromium::items):
* platform/chromium/DataTransferItemListChromium.cpp: Removed.
* platform/chromium/DataTransferItemListChromium.h: Removed.

Source/WebKit/chromium:

* src/WebDragData.cpp:
(WebKit::WebDragData::items):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112448 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/chromium/ChromiumDataObject.cpp
Source/WebCore/platform/chromium/ChromiumDataObject.h
Source/WebCore/platform/chromium/ChromiumDataObjectItem.cpp [moved from Source/WebCore/platform/chromium/DataTransferItemChromium.cpp with 72% similarity]
Source/WebCore/platform/chromium/ChromiumDataObjectItem.h [moved from Source/WebCore/platform/chromium/DataTransferItemChromium.h with 74% similarity]
Source/WebCore/platform/chromium/ClipboardChromium.cpp
Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp [deleted file]
Source/WebCore/platform/chromium/DataTransferItemListChromium.h [deleted file]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebDragData.cpp

index bca3f4f..5befc36 100644 (file)
@@ -1,3 +1,73 @@
+2012-03-27  Daniel Cheng  <dcheng@chromium.org>
+
+        [chromium] Merge ChromiumDataObject and DataTransferItemListChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=82407
+
+        Reviewed by Tony Chang.
+
+        Since ChromiumDataObject is just a very thin wrapper for DataTransferItemListChromium now,
+        combine the two and remove a layer of indirection.
+
+        No functionality change, should be covered by existing tests.
+
+        * WebCore.gypi:
+        * platform/chromium/ChromiumDataObject.cpp: Replacing DataTransferItemListChromium.
+        (WebCore::ChromiumDataObject::createFromPasteboard):
+        (WebCore::ChromiumDataObject::create):
+        (WebCore::ChromiumDataObject::length):
+        (WebCore):
+        (WebCore::ChromiumDataObject::item):
+        (WebCore::ChromiumDataObject::deleteItem):
+        (WebCore::ChromiumDataObject::clearAll):
+        (WebCore::ChromiumDataObject::add):
+        (WebCore::ChromiumDataObject::clearData):
+        (WebCore::ChromiumDataObject::clearAllExceptFiles):
+        (WebCore::ChromiumDataObject::types):
+        (WebCore::ChromiumDataObject::getData):
+        (WebCore::ChromiumDataObject::setData):
+        (WebCore::ChromiumDataObject::urlAndTitle):
+        (WebCore::ChromiumDataObject::setURLAndTitle):
+        (WebCore::ChromiumDataObject::htmlAndBaseURL):
+        (WebCore::ChromiumDataObject::setHTMLAndBaseURL):
+        (WebCore::ChromiumDataObject::containsFilenames):
+        (WebCore::ChromiumDataObject::filenames):
+        (WebCore::ChromiumDataObject::addFilename):
+        (WebCore::ChromiumDataObject::addSharedBuffer):
+        (WebCore::ChromiumDataObject::ChromiumDataObject):
+        (WebCore::ChromiumDataObject::findStringItem):
+        (WebCore::ChromiumDataObject::internalAddStringItem):
+        (WebCore::ChromiumDataObject::internalAddFileItem):
+        * platform/chromium/ChromiumDataObject.h:
+        (WebCore):
+        (ChromiumDataObject):
+        * platform/chromium/ChromiumDataObjectItem.cpp: Renamed from Source/WebCore/platform/chromium/DataTransferItemChromium.cpp.
+        (WebCore):
+        (WebCore::ChromiumDataObjectItem::createFromString):
+        (WebCore::ChromiumDataObjectItem::createFromFile):
+        (WebCore::ChromiumDataObjectItem::createFromURL):
+        (WebCore::ChromiumDataObjectItem::createFromHTML):
+        (WebCore::ChromiumDataObjectItem::createFromSharedBuffer):
+        (WebCore::ChromiumDataObjectItem::createFromPasteboard):
+        (WebCore::ChromiumDataObjectItem::ChromiumDataObjectItem):
+        (WebCore::ChromiumDataObjectItem::getAsString):
+        (WebCore::ChromiumDataObjectItem::getAsFile):
+        (WebCore::ChromiumDataObjectItem::internalGetAsString):
+        (WebCore::ChromiumDataObjectItem::isFilename):
+        * platform/chromium/ChromiumDataObjectItem.h: Renamed from Source/WebCore/platform/chromium/DataTransferItemChromium.h.
+        (WebCore):
+        (ChromiumDataObjectItem):
+        (WebCore::ChromiumDataObjectItem::kind):
+        (WebCore::ChromiumDataObjectItem::type):
+        (WebCore::ChromiumDataObjectItem::sharedBuffer):
+        (WebCore::ChromiumDataObjectItem::title):
+        (WebCore::ChromiumDataObjectItem::baseURL):
+        * platform/chromium/ClipboardChromium.cpp:
+        (WebCore::ClipboardChromium::files):
+        (WebCore::ClipboardChromium::hasData):
+        (WebCore::ClipboardChromium::items):
+        * platform/chromium/DataTransferItemListChromium.cpp: Removed.
+        * platform/chromium/DataTransferItemListChromium.h: Removed.
+
 2012-03-28  Nat Duca  <nduca@chromium.org>
 
         [chromium] Scheduler should not tell FrameRateController to begin a frame when we dont swap
 2012-03-28  Nat Duca  <nduca@chromium.org>
 
         [chromium] Scheduler should not tell FrameRateController to begin a frame when we dont swap
index 1cf3660..a16f1a5 100644 (file)
             'platform/cf/SharedBufferCF.cpp',
             'platform/chromium/ChromiumDataObject.cpp',
             'platform/chromium/ChromiumDataObject.h',
             'platform/cf/SharedBufferCF.cpp',
             'platform/chromium/ChromiumDataObject.cpp',
             'platform/chromium/ChromiumDataObject.h',
+            'platform/chromium/ChromiumDataObjectItem.cpp',
+            'platform/chromium/ChromiumDataObjectItem.h',
             'platform/chromium/ClipboardChromium.cpp',
             'platform/chromium/ClipboardChromium.h',
             'platform/chromium/ClipboardChromiumPosix.cpp',
             'platform/chromium/ClipboardChromium.cpp',
             'platform/chromium/ClipboardChromium.h',
             'platform/chromium/ClipboardChromiumPosix.cpp',
             'platform/chromium/ContextMenuChromium.cpp',
             'platform/chromium/ContextMenuItemChromium.cpp',
             'platform/chromium/CursorChromium.cpp',
             'platform/chromium/ContextMenuChromium.cpp',
             'platform/chromium/ContextMenuItemChromium.cpp',
             'platform/chromium/CursorChromium.cpp',
-            'platform/chromium/DataTransferItemChromium.cpp',
-            'platform/chromium/DataTransferItemChromium.h',
-            'platform/chromium/DataTransferItemListChromium.cpp',
-            'platform/chromium/DataTransferItemListChromium.h',
             'platform/chromium/DragDataChromium.cpp',
             'platform/chromium/DragDataRef.h',
             'platform/chromium/DragImageChromiumMac.cpp',
             'platform/chromium/DragDataChromium.cpp',
             'platform/chromium/DragDataRef.h',
             'platform/chromium/DragImageChromiumMac.cpp',
index 679f42d..0a1f8b6 100644 (file)
 #include "ClipboardMimeTypes.h"
 #include "ClipboardUtilitiesChromium.h"
 #include "DataTransferItem.h"
 #include "ClipboardMimeTypes.h"
 #include "ClipboardUtilitiesChromium.h"
 #include "DataTransferItem.h"
-#include "DataTransferItemListChromium.h"
+#include "ExceptionCode.h"
 #include "ExceptionCodePlaceholder.h"
 #include "ExceptionCodePlaceholder.h"
+#include "PlatformSupport.h"
 
 namespace WebCore {
 
 
 namespace WebCore {
 
-static PassRefPtr<DataTransferItemChromium> findItem(PassRefPtr<DataTransferItemListChromium> itemList, const String& type)
-{
-    for (size_t i = 0; i < itemList->length(); ++i) {
-        if (itemList->item(i)->kind() == DataTransferItem::kindString && itemList->item(i)->type() == type)
-            return itemList->item(i);
-    }
-    return 0;
-}
-
 PassRefPtr<ChromiumDataObject> ChromiumDataObject::createFromPasteboard()
 {
 PassRefPtr<ChromiumDataObject> ChromiumDataObject::createFromPasteboard()
 {
-    return adoptRef(new ChromiumDataObject(DataTransferItemListChromium::createFromPasteboard()));
+    RefPtr<ChromiumDataObject> dataObject = create();
+    uint64_t sequenceNumber = PlatformSupport::clipboardSequenceNumber(currentPasteboardBuffer());
+    bool ignored;
+    HashSet<String> types = PlatformSupport::clipboardReadAvailableTypes(currentPasteboardBuffer(), &ignored);
+    for (HashSet<String>::const_iterator it = types.begin(); it != types.end(); ++it)
+        dataObject->m_itemList.append(ChromiumDataObjectItem::createFromPasteboard(*it, sequenceNumber));
+    return dataObject.release();
 }
 
 PassRefPtr<ChromiumDataObject> ChromiumDataObject::create()
 {
 }
 
 PassRefPtr<ChromiumDataObject> ChromiumDataObject::create()
 {
-    return adoptRef(new ChromiumDataObject(DataTransferItemListChromium::create()));
+    return adoptRef(new ChromiumDataObject());
 }
 
 PassRefPtr<ChromiumDataObject> ChromiumDataObject::copy() const
 }
 
 PassRefPtr<ChromiumDataObject> ChromiumDataObject::copy() const
@@ -63,32 +61,60 @@ PassRefPtr<ChromiumDataObject> ChromiumDataObject::copy() const
     return adoptRef(new ChromiumDataObject(*this));
 }
 
     return adoptRef(new ChromiumDataObject(*this));
 }
 
-PassRefPtr<DataTransferItemListChromium> ChromiumDataObject::items() const
+size_t ChromiumDataObject::length() const
 {
 {
-    return m_itemList;
+    return m_itemList.size();
+}
+
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObject::item(unsigned long index)
+{
+    if (index >= length())
+        return 0;
+    return m_itemList[index];
+}
+
+void ChromiumDataObject::deleteItem(unsigned long index)
+{
+    if (index >= length())
+        return;
+    m_itemList.remove(index);
+}
+
+void ChromiumDataObject::clearAll()
+{
+    m_itemList.clear();
+}
+
+void ChromiumDataObject::add(const String& data, const String& type, ExceptionCode& ec)
+{
+    if (!internalAddStringItem(ChromiumDataObjectItem::createFromString(type, data)))
+        ec = NOT_SUPPORTED_ERR;
+}
+
+void ChromiumDataObject::add(PassRefPtr<File> file, ScriptExecutionContext* context)
+{
+    if (!file)
+        return;
+
+    m_itemList.append(ChromiumDataObjectItem::createFromFile(file));
 }
 
 void ChromiumDataObject::clearData(const String& type)
 {
 }
 
 void ChromiumDataObject::clearData(const String& type)
 {
-    for (size_t i = 0; i < m_itemList->length(); ++i) {
-        if (m_itemList->item(i)->kind() == DataTransferItem::kindString && m_itemList->item(i)->type() == type) {
+    for (size_t i = 0; i < m_itemList.size(); ++i) {
+        if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[i]->type() == type) {
             // Per the spec, type must be unique among all items of kind 'string'.
             // Per the spec, type must be unique among all items of kind 'string'.
-            m_itemList->deleteItem(i);
+            m_itemList.remove(i);
             return;
         }
     }
 }
 
             return;
         }
     }
 }
 
-void ChromiumDataObject::clearAll()
-{
-    m_itemList->clear();
-}
-
 void ChromiumDataObject::clearAllExceptFiles()
 {
 void ChromiumDataObject::clearAllExceptFiles()
 {
-    for (size_t i = 0; i < m_itemList->length(); ) {
-        if (m_itemList->item(i)->kind() != DataTransferItem::kindFile) {
-            m_itemList->deleteItem(i);
+    for (size_t i = 0; i < m_itemList.size(); ) {
+        if (m_itemList[i]->kind() != DataTransferItem::kindFile) {
+            m_itemList.remove(i);
             continue;
         }
         ++i;
             continue;
         }
         ++i;
@@ -99,10 +125,10 @@ HashSet<String> ChromiumDataObject::types() const
 {
     HashSet<String> results;
     bool containsFiles = false;
 {
     HashSet<String> results;
     bool containsFiles = false;
-    for (size_t i = 0; i < m_itemList->length(); ++i) {
-        if (m_itemList->item(i)->kind() == DataTransferItem::kindString)
-            results.add(m_itemList->item(i)->type());
-        else if (m_itemList->item(i)->kind() == DataTransferItem::kindFile)
+    for (size_t i = 0; i < m_itemList.size(); ++i) {
+        if (m_itemList[i]->kind() == DataTransferItem::kindString)
+            results.add(m_itemList[i]->type());
+        else if (m_itemList[i]->kind() == DataTransferItem::kindFile)
             containsFiles = true;
         else
             ASSERT_NOT_REACHED();
             containsFiles = true;
         else
             ASSERT_NOT_REACHED();
@@ -114,9 +140,9 @@ HashSet<String> ChromiumDataObject::types() const
 
 String ChromiumDataObject::getData(const String& type) const
 {
 
 String ChromiumDataObject::getData(const String& type) const
 {
-    for (size_t i = 0; i < m_itemList->length(); ++i)  {
-        if (m_itemList->item(i)->kind() == DataTransferItem::kindString && m_itemList->item(i)->type() == type)
-            return m_itemList->item(i)->internalGetAsString();
+    for (size_t i = 0; i < m_itemList.size(); ++i)  {
+        if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[i]->type() == type)
+            return m_itemList[i]->internalGetAsString();
     }
     return String();
 }
     }
     return String();
 }
@@ -124,13 +150,13 @@ String ChromiumDataObject::getData(const String& type) const
 bool ChromiumDataObject::setData(const String& type, const String& data)
 {
     clearData(type);
 bool ChromiumDataObject::setData(const String& type, const String& data)
 {
     clearData(type);
-    m_itemList->add(data, type, ASSERT_NO_EXCEPTION);
+    add(data, type, ASSERT_NO_EXCEPTION);
     return true;
 }
 
 void ChromiumDataObject::urlAndTitle(String& url, String* title) const
 {
     return true;
 }
 
 void ChromiumDataObject::urlAndTitle(String& url, String* title) const
 {
-    RefPtr<DataTransferItemChromium> item = findItem(m_itemList, mimeTypeTextURIList);
+    RefPtr<ChromiumDataObjectItem> item = findStringItem(mimeTypeTextURIList);
     if (!item)
         return;
     url = convertURIListToURL(item->internalGetAsString());
     if (!item)
         return;
     url = convertURIListToURL(item->internalGetAsString());
@@ -141,12 +167,12 @@ void ChromiumDataObject::urlAndTitle(String& url, String* title) const
 void ChromiumDataObject::setURLAndTitle(const String& url, const String& title)
 {
     clearData(mimeTypeTextURIList);
 void ChromiumDataObject::setURLAndTitle(const String& url, const String& title)
 {
     clearData(mimeTypeTextURIList);
-    m_itemList->internalAddStringItem(DataTransferItemChromium::createFromURL(url, title));
+    internalAddStringItem(ChromiumDataObjectItem::createFromURL(url, title));
 }
 
 void ChromiumDataObject::htmlAndBaseURL(String& html, KURL& baseURL) const
 {
 }
 
 void ChromiumDataObject::htmlAndBaseURL(String& html, KURL& baseURL) const
 {
-    RefPtr<DataTransferItemChromium> item = findItem(m_itemList, mimeTypeTextHTML);
+    RefPtr<ChromiumDataObjectItem> item = findStringItem(mimeTypeTextHTML);
     if (!item)
         return;
     html = item->internalGetAsString();
     if (!item)
         return;
     html = item->internalGetAsString();
@@ -156,13 +182,13 @@ void ChromiumDataObject::htmlAndBaseURL(String& html, KURL& baseURL) const
 void ChromiumDataObject::setHTMLAndBaseURL(const String& html, const KURL& baseURL)
 {
     clearData(mimeTypeTextHTML);
 void ChromiumDataObject::setHTMLAndBaseURL(const String& html, const KURL& baseURL)
 {
     clearData(mimeTypeTextHTML);
-    m_itemList->internalAddStringItem(DataTransferItemChromium::createFromHTML(html, baseURL));
+    internalAddStringItem(ChromiumDataObjectItem::createFromHTML(html, baseURL));
 }
 
 bool ChromiumDataObject::containsFilenames() const
 {
 }
 
 bool ChromiumDataObject::containsFilenames() const
 {
-    for (size_t i = 0; i < m_itemList->length(); ++i)
-        if (m_itemList->item(i)->isFilename())
+    for (size_t i = 0; i < m_itemList.size(); ++i)
+        if (m_itemList[i]->isFilename())
             return true;
     return false;
 }
             return true;
     return false;
 }
@@ -170,24 +196,23 @@ bool ChromiumDataObject::containsFilenames() const
 Vector<String> ChromiumDataObject::filenames() const
 {
     Vector<String> results;
 Vector<String> ChromiumDataObject::filenames() const
 {
     Vector<String> results;
-    for (size_t i = 0; i < m_itemList->length(); ++i)
-        if (m_itemList->item(i)->isFilename())
-            results.append(static_cast<File*>(m_itemList->item(i)->getAsFile().get())->path());
+    for (size_t i = 0; i < m_itemList.size(); ++i)
+        if (m_itemList[i]->isFilename())
+            results.append(static_cast<File*>(m_itemList[i]->getAsFile().get())->path());
     return results;
 }
 
 void ChromiumDataObject::addFilename(const String& filename)
 {
     return results;
 }
 
 void ChromiumDataObject::addFilename(const String& filename)
 {
-    m_itemList->internalAddFileItem(DataTransferItemChromium::createFromFile(File::create(filename)));
+    internalAddFileItem(ChromiumDataObjectItem::createFromFile(File::create(filename)));
 }
 
 void ChromiumDataObject::addSharedBuffer(const String& name, PassRefPtr<SharedBuffer> buffer)
 {
 }
 
 void ChromiumDataObject::addSharedBuffer(const String& name, PassRefPtr<SharedBuffer> buffer)
 {
-    m_itemList->internalAddFileItem(DataTransferItemChromium::createFromSharedBuffer(name, buffer));
+    internalAddFileItem(ChromiumDataObjectItem::createFromSharedBuffer(name, buffer));
 }
 
 }
 
-ChromiumDataObject::ChromiumDataObject(PassRefPtr<DataTransferItemListChromium> itemList)
-    : m_itemList(itemList)
+ChromiumDataObject::ChromiumDataObject()
 {
 }
 
 {
 }
 
@@ -197,4 +222,30 @@ ChromiumDataObject::ChromiumDataObject(const ChromiumDataObject& other)
 {
 }
 
 {
 }
 
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObject::findStringItem(const String& type) const
+{
+    for (size_t i = 0; i < m_itemList.size(); ++i) {
+        if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[i]->type() == type)
+            return m_itemList[i];
+    }
+    return 0;
+}
+
+bool ChromiumDataObject::internalAddStringItem(PassRefPtr<ChromiumDataObjectItem> item)
+{
+    ASSERT(item->kind() == DataTransferItem::kindString);
+    for (size_t i = 0; i < m_itemList.size(); ++i)
+        if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[i]->type() == item->type())
+            return false;
+
+    m_itemList.append(item);
+    return true;
+}
+
+void ChromiumDataObject::internalAddFileItem(PassRefPtr<ChromiumDataObjectItem> item)
+{
+    ASSERT(item->kind() == DataTransferItem::kindFile);
+    m_itemList.append(item);
+}
+
 } // namespace WebCore
 } // namespace WebCore
index 5a1c42e..4419828 100644 (file)
@@ -31,7 +31,7 @@
 #ifndef ChromiumDataObject_h
 #define ChromiumDataObject_h
 
 #ifndef ChromiumDataObject_h
 #define ChromiumDataObject_h
 
-#include "DataTransferItemListChromium.h"
+#include "ChromiumDataObjectItem.h"
 #include "PlatformString.h"
 #include <wtf/HashSet.h>
 #include <wtf/RefPtr.h>
 #include "PlatformString.h"
 #include <wtf/HashSet.h>
 #include <wtf/RefPtr.h>
@@ -43,6 +43,8 @@ namespace WebCore {
 class KURL;
 class SharedBuffer;
 
 class KURL;
 class SharedBuffer;
 
+typedef int ExceptionCode;
+
 // A data object for holding data that would be in a clipboard or moved
 // during a drag-n-drop operation.  This is the data that WebCore is aware
 // of and is not specific to a platform.
 // A data object for holding data that would be in a clipboard or moved
 // during a drag-n-drop operation.  This is the data that WebCore is aware
 // of and is not specific to a platform.
@@ -53,10 +55,17 @@ public:
 
     PassRefPtr<ChromiumDataObject> copy() const;
 
 
     PassRefPtr<ChromiumDataObject> copy() const;
 
-    PassRefPtr<DataTransferItemListChromium> items() const;
+    // DataTransferItemList support.
+    size_t length() const;
+    PassRefPtr<ChromiumDataObjectItem> item(unsigned long index);
+    // FIXME: Implement V8DataTransferItemList::indexedPropertyDeleter to get this called.
+    void deleteItem(unsigned long index);
+    void clearAll();
+    void add(const String& data, const String& type, ExceptionCode&);
+    void add(PassRefPtr<File>, ScriptExecutionContext*);
 
 
+    // WebCore helpers.
     void clearData(const String& type);
     void clearData(const String& type);
-    void clearAll();
     void clearAllExceptFiles();
 
     HashSet<String> types() const;
     void clearAllExceptFiles();
 
     HashSet<String> types() const;
@@ -77,10 +86,14 @@ public:
     void addSharedBuffer(const String& name, PassRefPtr<SharedBuffer>);
 
 private:
     void addSharedBuffer(const String& name, PassRefPtr<SharedBuffer>);
 
 private:
-    explicit ChromiumDataObject(PassRefPtr<DataTransferItemListChromium>);
+    ChromiumDataObject();
     explicit ChromiumDataObject(const ChromiumDataObject&);
 
     explicit ChromiumDataObject(const ChromiumDataObject&);
 
-    RefPtr<DataTransferItemListChromium> m_itemList;
+    PassRefPtr<ChromiumDataObjectItem> findStringItem(const String& type) const;
+    bool internalAddStringItem(PassRefPtr<ChromiumDataObjectItem>);
+    void internalAddFileItem(PassRefPtr<ChromiumDataObjectItem>);
+
+    Vector<RefPtr<ChromiumDataObjectItem> > m_itemList;
 };
 
 } // namespace WebCore
 };
 
 } // namespace WebCore
@@ -29,7 +29,7 @@
  */
 
 #include "config.h"
  */
 
 #include "config.h"
-#include "DataTransferItemChromium.h"
+#include "ChromiumDataObjectItem.h"
 
 #if ENABLE(DATA_TRANSFER_ITEMS)
 
 
 #if ENABLE(DATA_TRANSFER_ITEMS)
 
 
 namespace WebCore {
 
 
 namespace WebCore {
 
-PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromString(const String& type, const String& data)
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObjectItem::createFromString(const String& type, const String& data)
 {
 {
-    RefPtr<DataTransferItemChromium> item = adoptRef(new DataTransferItemChromium(DataTransferItem::kindString, type));
+    RefPtr<ChromiumDataObjectItem> item = adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindString, type));
     item->m_data = data;
     return item.release();
 }
 
     item->m_data = data;
     return item.release();
 }
 
-PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromFile(PassRefPtr<File> file)
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObjectItem::createFromFile(PassRefPtr<File> file)
 {
 {
-    RefPtr<DataTransferItemChromium> item = adoptRef(new DataTransferItemChromium(DataTransferItem::kindFile, file->type()));
+    RefPtr<ChromiumDataObjectItem> item = adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindFile, file->type()));
     item->m_file = file;
     return item.release();
 }
 
     item->m_file = file;
     return item.release();
 }
 
-PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromURL(const String& url, const String& title)
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObjectItem::createFromURL(const String& url, const String& title)
 {
 {
-    RefPtr<DataTransferItemChromium> item = adoptRef(new DataTransferItemChromium(DataTransferItem::kindString, mimeTypeTextURIList));
+    RefPtr<ChromiumDataObjectItem> item = adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindString, mimeTypeTextURIList));
     item->m_data = url;
     item->m_title = title;
     return item.release();
 }
 
     item->m_data = url;
     item->m_title = title;
     return item.release();
 }
 
-PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromHTML(const String& html, const KURL& baseURL)
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObjectItem::createFromHTML(const String& html, const KURL& baseURL)
 {
 {
-    RefPtr<DataTransferItemChromium> item = adoptRef(new DataTransferItemChromium(DataTransferItem::kindString, mimeTypeTextHTML));
+    RefPtr<ChromiumDataObjectItem> item = adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindString, mimeTypeTextHTML));
     item->m_data = html;
     item->m_baseURL = baseURL;
     return item.release();
 }
 
     item->m_data = html;
     item->m_baseURL = baseURL;
     return item.release();
 }
 
-PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromSharedBuffer(const String& name, PassRefPtr<SharedBuffer> buffer)
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObjectItem::createFromSharedBuffer(const String& name, PassRefPtr<SharedBuffer> buffer)
 {
 {
-    RefPtr<DataTransferItemChromium> item = adoptRef(new DataTransferItemChromium(DataTransferItem::kindFile, String()));
+    RefPtr<ChromiumDataObjectItem> item = adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindFile, String()));
     item->m_sharedBuffer = buffer;
     item->m_title = name;
     return item.release();
 }
 
     item->m_sharedBuffer = buffer;
     item->m_title = name;
     return item.release();
 }
 
-PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromPasteboard(const String& type, uint64_t sequenceNumber)
+PassRefPtr<ChromiumDataObjectItem> ChromiumDataObjectItem::createFromPasteboard(const String& type, uint64_t sequenceNumber)
 {
     if (type == mimeTypeImagePng)
 {
     if (type == mimeTypeImagePng)
-        return adoptRef(new DataTransferItemChromium(DataTransferItem::kindFile, type, sequenceNumber));
-    return adoptRef(new DataTransferItemChromium(DataTransferItem::kindString, type, sequenceNumber));
+        return adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindFile, type, sequenceNumber));
+    return adoptRef(new ChromiumDataObjectItem(DataTransferItem::kindString, type, sequenceNumber));
 }
 
 }
 
-DataTransferItemChromium::DataTransferItemChromium(const String& kind, const String& type)
+ChromiumDataObjectItem::ChromiumDataObjectItem(const String& kind, const String& type)
     : m_source(InternalSource)
     , m_kind(kind)
     , m_type(type)
     : m_source(InternalSource)
     , m_kind(kind)
     , m_type(type)
@@ -99,7 +99,7 @@ DataTransferItemChromium::DataTransferItemChromium(const String& kind, const Str
 {
 }
 
 {
 }
 
-DataTransferItemChromium::DataTransferItemChromium(const String& kind, const String& type, uint64_t sequenceNumber)
+ChromiumDataObjectItem::ChromiumDataObjectItem(const String& kind, const String& type, uint64_t sequenceNumber)
     : m_source(PasteboardSource)
     , m_kind(kind)
     , m_type(type)
     : m_source(PasteboardSource)
     , m_kind(kind)
     , m_type(type)
@@ -107,7 +107,7 @@ DataTransferItemChromium::DataTransferItemChromium(const String& kind, const Str
 {
 }
 
 {
 }
 
-void DataTransferItemChromium::getAsString(PassRefPtr<StringCallback> callback, ScriptExecutionContext* context) const
+void ChromiumDataObjectItem::getAsString(PassRefPtr<StringCallback> callback, ScriptExecutionContext* context) const
 {
     if (!callback || kind() != DataTransferItem::kindString)
         return;
 {
     if (!callback || kind() != DataTransferItem::kindString)
         return;
@@ -115,7 +115,7 @@ void DataTransferItemChromium::getAsString(PassRefPtr<StringCallback> callback,
     callback->scheduleCallback(context, internalGetAsString());
 }
 
     callback->scheduleCallback(context, internalGetAsString());
 }
 
-PassRefPtr<Blob> DataTransferItemChromium::getAsFile() const
+PassRefPtr<Blob> ChromiumDataObjectItem::getAsFile() const
 {
     if (kind() != DataTransferItem::kindFile)
         return 0;
 {
     if (kind() != DataTransferItem::kindFile)
         return 0;
@@ -153,7 +153,7 @@ PassRefPtr<Blob> DataTransferItemChromium::getAsFile() const
     return 0;
 }
 
     return 0;
 }
 
-String DataTransferItemChromium::internalGetAsString() const
+String ChromiumDataObjectItem::internalGetAsString() const
 {
     ASSERT(m_kind == DataTransferItem::kindString);
 
 {
     ASSERT(m_kind == DataTransferItem::kindString);
 
@@ -176,7 +176,7 @@ String DataTransferItemChromium::internalGetAsString() const
     return PlatformSupport::clipboardSequenceNumber(currentPasteboardBuffer()) == m_sequenceNumber ? data : String();
 }
 
     return PlatformSupport::clipboardSequenceNumber(currentPasteboardBuffer()) == m_sequenceNumber ? data : String();
 }
 
-bool DataTransferItemChromium::isFilename() const
+bool ChromiumDataObjectItem::isFilename() const
 {
     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=81261: When we properly support File dragout,
     // we'll need to make sure this works as expected for DragDataChromium.
 {
     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=81261: When we properly support File dragout,
     // we'll need to make sure this works as expected for DragDataChromium.
@@ -28,8 +28,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DataTransferItemChromium_h
-#define DataTransferItemChromium_h
+#ifndef ChromiumDataObjectItem_h 
+#define ChromiumDataObjectItem_h
 
 #if ENABLE(DATA_TRANSFER_ITEMS)
 
 
 #if ENABLE(DATA_TRANSFER_ITEMS)
 
@@ -46,14 +46,14 @@ class Blob;
 class ScriptExecutionContext;
 class StringCallback;
 
 class ScriptExecutionContext;
 class StringCallback;
 
-class DataTransferItemChromium : public RefCounted<DataTransferItemChromium> {
+class ChromiumDataObjectItem : public RefCounted<ChromiumDataObjectItem> {
 public:
 public:
-    static PassRefPtr<DataTransferItemChromium> createFromString(const String& type, const String& data);
-    static PassRefPtr<DataTransferItemChromium> createFromFile(PassRefPtr<File>);
-    static PassRefPtr<DataTransferItemChromium> createFromURL(const String& url, const String& title);
-    static PassRefPtr<DataTransferItemChromium> createFromHTML(const String& html, const KURL& baseURL);
-    static PassRefPtr<DataTransferItemChromium> createFromSharedBuffer(const String& filename, PassRefPtr<SharedBuffer>);
-    static PassRefPtr<DataTransferItemChromium> createFromPasteboard(const String& type, uint64_t sequenceNumber);
+    static PassRefPtr<ChromiumDataObjectItem> createFromString(const String& type, const String& data);
+    static PassRefPtr<ChromiumDataObjectItem> createFromFile(PassRefPtr<File>);
+    static PassRefPtr<ChromiumDataObjectItem> createFromURL(const String& url, const String& title);
+    static PassRefPtr<ChromiumDataObjectItem> createFromHTML(const String& html, const KURL& baseURL);
+    static PassRefPtr<ChromiumDataObjectItem> createFromSharedBuffer(const String& filename, PassRefPtr<SharedBuffer>);
+    static PassRefPtr<ChromiumDataObjectItem> createFromPasteboard(const String& type, uint64_t sequenceNumber);
 
     String kind() const { return m_kind; }
     String type() const { return m_type; }
 
     String kind() const { return m_kind; }
     String type() const { return m_type; }
@@ -73,8 +73,8 @@ private:
         InternalSource,
     };
 
         InternalSource,
     };
 
-    DataTransferItemChromium(const String& kind, const String& type);
-    DataTransferItemChromium(const String& kind, const String& type, uint64_t sequenceNumber);
+    ChromiumDataObjectItem(const String& kind, const String& type);
+    ChromiumDataObjectItem(const String& kind, const String& type, uint64_t sequenceNumber);
 
     DataSource m_source;
     String m_kind;
 
     DataSource m_source;
     String m_kind;
@@ -94,4 +94,4 @@ private:
 
 #endif // ENABLE(DATA_TRANSFER_ITEMS)
 
 
 #endif // ENABLE(DATA_TRANSFER_ITEMS)
 
-#endif // DataTransferItem_h
+#endif // ChromiumDataObjectItem_h
index 3121ea8..1821c88 100644 (file)
 
 #include "CachedImage.h"
 #include "ChromiumDataObject.h"
 
 #include "CachedImage.h"
 #include "ChromiumDataObject.h"
+#include "ChromiumDataObjectItem.h"
 #include "ClipboardMimeTypes.h"
 #include "ClipboardUtilitiesChromium.h"
 #include "DataTransferItem.h"
 #include "ClipboardMimeTypes.h"
 #include "ClipboardUtilitiesChromium.h"
 #include "DataTransferItem.h"
-#include "DataTransferItemChromium.h"
 #include "DataTransferItemList.h"
 #include "DataTransferItemList.h"
-#include "DataTransferItemListChromium.h"
 #include "Document.h"
 #include "DragData.h"
 #include "Element.h"
 #include "Document.h"
 #include "DragData.h"
 #include "Element.h"
@@ -64,7 +63,7 @@ namespace {
 class DataTransferItemListPolicyWrapper : public DataTransferItemList {
 public:
     static PassRefPtr<DataTransferItemListPolicyWrapper> create(
 class DataTransferItemListPolicyWrapper : public DataTransferItemList {
 public:
     static PassRefPtr<DataTransferItemListPolicyWrapper> create(
-        PassRefPtr<ClipboardChromium>, PassRefPtr<DataTransferItemListChromium>);
+        PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObject>);
 
     virtual size_t length() const;
     virtual PassRefPtr<DataTransferItem> item(unsigned long index);
 
     virtual size_t length() const;
     virtual PassRefPtr<DataTransferItem> item(unsigned long index);
@@ -74,16 +73,16 @@ public:
     virtual void add(PassRefPtr<File>);
 
 private:
     virtual void add(PassRefPtr<File>);
 
 private:
-    DataTransferItemListPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<DataTransferItemListChromium>);
+    DataTransferItemListPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObject>);
 
     RefPtr<ClipboardChromium> m_clipboard;
 
     RefPtr<ClipboardChromium> m_clipboard;
-    RefPtr<DataTransferItemListChromium> m_list;
+    RefPtr<ChromiumDataObject> m_dataObject;
 };
 
 class DataTransferItemPolicyWrapper : public DataTransferItem {
 public:
     static PassRefPtr<DataTransferItemPolicyWrapper> create(
 };
 
 class DataTransferItemPolicyWrapper : public DataTransferItem {
 public:
     static PassRefPtr<DataTransferItemPolicyWrapper> create(
-        PassRefPtr<ClipboardChromium>, PassRefPtr<DataTransferItemChromium>);
+        PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObjectItem>);
 
     virtual String kind() const;
     virtual String type() const;
 
     virtual String kind() const;
     virtual String type() const;
@@ -92,14 +91,14 @@ public:
     virtual PassRefPtr<Blob> getAsFile() const;
 
 private:
     virtual PassRefPtr<Blob> getAsFile() const;
 
 private:
-    DataTransferItemPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<DataTransferItemChromium>);
+    DataTransferItemPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObjectItem>);
 
     RefPtr<ClipboardChromium> m_clipboard;
 
     RefPtr<ClipboardChromium> m_clipboard;
-    RefPtr<DataTransferItemChromium> m_item;
+    RefPtr<ChromiumDataObjectItem> m_item;
 };
 
 PassRefPtr<DataTransferItemListPolicyWrapper> DataTransferItemListPolicyWrapper::create(
 };
 
 PassRefPtr<DataTransferItemListPolicyWrapper> DataTransferItemListPolicyWrapper::create(
-    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<DataTransferItemListChromium> list)
+    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<ChromiumDataObject> list)
 {
     return adoptRef(new DataTransferItemListPolicyWrapper(clipboard, list));
 }
 {
     return adoptRef(new DataTransferItemListPolicyWrapper(clipboard, list));
 }
@@ -108,14 +107,14 @@ size_t DataTransferItemListPolicyWrapper::length() const
 {
     if (m_clipboard->policy() == ClipboardNumb)
         return 0;
 {
     if (m_clipboard->policy() == ClipboardNumb)
         return 0;
-    return m_list->length();
+    return m_dataObject->length();
 }
 
 PassRefPtr<DataTransferItem> DataTransferItemListPolicyWrapper::item(unsigned long index)
 {
     if (m_clipboard->policy() == ClipboardNumb)
         return 0;
 }
 
 PassRefPtr<DataTransferItem> DataTransferItemListPolicyWrapper::item(unsigned long index)
 {
     if (m_clipboard->policy() == ClipboardNumb)
         return 0;
-    RefPtr<DataTransferItemChromium> item = m_list->item(index);
+    RefPtr<ChromiumDataObjectItem> item = m_dataObject->item(index);
     if (!item)
         return 0;
     return DataTransferItemPolicyWrapper::create(m_clipboard, item);
     if (!item)
         return 0;
     return DataTransferItemPolicyWrapper::create(m_clipboard, item);
@@ -127,39 +126,39 @@ void DataTransferItemListPolicyWrapper::deleteItem(unsigned long index, Exceptio
         ec = INVALID_STATE_ERR;
         return;
     }
         ec = INVALID_STATE_ERR;
         return;
     }
-    m_list->deleteItem(index);
+    m_dataObject->deleteItem(index);
 }
 
 void DataTransferItemListPolicyWrapper::clear()
 {
     if (m_clipboard->policy() != ClipboardWritable)
         return;
 }
 
 void DataTransferItemListPolicyWrapper::clear()
 {
     if (m_clipboard->policy() != ClipboardWritable)
         return;
-    m_list->clear();
+    m_dataObject->clearAll();
 }
 
 void DataTransferItemListPolicyWrapper::add(const String& data, const String& type, ExceptionCode& ec)
 {
     if (m_clipboard->policy() != ClipboardWritable)
         return;
 }
 
 void DataTransferItemListPolicyWrapper::add(const String& data, const String& type, ExceptionCode& ec)
 {
     if (m_clipboard->policy() != ClipboardWritable)
         return;
-    m_list->add(data, type, ec);
+    m_dataObject->add(data, type, ec);
 }
 
 void DataTransferItemListPolicyWrapper::add(PassRefPtr<File> file)
 {
     if (m_clipboard->policy() != ClipboardWritable)
         return;
 }
 
 void DataTransferItemListPolicyWrapper::add(PassRefPtr<File> file)
 {
     if (m_clipboard->policy() != ClipboardWritable)
         return;
-    m_list->add(file, m_clipboard->frame()->document()->scriptExecutionContext());
+    m_dataObject->add(file, m_clipboard->frame()->document()->scriptExecutionContext());
 }
 
 DataTransferItemListPolicyWrapper::DataTransferItemListPolicyWrapper(
 }
 
 DataTransferItemListPolicyWrapper::DataTransferItemListPolicyWrapper(
-    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<DataTransferItemListChromium> list)
+    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<ChromiumDataObject> dataObject)
     : m_clipboard(clipboard)
     : m_clipboard(clipboard)
-    , m_list(list)
+    , m_dataObject(dataObject)
 {
 }
 
 PassRefPtr<DataTransferItemPolicyWrapper> DataTransferItemPolicyWrapper::create(
 {
 }
 
 PassRefPtr<DataTransferItemPolicyWrapper> DataTransferItemPolicyWrapper::create(
-    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<DataTransferItemChromium> item)
+    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<ChromiumDataObjectItem> item)
 {
     return adoptRef(new DataTransferItemPolicyWrapper(clipboard, item));
 }
 {
     return adoptRef(new DataTransferItemPolicyWrapper(clipboard, item));
 }
@@ -195,7 +194,7 @@ PassRefPtr<Blob> DataTransferItemPolicyWrapper::getAsFile() const
 }
 
 DataTransferItemPolicyWrapper::DataTransferItemPolicyWrapper(
 }
 
 DataTransferItemPolicyWrapper::DataTransferItemPolicyWrapper(
-    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<DataTransferItemChromium> item)
+    PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<ChromiumDataObjectItem> item)
     : m_clipboard(clipboard)
     , m_item(item)
 {
     : m_clipboard(clipboard)
     , m_item(item)
 {
@@ -320,10 +319,9 @@ PassRefPtr<FileList> ClipboardChromium::files() const
     if (policy() != ClipboardReadable)
         return files.release();
 
     if (policy() != ClipboardReadable)
         return files.release();
 
-    RefPtr<DataTransferItemListChromium> list = m_dataObject->items();
-    for (size_t i = 0; i < list->length(); ++i) {
-        if (list->item(i)->kind() == DataTransferItem::kindFile) {
-            RefPtr<Blob> blob = list->item(i)->getAsFile();
+    for (size_t i = 0; i < m_dataObject->length(); ++i) {
+        if (m_dataObject->item(i)->kind() == DataTransferItem::kindFile) {
+            RefPtr<Blob> blob = m_dataObject->item(i)->getAsFile();
             if (blob && blob->isFile())
                 files->append(static_cast<File*>(blob.get()));
         }
             if (blob && blob->isFile())
                 files->append(static_cast<File*>(blob.get()));
         }
@@ -484,7 +482,7 @@ bool ClipboardChromium::hasData()
 {
     ASSERT(isForDragAndDrop());
 
 {
     ASSERT(isForDragAndDrop());
 
-    return m_dataObject->items()->length() > 0;
+    return m_dataObject->length() > 0;
 }
 
 #if ENABLE(DATA_TRANSFER_ITEMS)
 }
 
 #if ENABLE(DATA_TRANSFER_ITEMS)
@@ -493,7 +491,7 @@ PassRefPtr<DataTransferItemList> ClipboardChromium::items()
     // FIXME: According to the spec, we are supposed to return the same collection of items each
     // time. We now return a wrapper that always wraps the *same* set of items, so JS shouldn't be
     // able to tell, but we probably still want to fix this.
     // FIXME: According to the spec, we are supposed to return the same collection of items each
     // time. We now return a wrapper that always wraps the *same* set of items, so JS shouldn't be
     // able to tell, but we probably still want to fix this.
-    return DataTransferItemListPolicyWrapper::create(this, m_dataObject->items());
+    return DataTransferItemListPolicyWrapper::create(this, m_dataObject);
 }
 #endif
 
 }
 #endif
 
diff --git a/Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp b/Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp
deleted file mode 100644 (file)
index df763d7..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DataTransferItemListChromium.h"
-
-#if ENABLE(DATA_TRANSFER_ITEMS)
-
-#include "BlobURL.h"
-#include "ChromiumDataObject.h"
-#include "ClipboardChromium.h"
-#include "ClipboardMimeTypes.h"
-#include "ClipboardUtilitiesChromium.h"
-#include "DataTransferItem.h"
-#include "DataTransferItemChromium.h"
-#include "ExceptionCode.h"
-#include "File.h"
-#include "KURL.h"
-#include "PlatformSupport.h"
-#include "ScriptExecutionContext.h"
-#include "ThreadableBlobRegistry.h"
-#include <wtf/text/StringBuilder.h>
-
-namespace WebCore {
-
-PassRefPtr<DataTransferItemListChromium> DataTransferItemListChromium::create()
-{
-    return adoptRef(new DataTransferItemListChromium());
-}
-
-PassRefPtr<DataTransferItemListChromium> DataTransferItemListChromium::createFromPasteboard()
-{
-    RefPtr<DataTransferItemListChromium> list = create();
-    uint64_t sequenceNumber = PlatformSupport::clipboardSequenceNumber(currentPasteboardBuffer());
-    bool ignored;
-    HashSet<String> types = PlatformSupport::clipboardReadAvailableTypes(currentPasteboardBuffer(), &ignored);
-    for (HashSet<String>::const_iterator it = types.begin(); it != types.end(); ++it)
-        list->m_itemList.append(DataTransferItemChromium::createFromPasteboard(*it, sequenceNumber));
-    return list.release();
-}
-
-DataTransferItemListChromium::DataTransferItemListChromium()
-{
-}
-
-size_t DataTransferItemListChromium::length() const
-{
-    return m_itemList.size();
-}
-
-PassRefPtr<DataTransferItemChromium> DataTransferItemListChromium::item(unsigned long index)
-{
-    if (index >= length())
-        return 0;
-    return m_itemList[index];
-}
-
-void DataTransferItemListChromium::deleteItem(unsigned long index)
-{
-    if (index >= length())
-        return;
-    m_itemList.remove(index);
-}
-
-void DataTransferItemListChromium::clear()
-{
-    m_itemList.clear();
-}
-
-void DataTransferItemListChromium::add(const String& data, const String& type, ExceptionCode& ec)
-{
-    if (!internalAddStringItem(DataTransferItemChromium::createFromString(type, data)))
-        ec = NOT_SUPPORTED_ERR;
-}
-
-void DataTransferItemListChromium::add(PassRefPtr<File> file, ScriptExecutionContext* context)
-{
-    if (!file)
-        return;
-
-    m_itemList.append(DataTransferItemChromium::createFromFile(file));
-}
-
-// FIXME: Make sure item is released correctly in case of failure.
-bool DataTransferItemListChromium::internalAddStringItem(PassRefPtr<DataTransferItemChromium> item)
-{
-    ASSERT(item->kind() == DataTransferItem::kindString);
-    for (size_t i = 0; i < m_itemList.size(); ++i)
-        if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[i]->type() == item->type())
-            return false;
-
-    m_itemList.append(item);
-    return true;
-}
-
-void DataTransferItemListChromium::internalAddFileItem(PassRefPtr<DataTransferItemChromium> item)
-{
-    ASSERT(item->kind() == DataTransferItem::kindFile);
-    m_itemList.append(item);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(DATA_TRANSFER_ITEMS)
diff --git a/Source/WebCore/platform/chromium/DataTransferItemListChromium.h b/Source/WebCore/platform/chromium/DataTransferItemListChromium.h
deleted file mode 100644 (file)
index da43aa5..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DataTransferItemListChromium_h
-#define DataTransferItemListChromium_h
-
-#if ENABLE(DATA_TRANSFER_ITEMS)
-
-#include "DataTransferItemChromium.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ChromiumDataObject;
-class File;
-class KURL;
-class ScriptExecutionContext;
-
-typedef int ExceptionCode;
-
-class DataTransferItemListChromium : public RefCounted<DataTransferItemListChromium> {
-public:
-    static PassRefPtr<DataTransferItemListChromium> create();
-    static PassRefPtr<DataTransferItemListChromium> createFromPasteboard();
-
-    size_t length() const;
-    PassRefPtr<DataTransferItemChromium> item(unsigned long index);
-    // FIXME: Implement V8DataTransferItemList::indexedPropertyDeleter to get this called.
-    void deleteItem(unsigned long index);
-    void clear();
-    void add(const String& data, const String& type, ExceptionCode&);
-    void add(PassRefPtr<File>, ScriptExecutionContext*);
-
-private:
-    friend class ChromiumDataObject;
-
-    DataTransferItemListChromium();
-
-    // FIXME: Combine with ChromiumDataObject to eliminate the need for these methods.
-    bool internalAddStringItem(PassRefPtr<DataTransferItemChromium>);
-    void internalAddFileItem(PassRefPtr<DataTransferItemChromium>);
-
-    Vector<RefPtr<DataTransferItemChromium> > m_itemList;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(DATA_TRANSFER_ITEMS)
-
-#endif // DataTransferItemListChromium_h
index 8da983f..d485e7b 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-27  Daniel Cheng  <dcheng@chromium.org>
+
+        [chromium] Merge ChromiumDataObject and DataTransferItemListChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=82407
+
+        Reviewed by Tony Chang.
+
+        * src/WebDragData.cpp:
+        (WebKit::WebDragData::items):
+
 2012-03-28  Nat Duca  <nduca@chromium.org>
 
         [chromium] Scheduler should not tell FrameRateController to begin a frame when we dont swap
 2012-03-28  Nat Duca  <nduca@chromium.org>
 
         [chromium] Scheduler should not tell FrameRateController to begin a frame when we dont swap
index dbef95a..dbafafe 100644 (file)
@@ -70,8 +70,8 @@ void WebDragData::assign(const WebDragData& other)
 WebVector<WebDragData::Item> WebDragData::items() const
 {
     Vector<Item> itemList;
 WebVector<WebDragData::Item> WebDragData::items() const
 {
     Vector<Item> itemList;
-    for (size_t i = 0; i < m_private->items()->length(); ++i) {
-        DataTransferItemChromium* originalItem = m_private->items()->item(i).get();
+    for (size_t i = 0; i < m_private->length(); ++i) {
+        ChromiumDataObjectItem* originalItem = m_private->item(i).get();
         WebDragData::Item item;
         if (originalItem->kind() == DataTransferItem::kindString) {
             item.storageType = Item::StorageTypeString;
         WebDragData::Item item;
         if (originalItem->kind() == DataTransferItem::kindString) {
             item.storageType = Item::StorageTypeString;