Title: [181760] trunk
Revision
181760
Author
[email protected]
Date
2015-03-19 14:59:23 -0700 (Thu, 19 Mar 2015)

Log Message

<attachment> should put URLs on the pasteboard so that Finder can accept drops.
https://bugs.webkit.org/show_bug.cgi?id=142801
rdar://problem/19982527

Reviewed by Tim Horton.

Source/WebCore:

Test: editing/pasteboard/drag-and-drop-attachment-contenteditable.html

This patch adds all the necessary support to write attachment elements into
the pasteboard, including the promised type.

* WebCore.xcodeproj/project.pbxproj:
* page/DragActions.h:
* page/DragClient.h:
(WebCore::DragClient::declareAndWriteAttachment):
* page/DragController.cpp:
(WebCore::DragController::draggableElement):
(WebCore::DragController::startDrag):
* page/DragController.h:
(WebCore::DragController::draggingAttachmentURL):
* page/EventHandler.cpp:
(WebCore::EventHandler::dragHysteresisExceeded):
(WebCore::EventHandler::handleDrag):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::declareAndWriteAttachment):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::declareAndWriteAttachment):
* platform/URL.cpp:
(WebCore::URL::fileURLWithFileSystemPath):
* platform/URL.h:
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absoluteAttachmentURL):
* rendering/HitTestResult.h:

Source/WebKit/mac:

This patch adds all the necessary support to write attachment elements into
the pasteboard, including the promised type in WK1.

* Misc/WebNSPasteboardExtras.mm:
(-[NSPasteboard _web_declareAndWriteDragImageForElement:URL:title:archive:source:]):
* WebCoreSupport/WebDragClient.h:
* WebCoreSupport/WebDragClient.mm:
(WebDragClient::declareAndWriteAttachment):
* WebView/WebHTMLView.mm:
(-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]):
* WebView/WebUIDelegate.h:

Source/WebKit2:

This patch adds all the necessary support to write attachment elements into
the pasteboard, including the promised type in WK2.

* UIProcess/API/mac/WKView.mm:
(-[WKView _setPromisedDataForImage:withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:forPasteboard:]):
(-[WKView _setPromisedDataForAttachment:withExtension:withTitle:withURL:withVisibleURL:forPasteboard:]):
(-[WKView namesOfPromisedFilesDroppedAtDestination:]):
(-[WKView _setPromisedData:withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:forPasteboard:]): Deleted.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setPromisedDataForImage):
(WebKit::PageClientImpl::setPromisedDataForAttachment):
(WebKit::PageClientImpl::setPromisedData): Deleted.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::setPromisedDataForImage):
(WebKit::WebPageProxy::setPromisedDataForAttachment):
(WebKit::WebPageProxy::setPromisedData): Deleted.
* WebProcess/WebCoreSupport/WebDragClient.h:
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::declareAndWriteAttachment):
(WebKit::WebDragClient::declareAndWriteDragImage):

LayoutTests:

* editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt: Added.
* editing/pasteboard/drag-and-drop-attachment-contenteditable.html: Added.
* platform/mac-wk2/TestExpectations: Skipping new test on WK2 since it uses eventSender.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181759 => 181760)


--- trunk/LayoutTests/ChangeLog	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/LayoutTests/ChangeLog	2015-03-19 21:59:23 UTC (rev 181760)
@@ -1,3 +1,15 @@
+2015-03-19  Enrica Casucci  <[email protected]>
+
+        <attachment> should put URLs on the pasteboard so that Finder can accept drops.
+        https://bugs.webkit.org/show_bug.cgi?id=142801
+        rdar://problem/19982527
+
+        Reviewed by Tim Horton.
+
+        * editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt: Added.
+        * editing/pasteboard/drag-and-drop-attachment-contenteditable.html: Added.
+        * platform/mac-wk2/TestExpectations: Skipping new test on WK2 since it uses eventSender.
+
 2015-03-19  Dean Jackson  <[email protected]>
 
         http://webkit.org/b/142790
@@ -122,6 +134,7 @@
         * fast/repaint/multiple-backgrounds-style-change-expected.txt: Added.
         * fast/repaint/multiple-backgrounds-style-change.html: Added.
 
+>>>>>>> .r181712
 2015-03-18  Marcos Chavarría Teijeiro  <[email protected]>
 
         Unreviewed GTK Gardening 18th March

Added: trunk/LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt (0 => 181760)


--- trunk/LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt	2015-03-19 21:59:23 UTC (rev 181760)
@@ -0,0 +1,11 @@
+These tests dragging an attachment element into contenteditable
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS target.getElementsByTagName("attachment").length is 1
+PASS target.getElementsByTagName("attachment")[0].file.name is "apple.gif"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html (0 => 181760)


