[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 14:30:45 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2c0603790c15c40a52be0e071323cff64007f4ff
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 12 01:52:55 2010 +0000

    2010-10-11  Daniel Cheng  <dcheng at chromium.org>
    
            Reviewed by Tony Chang.
    
            [chromium] Prepare Clipboard/DragData for transition to new drag-and-drop interface.
            https://bugs.webkit.org/show_bug.cgi?id=44992
    
            In order to allow a graceful transition, ChromiumDataObject has been
            reimplemented as a wrapper around the three different types of data
            objects that the Chrome port uses:
            1. ChromiumDataObjectLegacy -- this is the original ChromiumDataObject.
               All the data that ClipboardChromium/DragDataChromium can potentially
               use is copied over, regardless of whether or not it is needed.
            2. ReadableDataObject -- used for dragging in and pasting into WebKit.
               For efficiency, it caches an optimistic list of types it believes it
               can handle. When getData() is called, a browser IPC is called to
               retrieve the appropriate data.
            3. WritableDataObject -- similar to ChromiumDataObjectLegacy in that it
               buffers all data when dragging out of WebKit or copying/cutting.
               Unfortunately, there is a difference between dragging out and
               copying/cutting--on drag outs, the data is buffered and flushed out
               when startDrag() is called. For copy/cut, any calls to setData()
               result in a browser IPC right away, so calls to setData() in one
               copy/cut event are not atomic.
    
            Copy and paste has been changed to use the new data objects. Dragging
            out uses the legacy data object, and dragging in now has two potential
            entry points--one using the legacy data object, and one using
            ReadableDataObject. Once Chromium transitions to using the new drag-in
            interface, the old interface will be removed.
    
            This change is covered by existing tests.
    
            * WebCore.gypi:
            * editing/chromium/EditorChromium.cpp:
            (WebCore::Editor::newGeneralClipboard):
            * page/chromium/EventHandlerChromium.cpp:
            (WebCore::EventHandler::createDraggingClipboard):
            * platform/chromium/ChromiumDataObject.cpp:
            (WebCore::ChromiumDataObject::ChromiumDataObject):
            (WebCore::ChromiumDataObject::create):
            (WebCore::ChromiumDataObject::createReadable):
            (WebCore::ChromiumDataObject::createWritable):
            (WebCore::ChromiumDataObject::clearData):
            (WebCore::ChromiumDataObject::clearAll):
            (WebCore::ChromiumDataObject::clearAllExceptFiles):
            (WebCore::ChromiumDataObject::hasData):
            (WebCore::ChromiumDataObject::types):
            (WebCore::ChromiumDataObject::getData):
            (WebCore::ChromiumDataObject::setData):
            (WebCore::ChromiumDataObject::urlTitle):
            (WebCore::ChromiumDataObject::setUrlTitle):
            (WebCore::ChromiumDataObject::htmlBaseUrl):
            (WebCore::ChromiumDataObject::setHtmlBaseUrl):
            (WebCore::ChromiumDataObject::containsFilenames):
            (WebCore::ChromiumDataObject::filenames):
            (WebCore::ChromiumDataObject::setFilenames):
            (WebCore::ChromiumDataObject::fileExtension):
            (WebCore::ChromiumDataObject::setFileExtension):
            (WebCore::ChromiumDataObject::fileContentFilename):
            (WebCore::ChromiumDataObject::setFileContentFilename):
            (WebCore::ChromiumDataObject::fileContent):
            (WebCore::ChromiumDataObject::setFileContent):
            * platform/chromium/ChromiumDataObject.h:
            * platform/chromium/ChromiumDataObjectLegacy.cpp: Copied from ChromiumDataObject.cpp
            (WebCore::ChromiumDataObjectLegacy::clearData):
            (WebCore::ChromiumDataObjectLegacy::clearAll):
            (WebCore::ChromiumDataObjectLegacy::clearAllExceptFiles):
            (WebCore::ChromiumDataObjectLegacy::hasData):
            (WebCore::ChromiumDataObjectLegacy::types):
            (WebCore::ChromiumDataObjectLegacy::getData):
            (WebCore::ChromiumDataObjectLegacy::setData):
            (WebCore::ChromiumDataObjectLegacy::ChromiumDataObjectLegacy):
            * platform/chromium/ChromiumDataObjectLegacy.h: Copied from ChromiumDataObject.h
            (WebCore::ChromiumDataObjectLegacy::create):
            (WebCore::ChromiumDataObjectLegacy::copy):
            (WebCore::ChromiumDataObjectLegacy::urlTitle):
            (WebCore::ChromiumDataObjectLegacy::setUrlTitle):
            (WebCore::ChromiumDataObjectLegacy::htmlBaseUrl):
            (WebCore::ChromiumDataObjectLegacy::setHtmlBaseUrl):
            (WebCore::ChromiumDataObjectLegacy::containsFilenames):
            (WebCore::ChromiumDataObjectLegacy::filenames):
            (WebCore::ChromiumDataObjectLegacy::setFilenames):
            (WebCore::ChromiumDataObjectLegacy::fileExtension):
            (WebCore::ChromiumDataObjectLegacy::setFileExtension):
            (WebCore::ChromiumDataObjectLegacy::fileContentFilename):
            (WebCore::ChromiumDataObjectLegacy::setFileContentFilename):
            (WebCore::ChromiumDataObjectLegacy::fileContent):
            (WebCore::ChromiumDataObjectLegacy::setFileContent):
            * platform/chromium/ClipboardChromium.cpp:
            (WebCore::ClipboardChromium::create):
            * platform/chromium/ClipboardChromium.h:
            * platform/chromium/ReadableDataObject.cpp:
            (WebCore::ReadableDataObject::getData):
            * platform/chromium/WritableDataObject.cpp:
            (WebCore::WritableDataObject::setData):
    2010-10-11  Daniel Cheng  <dcheng at chromium.org>
    
            Reviewed by Tony Chang.
    
            [chromium] Prepare Clipboard/DragData for transition to new drag-and-drop interface.
            https://bugs.webkit.org/show_bug.cgi?id=44992
    
            Add a new entry point for drag in to allow a graceful transition
            from the legacy drag and drop model, where all data is copied in at the
            beginning of a drag, to a model where data is retrieved on demand via
            IPCs. The rationale for this is when we begin supporting arbitrary MIME
            types in dataTransfer, we don't want to be copying aribtrary amounts of
            data over for each start drag IPC.
    
            * public/WebView.h:
            * src/WebDragData.cpp:
            (WebKit::WebDragData::initialize): Use the legacy data object.
            (WebKit::WebDragData::ensureMutable): Change the if to an ASSERT.
            * src/WebViewImpl.cpp:
            (WebKit::WebViewImpl::dragTargetDragEnterNew): New entry point.
            * src/WebViewImpl.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 60c579a..138ee11 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,100 @@
+2010-10-11  Daniel Cheng  <dcheng at chromium.org>
+
+        Reviewed by Tony Chang.
+
+        [chromium] Prepare Clipboard/DragData for transition to new drag-and-drop interface.
+        https://bugs.webkit.org/show_bug.cgi?id=44992
+
+        In order to allow a graceful transition, ChromiumDataObject has been
+        reimplemented as a wrapper around the three different types of data
+        objects that the Chrome port uses:
+        1. ChromiumDataObjectLegacy -- this is the original ChromiumDataObject.
+           All the data that ClipboardChromium/DragDataChromium can potentially
+           use is copied over, regardless of whether or not it is needed.
+        2. ReadableDataObject -- used for dragging in and pasting into WebKit.
+           For efficiency, it caches an optimistic list of types it believes it
+           can handle. When getData() is called, a browser IPC is called to
+           retrieve the appropriate data.
+        3. WritableDataObject -- similar to ChromiumDataObjectLegacy in that it
+           buffers all data when dragging out of WebKit or copying/cutting.
+           Unfortunately, there is a difference between dragging out and
+           copying/cutting--on drag outs, the data is buffered and flushed out
+           when startDrag() is called. For copy/cut, any calls to setData()
+           result in a browser IPC right away, so calls to setData() in one
+           copy/cut event are not atomic.
+
+        Copy and paste has been changed to use the new data objects. Dragging
+        out uses the legacy data object, and dragging in now has two potential
+        entry points--one using the legacy data object, and one using
+        ReadableDataObject. Once Chromium transitions to using the new drag-in
+        interface, the old interface will be removed.
+
+        This change is covered by existing tests.
+
+        * WebCore.gypi:
+        * editing/chromium/EditorChromium.cpp:
+        (WebCore::Editor::newGeneralClipboard):
+        * page/chromium/EventHandlerChromium.cpp:
+        (WebCore::EventHandler::createDraggingClipboard):
+        * platform/chromium/ChromiumDataObject.cpp:
+        (WebCore::ChromiumDataObject::ChromiumDataObject):
+        (WebCore::ChromiumDataObject::create):
+        (WebCore::ChromiumDataObject::createReadable):
+        (WebCore::ChromiumDataObject::createWritable):
+        (WebCore::ChromiumDataObject::clearData):
+        (WebCore::ChromiumDataObject::clearAll):
+        (WebCore::ChromiumDataObject::clearAllExceptFiles):
+        (WebCore::ChromiumDataObject::hasData):
+        (WebCore::ChromiumDataObject::types):
+        (WebCore::ChromiumDataObject::getData):
+        (WebCore::ChromiumDataObject::setData):
+        (WebCore::ChromiumDataObject::urlTitle):
+        (WebCore::ChromiumDataObject::setUrlTitle):
+        (WebCore::ChromiumDataObject::htmlBaseUrl):
+        (WebCore::ChromiumDataObject::setHtmlBaseUrl):
+        (WebCore::ChromiumDataObject::containsFilenames):
+        (WebCore::ChromiumDataObject::filenames):
+        (WebCore::ChromiumDataObject::setFilenames):
+        (WebCore::ChromiumDataObject::fileExtension):
+        (WebCore::ChromiumDataObject::setFileExtension):
+        (WebCore::ChromiumDataObject::fileContentFilename):
+        (WebCore::ChromiumDataObject::setFileContentFilename):
+        (WebCore::ChromiumDataObject::fileContent):
+        (WebCore::ChromiumDataObject::setFileContent):
+        * platform/chromium/ChromiumDataObject.h:
+        * platform/chromium/ChromiumDataObjectLegacy.cpp: Copied from ChromiumDataObject.cpp
+        (WebCore::ChromiumDataObjectLegacy::clearData):
+        (WebCore::ChromiumDataObjectLegacy::clearAll):
+        (WebCore::ChromiumDataObjectLegacy::clearAllExceptFiles):
+        (WebCore::ChromiumDataObjectLegacy::hasData):
+        (WebCore::ChromiumDataObjectLegacy::types):
+        (WebCore::ChromiumDataObjectLegacy::getData):
+        (WebCore::ChromiumDataObjectLegacy::setData):
+        (WebCore::ChromiumDataObjectLegacy::ChromiumDataObjectLegacy):
+        * platform/chromium/ChromiumDataObjectLegacy.h: Copied from ChromiumDataObject.h
+        (WebCore::ChromiumDataObjectLegacy::create):
+        (WebCore::ChromiumDataObjectLegacy::copy):
+        (WebCore::ChromiumDataObjectLegacy::urlTitle):
+        (WebCore::ChromiumDataObjectLegacy::setUrlTitle):
+        (WebCore::ChromiumDataObjectLegacy::htmlBaseUrl):
+        (WebCore::ChromiumDataObjectLegacy::setHtmlBaseUrl):
+        (WebCore::ChromiumDataObjectLegacy::containsFilenames):
+        (WebCore::ChromiumDataObjectLegacy::filenames):
+        (WebCore::ChromiumDataObjectLegacy::setFilenames):
+        (WebCore::ChromiumDataObjectLegacy::fileExtension):
+        (WebCore::ChromiumDataObjectLegacy::setFileExtension):
+        (WebCore::ChromiumDataObjectLegacy::fileContentFilename):
+        (WebCore::ChromiumDataObjectLegacy::setFileContentFilename):
+        (WebCore::ChromiumDataObjectLegacy::fileContent):
+        (WebCore::ChromiumDataObjectLegacy::setFileContent):
+        * platform/chromium/ClipboardChromium.cpp:
+        (WebCore::ClipboardChromium::create):
+        * platform/chromium/ClipboardChromium.h:
+        * platform/chromium/ReadableDataObject.cpp:
+        (WebCore::ReadableDataObject::getData):
+        * platform/chromium/WritableDataObject.cpp:
+        (WebCore::WritableDataObject::setData):
+
 2010-10-11  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index e5153fa..2b406a3 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2290,6 +2290,8 @@
             'platform/chromium/ChromiumBridge.h',
             'platform/chromium/ChromiumDataObject.cpp',
             'platform/chromium/ChromiumDataObject.h',
+            'platform/chromium/ChromiumDataObjectLegacy.cpp',
+            'platform/chromium/ChromiumDataObjectLegacy.h',
             'platform/chromium/ClipboardChromium.cpp',
             'platform/chromium/ClipboardChromium.h',
             'platform/chromium/ClipboardChromiumLinux.cpp',
diff --git a/WebCore/editing/chromium/EditorChromium.cpp b/WebCore/editing/chromium/EditorChromium.cpp
index 2bfb5af..ca7f41a 100644
--- a/WebCore/editing/chromium/EditorChromium.cpp
+++ b/WebCore/editing/chromium/EditorChromium.cpp
@@ -39,7 +39,7 @@ namespace WebCore {
 
 PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame)
 {
-    return ClipboardChromium::create(Clipboard::CopyAndPaste, ChromiumDataObject::create(Clipboard::CopyAndPaste), policy, frame);
+    return ClipboardChromium::create(Clipboard::CopyAndPaste, policy, frame);
 }
 
 } // namespace WebCore
