Data interaction with a URL should navigate the page if the operation is not handled
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2017 23:38:06 +0000 (23:38 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2017 23:38:06 +0000 (23:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168798
<rdar://problem/30665969>

Reviewed by Tim Horton.

Refactors some drag and drop code on the Mac, and implements PlatformPasteboard::stringForType.

* page/DragController.cpp:
(WebCore::DragController::performDragOperation):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::stringForType):
* platform/mac/DragDataMac.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212930 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebCore/platform/mac/DragDataMac.mm

index 9d2a5c3..188dc1a 100644 (file)
@@ -1,3 +1,19 @@
+2017-02-23  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Data interaction with a URL should navigate the page if the operation is not handled
+        https://bugs.webkit.org/show_bug.cgi?id=168798
+        <rdar://problem/30665969>
+
+        Reviewed by Tim Horton.
+
+        Refactors some drag and drop code on the Mac, and implements PlatformPasteboard::stringForType.
+
+        * page/DragController.cpp:
+        (WebCore::DragController::performDragOperation):
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::stringForType):
+        * platform/mac/DragDataMac.mm:
+
 2017-02-23  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] RealtimeOutgoingAudioSource does not need to upsample audio buffers
index e6faabf..cb135b8 100644 (file)
@@ -253,8 +253,12 @@ bool DragController::performDragOperation(const DragData& dragData)
     if (operationForLoad(dragData) == DragOperationNone)
         return false;
 
+    auto urlString = dragData.asURL();
+    if (urlString.isEmpty())
+        return false;
+
     m_client.willPerformDragDestinationAction(DragDestinationActionLoad, dragData);
-    m_page.mainFrame().loader().load(FrameLoadRequest(&m_page.mainFrame(), ResourceRequest(dragData.asURL()), shouldOpenExternalURLsPolicy));
+    m_page.mainFrame().loader().load(FrameLoadRequest(&m_page.mainFrame(), { urlString }, shouldOpenExternalURLsPolicy));
     return true;
 }
 
index 63071f9..eb6b0d2 100644 (file)
@@ -84,8 +84,16 @@ void PlatformPasteboard::getPathnamesForType(Vector<String>&, const String&)
 {
 }
 
-String PlatformPasteboard::stringForType(const String&)
+String PlatformPasteboard::stringForType(const String& type)
 {
+    NSArray *values = [m_pasteboard valuesForPasteboardType:type inItemSet:[NSIndexSet indexSetWithIndex:0]];
+    for (id value in values) {
+        if ([value isKindOfClass:[NSURL class]])
+            return [(NSURL *)value absoluteString];
+
+        if ([value isKindOfClass:[NSString class]])
+            return (NSString *)value;
+    }
     return String();
 }
 
index b687414..98d7b7f 100644 (file)
@@ -220,11 +220,15 @@ bool DragData::containsPromise() const
     return files.size() == 1;
 }
 
+#if !ENABLE(DATA_INTERACTION)
+
 bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
 {
     return !asURL(filenamePolicy).isEmpty();
 }
 
+#endif
+
 String DragData::asURL(FilenameConversionPolicy, String* title) const
 {
     // FIXME: Use filenamePolicy.