<!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>[206965] 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/206965">206965</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-10-08 21:17:26 -0700 (Sat, 08 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore:
[Mac] Write WebArchive to the pasteboard when copying image in WebKit
https://bugs.webkit.org/show_bug.cgi?id=163100

Reviewed by Darin Adler.

Write WebArchive to the pasteboard when copying image in WebKit. This
fixes pasting such images to a content editable field in WebKit because
Web archives take priority over RTFD when reading from the pasteboard
in WebKit.

Using RTFD when pasting the image in WebKit was causing issues because:
1. The pasted image would not be displayed because our RTFD import code
   is buggy.
2. The pasted image URL was a webkit-fake-url://
3. Formatting associated to the image (e.g. inline style) would be lost

No new tests, unskipped existing test on WebKit2.

* editing/Editor.h:
* editing/mac/EditorMac.mm:
(WebCore::Editor::imageInWebArchiveFormat):
(WebCore::Editor::writeImageToPasteboard):
* platform/Pasteboard.h:
* platform/mac/PasteboardMac.mm:
(WebCore::writableTypesForImage):
(WebCore::Pasteboard::write):
(WebCore::Pasteboard::Pasteboard): Deleted.
(WebCore::Pasteboard::createForCopyAndPaste): Deleted.

LayoutTests:
[Mac] Write HTML to the pasteboard when copying image in WebKit
https://bugs.webkit.org/show_bug.cgi?id=163100

Reviewed by Darin Adler.

Convert editing/pasteboard/copy-standalone-image.html into a ref test
and unskip on WebKit2 now that it passes there as well. Before this
patch, the test would fail on WebKit2 (the pasted image would not be
displayed).

