Title: [206965] trunk
Revision
206965
Author
cdu...@apple.com
Date
2016-10-08 21:17:26 -0700 (Sat, 08 Oct 2016)

Log Message

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:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206964 => 206965)


--- trunk/LayoutTests/ChangeLog	2016-10-09 03:46:39 UTC (rev 206964)
+++ trunk/LayoutTests/ChangeLog	2016-10-09 04:17:26 UTC (rev 206965)
@@ -1,5 +1,28 @@
 2016-10-08  Chris Dumez  <cdu...@apple.com>
 
+        [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  <cdu...@apple.com>
+
         Update CustomEvent to stop using legacy [ConstructorTemplate=Event]
         https://bugs.webkit.org/show_bug.cgi?id=163174
 

Added: trunk/LayoutTests/editing/pasteboard/copy-standalone-image-expected.html (0 => 206965)


--- 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)
@@ -0,0 +1,15 @@
+<html>
+<body>
+<p>This is an automatic test of copying an image document.</p>
+<p>To perform this test manually, click once in the image frame, choose Edit -> Copy
+then click in the red box and paste the image. If the image pastes successfully the
+test is passed.</p>
+
+<iframe name="imageframe" src=""
+
+<div id="dest" contenteditable="true"><img src="" style="-webkit-user-select:none;"></div>
+<script>
+frames['imageframe'].focus();
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/editing/pasteboard/copy-standalone-image.html (206964 => 206965)


--- 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)
@@ -1,9 +1,6 @@
-<html> 
+<html>
 <head>
 <script>
-if (window.testRunner)
-     testRunner.dumpEditingCallbacks();
-
 function editingTest() {
     frames['imageframe'].document.execCommand("Copy");
     
@@ -11,31 +8,18 @@
     var e = document.getElementById("dest");
     s.setPosition(e, 0);
     document.execCommand("Paste");
+    frames['imageframe'].focus();
 }
 </script>
-<style>
-.editable { 
-    border: 2px solid red; 
-    padding: 12px; 
-    font-size: 24px; 
-}
-
-iframe {
-    border: 2px solid blue; 
-}
-</style>
 </head>
 <body>
-
 <p>This is an automatic test of copying an image document.</p>
 <p>To perform this test manually, click once in the image frame, choose Edit -> Copy
 then click in the red box and paste the image. If the image pastes successfully the
 test is passed.</p>
 
-<iframe name="imageframe" src="" _onload_="editingTest()">
-</iframe>
+<iframe name="imageframe" src="" _onload_="editingTest()"></iframe>
 
-<div id="dest" class="editable" contenteditable="true"> </div>
-
+<div id="dest" contenteditable="true"></div>
 </body>
 </html>

Deleted: trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)


--- 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)
@@ -1,32 +0,0 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #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: "This is an automatic test of copying an image document."
-      RenderBlock {P} at (0,33) size 784x34
-        RenderText {#text} at (0,0) size 759x34
-          text run at (0,0) width 759: "To perform this test manually, click once in the image frame, choose Edit -> Copy then click in the red box and paste the"
-          text run at (0,17) width 355: "image. If the image pastes successfully the test is passed."
-      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

Deleted: trunk/LayoutTests/platform/ios-simulator/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)


--- 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)
@@ -1,32 +0,0 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #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: "This is an automatic test of copying an image document."
-      RenderBlock {P} at (0,36) size 784x40
-        RenderText {#text} at (0,0) size 773x39
-          text run at (0,0) width 773: "To perform this test manually, click once in the image frame, choose Edit -> Copy then click in the red box and paste the"
-          text run at (0,20) width 365: "image. If the image pastes successfully the test is passed."
-      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

Deleted: trunk/LayoutTests/platform/ios-simulator-wk2/editing/pasteboard/copy-standalone-image-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)


--- 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)
@@ -1,32 +0,0 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of P > DIV > BODY > HTML > #document to 1 of P > DIV > BODY > HTML > #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: "This is an automatic test of copying an image document."
-      RenderBlock {P} at (0,34) size 784x36
-        RenderText {#text} at (0,0) size 773x36
-          text run at (0,0) width 773: "To perform this test manually, click once in the image frame, choose Edit -> Copy then click in the red box and paste the"
-          text run at (0,18) width 365: "image. If the image pastes successfully the test is passed."
-      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

Deleted: trunk/LayoutTests/platform/win/editing/pasteboard/copy-standalone-image-expected.txt (206964 => 206965)


--- 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)
@@ -1,32 +0,0 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
-EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of P > DIV > BODY > HTML > #document to 1 of P > DIV > BODY > HTML > #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: "This is an automatic test of copying an image document."
-      RenderBlock {P} at (0,34) size 784x36
-        RenderText {#text} at (0,0) size 759x36
-          text run at (0,0) width 759: "To perform this test manually, click once in the image frame, choose Edit -> Copy then click in the red box and paste the"
-          text run at (0,18) width 355: "image. If the image pastes successfully the test is passed."
-      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

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (206964 => 206965)


--- 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)
@@ -511,9 +511,6 @@
 # These storage tests fail in WebKit2 on the bot, but not running locally
 storage/websql/multiple-databases-garbage-collection.html
 