diff --git a/WebCore/page/chromium/EventHandlerChromium.cpp b/WebCore/page/chromium/EventHandlerChromium.cpp
index 9138b8d..9b40fb3 100644
--- a/WebCore/page/chromium/EventHandlerChromium.cpp
+++ b/WebCore/page/chromium/EventHandlerChromium.cpp
@@ -128,8 +128,8 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
 
 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
 {
-    RefPtr<ChromiumDataObject> dataObject = ChromiumDataObject::create(Clipboard::DragAndDrop);
-    return ClipboardChromium::create(Clipboard::DragAndDrop, dataObject.get(), ClipboardWritable, m_frame);
+    RefPtr<ChromiumDataObjectLegacy> dataObject = ChromiumDataObjectLegacy::create(Clipboard::DragAndDrop);
+    return ClipboardChromium::create(Clipboard::DragAndDrop, ChromiumDataObject::create(dataObject), ClipboardWritable, m_frame);
 }
 
 void EventHandler::focusDocumentView()
diff --git a/WebCore/platform/chromium/ChromiumDataObject.cpp b/WebCore/platform/chromium/ChromiumDataObject.cpp
index 73e6f48..78b794b 100644
--- a/WebCore/platform/chromium/ChromiumDataObject.cpp
+++ b/WebCore/platform/chromium/ChromiumDataObject.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -31,220 +31,189 @@
 #include "config.h"
 #include "ChromiumDataObject.h"
 
