Refactor drag and drop implementation on Mac
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2017 02:01:29 +0000 (02:01 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2017 02:01:29 +0000 (02:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167427

Reviewed by Enrica Casucci.

Source/WebCore:

Refactors some code around drag and drop on Mac, and cleans up some other related code as needed. This patch
should result in no behavior change.

* dom/DataTransfer.cpp:
* page/EventHandler.cpp:
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::eventLoopHandleMouseDragged):
* page/mac/EventHandlerMac.mm:
* platform/DragImage.cpp:
* platform/Pasteboard.h:
* platform/ios/DragImageIOS.mm:
* platform/ios/PasteboardIOS.mm:
* platform/mac/DragDataMac.mm:
(rtfPasteboardType):
(rtfdPasteboardType):
(stringPasteboardType):
(urlPasteboardType):
(htmlPasteboardType):
(colorPasteboardType):
(pdfPasteboardType):
(tiffPasteboardType):
(WebCore::DragData::DragData):
(WebCore::DragData::containsColor):
(WebCore::DragData::containsFiles):
(WebCore::DragData::numberOfFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsPromise):
(WebCore::DragData::asURL):
* platform/mac/DragImageMac.mm:

Source/WebKit/mac:

Refactor some WebKit1 code on the Mac pertaining to drag and drop. See WebCore ChangeLog for more details.

* Misc/WebNSPasteboardExtras.h:
* WebCoreSupport/WebDragClient.mm:
* WebView/WebFrame.mm:
* WebView/WebFrameInternal.h:
* WebView/WebHTMLView.mm:
* WebView/WebView.mm:
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):

Source/WebKit2:

See WebCore ChangeLog for more details.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DragData>::encode):
(IPC::ArgumentCoder<DragData>::decode):
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:

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

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/DataTransfer.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/ios/EventHandlerIOS.mm
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/platform/DragImage.cpp
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/ios/DragImageIOS.mm
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/platform/mac/DragDataMac.mm
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebFrameInternal.h
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm

index 1c97b6e..f37b961 100644 (file)
@@ -1,3 +1,42 @@
+2017-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor drag and drop implementation on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=167427
+
+        Reviewed by Enrica Casucci.
+
+        Refactors some code around drag and drop on Mac, and cleans up some other related code as needed. This patch
+        should result in no behavior change.
+
+        * dom/DataTransfer.cpp:
+        * page/EventHandler.cpp:
+        * page/ios/EventHandlerIOS.mm:
+        (WebCore::EventHandler::eventLoopHandleMouseDragged):
+        * page/mac/EventHandlerMac.mm:
+        * platform/DragImage.cpp:
+        * platform/Pasteboard.h:
+        * platform/ios/DragImageIOS.mm:
+        * platform/ios/PasteboardIOS.mm:
+        * platform/mac/DragDataMac.mm:
+        (rtfPasteboardType):
+        (rtfdPasteboardType):
+        (stringPasteboardType):
+        (urlPasteboardType):
+        (htmlPasteboardType):
+        (colorPasteboardType):
+        (pdfPasteboardType):
+        (tiffPasteboardType):
+        (WebCore::DragData::DragData):
+        (WebCore::DragData::containsColor):
+        (WebCore::DragData::containsFiles):
+        (WebCore::DragData::numberOfFiles):
+        (WebCore::DragData::asFilenames):
+        (WebCore::DragData::containsPlainText):
+        (WebCore::DragData::containsCompatibleContent):
+        (WebCore::DragData::containsPromise):
+        (WebCore::DragData::asURL):
+        * platform/mac/DragImageMac.mm:
+
 2017-01-25  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] Add support for incoming and outgoing libwebrtc audio tracks
index 561eb42..9ecb351 100644 (file)
@@ -290,7 +290,7 @@ void DataTransfer::updateDragImage()
     m_pasteboard->setDragImage(computedImage, computedHotSpot);
 }
 
