<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[81620] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/81620">81620</a></dd>
<dt>Author</dt> <dd>dcheng@chromium.org</dd>
<dt>Date</dt> <dd>2011-03-21 17:03:12 -0700 (Mon, 21 Mar 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>2011-03-21  Daniel Cheng  <dcheng@chromium.org>

        Reviewed by Tony Chang.

        [chromium] Implement glue between DataTransferItems and the pasteboard.
        https://bugs.webkit.org/show_bug.cgi?id=56330

        Update the layout test to take into account that the actual contents of the clipboard
        are exposed in a paste via DataTransferItems now.
        Also fix the flakiness in the layout test.

        * editing/pasteboard/data-transfer-items-expected.txt:
        * editing/pasteboard/data-transfer-items.html:
        * platform/chromium/test_expectations.txt:
2011-03-21  Daniel Cheng  <dcheng@chromium.org>

        Reviewed by Tony Chang.

        [chromium] Implement glue between DataTransferItems and the pasteboard.
        https://bugs.webkit.org/show_bug.cgi?id=56330

        Support retrieving clipboard data in a paste through DataTransferItems.

        Test: editing/pasteboard/data-transfer-items.html

        * platform/chromium/ClipboardChromium.cpp:
        (WebCore::ClipboardChromium::items):
        * platform/chromium/DataTransferItemChromium.cpp:
        (WebCore::DataTransferItemChromium::createFromPasteboard):
        (WebCore::DataTransferItemChromium::create):
        (WebCore::DataTransferItemChromium::DataTransferItemChromium):
        (WebCore::DataTransferItemChromium::getAsString):
        * platform/chromium/DataTransferItemChromium.h:
        * platform/chromium/DataTransferItemsChromium.cpp:
        (WebCore::DataTransferItemsChromium::addPasteboardItem):
        * platform/chromium/DataTransferItemsChromium.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestseditingpasteboarddatatransferitemsexpectedtxt">trunk/LayoutTests/editing/pasteboard/data-transfer-items-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboarddatatransferitemshtml">trunk/LayoutTests/editing/pasteboard/data-transfer-items.html</a></li>
<li><a href="#trunkLayoutTestsplatformchromiumtest_expectationstxt">trunk/LayoutTests/platform/chromium/test_expectations.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformchromiumClipboardChromiumcpp">trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformchromiumDataTransferItemChromiumcpp">trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformchromiumDataTransferItemChromiumh">trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.h</a></li>
<li><a href="#trunkSourceWebCoreplatformchromiumDataTransferItemsChromiumcpp">trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformchromiumDataTransferItemsChromiumh">trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/LayoutTests/ChangeLog 2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2011-03-21  Daniel Cheng  <dcheng@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        [chromium] Implement glue between DataTransferItems and the pasteboard.
+        https://bugs.webkit.org/show_bug.cgi?id=56330
+
+        Update the layout test to take into account that the actual contents of the clipboard
+        are exposed in a paste via DataTransferItems now.
+        Also fix the flakiness in the layout test.
+
+        * editing/pasteboard/data-transfer-items-expected.txt:
+        * editing/pasteboard/data-transfer-items.html:
+        * platform/chromium/test_expectations.txt:
+
</ins><span class="cx"> 2011-03-21  Dean Jackson  <dino@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Chris Marrin and Simon Fraser.
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboarddatatransferitemsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/data-transfer-items-expected.txt (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/data-transfer-items-expected.txt    2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/LayoutTests/editing/pasteboard/data-transfer-items-expected.txt       2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -1,18 +1,24 @@
</span><del>-CONSOLE MESSAGE: line 19: Populating DataTransferItems...
-CONSOLE MESSAGE: line 27: Caught exception "Error: INVALID_STATE_ERR: DOM Exception 11" as expected.
-CONSOLE MESSAGE: line 31: Verifying contents of DataTransferItems...
-CONSOLE MESSAGE: line 32: items.length: 2
-CONSOLE MESSAGE: line 33: items[0].kind: string
-CONSOLE MESSAGE: line 34: items[0].type: text/plain
-CONSOLE MESSAGE: line 35: items[1].kind: string
-CONSOLE MESSAGE: line 36: items[1].type: text/html
-CONSOLE MESSAGE: line 40: Checking if items past the end of the collection can be indexed:
-CONSOLE MESSAGE: line 41: items[2]: undefined
-CONSOLE MESSAGE: line 51: Checking that a read-only DataTransferItems cannot be mutated...
-CONSOLE MESSAGE: line 54: items.length: 0
-CONSOLE MESSAGE: line 55: items[0]: undefined
-CONSOLE MESSAGE: line 68: Testing if DataTransferItems can be accessed outside an event handler...
-CONSOLE MESSAGE: line 13: items[0] value: Hello World!
-CONSOLE MESSAGE: line 13: items[1] value: <b>Hello World!
-CONSOLE MESSAGE: line 99: PASSED
</del><ins>+CONSOLE MESSAGE: line 24: Populating DataTransferItems...
+CONSOLE MESSAGE: line 32: Caught exception "Error: INVALID_STATE_ERR: DOM Exception 11" as expected.
+CONSOLE MESSAGE: line 36: Verifying contents of DataTransferItems...
+CONSOLE MESSAGE: line 37: items.length: 2
+CONSOLE MESSAGE: line 38: items[0].kind: string
+CONSOLE MESSAGE: line 39: items[0].type: text/plain
+CONSOLE MESSAGE: line 40: items[1].kind: string
+CONSOLE MESSAGE: line 41: items[1].type: text/html
+CONSOLE MESSAGE: line 47: Checking if items past the end of the collection can be indexed:
+CONSOLE MESSAGE: line 48: items[2] is undefined: undefined
+CONSOLE MESSAGE: line 60: Checking that a read-only DataTransferItems cannot be mutated...
+CONSOLE MESSAGE: line 63: items.length: 2
+CONSOLE MESSAGE: line 64: items[0].kind: string
+CONSOLE MESSAGE: line 65: items[0].type: text/html
+CONSOLE MESSAGE: line 68: items[1].kind: string
+CONSOLE MESSAGE: line 69: items[1].type: text/plain
+CONSOLE MESSAGE: line 72: items[2] is undefined: undefined
+CONSOLE MESSAGE: line 89: Testing if DataTransferItems can be accessed outside an event handler...
+CONSOLE MESSAGE: line 98: DataTransferItem accessed outside event handler!
+CONSOLE MESSAGE: line 15: copy: items[0] value: Hello World!
+CONSOLE MESSAGE: line 15: copy: items[1] value: <b>Hello World!
+CONSOLE MESSAGE: line 15: paste: items[0] value: <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">This file tests the basic functionality and properties of DataTransferItems. This test requires DRT.</span>
+CONSOLE MESSAGE: line 15: paste: items[1] value: This file tests the basic functionality and properties of DataTransferItems. This test requires DRT.
</ins><span class="cx"> This file tests the basic functionality and properties of DataTransferItems. This test requires DRT.
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboarddatatransferitemshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/data-transfer-items.html (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/data-transfer-items.html    2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/LayoutTests/editing/pasteboard/data-transfer-items.html       2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -5,12 +5,17 @@
</span><span class="cx"> 
</span><span class="cx"> <script src="../editing.js"></script>
</span><span class="cx"> <script>
</span><ins>+var undefined;
+var pendingCallbacks = 0;
</ins><span class="cx"> var savedDataTransferItems = null;
</span><span class="cx"> var savedDataTransferItem = null;
</span><span class="cx"> 
</span><span class="cx"> function handleEvent(data)
</span><span class="cx"> {
</span><span class="cx">     console.log(data);
</span><ins>+    if (--pendingCallbacks == 0) {
+        window.layoutTestController.notifyDone();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function copy(ev)
</span><span class="lines">@@ -34,25 +39,37 @@
</span><span class="cx">     console.log('items[0].type: ' + items[0].type);
</span><span class="cx">     console.log('items[1].kind: ' + items[1].kind);
</span><span class="cx">     console.log('items[1].type: ' + items[1].type);
</span><del>-    items[0].getAsString(function (data) { handleEvent('items[0] value: ' + data); });
-    items[1].getAsString(function (data) { handleEvent('items[1] value: ' + data); });
</del><ins>+    items[0].getAsString(function (data) { handleEvent('copy: items[0] value: ' + data); });
+    pendingCallbacks++;
+    items[1].getAsString(function (data) { handleEvent('copy: items[1] value: ' + data); });
+    pendingCallbacks++;
</ins><span class="cx"> 
</span><span class="cx">     console.log('Checking if items past the end of the collection can be indexed:');
</span><del>-    console.log('items[2]: ' + items[2]);
-
-    savedDataTransferItems = items;
-    savedDataTransferItem = items[0];
</del><ins>+    console.log('items[2] is undefined: ' + typeof items[2]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function paste(ev)
</span><span class="cx"> {
</span><span class="cx">     var items = event.clipboardData.items;
</span><ins>+
+    // Cache references to make sure they aren't accessible outside the event handler.
+    savedDataTransferItems = items;
+    savedDataTransferItem = items[0];
+
</ins><span class="cx">     var originalLength = items.length;
</span><span class="cx">     console.log('Checking that a read-only DataTransferItems cannot be mutated...');
</span><span class="cx">     // Should be immutable.
</span><span class="cx">     items.add('Hello World!', 'text/plain');
</span><span class="cx">     console.log('items.length: ' + items.length);
</span><del>-    console.log('items[0]: ' + items[0]); // Shouldn't exist.
</del><ins>+    console.log('items[0].kind: ' + items[0].kind);
+    console.log('items[0].type: ' + items[0].type);
+    items[0].getAsString(function (data) { handleEvent('paste: items[0] value: ' + data); });
+    pendingCallbacks++;
+    console.log('items[1].kind: ' + items[1].kind);
+    console.log('items[1].type: ' + items[1].type);
+    items[1].getAsString(function (data) { handleEvent('paste: items[1] value: ' + data); });
+    pendingCallbacks++;
+    console.log('items[2] is undefined: ' + typeof items[2]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function runTest() {
</span><span class="lines">@@ -61,44 +78,28 @@
</span><span class="cx">     layoutTestController.waitUntilDone();
</span><span class="cx">     layoutTestController.dumpAsText();
</span><span class="cx"> 
</span><ins>+    eventSender.mouseMoveTo(0, 0);
+    for (var i = 0; i < 3; i++) {
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
</ins><span class="cx">     copyCommand();
</span><span class="cx">     pasteCommand();
</span><span class="cx"> 
</span><del>-    var failed = false;
</del><span class="cx">     console.log('Testing if DataTransferItems can be accessed outside an event handler...');
</span><span class="cx">     if (savedDataTransferItems.length != 0) {
</span><del>-        failed = true;
</del><span class="cx">         console.log('DataTransferItems.length non-zero outside event handler!');
</span><span class="cx">     }
</span><span class="cx">     savedDataTransferItems.add('Security?', 'text/foo');
</span><span class="cx">     if (savedDataTransferItems.length != 0) {
</span><del>-        failed = true;
</del><span class="cx">         console.log('DataTransferItems mutated outside event handler!');
</span><span class="cx">     }
</span><del>-    if (savedDataTransferItems[0]) {
-        failed = true;
</del><ins>+    if (typeof savedDataTransferItems[0] == 'undefined') {
</ins><span class="cx">         console.log('DataTransferItem accessed outside event handler!');
</span><span class="cx">     }
</span><del>-    if (savedDataTransferItem.kind != '') {
-        failed = true;
-        console.log('DataTransferItem.kind accessible outside event handler!');
</del><ins>+    if (typeof savedDataTransferItem == 'undefined') {
+        console.log('DataTransferItem accessed outside event handler!');
</ins><span class="cx">     }
</span><del>-    if (savedDataTransferItem.type != '') {
-        failed = true;
-        console.log('DataTransferItem.type accessible outside event handler!');
-    }
-    savedDataTransferItem.getAsString(function (data) {
-        failed = true;
-        console.log('getAsString called back outside event handler!');
-    });
-
-    window.setTimeout(function () {
-        if (failed)
-            console.log('FAILED');
-        else
-            console.log('PASSED');
-        window.layoutTestController.notifyDone();
-    }, 0);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> runTest();
</span></span></pre></div>
<a id="trunkLayoutTestsplatformchromiumtest_expectationstxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/chromium/test_expectations.txt        2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt   2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -112,8 +112,6 @@
</span><span class="cx"> BUGWK55913 DEBUG SLOW : jquery/offset.html = PASS
</span><span class="cx"> BUGWK55913 DEBUG SLOW : jquery/traversing.html = PASS
</span><span class="cx"> 
</span><del>-BUGCR76543 WIN MAC : editing/pasteboard/data-transfer-items.html = PASS TEXT
-
</del><span class="cx"> // -----------------------------------------------------------------
</span><span class="cx"> // SKIPPED TESTS
</span><span class="cx"> // -----------------------------------------------------------------
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/Source/WebCore/ChangeLog      2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2011-03-21  Daniel Cheng  <dcheng@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        [chromium] Implement glue between DataTransferItems and the pasteboard.
+        https://bugs.webkit.org/show_bug.cgi?id=56330
+
+        Support retrieving clipboard data in a paste through DataTransferItems.
+
+        Test: editing/pasteboard/data-transfer-items.html
+
+        * platform/chromium/ClipboardChromium.cpp:
+        (WebCore::ClipboardChromium::items):
+        * platform/chromium/DataTransferItemChromium.cpp:
+        (WebCore::DataTransferItemChromium::createFromPasteboard):
+        (WebCore::DataTransferItemChromium::create):
+        (WebCore::DataTransferItemChromium::DataTransferItemChromium):
+        (WebCore::DataTransferItemChromium::getAsString):
+        * platform/chromium/DataTransferItemChromium.h:
+        * platform/chromium/DataTransferItemsChromium.cpp:
+        (WebCore::DataTransferItemsChromium::addPasteboardItem):
+        * platform/chromium/DataTransferItemsChromium.h:
+
</ins><span class="cx"> 2011-03-21  Chris Fleizach  <cfleizach@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin Adler.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformchromiumClipboardChromiumcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp     2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp        2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -346,7 +346,18 @@
</span><span class="cx"> #if ENABLE(DATA_TRANSFER_ITEMS)
</span><span class="cx"> PassRefPtr<DataTransferItems> ClipboardChromium::items()
</span><span class="cx"> {
</span><del>-    return DataTransferItemsChromium::create(this, m_frame->document()->scriptExecutionContext());
</del><ins>+    RefPtr<DataTransferItemsChromium> items = DataTransferItemsChromium::create(this, m_frame->document()->scriptExecutionContext());
+
+    if (!m_dataObject)
+        return items;
+
+    if (isForCopyAndPaste() && policy() == ClipboardReadable) {
+        // Iterate through the types and add them.
+        HashSet<String> types = m_dataObject->types();
+        for (HashSet<String>::const_iterator it = types.begin(); it != types.end(); ++it)
+            items->addPasteboardItem(*it);
+    }
+    return items;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformchromiumDataTransferItemChromiumcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp      2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp 2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -34,24 +34,34 @@
</span><span class="cx"> #if ENABLE(DATA_TRANSFER_ITEMS)
</span><span class="cx"> 
</span><span class="cx"> #include "Clipboard.h"
</span><ins>+#include "ClipboardMimeTypes.h"
+#include "PlatformBridge.h"
</ins><span class="cx"> #include "StringCallback.h"
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromPasteboard(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context, const String& type)
+{
+    if (type == mimeTypeTextPlain || type == mimeTypeTextHTML)
+        return adoptRef(new DataTransferItemChromium(owner, context, PasteboardSource, DataTransferItem::kindString, type, ""));
+    return adoptRef(new DataTransferItemChromium(owner, context, PasteboardSource, DataTransferItem::kindFile, type, ""));
+}
+
</ins><span class="cx"> PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::create(PassRefPtr<Clipboard> owner,
</span><span class="cx">                                                                       ScriptExecutionContext* context,
</span><span class="cx">                                                                       const String& data,
</span><span class="cx">                                                                       const String& type)
</span><span class="cx"> {
</span><del>-    return adoptRef(new DataTransferItemChromium(owner, context, data, type));
</del><ins>+    return adoptRef(new DataTransferItemChromium(owner, context, InternalSource, DataTransferItem::kindString, type, data));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-DataTransferItemChromium::DataTransferItemChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context, const String& data, const String& type)
</del><ins>+DataTransferItemChromium::DataTransferItemChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context, DataSource source, const String& kind, const String& type, const String& data)
</ins><span class="cx">     : m_owner(owner)
</span><span class="cx">     , m_context(context)
</span><del>-    , m_kind(kindString)
</del><ins>+    , m_source(source)
+    , m_kind(kind)
</ins><span class="cx">     , m_type(type)
</span><del>-      , m_data(data)
</del><ins>+    , m_data(data)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -74,7 +84,23 @@
</span><span class="cx">     if ((m_owner->policy() != ClipboardReadable && m_owner->policy() != ClipboardWritable)
</span><span class="cx">         || m_kind != kindString)
</span><span class="cx">         return;
</span><del>-    callback->scheduleCallback(m_context, m_data);
</del><ins>+    if (m_source == InternalSource) {
+        callback->scheduleCallback(m_context, m_data);
+        return;
+    }
+    // This is ugly but there's no real alternative.
+    if (m_type == mimeTypeTextPlain) {
+        callback->scheduleCallback(m_context, PlatformBridge::clipboardReadPlainText(PasteboardPrivate::StandardBuffer));
+        return;
+    }
+    if (m_type == mimeTypeTextHTML) {
+        String html;
+        KURL ignoredSourceURL;
+        PlatformBridge::clipboardReadHTML(PasteboardPrivate::StandardBuffer, &html, &ignoredSourceURL);
+        callback->scheduleCallback(m_context, html);
+        return;
+    }
+    ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformchromiumDataTransferItemChromiumh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.h (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.h        2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/Source/WebCore/platform/chromium/DataTransferItemChromium.h   2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> 
</span><span class="cx"> class DataTransferItemChromium : public DataTransferItem {
</span><span class="cx"> public:
</span><ins>+    static PassRefPtr<DataTransferItemChromium> createFromPasteboard(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, const String& type);
</ins><span class="cx">     static PassRefPtr<DataTransferItemChromium> create(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, const String& data, const String& type);
</span><span class="cx"> 
</span><span class="cx">     virtual String kind() const;
</span><span class="lines">@@ -52,10 +53,16 @@
</span><span class="cx">     virtual void getAsString(PassRefPtr<StringCallback>);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    DataTransferItemChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, const String& data, const String& type);
</del><ins>+    enum DataSource {
+        PasteboardSource,
+        InternalSource,
+    };
</ins><span class="cx"> 
</span><ins>+    DataTransferItemChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, DataSource, const String& kind, const String& type, const String& data);
+
</ins><span class="cx">     const RefPtr<Clipboard> m_owner;
</span><span class="cx">     ScriptExecutionContext* m_context;
</span><ins>+    const DataSource m_source;
</ins><span class="cx">     const String m_kind;
</span><span class="cx">     const String m_type;
</span><span class="cx">     const String m_data;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformchromiumDataTransferItemsChromiumcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp     2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp        2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -101,6 +101,11 @@
</span><span class="cx">     m_items.append(DataTransferItemChromium::create(m_owner, m_context, data, type));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void DataTransferItemsChromium::addPasteboardItem(const String& type)
+{
+    m_items.append(DataTransferItemChromium::createFromPasteboard(m_owner, m_context, type));
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(DATA_TRANSFER_ITEMS)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformchromiumDataTransferItemsChromiumh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.h (81619 => 81620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.h       2011-03-21 23:34:31 UTC (rev 81619)
+++ trunk/Source/WebCore/platform/chromium/DataTransferItemsChromium.h  2011-03-22 00:03:12 UTC (rev 81620)
</span><span class="lines">@@ -57,8 +57,12 @@
</span><span class="cx">     virtual void add(const String& data, const String& type, ExceptionCode&);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class ClipboardChromium;
+
</ins><span class="cx">     DataTransferItemsChromium(PassRefPtr<Clipboard>, ScriptExecutionContext*);
</span><span class="cx"> 
</span><ins>+    virtual void addPasteboardItem(const String& type);
+
</ins><span class="cx">     RefPtr<Clipboard> m_owner;
</span><span class="cx">     // Indirectly owned by our parent.
</span><span class="cx">     ScriptExecutionContext* m_context;
</span></span></pre>
</div>
</div>

</body>
</html>