-#include "ChromiumBridge.h"
-#include "ClipboardMimeTypes.h"
-#include "Pasteboard.h"
-
 namespace WebCore {
 
-// Per RFC 2483, the line separator for "text/..." MIME types is CR-LF.
-static char const* const textMIMETypeLineSeparator = "\r\n";
+ChromiumDataObject::ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy> data)
+    : RefCounted<ChromiumDataObject>()
+    , m_legacyData(data)
+{
+}
 
-void ChromiumDataObject::clearData(const String& type)
+ChromiumDataObject::ChromiumDataObject(PassRefPtr<ReadableDataObject> data)
+    : RefCounted<ChromiumDataObject>()
+    , m_readableData(data)
+{
+}
+
+ChromiumDataObject::ChromiumDataObject(PassRefPtr<WritableDataObject> data)
+    : RefCounted<ChromiumDataObject>()
+    , m_writableData(data)
 {
-    if (type == mimeTypeTextPlain) {
-        m_plainText = "";
-        return;
-    }
+}
 
-    if (type == mimeTypeURL || type == mimeTypeTextURIList) {
-        m_uriList = "";
-        m_url = KURL();
-        m_urlTitle = "";
-        return;
-    }
+PassRefPtr<ChromiumDataObject> ChromiumDataObject::create(PassRefPtr<ChromiumDataObjectLegacy> data)
+{
+    return adoptRef(new ChromiumDataObject(data));
+}
 
-    if (type == mimeTypeTextHTML) {
-        m_textHtml = "";
-        m_htmlBaseUrl = KURL();
-        return;
-    }
+PassRefPtr<ChromiumDataObject> ChromiumDataObject::createReadable(Clipboard::ClipboardType clipboardType)
+{
+    return adoptRef(new ChromiumDataObject(ReadableDataObject::create(clipboardType)));
+}
 
-    if (type == mimeTypeDownloadURL) {
-        m_downloadMetadata = "";
-        return;
-    }
+PassRefPtr<ChromiumDataObject> ChromiumDataObject::createWritable(Clipboard::ClipboardType clipboardType)
+{
+    return adoptRef(new ChromiumDataObject(WritableDataObject::create(clipboardType)));
+}
+
+void ChromiumDataObject::clearData(const String& type)
+{
+    if (m_legacyData)
+        m_legacyData->clearData(type);
+    else
+        m_writableData->clearData(type);
 }
 
 void ChromiumDataObject::clearAll()
 {
-    clearAllExceptFiles();
-    m_filenames.clear();
+    if (m_legacyData)
+        m_legacyData->clearAll();
+    else
+        m_writableData->clearAll();
 }
 
 void ChromiumDataObject::clearAllExceptFiles()
 {
-    m_urlTitle = "";
-    m_url = KURL();
-    m_uriList = "";
-    m_downloadMetadata = "";
-    m_fileExtension = "";
-    m_plainText = "";
-    m_textHtml = "";
-    m_htmlBaseUrl = KURL();
-    m_fileContentFilename = "";
-    if (m_fileContent)
-        m_fileContent->clear();
+    if (m_legacyData)
+        m_legacyData->clearAllExceptFiles();
+    else
+        m_writableData->clearAllExceptFiles();
 }
 
 bool ChromiumDataObject::hasData() const
 {
-    return !m_url.isEmpty()
-        || !m_uriList.isEmpty()
-        || !m_downloadMetadata.isEmpty()
-        || !m_fileExtension.isEmpty()
-        || !m_filenames.isEmpty()
-        || !m_plainText.isEmpty()
-        || !m_textHtml.isEmpty()
-        || m_fileContent;
+    if (m_legacyData)
+        return m_legacyData->hasData();
+    return m_readableData->hasData();
 }
 
 HashSet<String> ChromiumDataObject::types() const
 {
-    // This is currently broken for pasteboard events, and always has been.
-    HashSet<String> results;
+    if (m_legacyData)
+        return m_legacyData->types();
+    return m_readableData->types();
+}
+
+String ChromiumDataObject::getData(const String& type, bool& success)
+{
+    if (m_legacyData)
+        return m_legacyData->getData(type, success);
+    return m_readableData->getData(type, success);
+}
+
+bool ChromiumDataObject::setData(const String& type, const String& data)
+{
+    if (m_legacyData)
+        return m_legacyData->setData(type, data);
+    return m_writableData->setData(type, data);
+}
+
+String ChromiumDataObject::urlTitle() const
+{
+    if (m_legacyData)
+        return m_legacyData->urlTitle();
+    return m_readableData->urlTitle();
+}
 
