Changeset 261570 in webkit
- Timestamp:
- May 12, 2020 12:27:48 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 added
- 3 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r261566 r261570 1 2020-05-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Rework drag and drop handling in preparation for GTK4 4 https://bugs.webkit.org/show_bug.cgi?id=211723 5 6 Reviewed by Adrian Perez de Castro. 7 8 Remove PasteboardHelper that is no longer used and add conversion functions to GtkUtilities. 9 10 * PlatformGTK.cmake: 11 * SourcesGTK.txt: 12 * platform/gtk/GtkUtilities.cpp: 13 (WebCore::gdkDragActionToDragOperation): 14 (WebCore::dragOperationToGdkDragActions): 15 (WebCore::dragOperationToSingleGdkDragAction): 16 * platform/gtk/GtkUtilities.h: 17 * platform/gtk/PasteboardHelper.cpp: Removed. 18 * platform/gtk/PasteboardHelper.h: Removed. 19 1 20 2020-05-12 Jacob Uphoff <jacob_uphoff@apple.com> 2 21 -
trunk/Source/WebCore/PlatformGTK.cmake
r260132 r261570 62 62 platform/gtk/GtkUtilities.h 63 63 platform/gtk/GtkVersioning.h 64 platform/gtk/PasteboardHelper.h65 64 platform/gtk/ScrollbarThemeGtk.h 66 65 platform/gtk/SelectionData.h -
trunk/Source/WebCore/SourcesGTK.txt
r261554 r261570 108 108 platform/gtk/LocalizedStringsGtk.cpp 109 109 platform/gtk/PasteboardGtk.cpp 110 platform/gtk/PasteboardHelper.cpp111 110 platform/gtk/PlatformKeyboardEventGtk.cpp 112 111 platform/gtk/PlatformScreenGtk.cpp -
trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp
r260508 r261570 103 103 } 104 104 105 DragOperation gdkDragActionToDragOperation(GdkDragAction gdkAction) 106 { 107 // We have no good way to detect DragOperationEvery other than 108 // to use it when all applicable flags are on. 109 if (gdkAction & GDK_ACTION_COPY 110 && gdkAction & GDK_ACTION_MOVE 111 && gdkAction & GDK_ACTION_LINK) 112 return DragOperationEvery; 113 114 unsigned action = DragOperationNone; 115 if (gdkAction & GDK_ACTION_COPY) 116 action |= DragOperationCopy; 117 if (gdkAction & GDK_ACTION_MOVE) 118 action |= DragOperationMove; 119 if (gdkAction & GDK_ACTION_LINK) 120 action |= DragOperationLink; 121 122 return static_cast<DragOperation>(action); 123 } 124 125 GdkDragAction dragOperationToGdkDragActions(DragOperation coreAction) 126 { 127 unsigned gdkAction = 0; 128 if (coreAction == DragOperationNone) 129 return static_cast<GdkDragAction>(gdkAction); 130 131 if (coreAction & DragOperationCopy) 132 gdkAction |= GDK_ACTION_COPY; 133 if (coreAction & DragOperationMove) 134 gdkAction |= GDK_ACTION_MOVE; 135 if (coreAction & DragOperationLink) 136 gdkAction |= GDK_ACTION_LINK; 137 138 return static_cast<GdkDragAction>(gdkAction); 139 } 140 141 GdkDragAction dragOperationToSingleGdkDragAction(DragOperation coreAction) 142 { 143 if (coreAction == DragOperationEvery || coreAction & DragOperationCopy) 144 return GDK_ACTION_COPY; 145 if (coreAction & DragOperationMove) 146 return GDK_ACTION_MOVE; 147 if (coreAction & DragOperationLink) 148 return GDK_ACTION_LINK; 149 return static_cast<GdkDragAction>(0); 150 } 151 105 152 } // namespace WebCore -
trunk/Source/WebCore/platform/gtk/GtkUtilities.h
r261014 r261570 19 19 #pragma once 20 20 21 #include "DragActions.h" 21 22 #include <gtk/gtk.h> 22 23 #include <wtf/MonotonicTime.h> … … 48 49 WEBCORE_EXPORT unsigned stateModifierForGdkButton(unsigned button); 49 50 51 WEBCORE_EXPORT DragOperation gdkDragActionToDragOperation(GdkDragAction); 52 WEBCORE_EXPORT GdkDragAction dragOperationToGdkDragActions(DragOperation); 53 WEBCORE_EXPORT GdkDragAction dragOperationToSingleGdkDragAction(DragOperation); 54 50 55 } // namespace WebCore -
trunk/Source/WebKit/ChangeLog
r261566 r261570 1 2020-05-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Rework drag and drop handling in preparation for GTK4 4 https://bugs.webkit.org/show_bug.cgi?id=211723 5 6 Reviewed by Adrian Perez de Castro. 7 8 Split DragAndDropHelper class into DragSource and DropTarget classes. This separates the source and destination 9 parts making it easier to follow. This patch also adds PageClient::didPerformDragControllerAction() to notify 10 back the view when an operation is done to update the result. 11 12 * SourcesGTK.txt: 13 * UIProcess/API/gtk/DragSource.h: Added. 14 * UIProcess/API/gtk/DragSourceGtk3.cpp: Added. 15 (WebKit::DragSource::DragSource): 16 (WebKit::DragSource::~DragSource): 17 (WebKit::DragSource::begin): 18 * UIProcess/API/gtk/DropTarget.h: Added. 19 * UIProcess/API/gtk/DropTargetGtk3.cpp: Added. 20 (WebKit::DropTarget::DropTarget): 21 (WebKit::DropTarget::~DropTarget): 22 (WebKit::DropTarget::accept): 23 (WebKit::DropTarget::enter): 24 (WebKit::DropTarget::update): 25 (WebKit::DropTarget::dataReceived): 26 (WebKit::DropTarget::didPerformAction): 27 (WebKit::DropTarget::leaveTimerFired): 28 (WebKit::DropTarget::leave): 29 (WebKit::DropTarget::drop): 30 * UIProcess/API/gtk/PageClientImpl.cpp: 31 (WebKit::PageClientImpl::startDrag): 32 (WebKit::PageClientImpl::didPerformDragControllerAction): 33 * UIProcess/API/gtk/PageClientImpl.h: 34 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 35 (webkitWebViewBaseConstructed): 36 (webkit_web_view_base_class_init): 37 (webkitWebViewBaseStartDrag): 38 (webkitWebViewBaseDidPerformDragControllerAction): 39 * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: 40 * UIProcess/PageClient.h: 41 (WebKit::PageClient::didPerformDragControllerAction): 42 * UIProcess/WebPageProxy.cpp: 43 (WebKit::WebPageProxy::didPerformDragControllerAction): 44 * UIProcess/gtk/DragAndDropHandler.cpp: Removed. 45 * WebProcess/WebPage/WebPage.cpp: 46 (WebKit::WebPage::performDragControllerAction): 47 * WebProcess/WebPage/gtk/WebPageGtk.cpp: 48 1 49 2020-05-12 Jacob Uphoff <jacob_uphoff@apple.com> 2 50 -
trunk/Source/WebKit/SourcesGTK.txt
r261554 r261570 195 195 UIProcess/API/glib/WebKitWindowProperties.cpp @no-unify 196 196 197 UIProcess/API/gtk/DragSourceGtk3.cpp @no-unify 198 UIProcess/API/gtk/DragSourceGtk4.cpp @no-unify 199 UIProcess/API/gtk/DropTargetGtk3.cpp @no-unify 200 UIProcess/API/gtk/DropTargetGtk4.cpp @no-unify 197 201 UIProcess/API/gtk/InputMethodFilterGtk.cpp @no-unify 198 202 UIProcess/API/gtk/PageClientImpl.cpp @no-unify … … 257 261 UIProcess/gtk/ClipboardGtk3.cpp @no-unify 258 262 UIProcess/gtk/ClipboardGtk4.cpp @no-unify 259 UIProcess/gtk/DragAndDropHandler.cpp260 263 UIProcess/gtk/GestureController.cpp 261 264 UIProcess/gtk/HardwareAccelerationManager.cpp -
trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
r261048 r261570 331 331 void PageClientImpl::startDrag(Ref<SelectionData>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage) 332 332 { 333 #if !USE(GTK4) 334 WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget); 335 webkitWebViewBaseDragAndDropHandler(webView).startDrag(WTFMove(selection), dragOperation, WTFMove(dragImage)); 336 337 // A drag starting should prevent a double-click from happening. This might 338 // happen if a drag is followed very quickly by another click (like in the WTR). 339 webkitWebViewBaseResetClickCounter(webView); 340 #endif 333 webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), WTFMove(selection), dragOperation, WTFMove(dragImage)); 334 } 335 336 void PageClientImpl::didPerformDragControllerAction() 337 { 338 webkitWebViewBaseDidPerformDragControllerAction(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); 341 339 } 342 340 #endif -
trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
r255343 r261570 102 102 #if ENABLE(DRAG_SUPPORT) 103 103 void startDrag(Ref<WebCore::SelectionData>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) override; 104 void didPerformDragControllerAction() override; 104 105 #endif 105 106 -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r261284 r261570 32 32 #include "APIPageConfiguration.h" 33 33 #include "AcceleratedBackingStore.h" 34 #include "DragSource.h" 34 35 #include "DrawingAreaProxyCoordinatedGraphics.h" 36 #include "DropTarget.h" 35 37 #include "InputMethodFilter.h" 36 38 #include "KeyBindingTranslator.h" … … 59 61 #include <WebCore/GtkVersioning.h> 60 62 #include <WebCore/NotImplemented.h> 61 #include <WebCore/PasteboardHelper.h>62 63 #include <WebCore/PlatformDisplay.h> 63 64 #include <WebCore/RefPtrCairo.h> … … 220 221 std::unique_ptr<AcceleratedBackingStore> acceleratedBackingStore; 221 222 222 #if ENABLE(DRAG_SUPPORT) && !USE(GTK4) 223 std::unique_ptr<DragAndDropHandler> dragAndDropHandler; 223 #if ENABLE(DRAG_SUPPORT) 224 std::unique_ptr<DragSource> dragSource; 225 std::unique_ptr<DropTarget> dropTarget; 224 226 #endif 225 227 … … 1555 1557 } 1556 1558 1557 #if ENABLE(DRAG_SUPPORT) && !USE(GTK4)1558 static void webkitWebViewBaseDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint /* time */)1559 {1560 WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;1561 ASSERT(priv->dragAndDropHandler);1562 priv->dragAndDropHandler->fillDragData(context, selectionData, info);1563 }1564 1565 static void webkitWebViewBaseDragEnd(GtkWidget* widget, GdkDragContext* context)1566 {1567 WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;1568 ASSERT(priv->dragAndDropHandler);1569 priv->dragAndDropHandler->finishDrag(context);1570 }1571 1572 static void webkitWebViewBaseDragDataReceived(GtkWidget* widget, GdkDragContext* context, gint /* x */, gint /* y */, GtkSelectionData* selectionData, guint info, guint time)1573 {1574 webkitWebViewBaseDragAndDropHandler(WEBKIT_WEB_VIEW_BASE(widget)).dragEntered(context, selectionData, info, time);1575 }1576 #endif // ENABLE(DRAG_SUPPORT)1577 1578 1559 #if !USE(GTK4) 1579 1560 static gboolean webkitWebViewBaseEvent(GtkWidget* widget, GdkEvent* event) … … 1601 1582 return priv->accessible.get(); 1602 1583 } 1603 1604 #if ENABLE(DRAG_SUPPORT) && !USE(GTK4)1605 static gboolean webkitWebViewBaseDragMotion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)1606 {1607 webkitWebViewBaseDragAndDropHandler(WEBKIT_WEB_VIEW_BASE(widget)).dragMotion(context, IntPoint(x, y), time);1608 return TRUE;1609 }1610 1611 static void webkitWebViewBaseDragLeave(GtkWidget* widget, GdkDragContext* context, guint /* time */)1612 {1613 WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;1614 ASSERT(priv->dragAndDropHandler);1615 priv->dragAndDropHandler->dragLeave(context);1616 }1617 1618 static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)1619 {1620 WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;1621 ASSERT(priv->dragAndDropHandler);1622 return priv->dragAndDropHandler->drop(context, IntPoint(x, y), time);1623 }1624 #endif // ENABLE(DRAG_SUPPORT)1625 1584 1626 1585 #if !USE(GTK4) … … 1674 1633 gtk_container_add(GTK_CONTAINER(viewWidget), priv->keyBindingTranslator.widget()); 1675 1634 1676 #if !USE(GTK4) 1677 gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), nullptr, 0, 1678 static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); 1679 gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::singleton().targetList()); 1635 #if ENABLE(DRAG_SUPPORT) 1636 priv->dropTarget = makeUnique<DropTarget>(viewWidget); 1680 1637 #endif 1681 1638 … … 1748 1705 #endif 1749 1706 widgetClass->query_tooltip = webkitWebViewBaseQueryTooltip; 1750 #if ENABLE(DRAG_SUPPORT) && !USE(GTK4)1751 widgetClass->drag_end = webkitWebViewBaseDragEnd;1752 widgetClass->drag_data_get = webkitWebViewBaseDragDataGet;1753 widgetClass->drag_motion = webkitWebViewBaseDragMotion;1754 widgetClass->drag_leave = webkitWebViewBaseDragLeave;1755 widgetClass->drag_drop = webkitWebViewBaseDragDrop;1756 widgetClass->drag_data_received = webkitWebViewBaseDragDataReceived;1757 #endif // ENABLE(DRAG_SUPPORT)1758 1707 #if !USE(GTK4) 1759 1708 widgetClass->event = webkitWebViewBaseEvent; … … 1830 1779 } 1831 1780 1832 #if ENABLE(DRAG_SUPPORT) && !USE(GTK4) 1833 DragAndDropHandler& webkitWebViewBaseDragAndDropHandler(WebKitWebViewBase* webViewBase) 1834 { 1835 WebKitWebViewBasePrivate* priv = webViewBase->priv; 1836 if (!priv->dragAndDropHandler) 1837 priv->dragAndDropHandler = makeUnique<DragAndDropHandler>(*priv->pageProxy); 1838 return *priv->dragAndDropHandler; 1781 #if ENABLE(DRAG_SUPPORT) 1782 void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, Ref<SelectionData>&& selectionData, DragOperation dragOperation, RefPtr<ShareableBitmap>&& image) 1783 { 1784 WebKitWebViewBasePrivate* priv = webViewBase->priv; 1785 if (!priv->dragSource) 1786 priv->dragSource = makeUnique<DragSource>(GTK_WIDGET(webViewBase)); 1787 1788 priv->dragSource->begin(WTFMove(selectionData), dragOperation, WTFMove(image)); 1789 1790 #if !USE(GTK4) 1791 // A drag starting should prevent a double-click from happening. This might 1792 // happen if a drag is followed very quickly by another click (like in the WTR). 1793 priv->clickCounter.reset(); 1794 #endif 1795 } 1796 1797 void webkitWebViewBaseDidPerformDragControllerAction(WebKitWebViewBase* webViewBase) 1798 { 1799 webViewBase->priv->dropTarget->didPerformAction(); 1839 1800 } 1840 1801 #endif // ENABLE(DRAG_SUPPORT) -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
r260889 r261570 33 33 #include "InputMethodState.h" 34 34 #include "SameDocumentNavigationType.h" 35 #include "ShareableBitmap.h" 35 36 #include "ViewGestureController.h" 36 37 #include "ViewSnapshotStore.h" … … 40 41 #include "WebKitWebViewBase.h" 41 42 #include "WebPageProxy.h" 43 #include <WebCore/DragActions.h> 44 #include <WebCore/SelectionData.h> 42 45 #include <wtf/Optional.h> 43 46 … … 79 82 void webkitWebViewBasePageClosed(WebKitWebViewBase*); 80 83 81 #if ENABLE(DRAG_SUPPORT) && !USE(GTK4) 82 WebKit::DragAndDropHandler& webkitWebViewBaseDragAndDropHandler(WebKitWebViewBase*); 84 #if ENABLE(DRAG_SUPPORT) 85 void webkitWebViewBaseStartDrag(WebKitWebViewBase*, Ref<WebCore::SelectionData>&&, WebCore::DragOperation, RefPtr<WebKit::ShareableBitmap>&&); 86 void webkitWebViewBaseDidPerformDragControllerAction(WebKitWebViewBase*); 83 87 #endif 84 88 -
trunk/Source/WebKit/UIProcess/PageClient.h
r261457 r261570 251 251 #endif 252 252 virtual void didPerformDragOperation(bool) { } 253 virtual void didPerformDragControllerAction() { } 253 254 #endif // ENABLE(DRAG_SUPPORT) 254 255 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r261506 r261570 2425 2425 m_currentDragCaretEditableElementRect = editableElementRect; 2426 2426 setDragCaretRect(insertionRect); 2427 pageClient().didPerformDragControllerAction(); 2427 2428 } 2428 2429 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r261560 r261570 3944 3944 } 3945 3945 case DragControllerAction::Updated: { 3946 DragOperation resolvedDragOperation = m_page->dragController().drag Entered(dragData);3946 DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData); 3947 3947 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }, { })); 3948 3948 return; -
trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp
r257299 r261570 43 43 #include <WebCore/NotImplemented.h> 44 44 #include <WebCore/Page.h> 45 #include <WebCore/PasteboardHelper.h>46 45 #include <WebCore/PlatformKeyboardEvent.h> 47 46 #include <WebCore/RenderTheme.h>
Note: See TracChangeset
for help on using the changeset viewer.