* editing/pasteboard/copy-standalone-image-expected.html: Added.
* editing/pasteboard/copy-standalone-image.html:
* platform/gtk/editing/pasteboard/copy-standalone-image-expected.png: Removed.
* platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
* platform/ios-simulator-wk2/editing/pasteboard/copy-standalone-image-expected.png: Removed.
* platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
* platform/mac/editing/pasteboard/copy-standalone-image-expected.png: Removed.
* platform/mac/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
* platform/win/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
* platform/wk2/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardcopystandaloneimagehtml">trunk/LayoutTests/editing/pasteboard/copy-standalone-image.html</a></li>
<li><a href="#trunkLayoutTestsplatformwk2TestExpectations">trunk/LayoutTests/platform/wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorh">trunk/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#trunkSourceWebCoreeditingmacEditorMacmm">trunk/Source/WebCore/editing/mac/EditorMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformPasteboardh">trunk/Source/WebCore/platform/Pasteboard.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacPasteboardMacmm">trunk/Source/WebCore/platform/mac/PasteboardMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestseditingpasteboardcopystandaloneimageexpectedhtml">trunk/LayoutTests/editing/pasteboard/copy-standalone-image-expected.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformgtkeditingpasteboardcopystandaloneimageexpectedpng">trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformgtkeditingpasteboardcopystandaloneimageexpectedtxt">trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatoreditingpasteboardcopystandaloneimageexpectedtxt">trunk/LayoutTests/platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2editingpasteboardcopystandaloneimageexpectedpng">trunk/LayoutTests/platform/ios-simulator-wk2/editing/pasteboard/copy-standalone-image-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingpasteboardcopystandaloneimageexpectedpng">trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingpasteboardcopystandaloneimageexpectedtxt">trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformwineditingpasteboardcopystandaloneimageexpectedtxt">trunk/LayoutTests/platform/win/editing/pasteboard/copy-standalone-image-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/ChangeLog        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2016-10-08  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [Mac] Write HTML to the pasteboard when copying image in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=163100
+
+        Reviewed by Darin Adler.
+
+        Convert editing/pasteboard/copy-standalone-image.html into a ref test
+        and unskip on WebKit2 now that it passes there as well. Before this
+        patch, the test would fail on WebKit2 (the pasted image would not be
+        displayed).
+
+        * editing/pasteboard/copy-standalone-image-expected.html: Added.
+        * editing/pasteboard/copy-standalone-image.html:
+        * platform/gtk/editing/pasteboard/copy-standalone-image-expected.png: Removed.
+        * platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
+        * platform/ios-simulator-wk2/editing/pasteboard/copy-standalone-image-expected.png: Removed.
+        * platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
+        * platform/mac/editing/pasteboard/copy-standalone-image-expected.png: Removed.
+        * platform/mac/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
+        * platform/win/editing/pasteboard/copy-standalone-image-expected.txt: Removed.
+        * platform/wk2/TestExpectations:
+
+2016-10-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Update CustomEvent to stop using legacy [ConstructorTemplate=Event]
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=163174
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardcopystandaloneimageexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/pasteboard/copy-standalone-image-expected.html (0 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/copy-standalone-image-expected.html                                (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-standalone-image-expected.html        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;This is an automatic test of copying an image document.&lt;/p&gt;
+&lt;p&gt;To perform this test manually, click once in the image frame, choose Edit -&gt; Copy
+then click in the red box and paste the image. If the image pastes successfully the
+test is passed.&lt;/p&gt;
+
+&lt;iframe name=&quot;imageframe&quot; src=&quot;../resources/abe.png&quot;&gt;&lt;/iframe&gt;
+
+&lt;div id=&quot;dest&quot; contenteditable=&quot;true&quot;&gt;&lt;img src=&quot;../resources/abe.png&quot; style=&quot;-webkit-user-select:none;&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+frames['imageframe'].focus();
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardcopystandaloneimagehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/copy-standalone-image.html (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/copy-standalone-image.html        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/editing/pasteboard/copy-standalone-image.html        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,9 +1,6 @@
</span><del>-&lt;html&gt; 
</del><ins>+&lt;html&gt;
</ins><span class="cx"> &lt;head&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-if (window.testRunner)
-     testRunner.dumpEditingCallbacks();
-
</del><span class="cx"> function editingTest() {
</span><span class="cx">     frames['imageframe'].document.execCommand(&quot;Copy&quot;);
</span><span class="cx">     
</span><span class="lines">@@ -11,31 +8,18 @@
</span><span class="cx">     var e = document.getElementById(&quot;dest&quot;);
</span><span class="cx">     s.setPosition(e, 0);
</span><span class="cx">     document.execCommand(&quot;Paste&quot;);
</span><ins>+    frames['imageframe'].focus();
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;style&gt;
-.editable { 
-    border: 2px solid red; 
-    padding: 12px; 
-    font-size: 24px; 
-}
-
-iframe {
-    border: 2px solid blue; 
-}
-&lt;/style&gt;
</del><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><del>-
</del><span class="cx"> &lt;p&gt;This is an automatic test of copying an image document.&lt;/p&gt;
</span><span class="cx"> &lt;p&gt;To perform this test manually, click once in the image frame, choose Edit -&gt; Copy
</span><span class="cx"> then click in the red box and paste the image. If the image pastes successfully the
</span><span class="cx"> test is passed.&lt;/p&gt;
</span><span class="cx"> 
</span><del>-&lt;iframe name=&quot;imageframe&quot; src=&quot;../resources/abe.png&quot; onload=&quot;editingTest()&quot;&gt;
-&lt;/iframe&gt;
</del><ins>+&lt;iframe name=&quot;imageframe&quot; src=&quot;../resources/abe.png&quot; onload=&quot;editingTest()&quot;&gt;&lt;/iframe&gt;
</ins><span class="cx"> 
</span><del>-&lt;div id=&quot;dest&quot; class=&quot;editable&quot; contenteditable=&quot;true&quot;&gt; &lt;/div&gt;
-
</del><ins>+&lt;div id=&quot;dest&quot; contenteditable=&quot;true&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkeditingpasteboardcopystandaloneimageexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkeditingpasteboardcopystandaloneimageexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 1 of DIV &gt; BODY &gt; HTML &gt; #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 1 of DIV &gt; BODY &gt; HTML &gt; #document to 1 of DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x17
-        RenderText {#text} at (0,0) size 354x17
-          text run at (0,0) width 354: &quot;This is an automatic test of copying an image document.&quot;
-      RenderBlock {P} at (0,33) size 784x34
-        RenderText {#text} at (0,0) size 759x34
-          text run at (0,0) width 759: &quot;To perform this test manually, click once in the image frame, choose Edit -&gt; Copy then click in the red box and paste the&quot;
-          text run at (0,17) width 355: &quot;image. If the image pastes successfully the test is passed.&quot;
-      RenderBlock (anonymous) at (0,83) size 784x154
-        RenderIFrame {IFRAME} at (0,0) size 304x154 [border: (2px solid #0000FF)]
-          layer at (0,0) size 300x150
-            RenderView at (0,0) size 300x150
-          layer at (0,0) size 300x150
-            RenderBlock {HTML} at (0,0) size 300x150
-              RenderBody {BODY} at (0,0) size 300x150
-                RenderImage {IMG} at (0,0) size 76x103
-        RenderText {#text} at (0,0) size 0x0
-      RenderBlock {DIV} at (0,237) size 784x131 [border: (2px solid #FF0000)]
-        RenderImage {IMG} at (14,14) size 76x103
-        RenderText {#text} at (0,0) size 0x0
-caret: position 1 of child 0 {IMG} of child 7 {DIV} of body
</del></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatoreditingpasteboardcopystandaloneimageexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 1 of DIV &gt; BODY &gt; HTML &gt; #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 1 of DIV &gt; BODY &gt; HTML &gt; #document to 1 of DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x20
-        RenderText {#text} at (0,0) size 362x19
-          text run at (0,0) width 362: &quot;This is an automatic test of copying an image document.&quot;
-      RenderBlock {P} at (0,36) size 784x40
-        RenderText {#text} at (0,0) size 773x39
-          text run at (0,0) width 773: &quot;To perform this test manually, click once in the image frame, choose Edit -&gt; Copy then click in the red box and paste the&quot;
-          text run at (0,20) width 365: &quot;image. If the image pastes successfully the test is passed.&quot;
-      RenderBlock (anonymous) at (0,92) size 784x154
-        RenderPartObject {IFRAME} at (0,0) size 304x154 [border: (2px solid #0000FF)]
-          layer at (0,0) size 300x150
-            RenderView at (0,0) size 300x150
-          layer at (0,0) size 300x150
-            RenderBlock {HTML} at (0,0) size 300x150
-              RenderBody {BODY} at (0,0) size 300x150
-                RenderImage {IMG} at (0,0) size 76x103
-        RenderText {#text} at (0,0) size 0x0
-      RenderBlock {DIV} at (0,246) size 784x131 [border: (2px solid #FF0000)]
-        RenderImage {IMG} at (14,14) size 76x103
-        RenderText {#text} at (0,0) size 0x0
-caret: position 1 of child 0 {IMG} of child 7 {DIV} of body
</del></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2editingpasteboardcopystandaloneimageexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/ios-simulator-wk2/editing/pasteboard/copy-standalone-image-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingpasteboardcopystandaloneimageexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingpasteboardcopystandaloneimageexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 1 of DIV &gt; BODY &gt; HTML &gt; #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 1 of P &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of P &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 362x18
-          text run at (0,0) width 362: &quot;This is an automatic test of copying an image document.&quot;
-      RenderBlock {P} at (0,34) size 784x36
-        RenderText {#text} at (0,0) size 773x36
-          text run at (0,0) width 773: &quot;To perform this test manually, click once in the image frame, choose Edit -&gt; Copy then click in the red box and paste the&quot;
-          text run at (0,18) width 365: &quot;image. If the image pastes successfully the test is passed.&quot;
-      RenderBlock (anonymous) at (0,86) size 784x154
-        RenderIFrame {IFRAME} at (0,0) size 304x154 [border: (2px solid #0000FF)]
-          layer at (0,0) size 300x150
-            RenderView at (0,0) size 300x150
-          layer at (0,0) size 300x150
-            RenderBlock {HTML} at (0,0) size 300x150
-              RenderBody {BODY} at (0,0) size 300x150
-                RenderImage {IMG} at (0,0) size 76x103
-        RenderText {#text} at (0,0) size 0x0
-      RenderBlock {DIV} at (0,240) size 784x131 [border: (2px solid #FF0000)]
-        RenderBlock {P} at (14,14) size 756x103
-          RenderImage {IMG} at (0,0) size 76x103
-caret: position 1 of child 0 {IMG} of child 0 {P} of child 7 {DIV} of body
</del></span></pre></div>
<a id="trunkLayoutTestsplatformwineditingpasteboardcopystandaloneimageexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/win/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/platform/win/editing/pasteboard/copy-standalone-image-expected.txt        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 1 of DIV &gt; BODY &gt; HTML &gt; #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 1 of P &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of P &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 354x18
-          text run at (0,0) width 354: &quot;This is an automatic test of copying an image document.&quot;
-      RenderBlock {P} at (0,34) size 784x36
-        RenderText {#text} at (0,0) size 759x36
-          text run at (0,0) width 759: &quot;To perform this test manually, click once in the image frame, choose Edit -&gt; Copy then click in the red box and paste the&quot;
-          text run at (0,18) width 355: &quot;image. If the image pastes successfully the test is passed.&quot;
-      RenderBlock (anonymous) at (0,86) size 784x154
-        RenderIFrame {IFRAME} at (0,0) size 304x154 [border: (2px solid #0000FF)]
-          layer at (0,0) size 300x150
-            RenderView at (0,0) size 300x150
-          layer at (0,0) size 300x150
-            RenderBlock {HTML} at (0,0) size 300x150
-              RenderBody {BODY} at (0,0) size 300x150
-                RenderImage {IMG} at (0,0) size 76x103
-        RenderText {#text} at (0,0) size 0x0
-      RenderBlock {DIV} at (0,240) size 784x131 [border: (2px solid #FF0000)]
-        RenderBlock {P} at (14,14) size 756x103
-          RenderImage {IMG} at (0,0) size 76x103
-caret: position 1 of child 0 {IMG} of child 0 {P} of child 7 {DIV} of body
</del></span></pre></div>
<a id="trunkLayoutTestsplatformwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wk2/TestExpectations (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/wk2/TestExpectations        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/platform/wk2/TestExpectations        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -511,9 +511,6 @@
</span><span class="cx"> # These storage tests fail in WebKit2 on the bot, but not running locally
</span><span class="cx"> storage/websql/multiple-databases-garbage-collection.html
</span><span class="cx"> 
</span><del>-# Crashes the WebProcess
-editing/pasteboard/copy-standalone-image.html
-
</del><span class="cx"> # Mysterious failure after enabling paste tests
</span><span class="cx"> editing/mac/pasteboard/text-precomposed.html
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/Source/WebCore/ChangeLog        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2016-10-08  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [Mac] Write WebArchive to the pasteboard when copying image in WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=163100
+
+        Reviewed by Darin Adler.
+
+        Write WebArchive to the pasteboard when copying image in WebKit. This
+        fixes pasting such images to a content editable field in WebKit because
+        Web archives take priority over RTFD when reading from the pasteboard
+        in WebKit.
+
+        Using RTFD when pasting the image in WebKit was causing issues because:
+        1. The pasted image would not be displayed because our RTFD import code
+           is buggy.
+        2. The pasted image URL was a webkit-fake-url://
+        3. Formatting associated to the image (e.g. inline style) would be lost
+
+        No new tests, unskipped existing test on WebKit2.
+
+        * editing/Editor.h:
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::imageInWebArchiveFormat):
+        (WebCore::Editor::writeImageToPasteboard):
+        * platform/Pasteboard.h:
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::writableTypesForImage):
+        (WebCore::Pasteboard::write):
+        (WebCore::Pasteboard::Pasteboard): Deleted.
+        (WebCore::Pasteboard::createForCopyAndPaste): Deleted.
+
+2016-10-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Update CustomEvent to stop using legacy [ConstructorTemplate=Event]
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=163174
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.h (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.h        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/Source/WebCore/editing/Editor.h        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -508,6 +508,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; selectionInWebArchiveFormat();
</span><ins>+    RefPtr&lt;SharedBuffer&gt; imageInWebArchiveFormat(Element&amp;);
</ins><span class="cx">     RefPtr&lt;Range&gt; adjustedSelectionRange();
</span><span class="cx">     RefPtr&lt;DocumentFragment&gt; createFragmentForImageResourceAndAddResource(RefPtr&lt;ArchiveResource&gt;&amp;&amp;);
</span><span class="cx">     RefPtr&lt;DocumentFragment&gt; createFragmentAndAddResources(NSAttributedString *);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacEditorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/EditorMac.mm        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -310,6 +310,14 @@
</span><span class="cx">     return SharedBuffer::wrapCFData(archive-&gt;rawDataRepresentation().get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;SharedBuffer&gt; Editor::imageInWebArchiveFormat(Element&amp; imageElement)
+{
+    RefPtr&lt;LegacyWebArchive&gt; archive = LegacyWebArchive::create(imageElement);
+    if (!archive)
+        return nullptr;
+    return SharedBuffer::wrapCFData(archive-&gt;rawDataRepresentation().get());
+}
+
</ins><span class="cx"> RefPtr&lt;Range&gt; Editor::adjustedSelectionRange()
</span><span class="cx"> {
</span><span class="cx">     // FIXME: Why do we need to adjust the selection to include the anchor tag it's in?
</span><span class="lines">@@ -436,6 +444,7 @@
</span><span class="cx">         return;
</span><span class="cx">     ASSERT(cachedImage);
</span><span class="cx"> 
</span><ins>+    pasteboardImage.dataInWebArchiveFormat = imageInWebArchiveFormat(imageElement);
</ins><span class="cx">     pasteboardImage.url.url = url;
</span><span class="cx">     pasteboardImage.url.title = title;
</span><span class="cx">     pasteboardImage.url.userVisibleForm = client()-&gt;userVisibleString(pasteboardImage.url.url);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPasteboardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Pasteboard.h (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Pasteboard.h        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/Source/WebCore/platform/Pasteboard.h        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -96,6 +96,9 @@
</span><span class="cx">     WEBCORE_EXPORT PasteboardImage();
</span><span class="cx">     WEBCORE_EXPORT ~PasteboardImage();
</span><span class="cx">     RefPtr&lt;Image&gt; image;
</span><ins>+#if PLATFORM(MAC)
+    RefPtr&lt;SharedBuffer&gt; dataInWebArchiveFormat;
+#endif
</ins><span class="cx"> #if !(PLATFORM(EFL) || PLATFORM(WIN))
</span><span class="cx">     PasteboardURL url;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacPasteboardMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (206964 => 206965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm        2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm        2016-10-09 04:17:26 UTC (rev 206965)
</span><span class="lines">@@ -98,10 +98,9 @@
</span><span class="cx">     return types;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline Vector&lt;String&gt; createWritableTypesForImage()
</del><ins>+static Vector&lt;String&gt; writableTypesForImage()
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;String&gt; types;
</span><del>-    
</del><span class="cx">     types.append(String(NSTIFFPboardType));
</span><span class="cx">     types.appendVector(writableTypesForURL());
</span><span class="cx">     types.append(String(NSRTFDPboardType));
</span><span class="lines">@@ -108,13 +107,6 @@
</span><span class="cx">     return types;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Vector&lt;String&gt; writableTypesForImage()
-{
-    Vector&lt;String&gt; types;
-    types.appendVector(createWritableTypesForImage());
-    return types;
-}
-
</del><span class="cx"> Pasteboard::Pasteboard(const String&amp; pasteboardName)
</span><span class="cx">     : m_pasteboardName(pasteboardName)
</span><span class="cx">     , m_changeCount(platformStrategies()-&gt;pasteboardStrategy()-&gt;changeCount(m_pasteboardName))
</span><span class="lines">@@ -262,8 +254,14 @@
</span><span class="cx">     // FIXME: Why can we assert this? It doesn't seem like it's guaranteed.
</span><span class="cx">     ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(pasteboardImage.resourceMIMEType));
</span><span class="cx"> 
</span><del>-    m_changeCount = writeURLForTypes(writableTypesForImage(), m_pasteboardName, pasteboardImage.url);
</del><ins>+    auto types = writableTypesForImage();
+    if (pasteboardImage.dataInWebArchiveFormat)
+        types.append(WebArchivePboardType);
+
+    m_changeCount = writeURLForTypes(types, m_pasteboardName, pasteboardImage.url);
</ins><span class="cx">     m_changeCount = platformStrategies()-&gt;pasteboardStrategy()-&gt;setBufferForType(SharedBuffer::wrapCFData(imageData).ptr(), NSTIFFPboardType, m_pasteboardName);
</span><ins>+    if (pasteboardImage.dataInWebArchiveFormat)
+        m_changeCount = platformStrategies()-&gt;pasteboardStrategy()-&gt;setBufferForType(pasteboardImage.dataInWebArchiveFormat.get(), WebArchivePboardType, m_pasteboardName);
</ins><span class="cx">     writeFileWrapperAsRTFDAttachment(fileWrapper(pasteboardImage), m_pasteboardName, m_changeCount);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>