Changeset 226899 in webkit


Ignore:
Timestamp:
Jan 12, 2018 10:49:11 AM (6 years ago)
Author:
Wenson Hsieh
Message:

[WK2] Unify macOS and iOS codepaths in the UI process when starting a drag
https://bugs.webkit.org/show_bug.cgi?id=181574

Reviewed by Tim Horton.

Rearrange some macOS drag start logic in the UI process so that it uses the same codepaths in WebPageProxy as
iOS. Namely, startDrag should just forward the DragItem and drag image handle along to the appropriate views on
each platform (WKContentView and WebViewImpl).

There should be no change in behavior.

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

Both macOS and iOS now funnel through this method.

  • UIProcess/Cocoa/WebViewImpl.h:
  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::startDrag):
(WebKit::WebViewImpl::dragImageForView): Deleted.

Rename dragImageForView to startDrag. Move the call to didStartDrag() here, and call dragCancelled() in the
case where we bailed from starting the drag (due to failing to create a drag image).

  • UIProcess/PageClient.h:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::setDragImage): Deleted.

Rename setDragImage to startDrag.

  • UIProcess/mac/PageClientImplMac.h:
  • UIProcess/mac/PageClientImplMac.mm:

(WebKit::PageClientImpl::startDrag):
(WebKit::PageClientImpl::setDragImage): Deleted.

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::startDrag): Deleted.