-    if (!m_plainText.isEmpty()) {
-        results.add(mimeTypeText);
-        results.add(mimeTypeTextPlain);
-    }
+void ChromiumDataObject::setUrlTitle(const String& urlTitle)
+{
+    if (m_legacyData)
+        m_legacyData->setUrlTitle(urlTitle);
+    else
+        m_writableData->setUrlTitle(urlTitle);
+}
 
-    if (m_url.isValid())
-        results.add(mimeTypeURL);
+KURL ChromiumDataObject::htmlBaseUrl() const
+{
+    if (m_legacyData)
+        return m_legacyData->htmlBaseUrl();
+    return m_readableData->htmlBaseUrl();
+}
 
-    if (!m_uriList.isEmpty())
-        results.add(mimeTypeTextURIList);
+void ChromiumDataObject::setHtmlBaseUrl(const KURL& url)
+{
+    if (m_legacyData)
+        m_legacyData->setHtmlBaseUrl(url);
+    else
+        m_writableData->setHtmlBaseUrl(url);
+}
 
-    if (!m_textHtml.isEmpty())
-        results.add(mimeTypeTextHTML);
+bool ChromiumDataObject::containsFilenames() const
+{
+    if (m_legacyData)
+        return m_legacyData->containsFilenames();
+    return m_readableData->containsFilenames();
+}
 
-    if (!m_filenames.isEmpty())
-        results.add("Files");
+Vector<String> ChromiumDataObject::filenames() const
+{
+    if (m_legacyData)
+        return m_legacyData->filenames();
+    return m_readableData->filenames();
+}
 
-    return results;
+void ChromiumDataObject::setFilenames(const Vector<String>& filenames)
+{
+    if (m_legacyData)
+        m_legacyData->setFilenames(filenames);
+    else
+        ASSERT_NOT_REACHED();
 }
 
-String ChromiumDataObject::getData(const String& type, bool& success)
+String ChromiumDataObject::fileExtension() const
 {
-    if (type == mimeTypeTextPlain) {
-        if (m_clipboardType == Clipboard::CopyAndPaste) {
-            PasteboardPrivate::ClipboardBuffer buffer =
-                Pasteboard::generalPasteboard()->isSelectionMode() ?
-                PasteboardPrivate::SelectionBuffer :
-                PasteboardPrivate::StandardBuffer;
-            String text = ChromiumBridge::clipboardReadPlainText(buffer);
-            success = !text.isEmpty();
-            return text;
-        }
-        success = !m_plainText.isEmpty();
-        return m_plainText;
-    }
-
-    if (type == mimeTypeURL) {
-        success = !m_url.isEmpty();
-        return m_url.string();
-    }
-
-    if (type == mimeTypeTextURIList) {
-        success = !m_uriList.isEmpty();
-        return m_uriList;
-    }
-
-    if (type == mimeTypeTextHTML) {
-        if (m_clipboardType == Clipboard::CopyAndPaste) {
-            PasteboardPrivate::ClipboardBuffer buffer =
-                Pasteboard::generalPasteboard()->isSelectionMode() ?
-                PasteboardPrivate::SelectionBuffer :
-                PasteboardPrivate::StandardBuffer;
-            String htmlText;
-            KURL sourceURL;
-            ChromiumBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL);
-            success = !htmlText.isEmpty();
-            return htmlText;
-        }
-        success = !m_textHtml.isEmpty();
-        return m_textHtml;
-    }
-
-    if (type == mimeTypeDownloadURL) {
-        success = !m_downloadMetadata.isEmpty();
-        return m_downloadMetadata;
-    }
-
-    success = false;
-    return String();
+    if (m_legacyData)
+        return m_legacyData->fileExtension();
+    return m_writableData->fileExtension();
 }
 
