Title: [211323] trunk/Source/WebKit/mac
Revision
211323
Author
wenson_hs...@apple.com
Date
2017-01-27 21:08:31 -0800 (Fri, 27 Jan 2017)

Log Message

[WK1] Do not prevent the drag client from initializing on Mac
https://bugs.webkit.org/show_bug.cgi?id=167541

Reviewed by Dan Bernstein.

Fixes fallout from r211192. To ensure compability with WebKit clients, we need to ensure that WebDragClient is
initialized everywhere when creating a WebView. Stub out method implementations as no-ops for non-Mac platforms.
This caused certain clients, such as Mail, to crash when a webView closes due to  null dereference.

* WebCoreSupport/WebDragClient.mm:
(WebDragClient::WebDragClient):
(WebDragClient::actionMaskForDrag):
(WebDragClient::willPerformDragDestinationAction):
(WebDragClient::dragSourceActionMaskForPoint):
(WebDragClient::willPerformDragSourceAction):
(WebDragClient::startDrag):
(WebDragClient::declareAndWriteDragImage):
(WebDragClient::declareAndWriteAttachment):
* WebView/WebView.mm:
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (211322 => 211323)


--- trunk/Source/WebKit/mac/ChangeLog	2017-01-28 05:05:37 UTC (rev 211322)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-01-28 05:08:31 UTC (rev 211323)
@@ -1,3 +1,26 @@
+2017-01-27  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [WK1] Do not prevent the drag client from initializing on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=167541
+
+        Reviewed by Dan Bernstein.
+
+        Fixes fallout from r211192. To ensure compability with WebKit clients, we need to ensure that WebDragClient is
+        initialized everywhere when creating a WebView. Stub out method implementations as no-ops for non-Mac platforms.
+        This caused certain clients, such as Mail, to crash when a webView closes due to  null dereference.
+
+        * WebCoreSupport/WebDragClient.mm:
+        (WebDragClient::WebDragClient):
+        (WebDragClient::actionMaskForDrag):
+        (WebDragClient::willPerformDragDestinationAction):
+        (WebDragClient::dragSourceActionMaskForPoint):
+        (WebDragClient::willPerformDragSourceAction):
+        (WebDragClient::startDrag):
+        (WebDragClient::declareAndWriteDragImage):
+        (WebDragClient::declareAndWriteAttachment):
+        * WebView/WebView.mm:
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+
 2017-01-26  Chris Dumez  <cdu...@apple.com>
 
         Crash when navigating back to a page in PacheCache when one of its frames has been removed

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm (211322 => 211323)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2017-01-28 05:05:37 UTC (rev 211322)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2017-01-28 05:08:31 UTC (rev 211323)
@@ -25,7 +25,7 @@
 
 #import "WebDragClient.h"
 
-#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
+#if ENABLE(DRAG_SUPPORT)
 
 #import "DOMElementInternal.h"
 #import "WebArchive.h"
@@ -36,11 +36,15 @@
 #import "WebHTMLViewPrivate.h"
 #import "WebKitLogging.h"
 #import "WebKitNSStringExtras.h"
-#import "WebNSPasteboardExtras.h"
 #import "WebNSURLExtras.h"
 #import "WebUIDelegate.h"
 #import "WebUIDelegatePrivate.h"
 #import "WebViewInternal.h"
+
+#if PLATFORM(MAC)
+#import "WebNSPasteboardExtras.h"
+#endif
+
 #import <WebCore/DataTransfer.h>
 #import <WebCore/DragData.h>
 #import <WebCore/Editor.h>
@@ -57,8 +61,11 @@
 WebDragClient::WebDragClient(WebView* webView)
     : m_webView(webView) 
 {
+    UNUSED_PARAM(m_webView);
 }
 
+#if PLATFORM(MAC)
+
 static WebHTMLView *getTopHTMLView(Frame* frame)
 {
     ASSERT(frame);
@@ -138,9 +145,45 @@
 }
 #endif
 
+#else
+
+WebCore::DragDestinationAction WebDragClient::actionMaskForDrag(const WebCore::DragData&)
+{
+    return DragDestinationActionNone;
+}
+
+void WebDragClient::willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&)
+{
+}
+
+WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
+{
+    return DragSourceActionNone;
+}
+
+void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&)
+{
+}
+
+void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, DataTransfer&, Frame&, bool)
+{
+}
+
+void WebDragClient::declareAndWriteDragImage(const String&, Element&, const URL&, const String&, WebCore::Frame*)
+{
+}
+
+#if ENABLE(ATTACHMENT_ELEMENT)
+void WebDragClient::declareAndWriteAttachment(const String&, Element&, const URL&, const String&, WebCore::Frame*)
+{
+}
+#endif
+
+#endif
+
 void WebDragClient::dragControllerDestroyed() 
 {
     delete this;
 }
 
-#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
+#endif // ENABLE(DRAG_SUPPORT)

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (211322 => 211323)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2017-01-28 05:05:37 UTC (rev 211322)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2017-01-28 05:08:31 UTC (rev 211323)
@@ -1609,7 +1609,7 @@
         makeUniqueRef<WebCore::LibWebRTCProvider>()
     );
     pageConfiguration.chromeClient = new WebChromeClientIOS(self);
-#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
+#if ENABLE(DRAG_SUPPORT)
     pageConfiguration.dragClient = new WebDragClient(self);
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to