Location:
trunk/Source/WebKit
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r226886 r226899  
     12018-01-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [WK2] Unify macOS and iOS codepaths in the UI process when starting a drag
     4        https://bugs.webkit.org/show_bug.cgi?id=181574
     5
     6        Reviewed by Tim Horton.
     7
     8        Rearrange some macOS drag start logic in the UI process so that it uses the same codepaths in WebPageProxy as
     9        iOS. Namely, startDrag should just forward the DragItem and drag image handle along to the appropriate views on
     10        each platform (WKContentView and WebViewImpl).
     11
     12        There should be no change in behavior.
     13
     14        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     15
     16        Both macOS and iOS now funnel through this method.
     17
     18        * UIProcess/Cocoa/WebViewImpl.h:
     19        * UIProcess/Cocoa/WebViewImpl.mm:
     20        (WebKit::WebViewImpl::startDrag):
     21        (WebKit::WebViewImpl::dragImageForView): Deleted.
     22
     23        Rename dragImageForView to startDrag. Move the call to didStartDrag() here, and call dragCancelled() in the
     24        case where we bailed from starting the drag (due to failing to create a drag image).
     25
     26        * UIProcess/PageClient.h:
     27        * UIProcess/ios/PageClientImplIOS.h:
     28        * UIProcess/ios/PageClientImplIOS.mm:
     29        (WebKit::PageClientImpl::setDragImage): Deleted.
     30
     31        Rename setDragImage to startDrag.
     32
     33        * UIProcess/mac/PageClientImplMac.h:
     34        * UIProcess/mac/PageClientImplMac.mm:
     35        (WebKit::PageClientImpl::startDrag):
     36        (WebKit::PageClientImpl::setDragImage): Deleted.
     37        * UIProcess/mac/WebPageProxyMac.mm:
     38        (WebKit::WebPageProxy::startDrag): Deleted.
     39
    1402018-01-12  Antoine Quint  <graouts@apple.com>
    241
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r226312 r226899  
    104104}
    105105
    106 #if PLATFORM(IOS) && ENABLE(DRAG_SUPPORT)
     106#if ENABLE(DRAG_SUPPORT)
    107107
    108108void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle)
     
    110110    m_pageClient.startDrag(dragItem, dragImageHandle);
    111111}
     112
     113#if PLATFORM(IOS)
    112114
    113115void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::Handle&, uint64_t, const String&, const String&, const String&, const String&, const String&, const SharedMemory::Handle&, uint64_t)
     
    126128}
    127129
    128 #endif // PLATFORM(IOS) && ENABLE(DRAG_SUPPORT)
     130#endif // PLATFORM(IOS)
     131
     132#endif // ENABLE(DRAG_SUPPORT)
    129133
    130134}
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h

    r226808 r226899  
    3434#include "WebPageProxy.h"
    3535#include "_WKOverlayScrollbarStyle.h"
    36 #include <WebCore/PromisedBlobInfo.h>
    3736#include <WebCore/TextIndicatorWindow.h>
    3837#include <WebCore/UserInterfaceLayoutDirection.h>
     
    109108
    110109namespace WebCore {
     110struct DragItem;
    111111struct KeyPressCommand;
    112112}
     
    414414    void startWindowDrag();
    415415
    416     void dragImageForView(NSView *, NSImage *, CGPoint clientPoint, bool linkDrag);
     416    void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image);
    417417    void setFileAndURLTypes(NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, NSPasteboard *);
    418418    void setPromisedDataForImage(WebCore::Image*, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName);
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r226808 r226899  
    7474#import <WebCore/DictionaryLookup.h>
    7575#import <WebCore/DragData.h>
     76#import <WebCore/DragItem.h>
    7677#import <WebCore/Editor.h>
    7778#import <WebCore/KeypressCommand.h>
     
    37773778}
    37783779
    3779 void WebViewImpl::dragImageForView(NSView *view, NSImage *image, CGPoint clientPoint, bool)
    3780 {
     3780void WebViewImpl::startDrag(const WebCore::DragItem& item, const ShareableBitmap::Handle& dragImageHandle)
     3781{
     3782    auto dragImageAsBitmap = ShareableBitmap::create(dragImageHandle);
     3783    if (!dragImageAsBitmap) {
     3784        m_page->dragCancelled();
     3785        return;
     3786    }
     3787
     3788    auto dragCGImage = dragImageAsBitmap->makeCGImage();
     3789    auto dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImageAsBitmap->size()]);
     3790
     3791    WebCore::IntSize size([dragNSImage size]);
     3792    size.scale(1.0 / m_page->deviceScaleFactor());
     3793    [dragNSImage setSize:size];
     3794
    37813795    // The call below could release the view.
    37823796    auto protector = m_view.get();
     
    37883802#pragma clang diagnostic push
    37893803#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    3790     [view dragImage:image
    3791                  at:NSPointFromCGPoint(clientPoint)
    3792              offset:NSZeroSize
    3793               event:m_lastMouseDownEvent.get()
    3794          pasteboard:pasteboard
    3795              source:m_view.getAutoreleased()
    3796           slideBack:YES];
     3804    [m_view dragImage:dragNSImage.get() at:NSPointFromCGPoint(item.dragLocationInWindowCoordinates) offset:NSZeroSize event:m_lastMouseDownEvent.get() pasteboard:pasteboard source:m_view.getAutoreleased() slideBack:YES];
    37973805#pragma clang diagnostic pop
     3806    m_page->didStartDrag();
    37983807}
    37993808
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r226808 r226899  
    173173    virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&) = 0;
    174174    virtual bool executeSavedCommandBySelector(const String& selector) = 0;
    175     virtual void setDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) = 0;
     175    virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) = 0;
    176176    virtual void updateSecureInputState() = 0;
    177177    virtual void resetSecureInputState() = 0;
     
    376376    virtual void didHandleStartDataInteractionRequest(bool started) = 0;
    377377    virtual void didHandleAdditionalDragItemsRequest(bool added) = 0;
    378     virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) = 0;
    379378    virtual void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) = 0;
    380379    virtual void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) = 0;
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r226808 r226899  
    8383    void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
    8484    bool executeSavedCommandBySelector(const String& selector) override;
    85     void setDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) override;
    8685    void updateSecureInputState() override;
    8786    void resetSecureInputState() override;
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r226808 r226899  
    364364}
    365365
    366 void PageClientImpl::setDragImage(const IntPoint&, Ref<ShareableBitmap>&&, DragSourceAction)
    367 {
    368     notImplemented();
    369 }
    370 
    371366void PageClientImpl::selectionDidChange()
    372367{
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r226808 r226899  
    3838namespace WebCore {
    3939class AlternativeTextUIController;
     40struct DragItem;
    4041struct PromisedBlobInfo;
    4142}
     
    9697    void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
    9798    bool executeSavedCommandBySelector(const String& selector) override;
    98     void setDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) override;
     99    void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override;
    99100    void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title,
    100101        const String& url, const String& visibleUrl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) override;
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r226808 r226899  
    6060#import <WebCore/Cursor.h>
    6161#import <WebCore/DictionaryLookup.h>
     62#import <WebCore/DragItem.h>
    6263#import <WebCore/FloatRect.h>
    6364#import <WebCore/GraphicsContext.h>
     
    348349}
    349350
    350 void PageClientImpl::setDragImage(const IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, DragSourceAction action)
    351 {
    352     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
    353     RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
    354     IntSize size([dragNSImage size]);
    355     size.scale(1.0 / m_impl->page().deviceScaleFactor());
    356     [dragNSImage setSize:size];
    357 
    358     m_impl->dragImageForView(m_view, dragNSImage.get(), clientPosition, action == DragSourceActionLink);
     351void PageClientImpl::startDrag(const WebCore::DragItem& item, const ShareableBitmap::Handle& image)
     352{
     353    m_impl->startDrag(item, image);
    359354}
    360355
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r226312 r226899  
    267267
    268268#if ENABLE(DRAG_SUPPORT)
    269 void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle)
    270 {
    271     if (auto dragImage = ShareableBitmap::create(dragImageHandle))
    272         m_pageClient.setDragImage(dragItem.dragLocationInWindowCoordinates, dragImage.releaseNonNull(), static_cast<DragSourceAction>(dragItem.sourceAction));
    273 
    274     didStartDrag();
    275 }
    276269
    277270void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
Note: See TracChangeset for help on using the changeset viewer.