-bool ChromiumDataObject::setData(const String& type, const String& data)
+void ChromiumDataObject::setFileExtension(const String& fileExtension)
 {
-    if (type == mimeTypeTextPlain) {
-        m_plainText = data;
-        return true;
-    }
-
-    if (type == mimeTypeURL || type == mimeTypeTextURIList) {
-        m_url = KURL();
-        Vector<String> uriList;
-        // Line separator is \r\n per RFC 2483 - however, for compatibility
-        // reasons we also allow just \n here.
-        data.split('\n', uriList);
-        // Process the input and copy the first valid URL into the url member.
-        // In case no URLs can be found, subsequent calls to getData("URL")
-        // will get an empty string. This is in line with the HTML5 spec (see
-        // "The DragEvent and DataTransfer interfaces").
-        for (size_t i = 0; i < uriList.size(); ++i) {
-            String& line = uriList[i];
-            line = line.stripWhiteSpace();
-            if (line.isEmpty()) {
-                continue;
-            }
-            if (line[0] == '#')
-                continue;
-            KURL url = KURL(ParsedURLString, line);
-            if (url.isValid()) {
-                m_url = url;
-                break;
-            }
-        }
-        m_uriList = data;
-        return true;
-    }
-
-    if (type == mimeTypeTextHTML) {
-        m_textHtml = data;
-        m_htmlBaseUrl = KURL();
-        return true;
-    }
-
-    if (type == mimeTypeDownloadURL) {
-        m_downloadMetadata = data;
-        return true;
-    }
-
-    return false;
-}
-
-ChromiumDataObject::ChromiumDataObject(Clipboard::ClipboardType clipboardType)
-    : m_clipboardType(clipboardType)
-{
-}
-
-ChromiumDataObject::ChromiumDataObject(const ChromiumDataObject& other)
-    : RefCounted<ChromiumDataObject>()
-    , m_clipboardType(other.m_clipboardType)
-    , m_urlTitle(other.m_urlTitle)
-    , m_downloadMetadata(other.m_downloadMetadata)
-    , m_fileExtension(other.m_fileExtension)
-    , m_filenames(other.m_filenames)
-    , m_plainText(other.m_plainText)
-    , m_textHtml(other.m_textHtml)
-    , m_htmlBaseUrl(other.m_htmlBaseUrl)
-    , m_fileContentFilename(other.m_fileContentFilename)
-    , m_url(other.m_url)
-    , m_uriList(other.m_uriList)
-{
-    if (other.m_fileContent.get())
-        m_fileContent = other.m_fileContent->copy();
-}
-
-} // namespace WebCore
+    if (m_legacyData)
+        m_legacyData->setFileExtension(fileExtension);
+    else
+        m_writableData->setFileExtension(fileExtension);
+}
+
+String ChromiumDataObject::fileContentFilename() const
+{
+    if (m_legacyData)
+        return m_legacyData->fileContentFilename();
+    return m_writableData->fileContentFilename();
+}
+
+void ChromiumDataObject::setFileContentFilename(const String& fileContentFilename)
+{
+    if (m_legacyData)
+          m_legacyData->setFileContentFilename(fileContentFilename);
+    else
+          m_writableData->setFileContentFilename(fileContentFilename);
+}
+
+PassRefPtr<SharedBuffer> ChromiumDataObject::fileContent() const
+{
+    if (m_legacyData)
+        return m_legacyData->fileContent();
+    return m_writableData->fileContent();
+}
+
+void ChromiumDataObject::setFileContent(PassRefPtr<SharedBuffer> fileContent)
+{
+    if (m_legacyData)
+        m_legacyData->setFileContent(fileContent);
+    else
+        m_writableData->setFileContent(fileContent);
+}
+
+}
+
diff --git a/WebCore/platform/chromium/ChromiumDataObject.h b/WebCore/platform/chromium/ChromiumDataObject.h
index d86423a..4aac5c9 100644
--- a/WebCore/platform/chromium/ChromiumDataObject.h
+++ b/WebCore/platform/chromium/ChromiumDataObject.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -31,31 +31,18 @@
 #ifndef ChromiumDataObject_h
 #define ChromiumDataObject_h
 
-#include "Clipboard.h"
-#include "KURL.h"
-#include "PlatformString.h"
-#include "SharedBuffer.h"
-#include <wtf/HashSet.h>
+#include "ChromiumDataObjectLegacy.h"
+#include "ReadableDataObject.h"
+#include "WritableDataObject.h"
 #include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
 
 namespace WebCore {
 
-// 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.
 class ChromiumDataObject : public RefCounted<ChromiumDataObject> {
 public:
-    static PassRefPtr<ChromiumDataObject> create(Clipboard::ClipboardType clipboardType)
-    {
-        return adoptRef(new ChromiumDataObject(clipboardType));
-    }
-
-    PassRefPtr<ChromiumDataObject> copy() const
-    {
-        return adoptRef(new ChromiumDataObject(*this));
-    }
+    static PassRefPtr<ChromiumDataObject> create(PassRefPtr<ChromiumDataObjectLegacy> data);
+    static PassRefPtr<ChromiumDataObject> createReadable(Clipboard::ClipboardType);
+    static PassRefPtr<ChromiumDataObject> createWritable(Clipboard::ClipboardType);
 
     void clearData(const String& type);
     void clearAll();
@@ -68,52 +55,34 @@ public:
     bool setData(const String& type, const String& data);
 
     // Special handlers for URL/HTML metadata.
-    String urlTitle() const { return m_urlTitle; }
-    void setUrlTitle(const String& urlTitle) { m_urlTitle = urlTitle; }
-    KURL htmlBaseUrl() const { return m_htmlBaseUrl; }
-    void setHtmlBaseUrl(const KURL& url) { m_htmlBaseUrl = url; }
+    String urlTitle() const;
+    void setUrlTitle(const String& urlTitle);
+    KURL htmlBaseUrl() const;
+    void setHtmlBaseUrl(const KURL& url);
 
     // Used to handle files being dragged in.
-    bool containsFilenames() const { return !m_filenames.isEmpty(); }
-    Vector<String> filenames() const { return m_filenames; }
-    void setFilenames(const Vector<String>& filenames) { m_filenames = filenames; }
+    bool containsFilenames() const;
+    Vector<String> filenames() const;
+    void setFilenames(const Vector<String>& filenames);
 
     // Used to handle files (images) being dragged out.
-    String fileExtension() const { return m_fileExtension; }
-    void setFileExtension(const String& fileExtension) { m_fileExtension = fileExtension; }
-    String fileContentFilename() const { return m_fileContentFilename; }
-    void setFileContentFilename(const String& fileContentFilename) { m_fileContentFilename = fileContentFilename; }
-    PassRefPtr<SharedBuffer> fileContent() const { return m_fileContent; }
-    void setFileContent(PassRefPtr<SharedBuffer> fileContent) { m_fileContent = fileContent; }
+    String fileExtension() const;
+    void setFileExtension(const String& fileExtension);
+    String fileContentFilename() const;
+    void setFileContentFilename(const String& fileContentFilename);
+    PassRefPtr<SharedBuffer> fileContent() const;
+    void setFileContent(PassRefPtr<SharedBuffer> fileContent);
 
 private:
-    ChromiumDataObject(Clipboard::ClipboardType);
-    ChromiumDataObject(const ChromiumDataObject&);
-
-    Clipboard::ClipboardType m_clipboardType;
-
-    String m_urlTitle;
-
-    String m_downloadMetadata;
-
-    String m_fileExtension;
-    Vector<String> m_filenames;
-
-    String m_plainText;
-
-    String m_textHtml;
-    KURL m_htmlBaseUrl;
-
-    String m_fileContentFilename;
-    RefPtr<SharedBuffer> m_fileContent;
+    ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy>);
+    ChromiumDataObject(PassRefPtr<ReadableDataObject>);
+    ChromiumDataObject(PassRefPtr<WritableDataObject>);
 
-    // 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.
-    KURL m_url;
-    String m_uriList;
+    RefPtr<ChromiumDataObjectLegacy> m_legacyData;
+    RefPtr<ReadableDataObject> m_readableData;
+    RefPtr<WritableDataObject> m_writableData;
 };
 
-} // namespace WebCore
+}
 
 #endif