--- trunk/LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html	2015-03-19 21:59:23 UTC (rev 181760)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+#target {
+    height: 200px;
+    width: 220px;
+    border: 5px solid blue;
+}
+</style>
+</head>
+<body _onload_="runTest()">
+<p id="description"></p>
+<div id="test1"><attachment id='attachment'></attachment></div>
+<div contenteditable=true id="target"></div>
+<div id="console"></div>
+
+<script>
+    description('These tests dragging an attachment element into contenteditable');
+var jsTestIsAsync = true;
+var target = document.getElementById('target');
+
+function contentInserted() {
+    shouldBe('target.getElementsByTagName("attachment").length', '1');
+    shouldBeEqualToString('target.getElementsByTagName("attachment")[0].file.name', 'apple.gif');
+    finishJSTest();
+}
+
+function setupAttachment() {
+    if (window.internals) {
+        var attachment = document.getElementById('attachment');
+        attachment.file = window.internals.createFile("resources/apple.gif");
+    }
+}
+
+function runTest() {
+    setupAttachment();
+    target.addEventListener('DOMNodeInserted', contentInserted, false);
+    if (!window.testRunner)
+        return;
+    
+    testRunner.waitUntilDone();
+
+    e = document.getElementById("attachment");
+    x = e.offsetLeft + e.offsetWidth / 2;
+    y = e.offsetTop + e.offsetHeight / 2;
+
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.leapForward(100);
+    e = document.getElementById("target");
+    x = e.offsetLeft + e.offsetWidth / 2;
+    y = e.offsetTop + e.offsetHeight / 2;
+
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseUp();
+}
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (181759 => 181760)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2015-03-19 21:59:23 UTC (rev 181760)
@@ -23,6 +23,7 @@
 editing/pasteboard/drag-and-drop-image-contenteditable.html
 editing/pasteboard/drag-and-drop-inputimage-contenteditable.html
 editing/pasteboard/drag-and-drop-objectimage-contenteditable.html
+editing/pasteboard/drag-and-drop-attachment-contenteditable.html
 editing/pasteboard/drag-drop-dead-frame.html
 editing/pasteboard/drag-drop-input-textarea.html
 editing/pasteboard/drag-drop-list.html

Modified: trunk/Source/WebCore/ChangeLog (181759 => 181760)


--- trunk/Source/WebCore/ChangeLog	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/ChangeLog	2015-03-19 21:59:23 UTC (rev 181760)
@@ -1,3 +1,39 @@
+2015-03-19  Enrica Casucci  <[email protected]>
+
+        <attachment> should put URLs on the pasteboard so that Finder can accept drops.
+        https://bugs.webkit.org/show_bug.cgi?id=142801
+        rdar://problem/19982527
+
+        Reviewed by Tim Horton.
+
+        Test: editing/pasteboard/drag-and-drop-attachment-contenteditable.html
+
+        This patch adds all the necessary support to write attachment elements into
+        the pasteboard, including the promised type.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/DragActions.h:
+        * page/DragClient.h:
+        (WebCore::DragClient::declareAndWriteAttachment):
+        * page/DragController.cpp:
+        (WebCore::DragController::draggableElement):
+        (WebCore::DragController::startDrag):
+        * page/DragController.h:
+        (WebCore::DragController::draggingAttachmentURL):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::dragHysteresisExceeded):
+        (WebCore::EventHandler::handleDrag):
+        * page/mac/DragControllerMac.mm:
+        (WebCore::DragController::declareAndWriteAttachment):
+        * page/win/DragControllerWin.cpp:
+        (WebCore::DragController::declareAndWriteAttachment):
+        * platform/URL.cpp:
+        (WebCore::URL::fileURLWithFileSystemPath):
+        * platform/URL.h:
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::absoluteAttachmentURL):
+        * rendering/HitTestResult.h:
+
 2015-03-19  Chris Dumez  <[email protected]>
 
         Unreviewed, fix linking error after r181753.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (181759 => 181760)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-03-19 21:59:23 UTC (rev 181760)
@@ -2527,7 +2527,7 @@
 		7CC69941191EC5F500AF2270 /* JSWebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */; };
 		7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
 		7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; };