-# Crashes the WebProcess
-editing/pasteboard/copy-standalone-image.html
-
 # Mysterious failure after enabling paste tests
 editing/mac/pasteboard/text-precomposed.html
 

Modified: trunk/Source/WebCore/ChangeLog (206964 => 206965)


--- 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)
@@ -1,5 +1,36 @@
 2016-10-08  Chris Dumez  <cdu...@apple.com>
 
+        [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  <cdu...@apple.com>
+
         Update CustomEvent to stop using legacy [ConstructorTemplate=Event]
         https://bugs.webkit.org/show_bug.cgi?id=163174
 

Modified: trunk/Source/WebCore/editing/Editor.h (206964 => 206965)


--- 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)
@@ -508,6 +508,7 @@
 
 #if PLATFORM(COCOA)
     RefPtr<SharedBuffer> selectionInWebArchiveFormat();
+    RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&);
     RefPtr<Range> adjustedSelectionRange();
     RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&);
     RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);

Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (206964 => 206965)


--- 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)
@@ -310,6 +310,14 @@
     return SharedBuffer::wrapCFData(archive->rawDataRepresentation().get());
 }
 
+RefPtr<SharedBuffer> Editor::imageInWebArchiveFormat(Element& imageElement)
+{
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(imageElement);
+    if (!archive)
+        return nullptr;
+    return SharedBuffer::wrapCFData(archive->rawDataRepresentation().get());
+}
+
 RefPtr<Range> Editor::adjustedSelectionRange()
 {
     // FIXME: Why do we need to adjust the selection to include the anchor tag it's in?
@@ -436,6 +444,7 @@
         return;
     ASSERT(cachedImage);
 
+    pasteboardImage.dataInWebArchiveFormat = imageInWebArchiveFormat(imageElement);
     pasteboardImage.url.url = ""
     pasteboardImage.url.title = title;
     pasteboardImage.url.userVisibleForm = client()->userVisibleString(pasteboardImage.url.url);

Modified: trunk/Source/WebCore/platform/Pasteboard.h (206964 => 206965)


--- 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)
@@ -96,6 +96,9 @@
     WEBCORE_EXPORT PasteboardImage();
     WEBCORE_EXPORT ~PasteboardImage();
     RefPtr<Image> image;
+#if PLATFORM(MAC)
+    RefPtr<SharedBuffer> dataInWebArchiveFormat;
+#endif
 #if !(PLATFORM(EFL) || PLATFORM(WIN))
     PasteboardURL url;
 #endif

Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (206964 => 206965)


--- 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)
@@ -98,10 +98,9 @@
     return types;
 }
 
-static inline Vector<String> createWritableTypesForImage()
+static Vector<String> writableTypesForImage()
 {
     Vector<String> types;
-    
     types.append(String(NSTIFFPboardType));
     types.appendVector(writableTypesForURL());
     types.append(String(NSRTFDPboardType));
@@ -108,13 +107,6 @@
     return types;
 }
 
-static Vector<String> writableTypesForImage()
-{
-    Vector<String> types;
-    types.appendVector(createWritableTypesForImage());
-    return types;
-}
-
 Pasteboard::Pasteboard(const String& pasteboardName)
     : m_pasteboardName(pasteboardName)
     , m_changeCount(platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
@@ -262,8 +254,14 @@
     // FIXME: Why can we assert this? It doesn't seem like it's guaranteed.
     ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(pasteboardImage.resourceMIMEType));
 
-    m_changeCount = writeURLForTypes(writableTypesForImage(), m_pasteboardName, pasteboardImage.url);
+    auto types = writableTypesForImage();
+    if (pasteboardImage.dataInWebArchiveFormat)
+        types.append(WebArchivePboardType);
+
+    m_changeCount = writeURLForTypes(types, m_pasteboardName, pasteboardImage.url);
     m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapCFData(imageData).ptr(), NSTIFFPboardType, m_pasteboardName);
+    if (pasteboardImage.dataInWebArchiveFormat)
+        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(pasteboardImage.dataInWebArchiveFormat.get(), WebArchivePboardType, m_pasteboardName);
     writeFileWrapperAsRTFDAttachment(fileWrapper(pasteboardImage), m_pasteboardName, m_changeCount);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to