-#if !PLATFORM(COCOA)
+#if !PLATFORM(MAC)
 
 DragImageRef DataTransfer::createDragImage(IntPoint& location) const
 {
index 5a5a35e..ee4e772 100644 (file)
@@ -131,6 +131,9 @@ const int LinkDragHysteresis = 40;
 const int ImageDragHysteresis = 5;
 const int TextDragHysteresis = 3;
 const int GeneralDragHysteresis = 3;
+#if PLATFORM(COCOA)
+const double EventHandler::TextDragDelay = 0.15;
+#endif
 #endif // ENABLE(DRAG_SUPPORT)
 
 #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
@@ -806,14 +809,14 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
 }
 
 #if ENABLE(DRAG_SUPPORT)
-bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event)
+bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event, CheckDragHysteresis checkDragHysteresis)
 {
     if (!m_mousePressed)
         return false;
 
     Ref<Frame> protectedFrame(m_frame);
 
-    if (handleDrag(event, ShouldCheckDragHysteresis))
+    if (handleDrag(event, checkDragHysteresis))
         return true;
 
     Node* targetNode = event.targetNode();
index 6ed7ae3..9c75765 100644 (file)
@@ -338,7 +338,7 @@ private:
     bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
 
 #if ENABLE(DRAG_SUPPORT)
-    bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
+    bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis);
 #endif
 
     WEBCORE_EXPORT bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
index 29badef..d3f75d9 100644 (file)
 #import <WebKitAdditions/EventHandlerIOSTouch.cpp>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/EventHandlerAdditions.mm>)
+#import <WebKitAdditions/EventHandlerAdditions.mm>
+#endif
+
 namespace WebCore {
 
 static RetainPtr<WebEvent>& currentEventSlot()
index ad7a59e..6c444aa 100644 (file)
 
 namespace WebCore {
 
-#if ENABLE(DRAG_SUPPORT)
-const double EventHandler::TextDragDelay = 0.15;
-#endif
-
 const double resetLatchedStateTimeout = 0.1;
 
 static RetainPtr<NSEvent>& currentNSEventSlot()
index aa566af..d8b5dea 100644 (file)
@@ -120,12 +120,16 @@ DragImageRef createDragImageForNode(Frame& frame, Node& node)
     return createDragImageFromSnapshot(snapshotNode(frame, node), &node);
 }
 
+#if !ENABLE(DATA_INTERACTION)
+
 DragImageRef createDragImageForSelection(Frame& frame, bool forceBlackText)
 {
     SnapshotOptions options = forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone;
     return createDragImageFromSnapshot(snapshotSelection(frame, options), nullptr);
 }
 
+#endif
+
 struct ScopedFrameSelectionState {
     ScopedFrameSelectionState(Frame& frame)
         : frame(frame)
index bac1f8f..06c3de7 100644 (file)
@@ -129,7 +129,7 @@ public:
 
 struct PasteboardPlainText {
     String text;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     bool isURL;
 #endif
 };
@@ -179,8 +179,8 @@ public:
     virtual void writePasteboard(const Pasteboard& sourcePasteboard);
 
 #if ENABLE(DRAG_SUPPORT)
-    static std::unique_ptr<Pasteboard> createForDragAndDrop();
-    static std::unique_ptr<Pasteboard> createForDragAndDrop(const DragData&);
+    WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForDragAndDrop();
+    WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForDragAndDrop(const DragData&);
 
     virtual void setDragImage(DragImageRef, const IntPoint& hotSpot);
 #endif
index 1cccfba..964ad6e 100644 (file)
 
 #import <CoreGraphics/CoreGraphics.h>
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/DragImageAdditions.mm>)
+
+#import <WebKitAdditions/DragImageAdditions.mm>
+
+#else
+
 namespace WebCore {
 
 // FIXME: fix signature of dragImageSize() to avoid copying the argument.
@@ -49,3 +55,5 @@ RetainPtr<CGImageRef> createDragImageFromImage(Image*, ImageOrientationDescripti
 }
 
 } // namespace WebCore
+
+#endif // USE(APPLE_INTERNAL_SDK)
index 96c72d0..5861393 100644 (file)
 - (BOOL)containsAttachments;
 @end
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PasteboardAdditions.mm>)
+#import <WebKitAdditions/PasteboardAdditions.mm>
+#endif
+
 namespace WebCore {
 
 // FIXME: Does this need to be declared in the header file?
index 75d50bc..0ffed6c 100644 (file)
 #import "PlatformStrategies.h"
 #import "WebCoreNSURLExtras.h"
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/DragDataAdditions.mm>)
+
+#import <WebKitAdditions/DragDataAdditions.mm>
+
+#else
+
+static inline String rtfPasteboardType()
+{
+    return String(NSRTFPboardType);
+}
+
+static inline String rtfdPasteboardType()
+{
+    return String(NSRTFDPboardType);
+}
+
+static inline String stringPasteboardType()
+{
+    return String(NSStringPboardType);
+}
+
+static inline String urlPasteboardType()
+{
+    return String(NSURLPboardType);
+}
+
+static inline String htmlPasteboardType()
+{
+    return String(NSHTMLPboardType);
+}
+
+static inline String colorPasteboardType()
+{
+    return String(NSColorPboardType);
+}
+
+static inline String pdfPasteboardType()
+{
+    return String(NSPDFPboardType);
+}
+
+static inline String tiffPasteboardType()
+{
+    return String(NSTIFFPboardType);
+}
+
+#endif // USE(APPLE_INTERNAL_SDK)
+
 namespace WebCore {
 
 DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, 
@@ -42,7 +90,11 @@ DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPo
     , m_platformDragData(data)
     , m_draggingSourceOperationMask(sourceOperationMask)
     , m_applicationFlags(flags)
+#if PLATFORM(MAC)
     , m_pasteboardName([[m_platformDragData draggingPasteboard] name])
+#else
+    , m_pasteboardName("data interaction pasteboard")
+#endif
 {
 }
 
@@ -66,30 +118,40 @@ bool DragData::containsColor() const
 {
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    return types.contains(String(NSColorPboardType));
+    return types.contains(colorPasteboardType());
 }
 
 bool DragData::containsFiles() const
 {
+#if PLATFORM(MAC)
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
     return types.contains(String(NSFilenamesPboardType)) || types.contains(String(NSFilesPromisePboardType));
+#else
+    return false;
+#endif
 }
 
 unsigned DragData::numberOfFiles() const
 {
     Vector<String> files;
+#if PLATFORM(MAC)
     platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName);
     if (!files.size())
         platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName);
