Changeset 226899 in webkit
- Timestamp:
- Jan 12, 2018 10:49:11 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r226886 r226899 1 2018-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 1 40 2018-01-12 Antoine Quint <graouts@apple.com> 2 41 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r226312 r226899 104 104 } 105 105 106 #if PLATFORM(IOS) &&ENABLE(DRAG_SUPPORT)106 #if ENABLE(DRAG_SUPPORT) 107 107 108 108 void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle) … … 110 110 m_pageClient.startDrag(dragItem, dragImageHandle); 111 111 } 112 113 #if PLATFORM(IOS) 112 114 113 115 void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::Handle&, uint64_t, const String&, const String&, const String&, const String&, const String&, const SharedMemory::Handle&, uint64_t) … … 126 128 } 127 129 128 #endif // PLATFORM(IOS) && ENABLE(DRAG_SUPPORT) 130 #endif // PLATFORM(IOS) 131 132 #endif // ENABLE(DRAG_SUPPORT) 129 133 130 134 } -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r226808 r226899 34 34 #include "WebPageProxy.h" 35 35 #include "_WKOverlayScrollbarStyle.h" 36 #include <WebCore/PromisedBlobInfo.h>37 36 #include <WebCore/TextIndicatorWindow.h> 38 37 #include <WebCore/UserInterfaceLayoutDirection.h> … … 109 108 110 109 namespace WebCore { 110 struct DragItem; 111 111 struct KeyPressCommand; 112 112 } … … 414 414 void startWindowDrag(); 415 415 416 void dragImageForView(NSView *, NSImage *, CGPoint clientPoint, bool linkDrag);416 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image); 417 417 void setFileAndURLTypes(NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, NSPasteboard *); 418 418 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 74 74 #import <WebCore/DictionaryLookup.h> 75 75 #import <WebCore/DragData.h> 76 #import <WebCore/DragItem.h> 76 77 #import <WebCore/Editor.h> 77 78 #import <WebCore/KeypressCommand.h> … … 3777 3778 } 3778 3779 3779 void WebViewImpl::dragImageForView(NSView *view, NSImage *image, CGPoint clientPoint, bool) 3780 { 3780 void 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 3781 3795 // The call below could release the view. 3782 3796 auto protector = m_view.get(); … … 3788 3802 #pragma clang diagnostic push 3789 3803 #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]; 3797 3805 #pragma clang diagnostic pop 3806 m_page->didStartDrag(); 3798 3807 } 3799 3808 -
trunk/Source/WebKit/UIProcess/PageClient.h
r226808 r226899 173 173 virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&) = 0; 174 174 virtual bool executeSavedCommandBySelector(const String& selector) = 0; 175 virtual void s etDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) = 0;175 virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) = 0; 176 176 virtual void updateSecureInputState() = 0; 177 177 virtual void resetSecureInputState() = 0; … … 376 376 virtual void didHandleStartDataInteractionRequest(bool started) = 0; 377 377 virtual void didHandleAdditionalDragItemsRequest(bool added) = 0; 378 virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) = 0;379 378 virtual void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) = 0; 380 379 virtual void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) = 0; -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h
r226808 r226899 83 83 void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override; 84 84 bool executeSavedCommandBySelector(const String& selector) override; 85 void setDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) override;86 85 void updateSecureInputState() override; 87 86 void resetSecureInputState() override; -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r226808 r226899 364 364 } 365 365 366 void PageClientImpl::setDragImage(const IntPoint&, Ref<ShareableBitmap>&&, DragSourceAction)367 {368 notImplemented();369 }370 371 366 void PageClientImpl::selectionDidChange() 372 367 { -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r226808 r226899 38 38 namespace WebCore { 39 39 class AlternativeTextUIController; 40 struct DragItem; 40 41 struct PromisedBlobInfo; 41 42 } … … 96 97 void executeUndoRedo(WebPageProxy::UndoOrRedo) override; 97 98 bool executeSavedCommandBySelector(const String& selector) override; 98 void s etDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) override;99 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override; 99 100 void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, 100 101 const String& url, const String& visibleUrl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) override; -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r226808 r226899 60 60 #import <WebCore/Cursor.h> 61 61 #import <WebCore/DictionaryLookup.h> 62 #import <WebCore/DragItem.h> 62 63 #import <WebCore/FloatRect.h> 63 64 #import <WebCore/GraphicsContext.h> … … 348 349 } 349 350 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); 351 void PageClientImpl::startDrag(const WebCore::DragItem& item, const ShareableBitmap::Handle& image) 352 { 353 m_impl->startDrag(item, image); 359 354 } 360 355 -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r226312 r226899 267 267 268 268 #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 }276 269 277 270 void 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.