diff --git a/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp b/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp
new file mode 100644
index 0000000..a2952c0
--- /dev/null
+++ b/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2008, 2009, 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 "ChromiumDataObjectLegacy.h"
+
+#include "ChromiumBridge.h"
+#include "ClipboardMimeTypes.h"
+#include "Pasteboard.h"
+
+namespace WebCore {
+
+// Per RFC 2483, the line separator for "text/..." MIME types is CR-LF.
+static char const* const textMIMETypeLineSeparator = "\r\n";
+
+void ChromiumDataObjectLegacy::clearData(const String& type)
+{
+    if (type == mimeTypeTextPlain) {
+        m_plainText = "";
+        return;
+    }
+
+    if (type == mimeTypeURL || type == mimeTypeTextURIList) {
+        m_uriList = "";
+        m_url = KURL();
+        m_urlTitle = "";
+        return;
+    }
+
+    if (type == mimeTypeTextHTML) {
+        m_textHtml = "";
+        m_htmlBaseUrl = KURL();
+        return;
+    }
+
+    if (type == mimeTypeDownloadURL) {
+        m_downloadMetadata = "";
+        return;
+    }
+}
+
+void ChromiumDataObjectLegacy::clearAll()
+{
+    clearAllExceptFiles();
+    m_filenames.clear();
+}
+
+void ChromiumDataObjectLegacy::clearAllExceptFiles()
+{
+    m_urlTitle = "";
+    m_url = KURL();
+    m_uriList = "";
+    m_downloadMetadata = "";
+    m_fileExtension = "";
+    m_plainText = "";
+    m_textHtml = "";
+    m_htmlBaseUrl = KURL();
+    m_fileContentFilename = "";
+    if (m_fileContent)
+        m_fileContent->clear();
+}
+
+bool ChromiumDataObjectLegacy::hasData() const
+{
+    return !m_url.isEmpty()
+        || !m_uriList.isEmpty()
+        || !m_downloadMetadata.isEmpty()
+        || !m_fileExtension.isEmpty()
+        || !m_filenames.isEmpty()
+        || !m_plainText.isEmpty()
+        || !m_textHtml.isEmpty()
+        || m_fileContent;
+}
+
+HashSet<String> ChromiumDataObjectLegacy::types() const
+{
+    // This is currently broken for pasteboard events, and always has been.
+    HashSet<String> results;
+
+    if (!m_plainText.isEmpty()) {
+        results.add(mimeTypeText);
+        results.add(mimeTypeTextPlain);
+    }
+
+    if (m_url.isValid())
+        results.add(mimeTypeURL);
+
+    if (!m_uriList.isEmpty())
+        results.add(mimeTypeTextURIList);
+
+    if (!m_textHtml.isEmpty())
+        results.add(mimeTypeTextHTML);
+
+    if (!m_filenames.isEmpty())
+        results.add("Files");
+
+    return results;
+}
+
+String ChromiumDataObjectLegacy::getData(const String& type, bool& success)
+{
+    if (type == mimeTypeTextPlain) {
+        if (m_clipboardType == Clipboard::CopyAndPaste) {
+            PasteboardPrivate::ClipboardBuffer buffer =
+                Pasteboard::generalPasteboard()->isSelectionMode() ?
+                PasteboardPrivate::SelectionBuffer :
+                PasteboardPrivate::StandardBuffer;
+            String text = ChromiumBridge::clipboardReadPlainText(buffer);
+            success = !text.isEmpty();
+            return text;
+        }
+        success = !m_plainText.isEmpty();
+        return m_plainText;
+    }
+
+    if (type == mimeTypeURL) {
+        success = !m_url.isEmpty();
+        return m_url.string();
+    }
+
+    if (type == mimeTypeTextURIList) {
+        success = !m_uriList.isEmpty();
+        return m_uriList;
+    }
+
+    if (type == mimeTypeTextHTML) {
+        if (m_clipboardType == Clipboard::CopyAndPaste) {
+            PasteboardPrivate::ClipboardBuffer buffer =
+                Pasteboard::generalPasteboard()->isSelectionMode() ?
+                PasteboardPrivate::SelectionBuffer :
+                PasteboardPrivate::StandardBuffer;
+            String htmlText;
+            KURL sourceURL;
+            ChromiumBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL);
+            success = !htmlText.isEmpty();
+            return htmlText;
+        }
+        success = !m_textHtml.isEmpty();
+        return m_textHtml;
+    }
+
+    if (type == mimeTypeDownloadURL) {
+        success = !m_downloadMetadata.isEmpty();
+        return m_downloadMetadata;
+    }
+
+    success = false;
+    return String();
+}
+
+bool ChromiumDataObjectLegacy::setData(const String& type, const String& data)
+{
+    if (type == mimeTypeTextPlain) {
+        m_plainText = data;
+        return true;
+    }
+
+    if (type == mimeTypeURL || type == mimeTypeTextURIList) {
+        m_url = KURL();
+        Vector<String> uriList;
+        // Line separator is \r\n per RFC 2483 - however, for compatibility
+        // reasons we also allow just \n here.
+        data.split('\n', uriList);
+        // Process the input and copy the first valid URL into the url member.
+        // In case no URLs can be found, subsequent calls to getData("URL")
+        // will get an empty string. This is in line with the HTML5 spec (see
+        // "The DragEvent and DataTransfer interfaces").
+        for (size_t i = 0; i < uriList.size(); ++i) {
+            String& line = uriList[i];
+            line = line.stripWhiteSpace();
+            if (line.isEmpty())
+                continue;
+            if (line[0] == '#')
+                continue;
+            KURL url = KURL(ParsedURLString, line);
+            if (url.isValid()) {
+                m_url = url;
+                break;
+            }
+        }
+        m_uriList = data;
+        return true;
+    }
+
+    if (type == mimeTypeTextHTML) {
+        m_textHtml = data;
+        m_htmlBaseUrl = KURL();
+        return true;
+    }
+
+    if (type == mimeTypeDownloadURL) {
+        m_downloadMetadata = data;
+        return true;
+    }
+
+    return false;
+}
+
+ChromiumDataObjectLegacy::ChromiumDataObjectLegacy(Clipboard::ClipboardType clipboardType)
+    : m_clipboardType(clipboardType)
+{
+}
+
+ChromiumDataObjectLegacy::ChromiumDataObjectLegacy(const ChromiumDataObjectLegacy& other)
+    : RefCounted<ChromiumDataObjectLegacy>()
+    , m_clipboardType(other.m_clipboardType)
+    , m_urlTitle(other.m_urlTitle)
+    , m_downloadMetadata(other.m_downloadMetadata)
+    , m_fileExtension(other.m_fileExtension)
+    , m_filenames(other.m_filenames)
+    , m_plainText(other.m_plainText)
+    , m_textHtml(other.m_textHtml)
+    , m_htmlBaseUrl(other.m_htmlBaseUrl)
+    , m_fileContentFilename(other.m_fileContentFilename)
+    , m_url(other.m_url)
+    , m_uriList(other.m_uriList)
+{
+    if (other.m_fileContent.get())
+        m_fileContent = other.m_fileContent->copy();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/chromium/ChromiumDataObjectLegacy.h b/WebCore/platform/chromium/ChromiumDataObjectLegacy.h
new file mode 100644
index 0000000..55be7aa
--- /dev/null
+++ b/WebCore/platform/chromium/ChromiumDataObjectLegacy.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2008, 2009, 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 ChromiumDataObjectLegacy_h
+#define ChromiumDataObjectLegacy_h
+
+#include "Clipboard.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "SharedBuffer.h"
+#include <wtf/HashSet.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+// 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.
+class ChromiumDataObjectLegacy : public RefCounted<ChromiumDataObjectLegacy> {
+public:
+    static PassRefPtr<ChromiumDataObjectLegacy> create(Clipboard::ClipboardType clipboardType)
+    {
+        return adoptRef(new ChromiumDataObjectLegacy(clipboardType));
+    }
+
+    PassRefPtr<ChromiumDataObjectLegacy> copy() const
+    {
+        return adoptRef(new ChromiumDataObjectLegacy(*this));
+    }
+
+    void clearData(const String& type);
+    void clearAll();
+    void clearAllExceptFiles();
+
+    bool hasData() const;
+
+    HashSet<String> types() const;
+    String getData(const String& type, bool& success);
+    bool setData(const String& type, const String& data);
+
+    // Special handlers for URL/HTML metadata.
+    String urlTitle() const { return m_urlTitle; }
+    void setUrlTitle(const String& urlTitle) { m_urlTitle = urlTitle; }
+    KURL htmlBaseUrl() const { return m_htmlBaseUrl; }
+    void setHtmlBaseUrl(const KURL& url) { m_htmlBaseUrl = url; }
+
+    // Used to handle files being dragged in.
+    bool containsFilenames() const { return !m_filenames.isEmpty(); }
+    Vector<String> filenames() const { return m_filenames; }
+    void setFilenames(const Vector<String>& filenames) { m_filenames = filenames; }
+
+    // Used to handle files (images) being dragged out.
+    String fileExtension() const { return m_fileExtension; }
+    void setFileExtension(const String& fileExtension) { m_fileExtension = fileExtension; }
+    String fileContentFilename() const { return m_fileContentFilename; }
+    void setFileContentFilename(const String& fileContentFilename) { m_fileContentFilename = fileContentFilename; }
+    PassRefPtr<SharedBuffer> fileContent() const { return m_fileContent; }
+    void setFileContent(PassRefPtr<SharedBuffer> fileContent) { m_fileContent = fileContent; }
+
+private:
+    ChromiumDataObjectLegacy(Clipboard::ClipboardType);
+    ChromiumDataObjectLegacy(const ChromiumDataObjectLegacy&);
+
+    Clipboard::ClipboardType m_clipboardType;
+
+    String m_urlTitle;
+
+    String m_downloadMetadata;
+
+    String m_fileExtension;
+    Vector<String> m_filenames;
+
+    String m_plainText;
+
+    String m_textHtml;
+    KURL m_htmlBaseUrl;
+
+    String m_fileContentFilename;
+    RefPtr<SharedBuffer> m_fileContent;
+
+    // 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.
+    KURL m_url;
+    String m_uriList;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp
index c1b34da..effbc4a 100644
--- a/WebCore/platform/chromium/ClipboardChromium.cpp
+++ b/WebCore/platform/chromium/ClipboardChromium.cpp
@@ -84,6 +84,16 @@ PassRefPtr<ClipboardChromium> ClipboardChromium::create(ClipboardType clipboardT
     return adoptRef(new ClipboardChromium(clipboardType, dataObject, policy, frame));
 }
 
+PassRefPtr<ClipboardChromium> ClipboardChromium::create(ClipboardType clipboardType,
+    ClipboardAccessPolicy policy, Frame* frame)
+{
+    RefPtr<ChromiumDataObject> dataObject =
+        policy == ClipboardWritable ?
+        ChromiumDataObject::createWritable(clipboardType) :
+        ChromiumDataObject::createReadable(clipboardType);
+    return adoptRef(new ClipboardChromium(clipboardType, dataObject, policy, frame));
+}
+
 void ClipboardChromium::clearData(const String& type)
 {
     if (policy() != ClipboardWritable || !m_dataObject)
diff --git a/WebCore/platform/chromium/ClipboardChromium.h b/WebCore/platform/chromium/ClipboardChromium.h
index 14f59e9..1d69921 100644
--- a/WebCore/platform/chromium/ClipboardChromium.h
+++ b/WebCore/platform/chromium/ClipboardChromium.h
@@ -48,6 +48,9 @@ namespace WebCore {
         static PassRefPtr<ClipboardChromium> create(
             ClipboardType, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy, Frame*);
 
+        static PassRefPtr<ClipboardChromium> create(
+            ClipboardType, ClipboardAccessPolicy, Frame*);
+
         // Returns the file name (not including the extension). This removes any
         // invalid file system characters as well as making sure the
         // path + extension is not bigger than allowed by the file system.
diff --git a/WebCore/platform/chromium/ReadableDataObject.cpp b/WebCore/platform/chromium/ReadableDataObject.cpp
index f0fdd19..97c481b 100644
--- a/WebCore/platform/chromium/ReadableDataObject.cpp
+++ b/WebCore/platform/chromium/ReadableDataObject.cpp
@@ -33,6 +33,8 @@
 
 #include "ChromiumBridge.h"
 #include "ClipboardMimeTypes.h"
+#include "Pasteboard.h"
+#include "PasteboardPrivate.h"
 
 namespace WebCore {
 
@@ -69,6 +71,27 @@ String ReadableDataObject::getData(const String& type, bool& succeeded) const
 {
     String data;
     String ignoredMetadata;
+    // Since the Chromium-side bridge isn't complete yet, we special case this
+    // for copy-and-paste, since that code path no longer uses
+    // ChromiumDataObjectLegacy.
+    if (m_clipboardType == Clipboard::CopyAndPaste) {
+        if (type == mimeTypeTextPlain) {
+            PasteboardPrivate::ClipboardBuffer buffer =
+                Pasteboard::generalPasteboard()->isSelectionMode() ?
+                PasteboardPrivate::SelectionBuffer :
+                PasteboardPrivate::StandardBuffer;
+            data = ChromiumBridge::clipboardReadPlainText(buffer);
+        } else if (type == mimeTypeTextHTML) {
+            PasteboardPrivate::ClipboardBuffer buffer =
+                Pasteboard::generalPasteboard()->isSelectionMode() ?
+                PasteboardPrivate::SelectionBuffer :
+                PasteboardPrivate::StandardBuffer;
+            KURL ignoredSourceURL;
+            ChromiumBridge::clipboardReadHTML(buffer, &data, &ignoredSourceURL);
+        }
+        succeeded = !data.isEmpty();
+        return data;
+    }
     succeeded = ChromiumBridge::clipboardReadData(
         clipboardBuffer(m_clipboardType), type, data, ignoredMetadata);
     return data;
diff --git a/WebCore/platform/chromium/WritableDataObject.cpp b/WebCore/platform/chromium/WritableDataObject.cpp
index ec8ff6e..7cbf42c 100644
--- a/WebCore/platform/chromium/WritableDataObject.cpp
+++ b/WebCore/platform/chromium/WritableDataObject.cpp
@@ -77,6 +77,9 @@ void WritableDataObject::clearAll()
 bool WritableDataObject::setData(const String& type, const String& data)
 {
     if (m_clipboardType == Clipboard::CopyAndPaste) {
+        // FIXME: This is currently unimplemented on the Chromium-side. This is
+        // "okay" for now since the original implementation didn't support it
+        // anyway. Going forward, this is something we'll need to fix though.
         ChromiumBridge::clipboardWriteData(type, data, "");
         return true;
     }
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 84c4cca..1168fe6 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,25 @@
+2010-10-11  Daniel Cheng  <dcheng at chromium.org>
+
+        Reviewed by Tony Chang.
+
+        [chromium] Prepare Clipboard/DragData for transition to new drag-and-drop interface.
+        https://bugs.webkit.org/show_bug.cgi?id=44992
+
+        Add a new entry point for drag in to allow a graceful transition
+        from the legacy drag and drop model, where all data is copied in at the
+        beginning of a drag, to a model where data is retrieved on demand via
+        IPCs. The rationale for this is when we begin supporting arbitrary MIME
+        types in dataTransfer, we don't want to be copying aribtrary amounts of
+        data over for each start drag IPC.
+
+        * public/WebView.h:
+        * src/WebDragData.cpp:
+        (WebKit::WebDragData::initialize): Use the legacy data object.
+        (WebKit::WebDragData::ensureMutable): Change the if to an ASSERT.
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::dragTargetDragEnterNew): New entry point.
+        * src/WebViewImpl.h:
+
 2010-10-11  Jeremy Orlow  <jorlow at chromium.org>
 
         Reviewed by Nate Chapin.
diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h
index 741b1d1..e504bd7 100644
--- a/WebKit/chromium/public/WebView.h
+++ b/WebKit/chromium/public/WebView.h
@@ -226,6 +226,9 @@ public:
         const WebDragData&, int identity,
         const WebPoint& clientPoint, const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed) = 0;
+    virtual WebDragOperation dragTargetDragEnterNew(
+        int identity, const WebPoint& clientPoint, const WebPoint& screenPoint,
+        WebDragOperationsMask operationsAllowed) = 0;
     virtual WebDragOperation dragTargetDragOver(
         const WebPoint& clientPoint, const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed) = 0;
diff --git a/WebKit/chromium/src/WebDragData.cpp b/WebKit/chromium/src/WebDragData.cpp
index f264369..9167c69 100644
--- a/WebKit/chromium/src/WebDragData.cpp
+++ b/WebKit/chromium/src/WebDragData.cpp
@@ -32,6 +32,7 @@
 #include "WebDragData.h"
 
 #include "ChromiumDataObject.h"
+#include "ChromiumDataObjectLegacy.h"
 #include "ClipboardMimeTypes.h"
 #include "WebData.h"
 #include "WebString.h"
@@ -49,7 +50,7 @@ class WebDragDataPrivate : public ChromiumDataObject {
 
 void WebDragData::initialize()
 {
-    assign(static_cast<WebDragDataPrivate*>(ChromiumDataObject::create(Clipboard::DragAndDrop).releaseRef()));
+    assign(static_cast<WebDragDataPrivate*>(ChromiumDataObject::create(ChromiumDataObjectLegacy::create(Clipboard::DragAndDrop)).releaseRef()));
 }
 
 void WebDragData::reset()
@@ -232,8 +233,7 @@ void WebDragData::assign(WebDragDataPrivate* p)
 void WebDragData::ensureMutable()
 {
     ASSERT(!isNull());
-    if (!m_private->hasOneRef())
-        assign(static_cast<WebDragDataPrivate*>(m_private->copy().releaseRef()));
+    ASSERT(m_private->hasOneRef());
 }
 
 } // namespace WebKit
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index 7625a44..f712cf7 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -1690,6 +1690,21 @@ WebDragOperation WebViewImpl::dragTargetDragEnter(
     return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter);
 }
 
+WebDragOperation WebViewImpl::dragTargetDragEnterNew(
+    int identity,
+    const WebPoint& clientPoint,
+    const WebPoint& screenPoint,
+    WebDragOperationsMask operationsAllowed)
+{
+    ASSERT(!m_currentDragData.get());
+
+    m_currentDragData = ChromiumDataObject::createReadable(Clipboard::DragAndDrop);
+    m_dragIdentity = identity;
+    m_operationsAllowed = operationsAllowed;
+
+    return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter);
+}
+
 WebDragOperation WebViewImpl::dragTargetDragOver(
     const WebPoint& clientPoint,
     const WebPoint& screenPoint,
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 30d0314..7e15d03 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -155,6 +155,11 @@ public:
         const WebPoint& clientPoint,
         const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed);
+    virtual WebDragOperation dragTargetDragEnterNew(
+        int identity,
+        const WebPoint& clientPoint,
+        const WebPoint& screenPoint,
+        WebDragOperationsMask operationsAllowed);
     virtual WebDragOperation dragTargetDragOver(
         const WebPoint& clientPoint,
         const WebPoint& screenPoint,

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list