+#endif
     return files.size();
 }
 
 void DragData::asFilenames(Vector<String>& result) const
 {
+#if PLATFORM(MAC)
     platformStrategies()->pasteboardStrategy()->getPathnamesForType(result, String(NSFilenamesPboardType), m_pasteboardName);
     if (!result.size())
         result = fileNames();
+#else
+    UNUSED_PARAM(result);
+#endif
 }
 
 bool DragData::containsPlainText() const
@@ -97,11 +159,13 @@ bool DragData::containsPlainText() const
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
 
-    return types.contains(String(NSStringPboardType))
-        || types.contains(String(NSRTFDPboardType))
-        || types.contains(String(NSRTFPboardType))
+    return types.contains(stringPasteboardType())
+        || types.contains(rtfdPasteboardType())
+        || types.contains(rtfPasteboardType())
+#if PLATFORM(MAC)
         || types.contains(String(NSFilenamesPboardType))
-        || platformStrategies()->pasteboardStrategy()->stringForType(String(NSURLPboardType), m_pasteboardName).length();
+#endif
+        || platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName).length();
 }
 
 String DragData::asPlainText() const
@@ -130,23 +194,27 @@ bool DragData::containsCompatibleContent() const
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
     return types.contains(String(WebArchivePboardType))
-        || types.contains(String(NSHTMLPboardType))
+        || types.contains(htmlPasteboardType())
+#if PLATFORM(MAC)
         || types.contains(String(NSFilenamesPboardType))
         || types.contains(String(NSFilesPromisePboardType))
-        || types.contains(String(NSTIFFPboardType))
-        || types.contains(String(NSPDFPboardType))
-        || types.contains(String(NSURLPboardType))
-        || types.contains(String(NSRTFDPboardType))
-        || types.contains(String(NSRTFPboardType))
-        || types.contains(String(NSStringPboardType))
-        || types.contains(String(NSColorPboardType))
+#endif
+        || types.contains(tiffPasteboardType())
+        || types.contains(pdfPasteboardType())
+        || types.contains(urlPasteboardType())
+        || types.contains(rtfdPasteboardType())
+        || types.contains(rtfPasteboardType())
+        || types.contains(stringPasteboardType())
+        || types.contains(colorPasteboardType())
         || types.contains(String(kUTTypePNG));
 }
 
 bool DragData::containsPromise() const
 {
     Vector<String> files;
+#if PLATFORM(MAC)
     platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName);