-		7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; };
+		7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7CDEEE1E197610D700E352CD /* ViewStateChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDEEE1D197610D700E352CD /* ViewStateChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */; };
 		7CE68345192143A800F4D928 /* UserMessageHandlerDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };

Modified: trunk/Source/WebCore/page/DragActions.h (181759 => 181760)


--- trunk/Source/WebCore/page/DragActions.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/DragActions.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -46,6 +46,9 @@
         DragSourceActionImage        = 2,
         DragSourceActionLink         = 4,
         DragSourceActionSelection    = 8,
+#if ENABLE(ATTACHMENT_ELEMENT)
+        DragSourceActionAttachment   = 16,
+#endif
         DragSourceActionAny          = UINT_MAX
     } DragSourceAction;
     

Modified: trunk/Source/WebCore/page/DragClient.h (181759 => 181760)


--- trunk/Source/WebCore/page/DragClient.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/DragClient.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -55,7 +55,10 @@
     // Mac-specific helper function to allow access to web archives and NSPasteboard extras in WebKit.
     // This is not abstract as that would require another #if PLATFORM(COCOA) for the SVGImage client empty implentation.
     virtual void declareAndWriteDragImage(const String&, Element&, const URL&, const String&, Frame*) { }
+#if ENABLE(ATTACHMENT_ELEMENT)
+    virtual void declareAndWriteAttachment(const String&, Element&, const URL&, const String&, Frame*) { }
 #endif
+#endif
 
     virtual ~DragClient() { }
 };

Modified: trunk/Source/WebCore/page/DragController.cpp (181759 => 181760)


--- trunk/Source/WebCore/page/DragController.cpp	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/DragController.cpp	2015-03-19 21:59:23 UTC (rev 181760)
@@ -49,6 +49,7 @@
 #include "FrameSelection.h"
 #include "FrameView.h"
 #include "HTMLAnchorElement.h"
+#include "HTMLAttachmentElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
@@ -623,6 +624,14 @@
     state.type = (sourceFrame->selection().contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone;
     if (!startElement)
         return nullptr;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    // Unlike image elements, attachment elements are immediately selected upon mouse down,
+    // but for those elements we still want to use the single element drag behavior as long as
+    // the element is the only content of the selection.
+    const VisibleSelection& selection = sourceFrame->selection().selection();
+    if (selection.isRange() && is<HTMLAttachmentElement>(selection.start().anchorNode()) && selection.start().anchorNode() == selection.end().anchorNode())
+        state.type = DragSourceActionNone;
+#endif
 
     for (auto renderer = startElement->renderer(); renderer; renderer = renderer->parent()) {
         Element* element = renderer->nonPseudoElement();
@@ -649,6 +658,14 @@
                 state.type = static_cast<DragSourceAction>(state.type | DragSourceActionLink);
                 return element;
             }
+#if ENABLE(ATTACHMENT_ELEMENT)
+            if ((m_dragSourceAction & DragSourceActionAttachment)
+                && is<HTMLAttachmentElement>(*element)
+                && downcast<HTMLAttachmentElement>(*element).file()) {
+                state.type = static_cast<DragSourceAction>(state.type | DragSourceActionAttachment);
+                return element;
+            }
+#endif
         }
     }
 
@@ -738,6 +755,10 @@
         return false;
     URL linkURL = hitTestResult.absoluteLinkURL();
     URL imageURL = hitTestResult.absoluteImageURL();
+#if ENABLE(ATTACHMENT_ELEMENT)
+    URL attachmentURL = hitTestResult.absoluteAttachmentURL();
+    m_draggingAttachmentURL = URL();
+#endif
 
     IntPoint mouseDraggedPoint = src.view()->windowToContents(dragEvent.position());
 
@@ -853,6 +874,23 @@
             dragImage = scaleDragImage(dragImage, FloatSize(m_page.deviceScaleFactor(), m_page.deviceScaleFactor()));
         }
         doSystemDrag(dragImage, dragLoc, mouseDraggedPoint, dataTransfer, src, true);
+#if ENABLE(ATTACHMENT_ELEMENT)
+    } else if (!attachmentURL.isEmpty() && (m_dragSourceAction & DragSourceActionAttachment)) {
+        if (!dataTransfer.pasteboard().hasData()) {
+            m_draggingAttachmentURL = attachmentURL;
+            selectElement(element);
+            declareAndWriteAttachment(dataTransfer, element, attachmentURL);
+        }
+        
+        m_client.willPerformDragSourceAction(DragSourceActionAttachment, dragOrigin, dataTransfer);
+        
+        if (!dragImage) {
+            dragImage = dissolveDragImageToFraction(createDragImageForSelection(src), DragImageAlpha);
+            dragLoc = dragLocForSelectionDrag(src);
+            m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
+        }
+        doSystemDrag(dragImage, dragLoc, dragOrigin, dataTransfer, src, false);
+#endif
     } else if (state.type == DragSourceActionDHTML) {
         if (dragImage) {
             ASSERT(m_dragSourceAction & DragSourceActionDHTML);

Modified: trunk/Source/WebCore/page/DragController.h (181759 => 181760)


--- trunk/Source/WebCore/page/DragController.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/DragController.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -73,6 +73,9 @@
         bool didInitiateDrag() const { return m_didInitiateDrag; }
         DragOperation sourceDragOperation() const { return m_sourceDragOperation; }
         const URL& draggingImageURL() const { return m_draggingImageURL; }
+#if ENABLE(ATTACHMENT_ELEMENT)
+        const URL& draggingAttachmentURL() const { return m_draggingAttachmentURL; }
+#endif
         void setDragOffset(const IntPoint& offset) { m_dragOffset = offset; }
         const IntPoint& dragOffset() const { return m_dragOffset; }
         DragSourceAction dragSourceAction() const { return m_dragSourceAction; }
@@ -114,7 +117,9 @@
         void doSystemDrag(DragImageRef, const IntPoint&, const IntPoint&, DataTransfer&, Frame&, bool forLink);
         void cleanupAfterSystemDrag();
         void declareAndWriteDragImage(DataTransfer&, Element&, const URL&, const String& label);
-
+#if ENABLE(ATTACHMENT_ELEMENT)
+        void declareAndWriteAttachment(DataTransfer&, Element&, const URL&);
+#endif
         Page& m_page;
         DragClient& m_client;
 
@@ -130,6 +135,9 @@
         DragOperation m_sourceDragOperation; // Set in startDrag when a drag starts from a mouse down within WebKit
         IntPoint m_dragOffset;
         URL m_draggingImageURL;
+#if ENABLE(ATTACHMENT_ELEMENT)
+        URL m_draggingAttachmentURL;
+#endif
     };
 
 }

Modified: trunk/Source/WebCore/page/EventHandler.cpp (181759 => 181760)


--- trunk/Source/WebCore/page/EventHandler.cpp	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2015-03-19 21:59:23 UTC (rev 181760)
@@ -3308,6 +3308,9 @@
         threshold = TextDragHysteresis;
         break;
     case DragSourceActionImage:
+#if ENABLE(ATTACHMENT_ELEMENT)
+    case DragSourceActionAttachment:
+#endif
         threshold = ImageDragHysteresis;
         break;
     case DragSourceActionLink:
@@ -3430,6 +3433,9 @@
         ASSERT((dragState().type & DragSourceActionSelection));
         ASSERT((dragState().type & ~DragSourceActionSelection) == DragSourceActionDHTML
             || (dragState().type & ~DragSourceActionSelection) == DragSourceActionImage
+#if ENABLE(ATTACHMENT_ELEMENT)
+            || (dragState().type & ~DragSourceActionSelection) == DragSourceActionAttachment
+#endif
             || (dragState().type & ~DragSourceActionSelection) == DragSourceActionLink);
         dragState().type = DragSourceActionSelection;
     }

Modified: trunk/Source/WebCore/page/mac/DragControllerMac.mm (181759 => 181760)


--- trunk/Source/WebCore/page/mac/DragControllerMac.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/mac/DragControllerMac.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -36,7 +36,9 @@
 #import "Editor.h"
 #import "EditorClient.h"
 #import "Element.h"
+#import "File.h"
 #import "FrameView.h"
+#import "HTMLAttachmentElement.h"
 #import "MainFrame.h"
 #import "Page.h"
 #import "Pasteboard.h"
@@ -87,6 +89,14 @@
         dragEnded();
 }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+void DragController::declareAndWriteAttachment(DataTransfer& dataTransfer, Element& element, const URL& url)
+{
+    const HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(element);
+    m_client.declareAndWriteAttachment(dataTransfer.pasteboard().name(), element, url, attachment.file()->path(), element.document().frame());
+}
+#endif
+    
 void DragController::declareAndWriteDragImage(DataTransfer& dataTransfer, Element& element, const URL& url, const String& label)
 {
     m_client.declareAndWriteDragImage(dataTransfer.pasteboard().name(), element, url, label, element.document().frame());

Modified: trunk/Source/WebCore/page/win/DragControllerWin.cpp (181759 => 181760)


--- trunk/Source/WebCore/page/win/DragControllerWin.cpp	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/page/win/DragControllerWin.cpp	2015-03-19 21:59:23 UTC (rev 181760)
@@ -69,6 +69,12 @@
 {
 }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+void DragController::declareAndWriteAttachment(DataTransfer&, Element&, const URL&)
+{
+}
+#endif
+
 void DragController::declareAndWriteDragImage(DataTransfer& dataTransfer, Element& element, const URL& url, const String& label)
 {
     Pasteboard& pasteboard = dataTransfer.pasteboard();

Modified: trunk/Source/WebCore/platform/URL.cpp (181759 => 181760)


--- trunk/Source/WebCore/platform/URL.cpp	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/platform/URL.cpp	2015-03-19 21:59:23 UTC (rev 181760)
@@ -2119,4 +2119,9 @@
     return URL(URL(), "webkit-fake-url://" + createCanonicalUUIDString() + '/' + relativePart);
 }
 
+URL URL::fileURLWithFileSystemPath(const String& filePath)
+{
+    return URL(URL(), "file:///" + filePath);
 }
+
+}

Modified: trunk/Source/WebCore/platform/URL.h (181759 => 181760)


--- trunk/Source/WebCore/platform/URL.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/platform/URL.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -73,6 +73,7 @@
     URL(const URL& base, const String& relative, const TextEncoding&);
 
     static URL fakeURLWithRelativePart(const String&);
+    static URL fileURLWithFileSystemPath(const String&);
 
     String strippedForUseAsReferrer() const;
 

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (181759 => 181760)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2015-03-19 21:59:23 UTC (rev 181760)
@@ -25,11 +25,13 @@
 #include "CachedImage.h"
 #include "DocumentMarkerController.h"
 #include "Editor.h"
+#include "File.h"
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "FrameTree.h"
 #include "HTMLAnchorElement.h"
 #include "HTMLAreaElement.h"
+#include "HTMLAttachmentElement.h"
 #include "HTMLAudioElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
@@ -310,6 +312,25 @@
     return m_innerNonSharedNode->renderBox()->absoluteContentQuad().enclosingBoundingBox();
 }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+URL HitTestResult::absoluteAttachmentURL() const
+{
+    if (!m_innerNonSharedNode)
+        return URL();
+    
+    if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isAttachment()))
+        return URL();
+    
+    if (!is<HTMLAttachmentElement>(*m_innerNonSharedNode))
+        return URL();
+    File* attachmentFile = downcast<HTMLAttachmentElement>(*m_innerNonSharedNode).file();
+    if (!attachmentFile)
+        return URL();
+    
+    return URL::fileURLWithFileSystemPath(attachmentFile->path());
+}
+#endif
+
 URL HitTestResult::absoluteImageURL() const
 {
     if (!m_innerNonSharedNode)

Modified: trunk/Source/WebCore/rendering/HitTestResult.h (181759 => 181760)


--- trunk/Source/WebCore/rendering/HitTestResult.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebCore/rendering/HitTestResult.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -106,6 +106,9 @@
     WEBCORE_EXPORT URL absolutePDFURL() const;
     WEBCORE_EXPORT URL absoluteMediaURL() const;
     WEBCORE_EXPORT URL absoluteLinkURL() const;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    WEBCORE_EXPORT URL absoluteAttachmentURL() const;
+#endif
     WEBCORE_EXPORT String textContent() const;
     WEBCORE_EXPORT bool isLiveLink() const;
     bool isOverLink() const;

Modified: trunk/Source/WebKit/mac/ChangeLog (181759 => 181760)


--- trunk/Source/WebKit/mac/ChangeLog	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit/mac/ChangeLog	2015-03-19 21:59:23 UTC (rev 181760)
@@ -1,3 +1,23 @@
+2015-03-19  Enrica Casucci  <[email protected]>
+
+        <attachment> should put URLs on the pasteboard so that Finder can accept drops.
+        https://bugs.webkit.org/show_bug.cgi?id=142801
+        rdar://problem/19982527
+
+        Reviewed by Tim Horton.
+
+        This patch adds all the necessary support to write attachment elements into
+        the pasteboard, including the promised type in WK1.
+
+        * Misc/WebNSPasteboardExtras.mm:
+        (-[NSPasteboard _web_declareAndWriteDragImageForElement:URL:title:archive:source:]):
+        * WebCoreSupport/WebDragClient.h:
+        * WebCoreSupport/WebDragClient.mm:
+        (WebDragClient::declareAndWriteAttachment):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]):
+        * WebView/WebUIDelegate.h:
+
 2015-03-19  Chris Dumez  <[email protected]>
 
         Clean up DOMTimer related settings

Modified: trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm (181759 => 181760)


--- trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -42,6 +42,7 @@
 #import <WebCore/Element.h>
 #import <WebCore/Image.h>
 #import <WebCore/MIMETypeRegistry.h>
+#import <WebCore/RenderAttachment.h>
 #import <WebCore/RenderImage.h>
 #import <WebKitLegacy/DOMExtensions.h>
 #import <WebKitLegacy/DOMPrivate.h>
@@ -271,21 +272,30 @@
     ASSERT(self == [NSPasteboard pasteboardWithName:NSDragPboard]);
 
     NSString *extension = @"";
+    RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]);
     if (auto* renderer = core(element)->renderer()) {
         if (is<RenderImage>(*renderer)) {
             if (CachedImage* image = downcast<RenderImage>(*renderer).cachedImage()) {
                 extension = image->image()->filenameExtension();
                 if (![extension length])
                     return nullptr;
+                [types addObjectsFromArray:[NSPasteboard _web_writableTypesForImageIncludingArchive:(archive != nil)]];
+                [self declareTypes:types.get() owner:source];
             }
         }
+#if ENABLE(ATTACHMENT_ELEMENT)
+        else if (is<RenderAttachment>(*renderer)) {
+            extension = URL.pathExtension;
+            [types addObjectsFromArray:[NSPasteboard _web_dragTypesForURL]];
+            [self declareTypes:types.get() owner:source];
+            RetainPtr<NSMutableArray> paths = adoptNS([[NSMutableArray alloc] init]);
+            [paths.get() addObject:title];
+            [self setPropertyList:paths.get() forType:NSFilenamesPboardType];
+        }
+#endif
     }
 
-    NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil];
-    [types addObjectsFromArray:[NSPasteboard _web_writableTypesForImageIncludingArchive:(archive != nil)]];
-    [self declareTypes:types owner:source];    
-    [self _web_writeImage:nil element:element URL:URL title:title archive:archive types:types source:source];
-    [types release];
+    [self _web_writeImage:nil element:element URL:URL title:title archive:archive types:types.get() source:source];
 
     NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil];
     [self setPropertyList:extensions forType:NSFilesPromisePboardType];

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h (181759 => 181760)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -39,6 +39,9 @@
     virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
     virtual void startDrag(WebCore::DragImageRef, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::DataTransfer&, WebCore::Frame&, bool linkDrag) override;
     virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) override;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    virtual void declareAndWriteAttachment(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String& path, WebCore::Frame*) override;
+#endif
 private:
     WebView* m_webView;
 };

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm (181759 => 181760)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -127,11 +127,17 @@
 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& title, WebCore::Frame* frame)
 {
     ASSERT(pasteboardName);
-    WebHTMLView *source = getTopHTMLView(frame);
-    WebArchive *archive = [kit(&element) webArchive];
+    [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:title archive:[kit(&element) webArchive] source:getTopHTMLView(frame)];
+}
+
+#if ENABLE(ATTACHMENT_ELEMENT)
+void WebDragClient::declareAndWriteAttachment(const String& pasteboardName, Element& element, const URL& url, const String& path, WebCore::Frame* frame)
+{
+    ASSERT(pasteboardName);
     
-    [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:title archive:archive source:source];
+    [[NSPasteboard pasteboardWithName:pasteboardName] _web_declareAndWriteDragImageForElement:kit(&element) URL:url title:path archive:nil source:getTopHTMLView(frame)];
 }
+#endif
 
 void WebDragClient::dragControllerDestroyed() 
 {

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (181759 => 181760)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -3962,12 +3962,12 @@
 - (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
 {
     NSFileWrapper *wrapper = nil;
-    NSURL *draggingImageURL = nil;
+    NSURL *draggingElementURL = nil;
     
     if (WebCore::CachedImage* tiffResource = [self promisedDragTIFFDataSource]) {
         if (auto* buffer = tiffResource->resourceBuffer()) {
             NSURLResponse *response = tiffResource->response().nsURLResponse();
-            draggingImageURL = [response URL];
+            draggingElementURL = [response URL];
             wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:buffer->createNSData().get()] autorelease];
             NSString* filename = [response suggestedFilename];
             NSString* trueExtension(tiffResource->image()->filenameExtension());
@@ -3988,10 +3988,14 @@
             return nil; 
         
         const URL& imageURL = page->dragController().draggingImageURL();
-        ASSERT(!imageURL.isEmpty());
-        draggingImageURL = imageURL;
+        if (!imageURL.isEmpty())
+            draggingElementURL = imageURL;
+#if ENABLE(ATTACHMENT_ELEMENT)
+        else
+            draggingElementURL = page->dragController().draggingAttachmentURL();
+#endif
 
-        wrapper = [[self _dataSource] _fileWrapperForURL:draggingImageURL];
+        wrapper = [[self _dataSource] _fileWrapperForURL:draggingElementURL];
     }
     
     if (wrapper == nil) {
@@ -4005,8 +4009,8 @@
     if (![wrapper writeToURL:[NSURL fileURLWithPath:path] options:NSFileWrapperWritingWithNameUpdating originalContentsURL:nil error:nullptr])
         LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToURL:options:originalContentsURL:error:]");
     
-    if (draggingImageURL)
-        [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingImageURL absoluteString] referrer:nil atPath:path];
+    if (draggingElementURL)
+        [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingElementURL absoluteString] referrer:nil atPath:path];
     
     return [NSArray arrayWithObject:[path lastPathComponent]];
 }

Modified: trunk/Source/WebKit/mac/WebView/WebUIDelegate.h (181759 => 181760)


--- trunk/Source/WebKit/mac/WebView/WebUIDelegate.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit/mac/WebView/WebUIDelegate.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -112,6 +112,7 @@
     WebDragSourceActionImage        = 2,
     WebDragSourceActionLink         = 4,
     WebDragSourceActionSelection    = 8,
+    WebDragSourceActionAttachment   = 16,
     WebDragSourceActionAny          = UINT_MAX
 };
 

Modified: trunk/Source/WebKit2/ChangeLog (181759 => 181760)


--- trunk/Source/WebKit2/ChangeLog	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/ChangeLog	2015-03-19 21:59:23 UTC (rev 181760)
@@ -1,3 +1,37 @@
+2015-03-19  Enrica Casucci  <[email protected]>
+
+        <attachment> should put URLs on the pasteboard so that Finder can accept drops.
+        https://bugs.webkit.org/show_bug.cgi?id=142801
+        rdar://problem/19982527
+
+        Reviewed by Tim Horton.
+
+        This patch adds all the necessary support to write attachment elements into
+        the pasteboard, including the promised type in WK2.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _setPromisedDataForImage:withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:forPasteboard:]):
+        (-[WKView _setPromisedDataForAttachment:withExtension:withTitle:withURL:withVisibleURL:forPasteboard:]):
+        (-[WKView namesOfPromisedFilesDroppedAtDestination:]):
+        (-[WKView _setPromisedData:withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:forPasteboard:]): Deleted.
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setPromisedDataForImage):
+        (WebKit::PageClientImpl::setPromisedDataForAttachment):
+        (WebKit::PageClientImpl::setPromisedData): Deleted.
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::setPromisedDataForImage):
+        (WebKit::WebPageProxy::setPromisedDataForAttachment):
+        (WebKit::WebPageProxy::setPromisedData): Deleted.
+        * WebProcess/WebCoreSupport/WebDragClient.h:
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::declareAndWriteAttachment):
+        (WebKit::WebDragClient::declareAndWriteDragImage):
+
 2015-03-19  Anders Carlsson  <[email protected]>
 
         Cache::remove should take a Key instead of an entry

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -3379,31 +3379,54 @@
                                                                      && hasCaseInsensitiveSuffix(filename, @".jpg"));
 }
 
-- (void)_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName
-
+- (void)_setFileAndURLTypes:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl forPasteboard:(NSPasteboard *)pasteboard
 {
-    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName];
-    RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]);
-    
-    [types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()];
-    [pasteboard declareTypes:types.get() owner:self];
     if (!matchesExtensionOrEquivalent(filename, extension))
         filename = [[filename stringByAppendingString:@"."] stringByAppendingString:extension];
-
+    
     [pasteboard setString:visibleUrl forType:NSStringPboardType];
     [pasteboard setString:visibleUrl forType:PasteboardTypes::WebURLPboardType];
     [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType];
     [pasteboard setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:visibleUrl], [NSArray arrayWithObject:title], nil] forType:PasteboardTypes::WebURLsWithTitlesPboardType];
     [pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType];
+    _data->_promisedFilename = filename;
+    _data->_promisedURL = url;
+}
 
+- (void)_setPromisedDataForImage:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName
+
+{
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName];
+    RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]);
+    
+    [types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()];
+    [pasteboard declareTypes:types.get() owner:self];
+    [self _setFileAndURLTypes:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl forPasteboard:pasteboard];
+
     if (archiveBuffer)
         [pasteboard setData:archiveBuffer->createNSData().get() forType:PasteboardTypes::WebArchivePboardType];
 
     _data->_promisedImage = image;
-    _data->_promisedFilename = filename;
-    _data->_promisedURL = url;
 }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+- (void)_setPromisedDataForAttachment:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl forPasteboard:(NSString *)pasteboardName
+
+{
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName];
+    RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]);
+    [types addObjectsFromArray:PasteboardTypes::forURL()];
+    [pasteboard declareTypes:types.get() owner:self];
+    [self _setFileAndURLTypes:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl forPasteboard:pasteboard];
+
+    RetainPtr<NSMutableArray> paths = adoptNS([[NSMutableArray alloc] init]);
+    [paths addObject:title];
+    [pasteboard setPropertyList:paths.get() forType:NSFilenamesPboardType];
+
+    _data->_promisedImage = nullptr;
+}
+#endif
+
 - (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard
 {
     _data->_promisedImage = 0;
@@ -3467,10 +3490,12 @@
     if (_data->_promisedImage) {
         data = ""
         wrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:data.get()]);
+    } else
+        wrapper = adoptNS([[NSFileWrapper alloc] initWithURL:[NSURL URLWithString:_data->_promisedURL] options:NSFileWrapperReadingImmediate error:nil]);
+    
+    if (wrapper)
         [wrapper setPreferredFilename:_data->_promisedFilename];
-    }
-    
-    if (!wrapper) {
+    else {
         LOG_ERROR("Failed to create image file.");
         return nil;
     }

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -101,7 +101,10 @@
 - (void)_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
 
 - (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
-- (void)_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName;
+- (void)_setPromisedDataForImage:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName;
+#if ENABLE(ATTACHMENT_ELEMENT)
+- (void)_setPromisedDataForAttachment:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl forPasteboard:(NSString *)pasteboardName;
+#endif
 - (void)_updateSecureInputState;
 - (void)_resetSecureInputState;
 - (void)_notifyInputContextAboutDiscardedComposition;

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -191,9 +191,14 @@
 #endif
 
 #if USE(APPKIT)
-    virtual void setPromisedData(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
+    virtual void setPromisedDataForImage(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
                                  const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer) = 0;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    virtual void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title,
+                                         const String& url, const String& visibleUrl) = 0;
+
 #endif
+#endif
 
 #if PLATFORM(GTK)
     virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) = 0;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -769,9 +769,12 @@
     void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
 #if PLATFORM(COCOA)
     void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag);
-    void setPromisedData(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
+    void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
                          const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize);
+#if ENABLE(ATTACHMENT_ELEMENT)
+    void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL);
 #endif
+#endif
 #if PLATFORM(GTK)
     void startDrag(const WebCore::DragData&, const ShareableBitmap::Handle& dragImage);
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-03-19 21:59:23 UTC (rev 181760)
@@ -297,8 +297,11 @@
 #endif
 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
     SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag)
-    SetPromisedData(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
+    SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
+#if ENABLE(ATTACHMENT_ELEMENT)
+    SetPromisedDataForAttachment(String pasteboardName, String filename, String extension, String title, String url, String visibleURL)
 #endif
+#endif
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
     StartDrag(WebCore::DragData dragData, WebKit::ShareableBitmap::Handle dragImage)
 #endif

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -94,8 +94,11 @@
     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
     virtual bool executeSavedCommandBySelector(const String& selector) override;
     virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) override;
-    virtual void setPromisedData(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
+    virtual void setPromisedDataForImage(const String& pasteboardName, PassRefPtr<WebCore::SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title,
         const String& url, const String& visibleUrl, PassRefPtr<WebCore::SharedBuffer> archiveBuffer) override;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    virtual void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl) override;
+#endif
     virtual void updateSecureInputState() override;
     virtual void resetSecureInputState() override;
     virtual void notifyInputContextAboutDiscardedComposition() override;

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -407,13 +407,20 @@
     [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
 }
 
-void PageClientImpl::setPromisedData(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer)
+void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer)
 {
     RefPtr<Image> image = BitmapImage::create();
     image->setData(imageBuffer.get(), true);
-    [m_wkView _setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName];
+    [m_wkView _setPromisedDataForImage:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName];
 }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+void PageClientImpl::setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl)
+{
+    [m_wkView _setPromisedDataForAttachment:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl forPasteboard:pasteboardName];
+}
+#endif
+
 void PageClientImpl::updateSecureInputState()
 {
     [m_wkView _updateSecureInputState];

Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (181759 => 181760)


--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -60,6 +60,7 @@
 @end
 
 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process().connection())
+#define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
 
 using namespace WebCore;
 
@@ -407,9 +408,11 @@
     process().send(Messages::WebPage::DidStartDrag(), m_pageID);
 }
 
-void WebPageProxy::setPromisedData(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
+void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
                                    const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize)
 {
+    MESSAGE_CHECK_URL(url);
+    MESSAGE_CHECK_URL(visibleURL);
     RefPtr<SharedMemory> sharedMemoryImage = SharedMemory::create(imageHandle, SharedMemory::ReadOnly);
     RefPtr<SharedBuffer> imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), imageSize);
     RefPtr<SharedBuffer> archiveBuffer;
@@ -418,9 +421,18 @@
         RefPtr<SharedMemory> sharedMemoryArchive = SharedMemory::create(archiveHandle, SharedMemory::ReadOnly);;
         archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), archiveSize);
     }
-    m_pageClient.setPromisedData(pasteboardName, imageBuffer, filename, extension, title, url, visibleURL, archiveBuffer);
+    m_pageClient.setPromisedDataForImage(pasteboardName, imageBuffer, filename, extension, title, url, visibleURL, archiveBuffer);
 }
+
+#if ENABLE(ATTACHMENT_ELEMENT)
+void WebPageProxy::setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL)
+{
+    MESSAGE_CHECK_URL(url);
+    MESSAGE_CHECK_URL(visibleURL);
+    m_pageClient.setPromisedDataForAttachment(pasteboardName, filename, extension, title, url, visibleURL);
+}
 #endif
+#endif
 
 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
 {

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h (181759 => 181760)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h	2015-03-19 21:59:23 UTC (rev 181760)
@@ -51,7 +51,10 @@
 
 #if PLATFORM(COCOA)
     virtual void declareAndWriteDragImage(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String&, WebCore::Frame*) override;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    virtual void declareAndWriteAttachment(const String& pasteboardName, WebCore::Element&, const WebCore::URL&, const String& path, WebCore::Frame*) override;
 #endif
+#endif
 
     virtual void dragControllerDestroyed() override;
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (181759 => 181760)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2015-03-19 21:44:59 UTC (rev 181759)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2015-03-19 21:59:23 UTC (rev 181760)
@@ -97,6 +97,16 @@
     return image;
 }
 
+#if ENABLE(ATTACHMENT_ELEMENT)
+void WebDragClient::declareAndWriteAttachment(const String& pasteboardName, Element& element, const URL& url, const String& path, WebCore::Frame* frame)
+{
+    ASSERT(pasteboardName == String(NSDragPboard));
+    
+    NSURL* nsURL = (NSURL *)url;
+    m_page->send(Messages::WebPageProxy::SetPromisedDataForAttachment(pasteboardName, String(nsURL.lastPathComponent), String(nsURL.pathExtension), path, String(nsURL.absoluteString), userVisibleString(nsURL)));
+}
+#endif
+
 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, Frame*)
 {
     ASSERT(pasteboardName == String(NSDragPboard));
@@ -143,7 +153,7 @@
         memcpy(archiveSharedMemoryBuffer->data(), archiveBuffer->data(), archiveSize);
         archiveSharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly);
     }
-    m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
+    m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to