Title: [182765] trunk/Source/WebKit2
Revision
182765
Author
[email protected]
Date
2015-04-13 16:23:28 -0700 (Mon, 13 Apr 2015)

Log Message

Clients of WKWebView should be able to override drag functions.
https://bugs.webkit.org/show_bug.cgi?id=143618

Reviewed by Darin Adler.

WKWebView now implements the drag protocol functions and
forwards the calls to the inner WKView.
In the page client, when we receive a request to start drag
from the WebProcess, we call _dragImageForView in WKView with
the target view. The function calls dragImage on the given view,
so that its clients can override the dragImage function.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView draggingEntered:]):
(-[WKWebView draggingUpdated:]):
(-[WKWebView draggingExited:]):
(-[WKWebView prepareForDragOperation:]):
(-[WKWebView performDragOperation:]):
* UIProcess/API/mac/WKView.mm:
(-[WKView _dragImageForView:withImage:at:linkDrag:]):
(-[WKView _setDragImage:at:linkDrag:]): Deleted.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setDragImage):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (182764 => 182765)


--- trunk/Source/WebKit2/ChangeLog	2015-04-13 23:20:18 UTC (rev 182764)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-13 23:23:28 UTC (rev 182765)
@@ -1,3 +1,30 @@
+2015-04-13  Enrica Casucci  <[email protected]>
+
+        Clients of WKWebView should be able to override drag functions.
+        https://bugs.webkit.org/show_bug.cgi?id=143618
+
+        Reviewed by Darin Adler.
+
+        WKWebView now implements the drag protocol functions and
+        forwards the calls to the inner WKView.
+        In the page client, when we receive a request to start drag
+        from the WebProcess, we call _dragImageForView in WKView with
+        the target view. The function calls dragImage on the given view,
+        so that its clients can override the dragImage function.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView draggingEntered:]):
+        (-[WKWebView draggingUpdated:]):
+        (-[WKWebView draggingExited:]):
+        (-[WKWebView prepareForDragOperation:]):
+        (-[WKWebView performDragOperation:]):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _dragImageForView:withImage:at:linkDrag:]):
+        (-[WKView _setDragImage:at:linkDrag:]): Deleted.
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setDragImage):
+
 2015-04-13  Alex Christensen  <[email protected]>
 
         [iOS] Unreviewed build fix after r182760.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (182764 => 182765)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-04-13 23:20:18 UTC (rev 182764)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-04-13 23:23:28 UTC (rev 182765)
@@ -1682,6 +1682,31 @@
     [_wkView _setIgnoresNonWheelEvents:ignoresNonWheelEvents];
 }
 
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+{
+    return [_wkView draggingEntered:sender];
+}
+
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
+{
+    return [_wkView draggingUpdated:sender];
+    
+}
+
+- (void)draggingExited:(id <NSDraggingInfo>)sender
+{
+    [_wkView draggingExited:sender];
+}
+
+- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
+{
+    return [_wkView prepareForDragOperation:sender];
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
+{
+    return [_wkView performDragOperation:sender];
+}
 #endif
 
 @end

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


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-04-13 23:20:18 UTC (rev 182764)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-04-13 23:23:28 UTC (rev 182765)
@@ -3444,25 +3444,22 @@
     [self _setPluginComplexTextInputState:pluginComplexTextInputState];
 }
 
-- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag
+- (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag
 {
-    IntSize size([image size]);
-    size.scale(1.0 / _data->_page->deviceScaleFactor());
-    [image setSize:size];
-    
     // The call below could release this WKView.
     RetainPtr<WKView> protector(self);
     
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-    [self dragImage:image
+    [view dragImage:image
                  at:clientPoint
              offset:NSZeroSize
-              event:(linkDrag) ? [NSApp currentEvent] :_data->_mouseDownEvent
+              event:(linkDrag) ? [NSApp currentEvent] : _data->_mouseDownEvent
          pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
              source:self
           slideBack:YES];
 #pragma clang diagnostic pop
+    
 }
 
 static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension)

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


--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2015-04-13 23:20:18 UTC (rev 182764)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2015-04-13 23:23:28 UTC (rev 182765)
@@ -99,8 +99,7 @@
 
 - (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
 - (void)_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
-
-- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
+- (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
 - (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;

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (182764 => 182765)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-04-13 23:20:18 UTC (rev 182764)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-04-13 23:23:28 UTC (rev 182765)
@@ -403,8 +403,11 @@
 {
     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
     RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
+    IntSize size([dragNSImage size]);
+    size.scale(1.0 / toImpl([m_wkView pageRef])->deviceScaleFactor());
+    [dragNSImage setSize:size];
 
-    [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
+    [m_wkView _dragImageForView: (m_webView) ? : m_wkView withImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
 }
 
 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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to