+#endif
     return files.size() == 1;
 }
 
@@ -160,24 +228,26 @@ String DragData::asURL(FilenameConversionPolicy, String* title) const
     // FIXME: Use filenamePolicy.
 
     if (title) {
+#if PLATFORM(MAC)
         String URLTitleString = platformStrategies()->pasteboardStrategy()->stringForType(String(WebURLNamePboardType), m_pasteboardName);
         if (!URLTitleString.isEmpty())
             *title = URLTitleString;
+#endif
     }
     
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
 
-    if (types.contains(String(NSURLPboardType))) {
-        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(String(NSURLPboardType), m_pasteboardName)];
+    if (types.contains(urlPasteboardType())) {
+        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName)];
         NSString *scheme = [URLFromPasteboard scheme];
         // Cannot drop other schemes unless <rdar://problem/10562662> and <rdar://problem/11187315> are fixed.
         if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"])
             return [URLByCanonicalizingURL(URLFromPasteboard) absoluteString];
     }
     
-    if (types.contains(String(NSStringPboardType))) {
-        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(String(NSStringPboardType), m_pasteboardName)];
+    if (types.contains(stringPasteboardType())) {
+        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(stringPasteboardType(), m_pasteboardName)];
         NSString *scheme = [URLFromPasteboard scheme];
         // Pasteboard content is not trusted, because JavaScript code can modify it. We can sanitize it for URLs and other typed content, but not for strings.
         // The result of this function is used to initiate navigation, so we shouldn't allow arbitrary file URLs.
@@ -186,6 +256,7 @@ String DragData::asURL(FilenameConversionPolicy, String* title) const
             return [URLByCanonicalizingURL(URLFromPasteboard) absoluteString];
     }
     
+#if PLATFORM(MAC)
     if (types.contains(String(NSFilenamesPboardType))) {
         Vector<String> files;
         platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName);
@@ -199,6 +270,7 @@ String DragData::asURL(FilenameConversionPolicy, String* title) const
 
     if (types.contains(String(NSFilesPromisePboardType)) && fileNames().size() == 1)
         return [URLByCanonicalizingURL([NSURL fileURLWithPath:fileNames()[0]]) absoluteString];
+#endif
 
     return String();        
 }
index d2f8f70..0e9dca1 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "DragImage.h"
 
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 
 #import "BitmapImage.h"
 #import "CoreGraphicsSPI.h"
@@ -348,4 +348,4 @@ DragImageRef createDragImageForLink(URL& url, const String& title, FontRendering
    
 } // namespace WebCore
 
-#endif // ENABLE(DRAG_SUPPORT)
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
index 80c7294..f46ffae 100644 (file)
@@ -1,3 +1,20 @@
+2017-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor drag and drop implementation on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=167427
+
+        Reviewed by Enrica Casucci.
+
+        Refactor some WebKit1 code on the Mac pertaining to drag and drop. See WebCore ChangeLog for more details.
+
+        * Misc/WebNSPasteboardExtras.h:
+        * WebCoreSupport/WebDragClient.mm:
+        * WebView/WebFrame.mm:
+        * WebView/WebFrameInternal.h:
+        * WebView/WebHTMLView.mm:
+        * WebView/WebView.mm:
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+
 2017-01-24  Youenn Fablet  <youennf@gmail.com>
 
         [WebRTC] Introduce libwebrtc abstraction for WK1/WK2 implementations
index ff90d59..e233dd1 100644 (file)
@@ -25,7 +25,7 @@
 
 #import "WebDragClient.h"
 
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 
 #import "DOMElementInternal.h"
 #import "WebArchive.h"
@@ -143,4 +143,4 @@ void WebDragClient::dragControllerDestroyed()
     delete this;
 }
 
-#endif // ENABLE(DRAG_SUPPORT)
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
index bd8a4d5..fec4c60 100644 (file)
@@ -933,7 +933,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     _private->coreFrame->editor().computeAndSetTypingStyle(properties.get(), undoAction);
 }
 
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 - (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation
 {
     if (!_private->coreFrame)
@@ -946,7 +946,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
                              LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), WebCore::ForceAtClick, WebCore::NoTap);
     _private->coreFrame->eventHandler().dragSourceEndedAt(event, (DragOperation)operation);
 }
