<!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>[212663] 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/212663">212663</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2017-02-20 11:32:56 -0800 (Mon, 20 Feb 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add a new drag code path and use it for dragging plain text
https://bugs.webkit.org/show_bug.cgi?id=168534
Reviewed by Geoffrey Garen.
Source/WebCore:
The new code path is currently only used for plain text selection dragging.
* WebCore.xcodeproj/project.pbxproj:
* page/DragClient.h:
(WebCore::DragClient::useLegacyDragClient):
Add a new member function. This currently returns true everywhere except legacy WebKit on Mac.
(WebCore::DragClient::beginDrag):
Add new empty member function.
* page/DragController.cpp:
(WebCore::dragImageAnchorPointForSelectionDrag):
Helper function that returns the anchor point for a selection drag image.
(WebCore::DragController::startDrag):
If we can use the new code path, set up a drag item with an image and pasteboard data.
(WebCore::DragController::beginDrag):
New function that calls out to the client.
* page/DragController.h:
Add new members.
* platform/DragItem.h:
Add a new class - it's essentially a tuple of a drag image, an anchor point and the pasteboard data the item represents.
* platform/mac/PasteboardWriter.h:
Rename createPasteboardWriting to createPasteboardWriter.
* platform/mac/PasteboardWriter.mm:
(WebCore::createPasteboardWriter):
Use the UTI pasteboard type.
Source/WebKit/mac:
* WebCoreSupport/WebDragClient.h:
Add new members.
* WebCoreSupport/WebDragClient.mm:
(WebDragClient::useLegacyDragClient):
Return false here.
(WebDragClient::beginDrag):
New client member function. Create an NSDraggingItem and use it to begin a dragging session.
* WebView/WebHTMLView.mm:
(-[WebHTMLView draggingSession:sourceOperationMaskForDraggingContext:]):
Get the source operation mask from WebCore.
(-[WebHTMLView draggingSession:endedAtPoint:operation:]):
Send a fake mouse up event.
* WebView/WebHTMLViewInternal.h:
Declare that WebHTMLView conforms to NSDraggingSource.
Tools:
Update the testing infrastructure to handle NSDraggingSession.
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/mac/DumpRenderTreePasteboard.mm: Renamed from Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m.
(-[LocalPasteboard writeObjects:]):
Implement this in terms of the legacy pasteboard API.
* DumpRenderTree/mac/EventSendingController.mm:
(drt_WebHTMLView_beginDraggingSessionWithItemsEventSource):
(+[EventSendingController initialize]):
Swizzle the drag method instead of adding a delegate method (like the old code does).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorepageDragClienth">trunk/Source/WebCore/page/DragClient.h</a></li>
<li><a href="#trunkSourceWebCorepageDragControllercpp">trunk/Source/WebCore/page/DragController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDragControllerh">trunk/Source/WebCore/page/DragController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacPasteboardWriterh">trunk/Source/WebCore/platform/mac/PasteboardWriter.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacPasteboardWritermm">trunk/Source/WebCore/platform/mac/PasteboardWriter.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebDragClienth">trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebDragClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewInternalh">trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeDumpRenderTreexcodeprojprojectpbxproj">trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsDumpRenderTreemacEventSendingControllermm">trunk/Tools/DumpRenderTree/mac/EventSendingController.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformDragItemh">trunk/Source/WebCore/platform/DragItem.h</a></li>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreePasteboardmm">trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreePasteboardm">trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/ChangeLog        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2017-02-17 Anders Carlsson <andersca@apple.com>
+
+ Add a new drag code path and use it for dragging plain text
+ https://bugs.webkit.org/show_bug.cgi?id=168534
+
+ Reviewed by Geoffrey Garen.
+
+ The new code path is currently only used for plain text selection dragging.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/DragClient.h:
+ (WebCore::DragClient::useLegacyDragClient):
+ Add a new member function. This currently returns true everywhere except legacy WebKit on Mac.
+
+ (WebCore::DragClient::beginDrag):
+ Add new empty member function.
+
+ * page/DragController.cpp:
+ (WebCore::dragImageAnchorPointForSelectionDrag):
+ Helper function that returns the anchor point for a selection drag image.
+
+ (WebCore::DragController::startDrag):
+ If we can use the new code path, set up a drag item with an image and pasteboard data.
+
+ (WebCore::DragController::beginDrag):
+ New function that calls out to the client.
+
+ * page/DragController.h:
+ Add new members.
+
+ * platform/DragItem.h:
+ Add a new class - it's essentially a tuple of a drag image, an anchor point and the pasteboard data the item represents.
+
+ * platform/mac/PasteboardWriter.h:
+ Rename createPasteboardWriting to createPasteboardWriter.
+
+ * platform/mac/PasteboardWriter.mm:
+ (WebCore::createPasteboardWriter):
+ Use the UTI pasteboard type.
+
</ins><span class="cx"> 2017-02-20 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Fix libwebrtc build after r212644.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -952,6 +952,7 @@
</span><span class="cx">                 1AF4CEEC18BC3C1B00BC2D34 /* VisitedLinkStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF4CEEB18BC3C1B00BC2D34 /* VisitedLinkStore.cpp */; };
</span><span class="cx">                 1AF5E4D41E56735B004A1F01 /* PasteboardWriterData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF5E4D21E56735A004A1F01 /* PasteboardWriterData.cpp */; };
</span><span class="cx">                 1AF5E4D51E56735B004A1F01 /* PasteboardWriterData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF5E4D31E56735A004A1F01 /* PasteboardWriterData.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                1AF5E4D91E5677A9004A1F01 /* DragItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF5E4D71E5677A9004A1F01 /* DragItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 1AF5E4E21E5779B1004A1F01 /* PasteboardWriter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF5E4E01E5779B1004A1F01 /* PasteboardWriter.mm */; };
</span><span class="cx">                 1AF5E4E31E5779B1004A1F01 /* PasteboardWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF5E4E11E5779B1004A1F01 /* PasteboardWriter.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AF62EE614DA22A70041556C /* ScrollingCoordinatorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF62EE314DA22A70041556C /* ScrollingCoordinatorMac.mm */; };
</span><span class="lines">@@ -8135,6 +8136,7 @@
</span><span class="cx">                 1AF4CEEB18BC3C1B00BC2D34 /* VisitedLinkStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkStore.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1AF5E4D21E56735A004A1F01 /* PasteboardWriterData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PasteboardWriterData.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1AF5E4D31E56735A004A1F01 /* PasteboardWriterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardWriterData.h; sourceTree = "<group>"; };
</span><ins>+                1AF5E4D71E5677A9004A1F01 /* DragItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragItem.h; sourceTree = "<group>"; };
</ins><span class="cx">                 1AF5E4E01E5779B1004A1F01 /* PasteboardWriter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteboardWriter.mm; sourceTree = "<group>"; };
</span><span class="cx">                 1AF5E4E11E5779B1004A1F01 /* PasteboardWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardWriter.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AF62EE314DA22A70041556C /* ScrollingCoordinatorMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingCoordinatorMac.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -22924,6 +22926,7 @@
</span><span class="cx">                                 A7B6E69D0B291A9600D0529F /* DragData.h */,
</span><span class="cx">                                 A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */,
</span><span class="cx">                                 A7CFB3D00B7ED10A0070C32D /* DragImage.h */,
</span><ins>+                                1AF5E4D71E5677A9004A1F01 /* DragItem.h */,
</ins><span class="cx">                                 1CA19E150DC255CA0065A994 /* EventLoop.h */,
</span><span class="cx">                                 262EC41C1D110B1F00BA78FC /* EventTrackingRegions.cpp */,
</span><span class="cx">                                 262EC4191D078F3D00BA78FC /* EventTrackingRegions.h */,
</span><span class="lines">@@ -28735,6 +28738,7 @@
</span><span class="cx">                                 0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */,
</span><span class="cx">                                 6F995A261A7078B100A735F4 /* WebGLVertexArrayObject.h in Headers */,
</span><span class="cx">                                 77A17A7812F28642004E02F6 /* WebGLVertexArrayObjectOES.h in Headers */,
</span><ins>+                                1AF5E4D91E5677A9004A1F01 /* DragItem.h in Headers */,
</ins><span class="cx">                                 A5E2123C1E4924A400CE1044 /* WebHeapAgent.h in Headers */,
</span><span class="cx">                                 A5840E25187B8AC200843B10 /* WebInjectedScriptHost.h in Headers */,
</span><span class="cx">                                 A584FE301864CB8400843B10 /* WebInjectedScriptManager.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCorepageDragClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DragClient.h (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DragClient.h        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/page/DragClient.h        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx">
</span><span class="cx"> #include "DragActions.h"
</span><del>-#include "DragImage.h"
</del><ins>+#include "DragItem.h"
</ins><span class="cx"> #include "FloatPoint.h"
</span><span class="cx"> #include "IntPoint.h"
</span><span class="cx">
</span><span class="lines">@@ -42,6 +42,8 @@
</span><span class="cx"> public:
</span><span class="cx"> virtual void dragControllerDestroyed() = 0;
</span><span class="cx">
</span><ins>+ virtual bool useLegacyDragClient() { return true; }
+
</ins><span class="cx"> virtual void willPerformDragDestinationAction(DragDestinationAction, const DragData&) = 0;
</span><span class="cx"> virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, DataTransfer&) = 0;
</span><span class="cx"> virtual DragDestinationAction actionMaskForDrag(const DragData&) = 0;
</span><span class="lines">@@ -50,6 +52,8 @@
</span><span class="cx"> virtual void startDrag(DragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, const FloatPoint& dragImageAnchor, DataTransfer&, Frame&, DragSourceAction) = 0;
</span><span class="cx"> virtual void dragEnded() { }
</span><span class="cx">
</span><ins>+ virtual void beginDrag(DragItem, Frame&, const IntPoint&, const IntPoint&, DataTransfer&, DragSourceAction) { }
+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> // Mac-specific helper function to allow access to web archives and NSPasteboard extras in WebKit.
</span><span class="cx"> // This is not abstract as that would require another #if PLATFORM(COCOA) for the SVGImage client empty implentation.
</span></span></pre></div>
<a id="trunkSourceWebCorepageDragControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DragController.cpp (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DragController.cpp        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/page/DragController.cpp        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -738,6 +738,16 @@
</span><span class="cx"> return IntPoint(dragOrigin.x() - dragImageOffset.x(), dragOrigin.y() + yOffset);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static FloatPoint dragImageAnchorPointForSelectionDrag(Frame& frame, const IntPoint& mouseDraggedPoint)
+{
+ IntRect draggingRect = enclosingIntRect(frame.selection().selectionBounds());
+
+ float x = (mouseDraggedPoint.x() - draggingRect.x()) / (float)draggingRect.width();
+ float y = (mouseDraggedPoint.y() - draggingRect.y()) / (float)draggingRect.height();
+
+ return FloatPoint { x, y };
+}
+
</ins><span class="cx"> static IntPoint dragLocForSelectionDrag(Frame& src)
</span><span class="cx"> {
</span><span class="cx"> IntRect draggingRect = enclosingIntRect(src.selection().selectionBounds());
</span><span class="lines">@@ -792,6 +802,7 @@
</span><span class="cx"> m_sourceDragOperation = srcOp;
</span><span class="cx">
</span><span class="cx"> DragImage dragImage;
</span><ins>+ FloatPoint dragImageAnchorPoint;
</ins><span class="cx"> IntPoint dragLoc(0, 0);
</span><span class="cx"> IntPoint dragImageOffset(0, 0);
</span><span class="cx">
</span><span class="lines">@@ -818,9 +829,13 @@
</span><span class="cx"> ASSERT(state.source);
</span><span class="cx"> Element& element = *state.source;
</span><span class="cx">
</span><ins>+ bool mustUseLegacyDragClient = dataTransfer.pasteboard().hasData() || m_client.useLegacyDragClient();
+
</ins><span class="cx"> IntRect dragImageBounds;
</span><span class="cx"> Image* image = getImage(element);
</span><span class="cx"> if (state.type == DragSourceActionSelection) {
</span><ins>+ PasteboardWriterData pasteboardWriterData;
+
</ins><span class="cx"> if (!dataTransfer.pasteboard().hasData()) {
</span><span class="cx"> // FIXME: This entire block is almost identical to the code in Editor::copy, and the code should be shared.
</span><span class="cx"> RefPtr<Range> selectionRange = src.selection().toNormalizedRange();
</span><span class="lines">@@ -836,9 +851,18 @@
</span><span class="cx">
</span><span class="cx"> src.editor().willWriteSelectionToPasteboard(selectionRange.get());
</span><span class="cx">
</span><del>- if (enclosingTextFormControl(src.selection().selection().start()))
- dataTransfer.pasteboard().writePlainText(src.editor().selectedTextForDataTransfer(), Pasteboard::CannotSmartReplace);
- else {
</del><ins>+ if (enclosingTextFormControl(src.selection().selection().start())) {
+ if (mustUseLegacyDragClient)
+ dataTransfer.pasteboard().writePlainText(src.editor().selectedTextForDataTransfer(), Pasteboard::CannotSmartReplace);
+ else {
+ PasteboardWriterData::PlainText plainText;
+ plainText.canSmartCopyOrDelete = false;
+ plainText.text = src.editor().selectedTextForDataTransfer();
+ pasteboardWriterData.setPlainText(WTFMove(plainText));
+ }
+ } else {
+ mustUseLegacyDragClient = true;
+
</ins><span class="cx"> #if PLATFORM(COCOA) || PLATFORM(GTK)
</span><span class="cx"> src.editor().writeSelectionToPasteboard(dataTransfer.pasteboard());
</span><span class="cx"> #else
</span><span class="lines">@@ -853,6 +877,7 @@
</span><span class="cx"> if (!dragImage) {
</span><span class="cx"> dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src), DragImageAlpha) };
</span><span class="cx"> dragLoc = dragLocForSelectionDrag(src);
</span><ins>+ dragImageAnchorPoint = dragImageAnchorPointForSelectionDrag(src, mouseDraggedPoint);
</ins><span class="cx"> m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -859,7 +884,18 @@
</span><span class="cx"> if (!dragImage)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, dragImageBounds, dataTransfer, src, DragSourceActionSelection);
</del><ins>+ if (mustUseLegacyDragClient) {
+ doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, dragImageBounds, dataTransfer, src, DragSourceActionSelection);
+ return true;
+ }
+
+ DragItem dragItem;
+ dragItem.image = WTFMove(dragImage);
+ dragItem.imageAnchorPoint = dragImageAnchorPoint;
+ dragItem.data = WTFMove(pasteboardWriterData);
+
+ beginDrag(WTFMove(dragItem), src, dragOrigin, mouseDraggedPoint, dataTransfer, DragSourceActionSelection);
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1007,6 +1043,30 @@
</span><span class="cx"> doSystemDrag(WTFMove(dragImage), dragImageOffset, dragOrigin, element.boundsInRootViewSpace(), dataTransfer, frame, DragSourceActionImage);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void DragController::beginDrag(DragItem dragItem, Frame& frame, const IntPoint& mouseDownPoint, const IntPoint& mouseDraggedPoint, DataTransfer& dataTransfer, DragSourceAction dragSourceAction)
+{
+ ASSERT(!m_client.useLegacyDragClient());
+
+ m_didInitiateDrag = true;
+ m_dragInitiator = frame.document();
+
+ // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
+ Ref<MainFrame> mainFrameProtector(m_page.mainFrame());
+ RefPtr<FrameView> viewProtector = mainFrameProtector->view();
+
+ auto mouseDownPointInRootViewCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(mouseDownPoint));
+ auto mouseDraggedPointInRootViewCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(mouseDraggedPoint));
+
+ m_client.beginDrag(WTFMove(dragItem), frame, mouseDownPointInRootViewCoordinates, mouseDraggedPointInRootViewCoordinates, dataTransfer, dragSourceAction);
+
+ // DragClient::beginDrag can cause the drag controller to be deleted.
+ if (!mainFrameProtector->page())
+ return;
+
+ // FIXME: This shouldn't be needed.
+ cleanupAfterSystemDrag();
+}
+
</ins><span class="cx"> void DragController::doSystemDrag(DragImage image, const IntPoint& dragLoc, const IntPoint& eventPos, const IntRect& dragImageBounds, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)
</span><span class="cx"> {
</span><span class="cx"> FloatPoint dragImageAnchor = { 0.5, 0.5 };
</span></span></pre></div>
<a id="trunkSourceWebCorepageDragControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DragController.h (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DragController.h        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/page/DragController.h        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -33,19 +33,20 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>- class DataTransfer;
- class Document;
- class DragClient;
- class DragData;
- class Element;
- class Frame;
- class FrameSelection;
- class HTMLInputElement;
- class IntRect;
- class Page;
- class PlatformMouseEvent;
</del><ins>+class DataTransfer;
+class Document;
+class DragClient;
+class DragData;
+class Element;
+class Frame;
+class FrameSelection;
+class HTMLInputElement;
+class IntRect;
+class Page;
+class PlatformMouseEvent;
</ins><span class="cx">
</span><del>- struct DragState;
</del><ins>+struct DragItem;
+struct DragState;
</ins><span class="cx">
</span><span class="cx"> class DragController {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(DragController); WTF_MAKE_FAST_ALLOCATED;
</span><span class="lines">@@ -113,6 +114,9 @@
</span><span class="cx">
</span><span class="cx"> void doImageDrag(Element&, const IntPoint&, const IntRect&, DataTransfer&, Frame&, IntPoint&);
</span><span class="cx"> void doSystemDrag(DragImage, const IntPoint&, const IntPoint&, const IntRect& dragImageBounds, DataTransfer&, Frame&, DragSourceAction);
</span><ins>+
+ void beginDrag(DragItem, Frame&, const IntPoint& mouseDownPoint, const IntPoint& mouseDraggedPoint, DataTransfer&, DragSourceAction);
+
</ins><span class="cx"> void cleanupAfterSystemDrag();
</span><span class="cx"> void declareAndWriteDragImage(DataTransfer&, Element&, const URL&, const String& label);
</span><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDragItemhfromrev212661trunkSourceWebCoreplatformmacPasteboardWriterh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/DragItem.h (from rev 212661, trunk/Source/WebCore/platform/mac/PasteboardWriter.h) (0 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DragItem.h         (rev 0)
+++ trunk/Source/WebCore/platform/DragItem.h        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#pragma once
+
+#include "DragImage.h"
+#include "FloatPoint.h"
+#include "PasteboardWriterData.h"
+
+namespace WebCore {
+
+struct DragItem final {
+ DragImage image;
+
+ // Where the image should be positioned relative to the cursor.
+ FloatPoint imageAnchorPoint;
+
+ PasteboardWriterData data;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacPasteboardWriterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/PasteboardWriter.h (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/PasteboardWriter.h        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/platform/mac/PasteboardWriter.h        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx">
</span><span class="cx"> class PasteboardWriterData;
</span><span class="cx">
</span><del>-WEBCORE_EXPORT RetainPtr<id <NSPasteboardWriting>> createPasteboardWriting(const PasteboardWriterData&);
</del><ins>+WEBCORE_EXPORT RetainPtr<id <NSPasteboardWriting>> createPasteboardWriter(const PasteboardWriterData&);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacPasteboardWritermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/PasteboardWriter.mm (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/PasteboardWriter.mm        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebCore/platform/mac/PasteboardWriter.mm        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -33,14 +33,16 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-RetainPtr<id <NSPasteboardWriting>> createPasteboardWriting(const PasteboardWriterData& data)
</del><ins>+RetainPtr<id <NSPasteboardWriting>> createPasteboardWriter(const PasteboardWriterData& data)
</ins><span class="cx"> {
</span><span class="cx"> auto pasteboardItem = adoptNS([[NSPasteboardItem alloc] init]);
</span><span class="cx">
</span><span class="cx"> if (auto& plainText = data.plainText()) {
</span><span class="cx"> [pasteboardItem setString:plainText->text forType:NSPasteboardTypeString];
</span><del>- if (plainText->canSmartCopyOrDelete)
- [pasteboardItem setData:nil forType:_NXSmartPaste];
</del><ins>+ if (plainText->canSmartCopyOrDelete) {
+ auto smartPasteType = adoptNS((__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (__bridge CFStringRef)_NXSmartPaste, nullptr));
+ [pasteboardItem setData:nil forType:smartPasteType.get()];
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return pasteboardItem;
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebKit/mac/ChangeLog        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2017-02-17 Anders Carlsson <andersca@apple.com>
+
+ Add a new drag code path and use it for dragging plain text
+ https://bugs.webkit.org/show_bug.cgi?id=168534
+
+ Reviewed by Geoffrey Garen.
+
+ * WebCoreSupport/WebDragClient.h:
+ Add new members.
+
+ * WebCoreSupport/WebDragClient.mm:
+ (WebDragClient::useLegacyDragClient):
+ Return false here.
+
+ (WebDragClient::beginDrag):
+ New client member function. Create an NSDraggingItem and use it to begin a dragging session.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView draggingSession:sourceOperationMaskForDraggingContext:]):
+ Get the source operation mask from WebCore.
+
+ (-[WebHTMLView draggingSession:endedAtPoint:operation:]):
+ Send a fake mouse up event.
+
+ * WebView/WebHTMLViewInternal.h:
+ Declare that WebHTMLView conforms to NSDraggingSource.
+
</ins><span class="cx"> 2017-02-20 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> List of WebCore symbols to re-export from WebKitLegacy should be built automatically
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebDragClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -32,6 +32,9 @@
</span><span class="cx"> class WebDragClient : public WebCore::DragClient {
</span><span class="cx"> public:
</span><span class="cx"> WebDragClient(WebView*);
</span><ins>+
+ bool useLegacyDragClient() override;
+
</ins><span class="cx"> void willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&) override;
</span><span class="cx"> void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&) override;
</span><span class="cx"> WebCore::DragDestinationAction actionMaskForDrag(const WebCore::DragData&) override;
</span><span class="lines">@@ -38,6 +41,9 @@
</span><span class="cx"> void dragControllerDestroyed() override;
</span><span class="cx"> WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
</span><span class="cx"> void startDrag(WebCore::DragImage, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, const WebCore::FloatPoint&, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction) override;
</span><ins>+
+ void beginDrag(WebCore::DragItem, WebCore::Frame&, const WebCore::IntPoint& mouseDownPosition, const WebCore::IntPoint& mouseDraggedPosition, WebCore::DataTransfer&, WebCore::DragSourceAction) override;
+
</ins><span class="cx"> void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) override;
</span><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span><span class="cx"> void declareAndWriteAttachment(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String& path, WebCore::Frame*) override;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebDragClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -32,8 +32,8 @@
</span><span class="cx"> #import "WebDOMOperations.h"
</span><span class="cx"> #import "WebFrame.h"
</span><span class="cx"> #import "WebFrameInternal.h"
</span><ins>+#import "WebFrameView.h"
</ins><span class="cx"> #import "WebHTMLViewInternal.h"
</span><del>-#import "WebHTMLViewPrivate.h"
</del><span class="cx"> #import "WebKitLogging.h"
</span><span class="cx"> #import "WebKitNSStringExtras.h"
</span><span class="cx"> #import "WebNSURLExtras.h"
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #import <WebCore/MainFrame.h>
</span><span class="cx"> #import <WebCore/Page.h>
</span><span class="cx"> #import <WebCore/Pasteboard.h>
</span><ins>+#import <WebCore/PasteboardWriter.h>
</ins><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="lines">@@ -66,6 +67,11 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">
</span><ins>+bool WebDragClient::useLegacyDragClient()
+{
+ return false;
+}
+
</ins><span class="cx"> static WebHTMLView *getTopHTMLView(Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(frame);
</span><span class="lines">@@ -130,6 +136,30 @@
</span><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebDragClient::beginDrag(DragItem dragItem, Frame& frame, const IntPoint& mouseDownPosition, const IntPoint& mouseDraggedPosition, DataTransfer& dataTransfer, DragSourceAction dragSourceAction)
+{
+ ASSERT(!dataTransfer.pasteboard().hasData());
+
+ RetainPtr<WebHTMLView> topWebHTMLView = dynamic_objc_cast<WebHTMLView>(m_webView.mainFrame.frameView.documentView);
+ ASSERT(topWebHTMLView);
+
+ [topWebHTMLView _stopAutoscrollTimer];
+
+ auto draggingItem = adoptNS([[NSDraggingItem alloc] initWithPasteboardWriter:createPasteboardWriter(dragItem.data).get()]);
+
+ auto dragImageSize = IntSize { [dragItem.image.get() size] };
+
+ dragImageSize.scale(1 / frame.page()->deviceScaleFactor());
+ [dragItem.image.get() setSize:dragImageSize];
+
+ NSRect draggingFrame = NSMakeRect(mouseDraggedPosition.x() - dragImageSize.width() * dragItem.imageAnchorPoint.x(), mouseDraggedPosition.y() - dragImageSize.height() * dragItem.imageAnchorPoint.y(), dragImageSize.width(), dragImageSize.height());
+ [draggingItem setDraggingFrame:draggingFrame contents:dragItem.image.get().get()];
+
+ // FIXME: We should be able to make a fake event with the mosue dragged coordinates.
+ NSEvent *event = frame.eventHandler().currentNSEvent();
+ [topWebHTMLView.get() beginDraggingSessionWithItems:@[ draggingItem.get() ] event:event source:topWebHTMLView.get()];
+}
+
</ins><span class="cx"> void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& title, WebCore::Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(pasteboardName);
</span><span class="lines">@@ -147,6 +177,10 @@
</span><span class="cx">
</span><span class="cx"> #else
</span><span class="cx">
</span><ins>+bool WebDragClient::useLegacyDragClient()
+{
+ return false;
+}
</ins><span class="cx"> WebCore::DragDestinationAction WebDragClient::actionMaskForDrag(const WebCore::DragData&)
</span><span class="cx"> {
</span><span class="cx"> return DragDestinationActionNone;
</span><span class="lines">@@ -169,6 +203,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebDragClient::beginDrag(DragItem, Frame&, const IntPoint&, const IntPoint&, DataTransfer&, DragSourceAction)
+{
+}
+
</ins><span class="cx"> void WebDragClient::declareAndWriteDragImage(const String&, Element&, const URL&, const String&, WebCore::Frame*)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -4691,6 +4691,42 @@
</span><span class="cx">
</span><span class="cx"> return [NSArray arrayWithObject:[path lastPathComponent]];
</span><span class="cx"> }
</span><ins>+
+// MARK: NSDraggingSource
+
+- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
+{
+ ASSERT(![self _webView] || [self _isTopHTMLView]);
+
+ Page* page = core([self _webView]);
+ if (!page)
+ return NSDragOperationNone;
+
+ return (NSDragOperation)page->dragController().sourceDragOperation();
+}
+
+- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
+{
+ ASSERT(![self _webView] || [self _isTopHTMLView]);
+
+ NSPoint windowLocation = [self.window convertRectFromScreen:{ screenPoint, NSZeroSize }].origin;
+
+ if (Page* page = core([self _webView]))
+ page->dragController().dragEnded();
+
+ [[self _frame] _dragSourceEndedAt:windowLocation operation:operation];
+
+ // Prevent queued mouseDragged events from coming after the drag and fake mouseUp event.
+ _private->ignoringMouseDraggedEvents = YES;
+
+ // Once the dragging machinery kicks in, we no longer get mouse drags or the up event.
+ // WebCore expects to get balanced down/up's, so we must fake up a mouseup.
+ NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:windowLocation modifierFlags:[NSApp currentEvent].modifierFlags timestamp:[NSDate timeIntervalSinceReferenceDate] windowNumber:self.window. windowNumber context:nullptr eventNumber:0 clickCount:0 pressure:0];
+
+ // This will also update the mouseover state.
+ [self mouseUp:fakeEvent];
+}
+
</ins><span class="cx"> #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -38,6 +38,11 @@
</span><span class="cx"> class KeyboardEvent;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+@interface WebHTMLView () <NSDraggingSource>
+@end
+#endif
+
</ins><span class="cx"> @interface WebHTMLView (WebInternal)
</span><span class="cx"> - (void)_selectionChanged;
</span><span class="cx"> #if !PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Tools/ChangeLog        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-02-17 Anders Carlsson <andersca@apple.com>
+
+ Add a new drag code path and use it for dragging plain text
+ https://bugs.webkit.org/show_bug.cgi?id=168534
+
+ Reviewed by Geoffrey Garen.
+
+ Update the testing infrastructure to handle NSDraggingSession.
+
+ * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+ * DumpRenderTree/mac/DumpRenderTreePasteboard.mm: Renamed from Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m.
+ (-[LocalPasteboard writeObjects:]):
+ Implement this in terms of the legacy pasteboard API.
+
+ * DumpRenderTree/mac/EventSendingController.mm:
+ (drt_WebHTMLView_beginDraggingSessionWithItemsEventSource):
+ (+[EventSendingController initialize]):
+ Swizzle the drag method instead of adding a delegate method (like the old code does).
+
</ins><span class="cx"> 2017-02-20 Florian Bruhin <git@the-compiler.org>
</span><span class="cx">
</span><span class="cx"> Handle EINTR during webkitpy server process select()
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeDumpRenderTreexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx">                 A1158D59189274360088C17B /* PixelDumpSupportIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1158D57189273EB0088C17B /* PixelDumpSupportIOS.mm */; };
</span><span class="cx">                 A134E531188FC27000901D06 /* DumpRenderTreeMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = A134E52F188FC27000901D06 /* DumpRenderTreeMain.mm */; };
</span><span class="cx">                 A134E53618905EFF00901D06 /* AccessibilityCommonMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */; };
</span><del>-                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.m in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.m */; };
</del><ins>+                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.mm */; };
</ins><span class="cx">                 A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */; };
</span><span class="cx">                 A8D79CEB0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */; };
</span><span class="cx">                 A9BB7C5C1C505278002C525B /* AccessibilityTextMarkerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9BB7C5B1C505278002C525B /* AccessibilityTextMarkerIOS.mm */; };
</span><span class="lines">@@ -343,7 +343,7 @@
</span><span class="cx">                 A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = DumpRenderTree.h; sourceTree = "<group>"; };
</span><span class="cx">                 A817090308B164D300CCB9FB /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 A84F608908B136DA00E9745F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
</span><del>-                A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DumpRenderTreePasteboard.m; path = mac/DumpRenderTreePasteboard.m; sourceTree = "<group>"; };
</del><ins>+                A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreePasteboard.mm; path = mac/DumpRenderTreePasteboard.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreeWindow.mm; path = mac/DumpRenderTreeWindow.mm; sourceTree = "<group>"; };
</span><span class="cx">                 A8B91ADD0CF3B372008F91FF /* DumpRenderTreeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreeWindow.h; path = mac/DumpRenderTreeWindow.h; sourceTree = "<group>"; };
</span><span class="cx">                 A8B91ADF0CF3B372008F91FF /* DumpRenderTreePasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreePasteboard.h; path = mac/DumpRenderTreePasteboard.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -780,7 +780,7 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 A8B91ADF0CF3B372008F91FF /* DumpRenderTreePasteboard.h */,
</span><del>-                                A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.m */,
</del><ins>+                                A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.mm */,
</ins><span class="cx">                                 2DA2E3A31E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.h */,
</span><span class="cx">                                 2DA2E3A41E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm */,
</span><span class="cx">                                 A8B91ADD0CF3B372008F91FF /* DumpRenderTreeWindow.h */,
</span><span class="lines">@@ -1111,7 +1111,7 @@
</span><span class="cx">                                 9830F31F15C81181005AB206 /* DumpRenderTreeCommon.cpp in Sources */,
</span><span class="cx">                                 BCA18B7B0C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm in Sources */,
</span><span class="cx">                                 A8D79CEB0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m in Sources */,
</span><del>-                                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.m in Sources */,
</del><ins>+                                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.mm in Sources */,
</ins><span class="cx">                                 A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */,
</span><span class="cx">                                 BCA18B620C9B08C200114369 /* EditingDelegate.mm in Sources */,
</span><span class="cx">                                 BCA18B700C9B08DB00114369 /* EventSendingController.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreePasteboardm"></a>
<div class="delfile"><h4>Deleted: trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -1,218 +0,0 @@
</span><del>-/*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved.
- * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
- * (C) 2007 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
- */
-
-#import "config.h"
-#import "DumpRenderTreeMac.h"
-#import "DumpRenderTreePasteboard.h"
-
-#if !PLATFORM(IOS)
-
-#import <WebKit/WebTypesInternal.h>
-
-@interface LocalPasteboard : NSPasteboard
-{
- NSMutableArray *typesArray;
- NSMutableSet *typesSet;
- NSMutableDictionary *dataByType;
- NSInteger changeCount;
- NSString *pasteboardName;
-}
-
--(id)initWithName:(NSString *)name;
-@end
-
-static NSMutableDictionary *localPasteboards;
-
-@implementation DumpRenderTreePasteboard
-
-// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
-+ (NSPasteboard *)_pasteboardWithName:(NSString *)name
-{
- static int number = 0;
- if (!name)
- name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
- if (!localPasteboards)
- localPasteboards = [[NSMutableDictionary alloc] init];
- LocalPasteboard *pasteboard = [localPasteboards objectForKey:name];
- if (pasteboard)
- return pasteboard;
- pasteboard = [[LocalPasteboard alloc] initWithName:name];
- [localPasteboards setObject:pasteboard forKey:name];
- [pasteboard release];
- return pasteboard;
-}
-
-+ (void)releaseLocalPasteboards
-{
- [localPasteboards release];
- localPasteboards = nil;
-}
-
-// Convenience method for JS so that it doesn't have to try and create a NSArray on the objc side instead
-// of the usual WebScriptObject that is passed around
-- (NSInteger)declareType:(NSString *)type owner:(id)newOwner
-{
- return [self declareTypes:[NSArray arrayWithObject:type] owner:newOwner];
-}
-
-@end
-
-@implementation LocalPasteboard
-
-+ (id)alloc
-{
- return NSAllocateObject(self, 0, 0);
-}
-
-- (id)initWithName:(NSString *)name
-{
- self = [super init];
- if (!self)
- return nil;
- typesArray = [[NSMutableArray alloc] init];
- typesSet = [[NSMutableSet alloc] init];
- dataByType = [[NSMutableDictionary alloc] init];
- pasteboardName = [name copy];
- return self;
-}
-
-- (void)dealloc
-{
- [typesArray release];
- [typesSet release];
- [dataByType release];
- [pasteboardName release];
- [super dealloc];
-}
-
-- (NSString *)name
-{
- return pasteboardName;
-}
-
-- (void)releaseGlobally
-{
-}
-
-- (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner
-{
- [typesArray removeAllObjects];
- [typesSet removeAllObjects];
- [dataByType removeAllObjects];
- return [self addTypes:newTypes owner:newOwner];
-}
-
-- (NSInteger)addTypes:(NSArray *)newTypes owner:(id)newOwner
-{
- unsigned count = [newTypes count];
- unsigned i;
- for (i = 0; i < count; ++i) {
- NSString *type = [newTypes objectAtIndex:i];
- NSString *setType = [typesSet member:type];
- if (!setType) {
- setType = [type copy];
- [typesArray addObject:setType];
- [typesSet addObject:setType];
- [setType release];
- }
- if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
- [newOwner pasteboard:self provideDataForType:setType];
- }
- return ++changeCount;
-}
-
-- (NSInteger)changeCount
-{
- return changeCount;
-}
-
-- (NSArray *)types
-{
- return typesArray;
-}
-
-- (NSString *)availableTypeFromArray:(NSArray *)types
-{
- unsigned count = [types count];
- unsigned i;
- for (i = 0; i < count; ++i) {
- NSString *type = [types objectAtIndex:i];
- NSString *setType = [typesSet member:type];
- if (setType)
- return setType;
- }
- return nil;
-}
-
-- (BOOL)setData:(NSData *)data forType:(NSString *)dataType
-{
- if (data == nil)
- data = [NSData data];
- if (![typesSet containsObject:dataType])
- return NO;
- [dataByType setObject:data forKey:dataType];
- ++changeCount;
- return YES;
-}
-
-- (NSData *)dataForType:(NSString *)dataType
-{
- return [dataByType objectForKey:dataType];
-}
-
-- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType
-{
- CFDataRef data = NULL;
- if (propertyList)
- data = CFPropertyListCreateXMLData(NULL, propertyList);
- BOOL result = [self setData:(NSData *)data forType:dataType];
- if (data)
- CFRelease(data);
- return result;
-}
-
-- (BOOL)setString:(NSString *)string forType:(NSString *)dataType
-{
- CFDataRef data = NULL;
- if (string) {
- if ([string length] == 0)
- data = CFDataCreate(NULL, NULL, 0);
- else
- data = CFStringCreateExternalRepresentation(NULL, (CFStringRef)string, kCFStringEncodingUTF8, 0);
- }
- BOOL result = [self setData:(NSData *)data forType:dataType];
- if (data)
- CFRelease(data);
- return result;
-}
-
-@end
-
-#endif // !PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreePasteboardmmfromrev212661trunkToolsDumpRenderTreemacDumpRenderTreePasteboardm"></a>
<div class="copfile"><h4>Copied: trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm (from rev 212661, trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.m) (0 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm         (rev 0)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -0,0 +1,239 @@
</span><ins>+/*
+ * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved.
+ * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
+ * (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
+ */
+
+#import "config.h"
+#import "DumpRenderTreePasteboard.h"
+
+#import "DumpRenderTreeMac.h"
+
+#if !PLATFORM(IOS)
+
+#import <WebKit/WebTypesInternal.h>
+#import <wtf/Assertions.h>
+#import <wtf/RetainPtr.h>
+
+@interface LocalPasteboard : NSPasteboard {
+ NSMutableArray *typesArray;
+ NSMutableSet *typesSet;
+ NSMutableDictionary *dataByType;
+ NSInteger changeCount;
+ NSString *pasteboardName;
+}
+
+-(id)initWithName:(NSString *)name;
+@end
+
+static NSMutableDictionary *localPasteboards;
+
+@implementation DumpRenderTreePasteboard
+
+// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
++ (NSPasteboard *)_pasteboardWithName:(NSString *)name
+{
+ static int number = 0;
+ if (!name)
+ name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
+ if (!localPasteboards)
+ localPasteboards = [[NSMutableDictionary alloc] init];
+ LocalPasteboard *pasteboard = [localPasteboards objectForKey:name];
+ if (pasteboard)
+ return pasteboard;
+ pasteboard = [[LocalPasteboard alloc] initWithName:name];
+ [localPasteboards setObject:pasteboard forKey:name];
+ [pasteboard release];
+ return pasteboard;
+}
+
++ (void)releaseLocalPasteboards
+{
+ [localPasteboards release];
+ localPasteboards = nil;
+}
+
+// Convenience method for JS so that it doesn't have to try and create a NSArray on the objc side instead
+// of the usual WebScriptObject that is passed around
+- (NSInteger)declareType:(NSString *)type owner:(id)newOwner
+{
+ return [self declareTypes:[NSArray arrayWithObject:type] owner:newOwner];
+}
+
+@end
+
+@implementation LocalPasteboard
+
++ (id)alloc
+{
+ return NSAllocateObject(self, 0, 0);
+}
+
+- (id)initWithName:(NSString *)name
+{
+ self = [super init];
+ if (!self)
+ return nil;
+ typesArray = [[NSMutableArray alloc] init];
+ typesSet = [[NSMutableSet alloc] init];
+ dataByType = [[NSMutableDictionary alloc] init];
+ pasteboardName = [name copy];
+ return self;
+}
+
+- (void)dealloc
+{
+ [typesArray release];
+ [typesSet release];
+ [dataByType release];
+ [pasteboardName release];
+ [super dealloc];
+}
+
+- (NSString *)name
+{
+ return pasteboardName;
+}
+
+- (void)releaseGlobally
+{
+}
+
+- (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner
+{
+ [typesArray removeAllObjects];
+ [typesSet removeAllObjects];
+ [dataByType removeAllObjects];
+ return [self addTypes:newTypes owner:newOwner];
+}
+
+- (NSInteger)addTypes:(NSArray *)newTypes owner:(id)newOwner
+{
+ unsigned count = [newTypes count];
+ unsigned i;
+ for (i = 0; i < count; ++i) {
+ NSString *type = [newTypes objectAtIndex:i];
+ NSString *setType = [typesSet member:type];
+ if (!setType) {
+ setType = [type copy];
+ [typesArray addObject:setType];
+ [typesSet addObject:setType];
+ [setType release];
+ }
+ if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
+ [newOwner pasteboard:self provideDataForType:setType];
+ }
+ return ++changeCount;
+}
+
+- (NSInteger)changeCount
+{
+ return changeCount;
+}
+
+- (NSArray *)types
+{
+ return typesArray;
+}
+
+- (NSString *)availableTypeFromArray:(NSArray *)types
+{
+ unsigned count = [types count];
+ unsigned i;
+ for (i = 0; i < count; ++i) {
+ NSString *type = [types objectAtIndex:i];
+ NSString *setType = [typesSet member:type];
+ if (setType)
+ return setType;
+ }
+ return nil;
+}
+
+- (BOOL)setData:(NSData *)data forType:(NSString *)dataType
+{
+ if (data == nil)
+ data = [NSData data];
+ if (![typesSet containsObject:dataType])
+ return NO;
+ [dataByType setObject:data forKey:dataType];
+ ++changeCount;
+ return YES;
+}
+
+- (NSData *)dataForType:(NSString *)dataType
+{
+ return [dataByType objectForKey:dataType];
+}
+
+- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType
+{
+ CFDataRef data = NULL;
+ if (propertyList)
+ data = CFPropertyListCreateXMLData(NULL, propertyList);
+ BOOL result = [self setData:(NSData *)data forType:dataType];
+ if (data)
+ CFRelease(data);
+ return result;
+}
+
+- (BOOL)setString:(NSString *)string forType:(NSString *)dataType
+{
+ CFDataRef data = NULL;
+ if (string) {
+ if (!string.length)
+ data = CFDataCreate(NULL, NULL, 0);
+ else
+ data = CFStringCreateExternalRepresentation(NULL, (CFStringRef)string, kCFStringEncodingUTF8, 0);
+ }
+ BOOL result = [self setData:(NSData *)data forType:dataType];
+ if (data)
+ CFRelease(data);
+ return result;
+}
+
+- (BOOL)writeObjects:(NSArray<id <NSPasteboardWriting>> *)objects
+{
+ for (id <NSPasteboardWriting> object in objects) {
+ for (NSString *type in [object writableTypesForPasteboard:self]) {
+ auto pasteboardType = adoptNS((__bridge NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)type, kUTTagClassNSPboardType));
+
+ [self addTypes:@[ pasteboardType.get() ] owner:self];
+
+ id propertyList = [object pasteboardPropertyListForType:type];
+ if ([propertyList isKindOfClass:NSData.class])
+ [self setData:propertyList forType:pasteboardType.get()];
+ else
+ ASSERT_NOT_REACHED();
+ }
+ }
+
+ return YES;
+}
+
+@end
+
+#endif // !PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkToolsDumpRenderTreemacEventSendingControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/EventSendingController.mm (212662 => 212663)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/EventSendingController.mm        2017-02-20 19:14:51 UTC (rev 212662)
+++ trunk/Tools/DumpRenderTree/mac/EventSendingController.mm        2017-02-20 19:32:56 UTC (rev 212663)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> #import <Carbon/Carbon.h> // for GetCurrentEventTime()
</span><ins>+#import <WebKit/WebHTMLView.h>
+#import <objc/runtime.h>
</ins><span class="cx"> #import <wtf/mac/AppKitCompatibilityDeclarations.h>
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -138,6 +140,35 @@
</span><span class="cx">
</span><span class="cx"> @implementation EventSendingController
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+static NSDraggingSession *drt_WebHTMLView_beginDraggingSessionWithItemsEventSource(WebHTMLView *self, id _cmd, NSArray<NSDraggingItem *> *items, NSEvent *event, id<NSDraggingSource> source)
+{
+ ASSERT(!draggingInfo);
+
+ WebFrameView *webFrameView = ^ {
+ for (NSView *superview = self.superview; superview; superview = superview.superview) {
+ if ([superview isKindOfClass:WebFrameView.class])
+ return (WebFrameView *)superview;
+ }
+
+ ASSERT_NOT_REACHED();
+ return (WebFrameView *)nil;
+ }();
+
+ WebView *webView = webFrameView.webFrame.webView;
+
+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ for (NSDraggingItem *item in items)
+ [pasteboard writeObjects:@[ item.item ]];
+
+ draggingInfo = [[DumpRenderTreeDraggingInfo alloc] initWithImage:nil offset:NSZeroSize pasteboard:pasteboard source:source];
+ [webView draggingUpdated:draggingInfo];
+ [EventSendingController replaySavedEvents];
+
+ return nullptr;
+}
+#endif
+
</ins><span class="cx"> + (void)initialize
</span><span class="cx"> {
</span><span class="cx"> webkitDomEventNames = [[NSArray alloc] initWithObjects:
</span><span class="lines">@@ -188,6 +219,15 @@
</span><span class="cx"> @"unload",
</span><span class="cx"> @"zoom",
</span><span class="cx"> nil];
</span><ins>+
+#if PLATFORM(MAC)
+ // Add an implementation of -[WebHTMLView beginDraggingSessionWithItems:event:source:].
+ SEL selector = @selector(beginDraggingSessionWithItems:event:source:);
+ const char* typeEncoding = method_getTypeEncoding(class_getInstanceMethod(NSView.class, selector));
+
+ if (!class_addMethod(WebHTMLView.class, selector, reinterpret_cast<IMP>(drt_WebHTMLView_beginDraggingSessionWithItemsEventSource), typeEncoding))
+ ASSERT_NOT_REACHED();
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
</span></span></pre>
</div>
</div>
</body>
</html>