-#endif
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 
 - (BOOL)_canProvideDocumentSource
 {
index 553c230..5c72d28 100644 (file)
@@ -179,7 +179,7 @@ WebView *getWebView(WebFrame *webFrame);
 - (DOMCSSStyleDeclaration *)_typingStyle;
 - (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
 
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 - (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
 #endif
 
index 0209d81..64e63e2 100644 (file)
@@ -4544,7 +4544,7 @@ static BOOL currentScrollIsBlit(NSView *clipView)
 }
 #endif
 
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 - (void)dragImage:(NSImage *)dragImage
                at:(NSPoint)at
            offset:(NSSize)offset
@@ -4688,7 +4688,7 @@ static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension
     
     return [NSArray arrayWithObject:[path lastPathComponent]];
 }
-#endif
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 
 #if !PLATFORM(IOS)
 - (void)mouseUp:(NSEvent *)event
index 57baa54..9e13f6a 100644 (file)
@@ -1608,7 +1608,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
         makeUniqueRef<WebCore::LibWebRTCProvider>()
     );
     pageConfiguration.chromeClient = new WebChromeClientIOS(self);
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
     pageConfiguration.dragClient = new WebDragClient(self);
 #endif
 
@@ -6475,7 +6475,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     return [self _elementAtWindowPoint:[self convertPoint:point toView:nil]];
 }
 
-#if ENABLE(DRAG_SUPPORT)
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 // The following 2 internal NSView methods are called on the drag destination to make scrolling while dragging work.
 // Scrolling while dragging will only work if the drag destination is in a scroll view. The WebView is the drag destination. 
 // When dragging to a WebView, the document subview should scroll, but it doesn't because it is not the drag destination. 
@@ -6596,7 +6596,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
         return self;
     return hitView;
 }
-#endif
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 
 - (BOOL)acceptsFirstResponder
 {
index d3ab57a..cb402c4 100644 (file)
@@ -1,3 +1,18 @@
+2017-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Refactor drag and drop implementation on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=167427
+
+        Reviewed by Enrica Casucci.
+
+        See WebCore ChangeLog for more details.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<DragData>::encode):
+        (IPC::ArgumentCoder<DragData>::decode):
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+
 2017-01-25  Andy Estes  <aestes@apple.com>
 
         Use #pragma once in a few places
index c6a8571..bf06c0c 100644 (file)
@@ -1223,8 +1223,10 @@ void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
     encoder << dragData.globalPosition();
     encoder.encodeEnum(dragData.draggingSourceOperationMask());
     encoder.encodeEnum(dragData.flags());
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     encoder << dragData.pasteboardName();
+#endif
+#if PLATFORM(MAC)
     encoder << dragData.fileNames();
 #endif
 }
@@ -1248,13 +1250,15 @@ bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
         return false;
 
     String pasteboardName;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     if (!decoder.decode(pasteboardName))
         return false;
 #endif
     Vector<String> fileNames;
+#if PLATFORM(MAC)
     if (!decoder.decode(fileNames))
         return false;
+#endif
 
     dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags);
     dragData.setFileNames(fileNames);
index ba7f7f7..5ff893b 100644 (file)
 #import <WebCore/ValidationBubble.h>
 #import <wtf/cf/TypeCastsCF.h>
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebPageProxyAdditions.mm>)
+#import <WebKitAdditions/WebPageProxyAdditions.mm>
+#endif
+
 namespace WebKit {
 
 #if ENABLE(DATA_DETECTION)
index 88ad5dc..9a84528 100644 (file)
 using namespace WebCore;
 using namespace WebKit;
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebDragClientAdditions.mm>)
+#import <WebKitAdditions/WebDragClientAdditions.mm>
+#endif
+
+#if PLATFORM(MAC)
+
 namespace WebKit {
 
 static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size, Frame& frame)
@@ -160,4 +166,6 @@ void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Eleme
 
 } // namespace WebKit
 
+#endif // PLATFORM(MAC)
+
 #endif // ENABLE(DRAG_SUPPORT)