Use OptionSet<DragOperation> for mask values
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Jun 2020 15:17:30 +0000 (15:17 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Jun 2020 15:17:30 +0000 (15:17 +0000)
<https://webkit.org/b/212605>

Reviewed by Darin Adler.

Source/WebCore:

In broad strokes:
- Replace use of DragOperation with OptionSet<DragOperation> or
  Optional<DragOperation>.
- Rename function parameters and local variables to denote use
  of mask values.
- Remove DragOperationNone enum value.
- Replace DragOperationEvery enum value with anyDragOperation().

* dom/DataTransfer.cpp:
(WebCore::DataTransfer::createForDrop):
(WebCore::DataTransfer::createForUpdatingDropTarget):
(WebCore::dragOpFromIEOp):
(WebCore::IEOpFromDragOp):
(WebCore::DataTransfer::sourceOperation const): Rename.
(WebCore::DataTransfer::sourceOperationMask const):
(WebCore::DataTransfer::destinationOperation const): Rename.
(WebCore::DataTransfer::destinationOperationMask const):
(WebCore::DataTransfer::setSourceOperation): Rename.
(WebCore::DataTransfer::setSourceOperationMask):
(WebCore::DataTransfer::setDestinationOperation): Rename.
(WebCore::DataTransfer::setDestinationOperationMask):
* dom/DataTransfer.h:
(WebCore::DataTransfer::createForDrop):
(WebCore::DataTransfer::createForUpdatingDropTarget):
(WebCore::DataTransfer::sourceOperation const): Rename.
(WebCore::DataTransfer::sourceOperationMask const):
(WebCore::DataTransfer::destinationOperation const): Rename.
(WebCore::DataTransfer::destinationOperationMask const):
(WebCore::DataTransfer::setSourceOperation): Rename.
(WebCore::DataTransfer::setSourceOperationMask):
(WebCore::DataTransfer::setDestinationOperation): Rename.
(WebCore::DataTransfer::setDestinationOperationMask):
* page/DragActions.h:
(WebCore::anyDragOperation): Add.
(WTF::EnumTraits<WebCore::DragOperation>): Add.
(WTF::OptionSet<WebCore::DragOperation>): Add.
* page/DragController.cpp:
(WebCore::DragController::dragEntered):
(WebCore::DragController::dragUpdated):
(WebCore::DragController::performDragOperation):
(WebCore::DragController::dragEnteredOrUpdated):
(WebCore::DragController::tryDocumentDrag):
(WebCore::DragController::operationForLoad):
(WebCore::defaultOperationForDrag):
(WebCore::DragController::tryDHTMLDrag):
- Change logic to call defaultOperationForDrag() to convert
  targetResponse.operationMask to a single operation when
  targetResponse.operationMask but doesn't contain with any
  bit values set in sourceOperationMask.
(WebCore::DragController::startDrag):
* page/DragController.h:
(WebCore::DragController::dragEntered):
(WebCore::DragController::dragUpdated):
(WebCore::DragController::sourceDragOperation const): Rename.
(WebCore::DragController::sourceDragOperationMask const):
(WebCore::DragController::startDrag):
(WebCore::DragController::dragEnteredOrUpdated):
(WebCore::DragController::operationForLoad):
(WebCore::DragController::tryDocumentDrag):
(WebCore::DragController::tryDHTMLDrag):
(WebCore::DragController::dragOperation):
* page/EventHandler.cpp:
(WebCore::convertDropZoneOperationToDragOperation):
(WebCore::convertDragOperationToDropZoneOperation):
(WebCore::findDropZone):
(WebCore::EventHandler::dispatchDragEnterOrDragOverEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::cancelDragAndDrop):
(WebCore::EventHandler::performDragAndDrop):
(WebCore::EventHandler::dragSourceEndedAt):
(WebCore::EventHandler::handleDrag):
* page/EventHandler.h:
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::cancelDragAndDrop):
(WebCore::EventHandler::performDragAndDrop):
(WebCore::EventHandler::dragSourceEndedAt):
(WebCore::EventHandler::dispatchDragEnterOrDragOverEvent):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::dragOperation):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::dragOperation):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::dragOperation):
- Clean up comment.
* platform/DragData.cpp:
(WebCore::DragData::DragData):
* platform/DragData.h:
(WebCore::DragData::DragData):
(WebCore::DragData::draggingSourceOperationMask const):
* platform/cocoa/DragDataCocoa.mm:
(WebCore::DragData::DragData):
* platform/gtk/GtkUtilities.cpp:
(WebCore::gdkDragActionToDragOperation):
(WebCore::dragOperationToGdkDragActions):
(WebCore::dragOperationToSingleGdkDragAction):
* platform/gtk/GtkUtilities.h:
(WebCore::gdkDragActionToDragOperation):
(WebCore::dragOperationToGdkDragActions):
(WebCore::dragOperationToSingleGdkDragAction):
* platform/win/DragDataWin.cpp:
(WebCore::DragData::DragData):

Source/WebKit:

In broad strokes:
- Replace use of DragOperation with OptionSet<DragOperation> or
  Optional<DragOperation>.
- Rename function parameters and local variables to denote use
  of mask values.
- Remove DragOperationNone enum value.
- Replace DragOperationEvery enum value with anyDragOperation().

* Platform/spi/ios/UIKitSPI.h:
(UIDragOperation):
- Remove unused (and misnamed) UIDragOperation enum typedef.
* Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
- Add support for WebCore::DragOperation enum.
* Shared/API/Cocoa/_WKDragActionsInternal.h:
(WebKit::coreDragOperationMask): Add conversion function.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DragData>::encode):
(IPC::ArgumentCoder<DragData>::decode):
- Update to encode/decode OptionSet<DragOperation>.

* UIProcess/API/gtk/DragSource.h:
(WebKit::DragSource::begin):
* UIProcess/API/gtk/DragSourceGtk3.cpp:
(WebKit::DragSource::begin):
* UIProcess/API/gtk/DragSourceGtk4.cpp:
(WebKit::DragSource::begin):
* UIProcess/API/gtk/DropTarget.h:
* UIProcess/API/gtk/DropTargetGtk3.cpp:
(WebKit::DropTarget::didPerformAction):
(WebKit::DropTarget::leaveTimerFired):
* UIProcess/API/gtk/DropTargetGtk4.cpp:
(WebKit::DropTarget::DropTarget):
(WebKit::DropTarget::didPerformAction):
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::startDrag):
* UIProcess/API/gtk/PageClientImpl.h:
(WebKit::PageClientImpl::startDrag):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseStartDrag):
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
(webkitWebViewBaseStartDrag):

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::sendDragEndToPage):
(WebKit::WebViewImpl::draggingEntered):
(WebKit::kit): Add conversion function.
(WebKit::WebViewImpl::draggingUpdated):
(WebKit::WebViewImpl::draggingExited):
(WebKit::WebViewImpl::performDragOperation):
- Make use of coreDragOperationMask() conversion function.
* UIProcess/PageClient.h:
(WebKit::WebViewImpl::startDrag):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didPerformDragControllerAction):
- Remove MESSAGE_CHECK now that we're using the actual type.
(WebKit::WebPageProxy::startDrag):
(WebKit::WebPageProxy::dragEnded):
(WebKit::WebPageProxy::resetCurrentDragInformation):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::didPerformDragControllerAction):
(WebKit::WebPageProxy::dragEnded):
(WebKit::WebPageProxy::startDrag):
(WebKit::WebPageProxy::currentDragOperation const):
* UIProcess/WebPageProxy.messages.in:
(WebPageProxy::DidPerformDragControllerAction):
(WebPageProxy::StartDrag):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _didHandleDragStartRequest:]):
(dropOperationForWebCoreDragOperation):
(coreDragOperationForUIDropOperation): Add conversion function.
- Note that this was not being converted from UIDropOperation to
  WebCore::DragOperation previously, and UIDropOperationMove
  (0x3) was not being properly converted to DragOperationMove
  (0x16).
(-[WKContentView dragDataForDropSession:dragDestinationAction:]):
(-[WKContentView _didPerformDragOperation:]):
(-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
(-[WKContentView dragInteraction:session:didEndWithOperation:]):
(-[WKContentView dropInteraction:sessionDidEnd:]):
* WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):
(WebKit::WebPage::dragEnded):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::performDragControllerAction):
(WebKit::WebPage::dragEnded):
* WebProcess/WebPage/WebPage.messages.in:
(WebPage::PerformDragControllerAction):
(WebPage::DragEnded):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestAdditionalItemsForDragSession):

Source/WebKitLegacy/mac:

In broad strokes:
- Replace use of DragOperation with OptionSet<DragOperation> or
  Optional<DragOperation>.
- Rename function parameters and local variables to denote use
  of mask values.
- Remove DragOperationNone enum value.
- Replace DragOperationEvery enum value with anyDragOperation().

* WebView/WebFrame.mm:
(-[WebFrame _dragSourceEndedAt:operation:]):
* WebView/WebHTMLView.mm:
(kit): Add conversion function.
(-[WebHTMLView draggingSourceOperationMaskForLocal:]):
(-[WebHTMLView draggingSession:sourceOperationMaskForDraggingContext:]):
* WebView/WebView.mm:
(coreDragOperationMask): Add conversion function.
(kit): Ditto.
- Map WebCore::DragOperationGeneric to _UIDragOperationMove
  based on logic in WebCore.  All other WebCore::DragOperation
  enum values map to _UIDragOperationNone.
(-[WebView dragDataForSession:client:global:operation:]):
(-[WebView _enteredDataInteraction:client:global:operation:]):
(-[WebView _updatedDataInteraction:client:global:operation:]):
(-[WebView draggingEntered:]):
(-[WebView draggingUpdated:]):
(-[WebView draggingExited:]):
(-[WebView performDragOperation:]):
* WebView/WebViewInternal.h:
(CocoaDragOperation):
- Add typedef so coreDragOperationMask() may be shared across
  platforms.
(coreDragOperationMask): Add declaration.
(coreOptions):
- Remove redundant parameter name.

Source/WebKitLegacy/win:

In broad strokes:
- Replace use of DragOperation with OptionSet<DragOperation> or
  Optional<DragOperation>.
- Rename function parameters and local variables to denote use
  of mask values.
- Remove DragOperationNone enum value.
- Replace DragOperationEvery enum value with anyDragOperation().

* WebCoreSupport/WebDragClient.cpp:
(draggingSourceOperationMaskToDragCursors):
(WebDragClient::startDrag):
* WebView.cpp:
(dragOperationToDragCursor):
(WebView::keyStateToDragOperation const):
(WebView::DragLeave):
* WebView.h:
(WebView::keyStateToDragOperation const):

Source/WTF:

* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
- Add constructor for OptionSet(Optional).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262680 268f45cc-cd09-0410-ab3c-d52691b4dbfc

54 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/OptionSet.h
Source/WebCore/ChangeLog
Source/WebCore/dom/DataTransfer.cpp
Source/WebCore/dom/DataTransfer.h
Source/WebCore/page/DragActions.h
Source/WebCore/page/DragController.cpp
Source/WebCore/page/DragController.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/gtk/DragControllerGtk.cpp
Source/WebCore/page/mac/DragControllerMac.mm
Source/WebCore/page/win/DragControllerWin.cpp
Source/WebCore/platform/DragData.cpp
Source/WebCore/platform/DragData.h
Source/WebCore/platform/cocoa/DragDataCocoa.mm
Source/WebCore/platform/gtk/GtkUtilities.cpp
Source/WebCore/platform/gtk/GtkUtilities.h
Source/WebCore/platform/win/DragDataWin.cpp
Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/API/Cocoa/_WKDragActionsInternal.h
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/UIProcess/API/gtk/DragSource.h
Source/WebKit/UIProcess/API/gtk/DragSourceGtk3.cpp
Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp
Source/WebKit/UIProcess/API/gtk/DropTarget.h
Source/WebKit/UIProcess/API/gtk/DropTargetGtk3.cpp
Source/WebKit/UIProcess/API/gtk/DropTargetGtk4.cpp
Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebFrame.mm
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/mac/WebView/WebViewInternal.h
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.cpp
Source/WebKitLegacy/win/WebView.cpp
Source/WebKitLegacy/win/WebView.h

index cb2296c..75db047 100644 (file)
@@ -1,3 +1,14 @@
+2020-06-06  David Kilzer  <ddkilzer@apple.com>
+
+        Use OptionSet<DragOperation> for mask values
+        <https://webkit.org/b/212605>
+
+        Reviewed by Darin Adler.
+
+        * wtf/OptionSet.h:
+        (WTF::OptionSet::OptionSet):
+        - Add constructor for OptionSet(Optional).
+
 2020-06-05  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, reverting r262619, r262625, and r262641.
index 2ad68fb..2dcf43c 100644 (file)
@@ -30,6 +30,7 @@
 #include <type_traits>
 #include <wtf/Assertions.h>
 #include <wtf/MathExtras.h>
+#include <wtf/Optional.h>
 
 namespace WTF {
 
@@ -165,6 +166,11 @@ public:
         }
     }
 
+    constexpr OptionSet(Optional<E> optional)
+        : m_storage(optional ? static_cast<StorageType>(*optional) : 0)
+    {
+    }
+
     constexpr StorageType toRaw() const { return m_storage; }
 
     constexpr bool isEmpty() const { return !m_storage; }
index 7692170..aa47303 100644 (file)
@@ -1,3 +1,112 @@
+2020-06-06  David Kilzer  <ddkilzer@apple.com>
+
+        Use OptionSet<DragOperation> for mask values
+        <https://webkit.org/b/212605>
+
+        Reviewed by Darin Adler.
+
+        In broad strokes:
+        - Replace use of DragOperation with OptionSet<DragOperation> or
+          Optional<DragOperation>.
+        - Rename function parameters and local variables to denote use
+          of mask values.
+        - Remove DragOperationNone enum value.
+        - Replace DragOperationEvery enum value with anyDragOperation().
+
+        * dom/DataTransfer.cpp:
+        (WebCore::DataTransfer::createForDrop):
+        (WebCore::DataTransfer::createForUpdatingDropTarget):
+        (WebCore::dragOpFromIEOp):
+        (WebCore::IEOpFromDragOp):
+        (WebCore::DataTransfer::sourceOperation const): Rename.
+        (WebCore::DataTransfer::sourceOperationMask const):
+        (WebCore::DataTransfer::destinationOperation const): Rename.
+        (WebCore::DataTransfer::destinationOperationMask const):
+        (WebCore::DataTransfer::setSourceOperation): Rename.
+        (WebCore::DataTransfer::setSourceOperationMask):
+        (WebCore::DataTransfer::setDestinationOperation): Rename.
+        (WebCore::DataTransfer::setDestinationOperationMask):
+        * dom/DataTransfer.h:
+        (WebCore::DataTransfer::createForDrop):
+        (WebCore::DataTransfer::createForUpdatingDropTarget):
+        (WebCore::DataTransfer::sourceOperation const): Rename.
+        (WebCore::DataTransfer::sourceOperationMask const):
+        (WebCore::DataTransfer::destinationOperation const): Rename.
+        (WebCore::DataTransfer::destinationOperationMask const):
+        (WebCore::DataTransfer::setSourceOperation): Rename.
+        (WebCore::DataTransfer::setSourceOperationMask):
+        (WebCore::DataTransfer::setDestinationOperation): Rename.
+        (WebCore::DataTransfer::setDestinationOperationMask):
+        * page/DragActions.h:
+        (WebCore::anyDragOperation): Add.
+        (WTF::EnumTraits<WebCore::DragOperation>): Add.
+        (WTF::OptionSet<WebCore::DragOperation>): Add.
+        * page/DragController.cpp:
+        (WebCore::DragController::dragEntered):
+        (WebCore::DragController::dragUpdated):
+        (WebCore::DragController::performDragOperation):
+        (WebCore::DragController::dragEnteredOrUpdated):
+        (WebCore::DragController::tryDocumentDrag):
+        (WebCore::DragController::operationForLoad):
+        (WebCore::defaultOperationForDrag):
+        (WebCore::DragController::tryDHTMLDrag):
+        - Change logic to call defaultOperationForDrag() to convert
+          targetResponse.operationMask to a single operation when
+          targetResponse.operationMask but doesn't contain with any
+          bit values set in sourceOperationMask.
+        (WebCore::DragController::startDrag):
+        * page/DragController.h:
+        (WebCore::DragController::dragEntered):
+        (WebCore::DragController::dragUpdated):
+        (WebCore::DragController::sourceDragOperation const): Rename.
+        (WebCore::DragController::sourceDragOperationMask const):
+        (WebCore::DragController::startDrag):
+        (WebCore::DragController::dragEnteredOrUpdated):
+        (WebCore::DragController::operationForLoad):
+        (WebCore::DragController::tryDocumentDrag):
+        (WebCore::DragController::tryDHTMLDrag):
+        (WebCore::DragController::dragOperation):
+        * page/EventHandler.cpp:
+        (WebCore::convertDropZoneOperationToDragOperation):
+        (WebCore::convertDragOperationToDropZoneOperation):
+        (WebCore::findDropZone):
+        (WebCore::EventHandler::dispatchDragEnterOrDragOverEvent):
+        (WebCore::EventHandler::updateDragAndDrop):
+        (WebCore::EventHandler::cancelDragAndDrop):
+        (WebCore::EventHandler::performDragAndDrop):
+        (WebCore::EventHandler::dragSourceEndedAt):
+        (WebCore::EventHandler::handleDrag):
+        * page/EventHandler.h:
+        (WebCore::EventHandler::updateDragAndDrop):
+        (WebCore::EventHandler::cancelDragAndDrop):
+        (WebCore::EventHandler::performDragAndDrop):
+        (WebCore::EventHandler::dragSourceEndedAt):
+        (WebCore::EventHandler::dispatchDragEnterOrDragOverEvent):
+        * page/gtk/DragControllerGtk.cpp:
+        (WebCore::DragController::dragOperation):
+        * page/mac/DragControllerMac.mm:
+        (WebCore::DragController::dragOperation):
+        * page/win/DragControllerWin.cpp:
+        (WebCore::DragController::dragOperation):
+        - Clean up comment.
+        * platform/DragData.cpp:
+        (WebCore::DragData::DragData):
+        * platform/DragData.h:
+        (WebCore::DragData::DragData):
+        (WebCore::DragData::draggingSourceOperationMask const):
+        * platform/cocoa/DragDataCocoa.mm:
+        (WebCore::DragData::DragData):
+        * platform/gtk/GtkUtilities.cpp:
+        (WebCore::gdkDragActionToDragOperation):
+        (WebCore::dragOperationToGdkDragActions):
+        (WebCore::dragOperationToSingleGdkDragAction):
+        * platform/gtk/GtkUtilities.h:
+        (WebCore::gdkDragActionToDragOperation):
+        (WebCore::dragOperationToGdkDragActions):
+        (WebCore::dragOperationToSingleGdkDragAction):
+        * platform/win/DragDataWin.cpp:
+        (WebCore::DragData::DragData):
+
 2020-06-06  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] FormattingContext::Geometry::computedValue should not try to resolve values when layout is required
index 904bdd9..8056406 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -489,18 +489,18 @@ Ref<DataTransfer> DataTransfer::createForDragStartEvent(const Document& document
     return dataTransfer;
 }
 
-Ref<DataTransfer> DataTransfer::createForDrop(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
+Ref<DataTransfer> DataTransfer::createForDrop(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, OptionSet<DragOperation> sourceOperationMask, bool draggingFiles)
 {
     auto dataTransfer = adoptRef(*new DataTransfer(DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
-    dataTransfer->setSourceOperation(sourceOperation);
+    dataTransfer->setSourceOperationMask(sourceOperationMask);
     dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
     return dataTransfer;
 }
 
-Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
+Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, OptionSet<DragOperation> sourceOperationMask, bool draggingFiles)
 {
     auto dataTransfer = adoptRef(*new DataTransfer(DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
-    dataTransfer->setSourceOperation(sourceOperation);
+    dataTransfer->setSourceOperationMask(sourceOperationMask);
     dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
     return dataTransfer;
 }
@@ -596,74 +596,74 @@ void DragImageLoader::imageChanged(CachedImage*, const IntRect*)
     m_dataTransfer->updateDragImage();
 }
 
-static DragOperation dragOpFromIEOp(const String& operation)
+static OptionSet<DragOperation> dragOpFromIEOp(const String& operation)
 {
     if (operation == "uninitialized")
-        return DragOperationEvery;
+        return anyDragOperation();
     if (operation == "none")
-        return DragOperationNone;
+        return { };
     if (operation == "copy")
-        return DragOperationCopy;
+        return { DragOperationCopy };
     if (operation == "link")
-        return DragOperationLink;
+        return { DragOperationLink };
     if (operation == "move")
-        return (DragOperation)(DragOperationGeneric | DragOperationMove);
+        return { DragOperationGeneric, DragOperationMove };
     if (operation == "copyLink")
-        return (DragOperation)(DragOperationCopy | DragOperationLink);
+        return { DragOperationCopy, DragOperationLink };
     if (operation == "copyMove")
-        return (DragOperation)(DragOperationCopy | DragOperationGeneric | DragOperationMove);
+        return { DragOperationCopy, DragOperationGeneric, DragOperationMove };
     if (operation == "linkMove")
-        return (DragOperation)(DragOperationLink | DragOperationGeneric | DragOperationMove);
+        return { DragOperationLink, DragOperationGeneric, DragOperationMove };
     if (operation == "all")
-        return DragOperationEvery;
-    return DragOperationPrivate; // really a marker for "no conversion"
+        return anyDragOperation();
+    return { DragOperationPrivate }; // Really a marker for "no conversion".
 }
 
-static const char* IEOpFromDragOp(DragOperation operation)
+static const char* IEOpFromDragOp(OptionSet<DragOperation> operationMask)
 {
-    bool isGenericMove = operation & (DragOperationGeneric | DragOperationMove);
+    bool isGenericMove = operationMask.containsAny({ DragOperationGeneric, DragOperationMove });
 
-    if ((isGenericMove && (operation & DragOperationCopy) && (operation & DragOperationLink)) || operation == DragOperationEvery)
+    if ((isGenericMove && operationMask.containsAll({ DragOperationCopy, DragOperationLink })) || operationMask.containsAll({ DragOperationCopy, DragOperationLink, DragOperationGeneric, DragOperationPrivate, DragOperationMove, DragOperationDelete }))
         return "all";
-    if (isGenericMove && (operation & DragOperationCopy))
+    if (isGenericMove && operationMask.contains(DragOperationCopy))
         return "copyMove";
-    if (isGenericMove && (operation & DragOperationLink))
+    if (isGenericMove && operationMask.contains(DragOperationLink))
         return "linkMove";
-    if ((operation & DragOperationCopy) && (operation & DragOperationLink))
+    if (operationMask.containsAll({ DragOperationCopy, DragOperationLink }))
         return "copyLink";
     if (isGenericMove)
         return "move";
-    if (operation & DragOperationCopy)
+    if (operationMask.contains(DragOperationCopy))
         return "copy";
-    if (operation & DragOperationLink)
+    if (operationMask.contains(DragOperationLink))
         return "link";
     return "none";
 }
 
-DragOperation DataTransfer::sourceOperation() const
+OptionSet<DragOperation> DataTransfer::sourceOperationMask() const
 {
-    DragOperation operation = dragOpFromIEOp(m_effectAllowed);
-    ASSERT(operation != DragOperationPrivate);
-    return operation;
+    auto operationMask = dragOpFromIEOp(m_effectAllowed);
+    ASSERT(operationMask != DragOperationPrivate);
+    return operationMask;
 }
 
-DragOperation DataTransfer::destinationOperation() const
+OptionSet<DragOperation> DataTransfer::destinationOperationMask() const
 {
-    DragOperation operation = dragOpFromIEOp(m_dropEffect);
-    ASSERT(operation == DragOperationCopy || operation == DragOperationNone || operation == DragOperationLink || operation == (DragOperation)(DragOperationGeneric | DragOperationMove) || operation == DragOperationEvery);
-    return operation;
+    auto operationMask = dragOpFromIEOp(m_dropEffect);
+    ASSERT(operationMask == DragOperationCopy || operationMask.isEmpty() || operationMask == DragOperationLink || operationMask == OptionSet<DragOperation>({ DragOperationGeneric, DragOperationMove }) || operationMask == anyDragOperation());
+    return operationMask;
 }
 
-void DataTransfer::setSourceOperation(DragOperation operation)
+void DataTransfer::setSourceOperationMask(OptionSet<DragOperation> operationMask)
 {
-    ASSERT_ARG(operation, operation != DragOperationPrivate);
-    m_effectAllowed = IEOpFromDragOp(operation);
+    ASSERT_ARG(operationMask, operationMask != DragOperationPrivate);
+    m_effectAllowed = IEOpFromDragOp(operationMask);
 }
 
-void DataTransfer::setDestinationOperation(DragOperation operation)
+void DataTransfer::setDestinationOperationMask(OptionSet<DragOperation> operationMask)
 {
-    ASSERT_ARG(operation, operation == DragOperationCopy || operation == DragOperationNone || operation == DragOperationLink || operation == DragOperationGeneric || operation == DragOperationMove || operation == (DragOperation)(DragOperationGeneric | DragOperationMove));
-    m_dropEffect = IEOpFromDragOp(operation);
+    ASSERT_ARG(operationMask, operationMask == DragOperationCopy || operationMask.isEmpty() || operationMask == DragOperationLink || operationMask == DragOperationGeneric || operationMask == DragOperationMove || operationMask == OptionSet<DragOperation>({ DragOperationGeneric, DragOperationMove }));
+    m_dropEffect = IEOpFromDragOp(operationMask);
 }
 
 String DataTransfer::dropEffect() const
index e5cfaf8..3cccf67 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
  * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2003-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -88,15 +88,15 @@ public:
 #if ENABLE(DRAG_SUPPORT)
     static Ref<DataTransfer> createForDrag();
     static Ref<DataTransfer> createForDragStartEvent(const Document&);
-    static Ref<DataTransfer> createForDrop(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
-    static Ref<DataTransfer> createForUpdatingDropTarget(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
+    static Ref<DataTransfer> createForDrop(const Document&, std::unique_ptr<Pasteboard>&&, OptionSet<DragOperation>, bool draggingFiles);
+    static Ref<DataTransfer> createForUpdatingDropTarget(const Document&, std::unique_ptr<Pasteboard>&&, OptionSet<DragOperation>, bool draggingFiles);
 
     bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
 
-    DragOperation sourceOperation() const;
-    DragOperation destinationOperation() const;
-    void setSourceOperation(DragOperation);
-    void setDestinationOperation(DragOperation);
+    OptionSet<DragOperation> sourceOperationMask() const;
+    OptionSet<DragOperation> destinationOperationMask() const;
+    void setSourceOperationMask(OptionSet<DragOperation>);
+    void setDestinationOperationMask(OptionSet<DragOperation>);
 
     void setDragHasStarted() { m_shouldUpdateDragImage = true; }
     DragImageRef createDragImage(IntPoint& dragLocation) const;
index a923cae..f3dd3e5 100644 (file)
@@ -60,17 +60,20 @@ typedef enum {
     DragSourceActionAny          = UINT_MAX
 } DragSourceAction;
 
-// Matches NSDragOperation.
-typedef enum {
-    DragOperationNone    = 0,
+// See NSDragOperation, _UIDragOperation and UIDropOperation.
+enum DragOperation {
     DragOperationCopy    = 1,
     DragOperationLink    = 2,
     DragOperationGeneric = 4,
     DragOperationPrivate = 8,
     DragOperationMove    = 16,
     DragOperationDelete  = 32,
-    DragOperationEvery   = UINT_MAX
-} DragOperation;
+};
+
+constexpr OptionSet<DragOperation> anyDragOperation()
+{
+    return { DragOperationCopy, DragOperationLink, DragOperationGeneric, DragOperationPrivate, DragOperationMove, DragOperationDelete };
+}
 
 enum class MayExtendDragSession : bool { No, Yes };
 enum class HasNonDefaultPasteboardData : bool { No, Yes };
@@ -93,6 +96,18 @@ template<> struct EnumTraits<WebCore::DragHandlingMethod> {
     >;
 };
 
+template<> struct EnumTraits<WebCore::DragOperation> {
+    using values = EnumValues<
+        WebCore::DragOperation,
+        WebCore::DragOperationCopy,
+        WebCore::DragOperationLink,
+        WebCore::DragOperationGeneric,
+        WebCore::DragOperationPrivate,
+        WebCore::DragOperationMove,
+        WebCore::DragOperationDelete
+    >;
+};
+
 template<> struct OptionSetTraits<WebCore::DragDestinationAction> {
     using values = OptionSetValues<
         WebCore::DragDestinationAction,
@@ -102,4 +117,16 @@ template<> struct OptionSetTraits<WebCore::DragDestinationAction> {
     >;
 };
 
+template<> struct OptionSetTraits<WebCore::DragOperation> {
+    using values = OptionSetValues<
+        WebCore::DragOperation,
+        WebCore::DragOperationCopy,
+        WebCore::DragOperationLink,
+        WebCore::DragOperationGeneric,
+        WebCore::DragOperationPrivate,
+        WebCore::DragOperationMove,
+        WebCore::DragOperationDelete
+    >;
+};
+
 } // namespace WTF
index 4193d4d..bfba908 100644 (file)
@@ -208,7 +208,7 @@ void DragController::dragEnded()
     client().dragEnded();
 }
 
-DragOperation DragController::dragEntered(const DragData& dragData)
+Optional<DragOperation> DragController::dragEntered(const DragData& dragData)
 {
     return dragEnteredOrUpdated(dragData);
 }
@@ -224,7 +224,7 @@ void DragController::dragExited(const DragData& dragData)
     m_fileInputElementUnderMouse = nullptr;
 }
 
-DragOperation DragController::dragUpdated(const DragData& dragData)
+Optional<DragOperation> DragController::dragUpdated(const DragData& dragData)
 {
     return dragEnteredOrUpdated(dragData);
 }
@@ -278,7 +278,7 @@ bool DragController::performDragOperation(const DragData& dragData)
     m_documentUnderMouse = nullptr;
     clearDragCaret();
 
-    if (operationForLoad(dragData) == DragOperationNone)
+    if (!operationForLoad(dragData))
         return false;
 
     auto urlString = dragData.asURL();
@@ -304,21 +304,21 @@ void DragController::mouseMovedIntoDocument(Document* newDocument)
     m_documentUnderMouse = newDocument;
 }
 
-DragOperation DragController::dragEnteredOrUpdated(const DragData& dragData)
+Optional<DragOperation> DragController::dragEnteredOrUpdated(const DragData& dragData)
 {
     mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData.clientPosition()));
 
     m_dragDestinationActionMask = dragData.dragDestinationActionMask();
     if (m_dragDestinationActionMask.isEmpty()) {
         clearDragCaret(); // FIXME: Why not call mouseMovedIntoDocument(nullptr)?
-        return DragOperationNone;
+        return WTF::nullopt;
     }
 
-    DragOperation dragOperation = DragOperationNone;
+    Optional<DragOperation> dragOperation;
     m_dragHandlingMethod = tryDocumentDrag(dragData, m_dragDestinationActionMask, dragOperation);
     if (m_dragHandlingMethod == DragHandlingMethod::None && (m_dragDestinationActionMask.contains(DragDestinationAction::Load))) {
         dragOperation = operationForLoad(dragData);
-        if (dragOperation != DragOperationNone)
+        if (dragOperation)
             m_dragHandlingMethod = DragHandlingMethod::PageLoad;
     } else if (m_dragHandlingMethod == DragHandlingMethod::SetColor)
         dragOperation = DragOperationCopy;
@@ -388,7 +388,7 @@ void DragController::updateSupportedTypeIdentifiersForDragHandlingMethod(DragHan
 
 #endif
 
-DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, OptionSet<DragDestinationAction> destinationActionMask, DragOperation& dragOperation)
+DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, OptionSet<DragDestinationAction> destinationActionMask, Optional<DragOperation>& dragOperation)
 {
     if (!m_documentUnderMouse)
         return DragHandlingMethod::None;
@@ -458,7 +458,7 @@ DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, Opt
                 m_numberOfItemsToBeAccepted = 1;
             
             if (!m_numberOfItemsToBeAccepted)
-                dragOperation = DragOperationNone;
+                dragOperation = WTF::nullopt;
             m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(m_numberOfItemsToBeAccepted);
         } else {
             // We are not over a file input element. The dragged item(s) will loaded into the view,
@@ -489,7 +489,7 @@ DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootVi
     return m_dragSourceAction;
 }
 
-DragOperation DragController::operationForLoad(const DragData& dragData)
+Optional<DragOperation> DragController::operationForLoad(const DragData& dragData)
 {
     Document* document = m_page.mainFrame().documentAtPoint(dragData.clientPosition());
 
@@ -504,7 +504,7 @@ DragOperation DragController::operationForLoad(const DragData& dragData)
     }
 
     if (document && (m_didInitiateDrag || (is<PluginDocument>(*document) && !pluginDocumentAcceptsDrags) || document->hasEditableStyle()))
-        return DragOperationNone;
+        return WTF::nullopt;
     return dragOperation(dragData);
 }
 
@@ -693,28 +693,28 @@ bool DragController::canProcessDrag(const DragData& dragData)
     return true;
 }
 
-static DragOperation defaultOperationForDrag(DragOperation srcOpMask)
+static Optional<DragOperation> defaultOperationForDrag(OptionSet<DragOperation> sourceOperationMask)
 {
     // This is designed to match IE's operation fallback for the case where
     // the page calls preventDefault() in a drag event but doesn't set dropEffect.
-    if (srcOpMask == DragOperationEvery)
+    if (sourceOperationMask.containsAll({ DragOperationCopy, DragOperationLink, DragOperationGeneric, DragOperationPrivate, DragOperationMove, DragOperationDelete }))
         return DragOperationCopy;
-    if (srcOpMask == DragOperationNone)
-        return DragOperationNone;
-    if (srcOpMask & DragOperationMove)
+    if (sourceOperationMask.isEmpty())
+        return WTF::nullopt;
+    if (sourceOperationMask.contains(DragOperationMove))
         return DragOperationMove;
-    if (srcOpMask & DragOperationGeneric)
+    if (sourceOperationMask.contains(DragOperationGeneric))
         return DragController::platformGenericDragOperation();
-    if (srcOpMask & DragOperationCopy)
+    if (sourceOperationMask.contains(DragOperationCopy))
         return DragOperationCopy;
-    if (srcOpMask & DragOperationLink)
+    if (sourceOperationMask.contains(DragOperationLink))
         return DragOperationLink;
     
     // FIXME: Does IE really return "generic" even if no operations were allowed by the source?
     return DragOperationGeneric;
 }
 
-bool DragController::tryDHTMLDrag(const DragData& dragData, DragOperation& operation)
+bool DragController::tryDHTMLDrag(const DragData& dragData, Optional<DragOperation>& operation)
 {
     ASSERT(m_documentUnderMouse);
     Ref<Frame> mainFrame(m_page.mainFrame());
@@ -722,17 +722,19 @@ bool DragController::tryDHTMLDrag(const DragData& dragData, DragOperation& opera
     if (!viewProtector)
         return false;
 
-    DragOperation sourceOperation = dragData.draggingSourceOperationMask();
-    auto targetResponse = mainFrame->eventHandler().updateDragAndDrop(createMouseEvent(dragData), [&dragData]() { return Pasteboard::createForDragAndDrop(dragData); }, sourceOperation, dragData.containsFiles());
+    auto sourceOperationMask = dragData.draggingSourceOperationMask();
+    auto targetResponse = mainFrame->eventHandler().updateDragAndDrop(createMouseEvent(dragData), [&dragData]() {
+        return Pasteboard::createForDragAndDrop(dragData);
+    }, sourceOperationMask, dragData.containsFiles());
     if (!targetResponse.accept)
         return false;
 
-    if (!targetResponse.operation)
-        operation = defaultOperationForDrag(sourceOperation);
-    else if (!(sourceOperation & targetResponse.operation.value())) // The element picked an operation which is not supported by the source
-        operation = DragOperationNone;
+    if (!targetResponse.operationMask)
+        operation = defaultOperationForDrag(sourceOperationMask);
+    else if (!sourceOperationMask.containsAny(targetResponse.operationMask.value())) // The element picked an operation which is not supported by the source.
+        operation = WTF::nullopt;
     else
-        operation = targetResponse.operation.value();
+        operation = defaultOperationForDrag(targetResponse.operationMask.value());
 
     return true;
 }
@@ -956,7 +958,7 @@ Optional<HitTestResult> DragController::hitTestResultForDragStart(Frame& source,
     return { hitTestResult };
 }
 
-bool DragController::startDrag(Frame& src, const DragState& state, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, HasNonDefaultPasteboardData hasData)
+bool DragController::startDrag(Frame& src, const DragState& state, OptionSet<DragOperation> sourceOperationMask, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, HasNonDefaultPasteboardData hasData)
 {
     if (!state.source)
         return false;
@@ -972,7 +974,7 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
     IntPoint mouseDraggedPoint = src.view()->windowToContents(dragEvent.position());
 
     m_draggingImageURL = URL();
-    m_sourceDragOperation = srcOp;
+    m_sourceDragOperationMask = sourceOperationMask;
 
     DragImage dragImage;
     IntPoint dragLoc(0, 0);
@@ -995,7 +997,7 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
         // Selection, image, and link drags receive a default set of allowed drag operations that
         // follows from:
         // http://trac.webkit.org/browser/trunk/WebKit/mac/WebView/WebHTMLView.mm?rev=48526#L3430
-        m_sourceDragOperation = static_cast<DragOperation>(m_sourceDragOperation | DragOperationGeneric | DragOperationCopy);
+        m_sourceDragOperationMask.add({ DragOperationGeneric, DragOperationCopy });
     }
 
     ASSERT(state.source);
index 90f875c..ea499e0 100644 (file)
@@ -59,9 +59,9 @@ public:
 
     static DragOperation platformGenericDragOperation();
 
-    WEBCORE_EXPORT DragOperation dragEntered(const DragData&);
+    WEBCORE_EXPORT Optional<DragOperation> dragEntered(const DragData&);
     WEBCORE_EXPORT void dragExited(const DragData&);
-    WEBCORE_EXPORT DragOperation dragUpdated(const DragData&);
+    WEBCORE_EXPORT Optional<DragOperation> dragUpdated(const DragData&);
     WEBCORE_EXPORT bool performDragOperation(const DragData&);
     WEBCORE_EXPORT void dragCancelled();
 
@@ -72,7 +72,7 @@ public:
     // drag logic is in WebCore.
     void setDidInitiateDrag(bool initiated) { m_didInitiateDrag = initiated; }
     bool didInitiateDrag() const { return m_didInitiateDrag; }
-    DragOperation sourceDragOperation() const { return m_sourceDragOperation; }
+    OptionSet<DragOperation> sourceDragOperationMask() const { return m_sourceDragOperationMask; }
     const URL& draggingImageURL() const { return m_draggingImageURL; }
     void setDragOffset(const IntPoint& offset) { m_dragOffset = offset; }
     const IntPoint& dragOffset() const { return m_dragOffset; }
@@ -95,7 +95,7 @@ public:
     WEBCORE_EXPORT void insertDroppedImagePlaceholdersAtCaret(const Vector<IntSize>& imageSizes);
 
     void prepareForDragStart(Frame& sourceFrame, DragSourceAction, Element& sourceElement, DataTransfer&, const IntPoint& dragOrigin) const;
-    bool startDrag(Frame& src, const DragState&, DragOperation srcOp, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, HasNonDefaultPasteboardData);
+    bool startDrag(Frame& src, const DragState&, OptionSet<DragOperation>, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, HasNonDefaultPasteboardData);
     static const IntSize& maxDragImageSize();
 
     static const int MaxOriginalImageArea;
@@ -108,11 +108,11 @@ private:
     bool dispatchTextInputEventFor(Frame*, const DragData&);
     bool canProcessDrag(const DragData&);
     bool concludeEditDrag(const DragData&);
-    DragOperation dragEnteredOrUpdated(const DragData&);
-    DragOperation operationForLoad(const DragData&);
-    DragHandlingMethod tryDocumentDrag(const DragData&, OptionSet<DragDestinationAction>, DragOperation&);
-    bool tryDHTMLDrag(const DragData&, DragOperation&);
-    DragOperation dragOperation(const DragData&);
+    Optional<DragOperation> dragEnteredOrUpdated(const DragData&);
+    Optional<DragOperation> operationForLoad(const DragData&);
+    DragHandlingMethod tryDocumentDrag(const DragData&, OptionSet<DragDestinationAction>, Optional<DragOperation>&);
+    bool tryDHTMLDrag(const DragData&, Optional<DragOperation>&);
+    Optional<DragOperation> dragOperation(const DragData&);
     void clearDragCaret();
     bool dragIsMove(FrameSelection&, const DragData&);
     bool isCopyKeyDown(const DragData&);
@@ -156,7 +156,7 @@ private:
     OptionSet<DragDestinationAction> m_dragDestinationActionMask;
     DragSourceAction m_dragSourceAction { DragSourceActionNone };
     bool m_didInitiateDrag { false };
-    DragOperation m_sourceDragOperation { DragOperationNone }; // Set in startDrag when a drag starts from a mouse down within WebKit
+    OptionSet<DragOperation> m_sourceDragOperationMask; // Set in startDrag when a drag starts from a mouse down within WebKit.
     IntPoint m_dragOffset;
     URL m_draggingImageURL;
     bool m_isPerformingDrop { false };
index 37d4b41..0e01345 100644 (file)
@@ -2334,7 +2334,7 @@ static bool targetIsFrame(Node* target, Frame*& frame)
     return true;
 }
 
-static DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation)
+static Optional<DragOperation> convertDropZoneOperationToDragOperation(const String& dragOperation)
 {
     if (dragOperation == "copy")
         return DragOperationCopy;
@@ -2342,21 +2342,22 @@ static DragOperation convertDropZoneOperationToDragOperation(const String& dragO
         return DragOperationMove;
     if (dragOperation == "link")
         return DragOperationLink;
-    return DragOperationNone;
+    return WTF::nullopt;
 }
 
-static String convertDragOperationToDropZoneOperation(DragOperation operation)
+static String convertDragOperationToDropZoneOperation(Optional<DragOperation> operation)
 {
-    switch (operation) {
-    case DragOperationCopy:
-        return "copy"_s;
-    case DragOperationMove:
-        return "move"_s;
-    case DragOperationLink:
-        return "link"_s;
-    default:
-        return "copy"_s;
+    if (operation) {
+        switch (*operation) {
+        case DragOperationMove:
+            return "move"_s;
+        case DragOperationLink:
+            return "link"_s;
+        default:
+            break;
+        }
     }
+    return "copy"_s;
 }
 
 static bool hasDropZoneType(DataTransfer& dataTransfer, const String& keyword)
@@ -2376,15 +2377,14 @@ static bool findDropZone(Node& target, DataTransfer& dataTransfer)
     for (; element; element = element->parentElement()) {
         SpaceSplitString keywords(element->attributeWithoutSynchronization(webkitdropzoneAttr), true);
         bool matched = false;
-        DragOperation dragOperation = DragOperationNone;
+        Optional<DragOperation> dragOperation;
         for (unsigned i = 0, size = keywords.size(); i < size; ++i) {
-            DragOperation op = convertDropZoneOperationToDragOperation(keywords[i]);
-            if (op != DragOperationNone) {
-                if (dragOperation == DragOperationNone)
-                    dragOperation = op;
+            if (auto operationFromKeyword = convertDropZoneOperationToDragOperation(keywords[i])) {
+                if (!dragOperation)
+                    dragOperation = operationFromKeyword;
             } else
                 matched = matched || hasDropZoneType(dataTransfer, keywords[i].string());
-            if (matched && dragOperation != DragOperationNone)
+            if (matched && dragOperation)
                 break;
         }
         if (matched) {
@@ -2395,20 +2395,19 @@ static bool findDropZone(Node& target, DataTransfer& dataTransfer)
     return false;
 }
 
-EventHandler::DragTargetResponse EventHandler::dispatchDragEnterOrDragOverEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent& event,
-    std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
+EventHandler::DragTargetResponse EventHandler::dispatchDragEnterOrDragOverEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent& event, std::unique_ptr<Pasteboard>&& pasteboard, OptionSet<DragOperation> sourceOperationMask, bool draggingFiles)
 {
-    auto dataTransfer = DataTransfer::createForUpdatingDropTarget(target.document(), WTFMove(pasteboard), sourceOperation, draggingFiles);
+    auto dataTransfer = DataTransfer::createForUpdatingDropTarget(target.document(), WTFMove(pasteboard), sourceOperationMask, draggingFiles);
     bool accept = dispatchDragEvent(eventType, target, event, dataTransfer.get());
     if (!accept)
         accept = findDropZone(target, dataTransfer);
     dataTransfer->makeInvalidForSecurity();
     if (accept && !dataTransfer->dropEffectIsUninitialized())
-        return { true, dataTransfer->destinationOperation() };
+        return { true, dataTransfer->destinationOperationMask() };
     return { accept, WTF::nullopt };
 }
 
-EventHandler::DragTargetResponse EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, const std::function<std::unique_ptr<Pasteboard>()>& makePasteboard, DragOperation sourceOperation, bool draggingFiles)
+EventHandler::DragTargetResponse EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, const std::function<std::unique_ptr<Pasteboard>()>& makePasteboard, OptionSet<DragOperation> sourceOperationMask, bool draggingFiles)
 {
     Ref<Frame> protectedFrame(m_frame);
     if (!m_frame.view())
@@ -2438,19 +2437,19 @@ EventHandler::DragTargetResponse EventHandler::updateDragAndDrop(const PlatformM
         Frame* targetFrame;
         if (targetIsFrame(newTarget.get(), targetFrame)) {
             if (targetFrame)
-                response = targetFrame->eventHandler().updateDragAndDrop(event, makePasteboard, sourceOperation, draggingFiles);
+                response = targetFrame->eventHandler().updateDragAndDrop(event, makePasteboard, sourceOperationMask, draggingFiles);
         } else if (newTarget) {
             // As per section 7.9.4 of the HTML 5 spec., we must always fire a drag event before firing a dragenter, dragleave, or dragover event.
             dispatchEventToDragSourceElement(eventNames().dragEvent, event);
-            response = dispatchDragEnterOrDragOverEvent(eventNames().dragenterEvent, *newTarget, event, makePasteboard(), sourceOperation, draggingFiles);
+            response = dispatchDragEnterOrDragOverEvent(eventNames().dragenterEvent, *newTarget, event, makePasteboard(), sourceOperationMask, draggingFiles);
         }
 
         if (targetIsFrame(m_dragTarget.get(), targetFrame)) {
             // FIXME: Recursing again here doesn't make sense if the newTarget and m_dragTarget were in the same frame.
             if (targetFrame)
-                response = targetFrame->eventHandler().updateDragAndDrop(event, makePasteboard, sourceOperation, draggingFiles);
+                response = targetFrame->eventHandler().updateDragAndDrop(event, makePasteboard, sourceOperationMask, draggingFiles);
         } else if (m_dragTarget) {
-            auto dataTransfer = DataTransfer::createForUpdatingDropTarget(m_dragTarget->document(), makePasteboard(), sourceOperation, draggingFiles);
+            auto dataTransfer = DataTransfer::createForUpdatingDropTarget(m_dragTarget->document(), makePasteboard(), sourceOperationMask, draggingFiles);
             dispatchDragEvent(eventNames().dragleaveEvent, *m_dragTarget, event, dataTransfer.get());
             dataTransfer->makeInvalidForSecurity();
         }
@@ -2464,12 +2463,12 @@ EventHandler::DragTargetResponse EventHandler::updateDragAndDrop(const PlatformM
         Frame* targetFrame;
         if (targetIsFrame(newTarget.get(), targetFrame)) {
             if (targetFrame)
-                response = targetFrame->eventHandler().updateDragAndDrop(event, makePasteboard, sourceOperation, draggingFiles);
+                response = targetFrame->eventHandler().updateDragAndDrop(event, makePasteboard, sourceOperationMask, draggingFiles);
         } else if (newTarget) {
             // Note, when dealing with sub-frames, we may need to fire only a dragover event as a drag event may have been fired earlier.
             if (!m_shouldOnlyFireDragOverEvent)
                 dispatchEventToDragSourceElement(eventNames().dragEvent, event);
-            response = dispatchDragEnterOrDragOverEvent(eventNames().dragoverEvent, *newTarget, event, makePasteboard(), sourceOperation, draggingFiles);
+            response = dispatchDragEnterOrDragOverEvent(eventNames().dragoverEvent, *newTarget, event, makePasteboard(), sourceOperationMask, draggingFiles);
             m_shouldOnlyFireDragOverEvent = false;
         }
     }
@@ -2477,25 +2476,25 @@ EventHandler::DragTargetResponse EventHandler::updateDragAndDrop(const PlatformM
     return response;
 }
 
-void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
+void EventHandler::cancelDragAndDrop(const PlatformMouseEvent& event, std::unique_ptr<Pasteboard>&& pasteboard, OptionSet<DragOperation> sourceOperationMask, bool draggingFiles)
 {
     Ref<Frame> protectedFrame(m_frame);
 
     Frame* targetFrame;
     if (targetIsFrame(m_dragTarget.get(), targetFrame)) {
         if (targetFrame)
-            targetFrame->eventHandler().cancelDragAndDrop(event, WTFMove(pasteboard), sourceOperation, draggingFiles);
+            targetFrame->eventHandler().cancelDragAndDrop(event, WTFMove(pasteboard), sourceOperationMask, draggingFiles);
     } else if (m_dragTarget) {
         dispatchEventToDragSourceElement(eventNames().dragEvent, event);
 
-        auto dataTransfer = DataTransfer::createForUpdatingDropTarget(m_dragTarget->document(), WTFMove(pasteboard), sourceOperation, draggingFiles);
+        auto dataTransfer = DataTransfer::createForUpdatingDropTarget(m_dragTarget->document(), WTFMove(pasteboard), sourceOperationMask, draggingFiles);
         dispatchDragEvent(eventNames().dragleaveEvent, *m_dragTarget, event, dataTransfer.get());
         dataTransfer->makeInvalidForSecurity();
     }
     clearDragState();
 }
 
-bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
+bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, std::unique_ptr<Pasteboard>&& pasteboard, OptionSet<DragOperation> sourceOperationMask, bool draggingFiles)
 {
     Ref<Frame> protectedFrame(m_frame);
 
@@ -2503,9 +2502,9 @@ bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, std::uniq
     bool preventedDefault = false;
     if (targetIsFrame(m_dragTarget.get(), targetFrame)) {
         if (targetFrame)
-            preventedDefault = targetFrame->eventHandler().performDragAndDrop(event, WTFMove(pasteboard), sourceOperation, draggingFiles);
+            preventedDefault = targetFrame->eventHandler().performDragAndDrop(event, WTFMove(pasteboard), sourceOperationMask, draggingFiles);
     } else if (m_dragTarget) {
-        auto dataTransfer = DataTransfer::createForDrop(m_dragTarget->document(), WTFMove(pasteboard), sourceOperation, draggingFiles);
+        auto dataTransfer = DataTransfer::createForDrop(m_dragTarget->document(), WTFMove(pasteboard), sourceOperationMask, draggingFiles);
         preventedDefault = dispatchDragEvent(eventNames().dropEvent, *m_dragTarget, event, dataTransfer);
         dataTransfer->makeInvalidForSecurity();
     }
@@ -3729,13 +3728,13 @@ void EventHandler::didStartDrag()
 #endif
 }
 
-void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, DragOperation operation, MayExtendDragSession mayExtendDragSession)
+void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, OptionSet<DragOperation> dragOperationMask, MayExtendDragSession mayExtendDragSession)
 {
     // Send a hit test request so that RenderLayer gets a chance to update the :hover and :active pseudoclasses.
     prepareMouseEvent(OptionSet<HitTestRequest::RequestType> { HitTestRequest::Release, HitTestRequest::DisallowUserAgentShadowContent }, event);
 
     if (shouldDispatchEventsToDragSourceElement()) {
-        dragState().dataTransfer->setDestinationOperation(operation);
+        dragState().dataTransfer->setDestinationOperationMask(dragOperationMask);
         dispatchEventToDragSourceElement(eventNames().dragendEvent, event);
     }
     invalidateDataTransfer();
@@ -3865,7 +3864,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr
     // Once we're past the hysteresis point, we don't want to treat this gesture as a click
     invalidateClick();
     
-    DragOperation srcOp = DragOperationNone;      
+    OptionSet<DragOperation> sourceOperationMask;
     
     // This does work only if we missed a dragEnd. Do it anyway, just to make sure the old dataTransfer gets numbed.
     // FIXME: Consider doing this earlier in this function as the earliest point we're sure it would be safe to drop an old drag.
@@ -3901,7 +3900,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr
 
         if (m_mouseDownMayStartDrag) {
             // Gather values from DHTML element, if it set any.
-            srcOp = dragState().dataTransfer->sourceOperation();
+            sourceOperationMask = dragState().dataTransfer->sourceOperationMask();
             
             // Yuck, a draggedImage:moveTo: message can be fired as a result of kicking off the
             // drag with dragImage! Because of that dumb reentrancy, we may think we've not
@@ -3912,7 +3911,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr
     
     if (m_mouseDownMayStartDrag) {
         Page* page = m_frame.page();
-        m_didStartDrag = page && page->dragController().startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownContentsPosition, hasNonDefaultPasteboardData);
+        m_didStartDrag = page && page->dragController().startDrag(m_frame, dragState(), sourceOperationMask, event.event(), m_mouseDownContentsPosition, hasNonDefaultPasteboardData);
         // In WebKit2 we could re-enter this code and start another drag.
         // On OS X this causes problems with the ownership of the pasteboard and the promised types.
         if (m_didStartDrag) {
index 6ffc83c..27cae61 100644 (file)
@@ -163,11 +163,11 @@ public:
 #if ENABLE(DRAG_SUPPORT)
     struct DragTargetResponse {
         bool accept { false };
-        Optional<DragOperation> operation;
+        Optional<OptionSet<DragOperation>> operationMask;
     };
-    DragTargetResponse updateDragAndDrop(const PlatformMouseEvent&, const std::function<std::unique_ptr<Pasteboard>()>&, DragOperation sourceOperation, bool draggingFiles);
-    void cancelDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
-    bool performDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
+    DragTargetResponse updateDragAndDrop(const PlatformMouseEvent&, const std::function<std::unique_ptr<Pasteboard>()>&, OptionSet<DragOperation>, bool draggingFiles);
+    void cancelDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, OptionSet<DragOperation>, bool draggingFiles);
+    bool performDragAndDrop(const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&&, OptionSet<DragOperation>, bool draggingFiles);
     void updateDragStateAfterEditDragIfNeeded(Element& rootEditableElement);
     RefPtr<Element> draggedElement() const;
 #endif
@@ -268,7 +268,7 @@ public:
     
     WEBCORE_EXPORT void didStartDrag();
     WEBCORE_EXPORT void dragCancelled();
-    WEBCORE_EXPORT void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation, MayExtendDragSession = MayExtendDragSession::No);
+    WEBCORE_EXPORT void dragSourceEndedAt(const PlatformMouseEvent&, OptionSet<DragOperation>, MayExtendDragSession = MayExtendDragSession::No);
 #endif
 
     void focusDocumentView();
@@ -416,7 +416,7 @@ private:
 
 #if ENABLE(DRAG_SUPPORT)
     bool dispatchDragEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, DataTransfer&);
-    DragTargetResponse dispatchDragEnterOrDragOverEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&& , DragOperation, bool draggingFiles);
+    DragTargetResponse dispatchDragEnterOrDragOverEvent(const AtomString& eventType, Element& target, const PlatformMouseEvent&, std::unique_ptr<Pasteboard>&& , OptionSet<DragOperation>, bool draggingFiles);
     void invalidateDataTransfer();
 
     bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis);
index 7d052cf..d71ab1d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -50,13 +50,13 @@ bool DragController::isCopyKeyDown(const DragData& dragData)
     return dragData.flags() & DragApplicationIsCopyKeyDown;
 }
 
-DragOperation DragController::dragOperation(const DragData& dragData)
+Optional<DragOperation> DragController::dragOperation(const DragData& dragData)
 {
     // FIXME: This logic is incomplete
     if (dragData.containsURL())
         return DragOperationCopy;
 
-    return DragOperationNone;
+    return WTF::nullopt;
 }
 
 const IntSize& DragController::maxDragImageSize()
index 85bd48a..c603fbd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -64,10 +64,10 @@ bool DragController::isCopyKeyDown(const DragData& dragData)
     return dragData.flags() & DragApplicationIsCopyKeyDown;
 }
     
-DragOperation DragController::dragOperation(const DragData& dragData)
+Optional<DragOperation> DragController::dragOperation(const DragData& dragData)
 {
     if (dragData.flags() & DragApplicationIsModal)
-        return DragOperationNone;
+        return WTF::nullopt;
 
     bool mayContainURL;
     if (canLoadDataFromDraggingPasteboard())
@@ -76,12 +76,12 @@ DragOperation DragController::dragOperation(const DragData& dragData)
         mayContainURL = dragData.containsURLTypeIdentifier();
 
     if (!mayContainURL && !dragData.containsPromise())
-        return DragOperationNone;
+        return WTF::nullopt;
 
     if (!m_documentUnderMouse || (!(dragData.flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
         return DragOperationCopy;
 
-    return DragOperationNone;
+    return WTF::nullopt;
 }
 
 const IntSize& DragController::maxDragImageSize()
index 2d46d6b..8db8c9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -42,13 +42,15 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-DragOperation DragController::dragOperation(const DragData& dragData)
+Optional<DragOperation> DragController::dragOperation(const DragData& dragData)
 {
-    //FIXME: to match the macos behaviour we should return DragOperationNone
-    //if we are a modal window, we are the drag source, or the window is an attached sheet
-    //If this can be determined from within WebCore operationForDrag can be pulled into 
-    //WebCore itself
-    return dragData.containsURL() && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
+    // FIXME: To match the macOS behaviour we should return WTF::nullopt.
+    // If we are a modal window, we are the drag source, or the window is an attached sheet.
+    // If this can be determined from within WebCore operationForDrag can be pulled into
+    // WebCore itself.
+    if (dragData.containsURL() && !m_didInitiateDrag)
+        return DragOperationCopy;
+    return WTF::nullopt;
 }
 
 bool DragController::isCopyKeyDown(const DragData&)
index 8f6755f..e8c40f5 100644 (file)
@@ -32,7 +32,7 @@
 namespace WebCore {
 
 #if !PLATFORM(COCOA)
-DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
+DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation> sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(data)
@@ -42,7 +42,7 @@ DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPo
 {  
 }
 
-DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
+DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation> sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(0)
index 421a299..31b8ab9 100644 (file)
@@ -75,13 +75,13 @@ public:
     enum class DraggingPurpose { ForEditing, ForFileUpload, ForColorControl };
 
     // clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
-    WEBCORE_EXPORT DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone, OptionSet<DragDestinationAction> = anyDragDestinationAction());
-    WEBCORE_EXPORT DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone, OptionSet<DragDestinationAction> = anyDragDestinationAction());
+    WEBCORE_EXPORT DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation>, DragApplicationFlags = DragApplicationNone, OptionSet<DragDestinationAction> = anyDragDestinationAction());
+    WEBCORE_EXPORT DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation>, DragApplicationFlags = DragApplicationNone, OptionSet<DragDestinationAction> = anyDragDestinationAction());
     // This constructor should used only by WebKit2 IPC because DragData
     // is initialized by the decoder and not in the constructor.
     DragData() = default;
 #if PLATFORM(WIN)
-    WEBCORE_EXPORT DragData(const DragDataMap&, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags = DragApplicationNone);
+    WEBCORE_EXPORT DragData(const DragDataMap&, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation> sourceOperationMask, DragApplicationFlags = DragApplicationNone);
     const DragDataMap& dragDataMap();
     void getDragFileDescriptorData(int& size, String& pathname);
     void getDragFileContentData(int size, void* dataBlob);
@@ -90,7 +90,7 @@ public:
     const IntPoint& globalPosition() const { return m_globalPosition; }
     DragApplicationFlags flags() const { return m_applicationFlags; }
     DragDataRef platformData() const { return m_platformDragData; }
-    DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
+    OptionSet<DragOperation> draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
     bool containsURL(FilenameConversionPolicy = ConvertFilenames) const;
     bool containsPlainText() const;
     bool containsCompatibleContent(DraggingPurpose = DraggingPurpose::ForEditing) const;
@@ -129,7 +129,7 @@ private:
     IntPoint m_clientPosition;
     IntPoint m_globalPosition;
     DragDataRef m_platformDragData;
-    DragOperation m_draggingSourceOperationMask;
+    OptionSet<DragOperation> m_draggingSourceOperationMask;
     DragApplicationFlags m_applicationFlags;
     Vector<String> m_fileNames;
     OptionSet<DragDestinationAction> m_dragDestinationActionMask;
index 9ccafc0..3a1289d 100644 (file)
@@ -116,7 +116,7 @@ static inline String tiffPasteboardType()
 #endif
 }
 
-DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
+DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation> sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(data)
@@ -131,7 +131,7 @@ DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPo
 {
 }
 
-DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
+DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation> sourceOperationMask, DragApplicationFlags flags, OptionSet<DragDestinationAction> destinationActionMask)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(0)
index 0c013cf..5e7f2f3 100644 (file)
@@ -149,49 +149,40 @@ unsigned stateModifierForGdkButton(unsigned button)
     return 1 << (8 + button - 1);
 }
 
-DragOperation gdkDragActionToDragOperation(GdkDragAction gdkAction)
+OptionSet<DragOperation> gdkDragActionToDragOperation(GdkDragAction gdkAction)
 {
-    // We have no good way to detect DragOperationEvery other than
-    // to use it when all applicable flags are on.
-    if (gdkAction & GDK_ACTION_COPY
-        && gdkAction & GDK_ACTION_MOVE
-        && gdkAction & GDK_ACTION_LINK)
-        return DragOperationEvery;
-
-    unsigned action = DragOperationNone;
+    OptionSet<DragOperation> action;
     if (gdkAction & GDK_ACTION_COPY)
-        action |= DragOperationCopy;
+        action.add(DragOperationCopy);
     if (gdkAction & GDK_ACTION_MOVE)
-        action |= DragOperationMove;
+        action.add(DragOperationMove);
     if (gdkAction & GDK_ACTION_LINK)
-        action |= DragOperationLink;
+        action.add(DragOperationLink);
 
-    return static_cast<DragOperation>(action);
+    return action;
 }
 
-GdkDragAction dragOperationToGdkDragActions(DragOperation coreAction)
+GdkDragAction dragOperationToGdkDragActions(OptionSet<DragOperation> coreAction)
 {
     unsigned gdkAction = 0;
-    if (coreAction == DragOperationNone)
-        return static_cast<GdkDragAction>(gdkAction);
 
-    if (coreAction & DragOperationCopy)
+    if (coreAction.contains(DragOperationCopy))
         gdkAction |= GDK_ACTION_COPY;
-    if (coreAction & DragOperationMove)
+    if (coreAction.contains(DragOperationMove))
         gdkAction |= GDK_ACTION_MOVE;
-    if (coreAction & DragOperationLink)
+    if (coreAction.contains(DragOperationLink))
         gdkAction |= GDK_ACTION_LINK;
 
     return static_cast<GdkDragAction>(gdkAction);
 }
 
-GdkDragAction dragOperationToSingleGdkDragAction(DragOperation coreAction)
+GdkDragAction dragOperationToSingleGdkDragAction(OptionSet<DragOperation> coreAction)
 {
-    if (coreAction == DragOperationEvery || coreAction & DragOperationCopy)
+    if (coreAction.contains(DragOperationCopy))
         return GDK_ACTION_COPY;
-    if (coreAction & DragOperationMove)
+    if (coreAction.contains(DragOperationMove))
         return GDK_ACTION_MOVE;
-    if (coreAction & DragOperationLink)
+    if (coreAction.contains(DragOperationLink))
         return GDK_ACTION_LINK;
     return static_cast<GdkDragAction>(0);
 }
index 5aab4eb..198bc8e 100644 (file)
@@ -51,8 +51,8 @@ String defaultGtkSystemFont();
 
 WEBCORE_EXPORT unsigned stateModifierForGdkButton(unsigned button);
 
-WEBCORE_EXPORT DragOperation gdkDragActionToDragOperation(GdkDragAction);
-WEBCORE_EXPORT GdkDragAction dragOperationToGdkDragActions(DragOperation);
-WEBCORE_EXPORT GdkDragAction dragOperationToSingleGdkDragAction(DragOperation);
+WEBCORE_EXPORT OptionSet<DragOperation> gdkDragActionToDragOperation(GdkDragAction);
+WEBCORE_EXPORT GdkDragAction dragOperationToGdkDragActions(OptionSet<DragOperation>);
+WEBCORE_EXPORT GdkDragAction dragOperationToSingleGdkDragAction(OptionSet<DragOperation>);
 
 } // namespace WebCore
index ee0d8b2..18870f2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Baidu Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@
 namespace WebCore {
 
 DragData::DragData(const DragDataMap& data, const IntPoint& clientPosition, const IntPoint& globalPosition,
-    DragOperation sourceOperationMask, DragApplicationFlags flags)
+    OptionSet<DragOperation> sourceOperationMask, DragApplicationFlags flags)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(0)
index 922e29a..c7e3143 100644 (file)
@@ -1,3 +1,105 @@
+2020-06-06  David Kilzer  <ddkilzer@apple.com>
+
+        Use OptionSet<DragOperation> for mask values
+        <https://webkit.org/b/212605>
+
+        Reviewed by Darin Adler.
+
+        In broad strokes:
+        - Replace use of DragOperation with OptionSet<DragOperation> or
+          Optional<DragOperation>.
+        - Rename function parameters and local variables to denote use
+          of mask values.
+        - Remove DragOperationNone enum value.
+        - Replace DragOperationEvery enum value with anyDragOperation().
+
+        * Platform/spi/ios/UIKitSPI.h:
+        (UIDragOperation):
+        - Remove unused (and misnamed) UIDragOperation enum typedef.
+        * Scripts/webkit/messages.py:
+        (types_that_cannot_be_forward_declared):
+        (headers_for_type):
+        - Add support for WebCore::DragOperation enum.
+        * Shared/API/Cocoa/_WKDragActionsInternal.h:
+        (WebKit::coreDragOperationMask): Add conversion function.
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<DragData>::encode):
+        (IPC::ArgumentCoder<DragData>::decode):
+        - Update to encode/decode OptionSet<DragOperation>.
+
+        * UIProcess/API/gtk/DragSource.h:
+        (WebKit::DragSource::begin):
+        * UIProcess/API/gtk/DragSourceGtk3.cpp:
+        (WebKit::DragSource::begin):
+        * UIProcess/API/gtk/DragSourceGtk4.cpp:
+        (WebKit::DragSource::begin):
+        * UIProcess/API/gtk/DropTarget.h:
+        * UIProcess/API/gtk/DropTargetGtk3.cpp:
+        (WebKit::DropTarget::didPerformAction):
+        (WebKit::DropTarget::leaveTimerFired):
+        * UIProcess/API/gtk/DropTargetGtk4.cpp:
+        (WebKit::DropTarget::DropTarget):
+        (WebKit::DropTarget::didPerformAction):
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::startDrag):
+        * UIProcess/API/gtk/PageClientImpl.h:
+        (WebKit::PageClientImpl::startDrag):
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseStartDrag):
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        (webkitWebViewBaseStartDrag):
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::sendDragEndToPage):
+        (WebKit::WebViewImpl::draggingEntered):
+        (WebKit::kit): Add conversion function.
+        (WebKit::WebViewImpl::draggingUpdated):
+        (WebKit::WebViewImpl::draggingExited):
+        (WebKit::WebViewImpl::performDragOperation):
+        - Make use of coreDragOperationMask() conversion function.
+        * UIProcess/PageClient.h:
+        (WebKit::WebViewImpl::startDrag):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didPerformDragControllerAction):
+        - Remove MESSAGE_CHECK now that we're using the actual type.
+        (WebKit::WebPageProxy::startDrag):
+        (WebKit::WebPageProxy::dragEnded):
+        (WebKit::WebPageProxy::resetCurrentDragInformation):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::didPerformDragControllerAction):
+        (WebKit::WebPageProxy::dragEnded):
+        (WebKit::WebPageProxy::startDrag):
+        (WebKit::WebPageProxy::currentDragOperation const):
+        * UIProcess/WebPageProxy.messages.in:
+        (WebPageProxy::DidPerformDragControllerAction):
+        (WebPageProxy::StartDrag):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _didHandleDragStartRequest:]):
+        (dropOperationForWebCoreDragOperation):
+        (coreDragOperationForUIDropOperation): Add conversion function.
+        - Note that this was not being converted from UIDropOperation to
+          WebCore::DragOperation previously, and UIDropOperationMove
+          (0x3) was not being properly converted to DragOperationMove
+          (0x16).
+        (-[WKContentView dragDataForDropSession:dragDestinationAction:]):
+        (-[WKContentView _didPerformDragOperation:]):
+        (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
+        (-[WKContentView dragInteraction:session:didEndWithOperation:]):
+        (-[WKContentView dropInteraction:sessionDidEnd:]):
+        * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::performDragControllerAction):
+        (WebKit::WebPage::dragEnded):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::performDragControllerAction):
+        (WebKit::WebPage::dragEnded):
+        * WebProcess/WebPage/WebPage.messages.in:
+        (WebPage::PerformDragControllerAction):
+        (WebPage::DragEnded):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestAdditionalItemsForDragSession):
+
 2020-06-06  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: unify the naming scheme for agents used by instrumentation
index 2d43bae..abee255 100644 (file)
@@ -1025,12 +1025,6 @@ CGFloat UIRoundToScreenScale(CGFloat value, UIScreen *);
 
 WTF_EXTERN_C_END
 
-typedef NS_OPTIONS(NSUInteger, UIDragOperation)
-{
-    UIDragOperationNone = 0,
-    UIDragOperationEvery = NSUIntegerMax,
-};
-
 @interface UIDragInteraction ()
 @property (nonatomic, assign, getter=_liftDelay, setter=_setLiftDelay:) NSTimeInterval liftDelay;
 - (void)_setAllowsPointerDragBeforeLiftDelay:(BOOL)allowsPointerDragBeforeLiftDelay;
index 024da9a..f87bbff 100644 (file)
@@ -209,6 +209,7 @@ def types_that_cannot_be_forward_declared():
         'WebCore::DictationContext',
         'WebCore::DocumentIdentifier',
         'WebCore::DocumentOrWorkerIdentifier',
+        'WebCore::DragOperation',  # FIXME: Remove after converting WebCore::DragOperation to enum class.
         'WebCore::FetchIdentifier',
         'WebCore::FrameIdentifier',
         'WebCore::LibWebRTCSocketIdentifier',
@@ -590,6 +591,7 @@ def headers_for_type(type):
         'WebCore::DocumentOrWorkerIdentifier': ['<WebCore/ServiceWorkerTypes.h>'],
         'WebKit::DocumentEditingContextRequest': ['"DocumentEditingContext.h"'],
         'WebCore::DragHandlingMethod': ['<WebCore/DragActions.h>'],
+        'WebCore::DragOperation': ['<WebCore/DragActions.h>'],
         'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'],
         'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'],
         'WebCore::ShareDataWithParsedURL': ['<WebCore/ShareData.h>'],
index c868c27..89789f3 100644 (file)
@@ -40,4 +40,24 @@ inline OptionSet<WebCore::DragDestinationAction> coreDragDestinationActionMask(W
     return result;
 }
 
+#if USE(APPKIT)
+inline OptionSet<WebCore::DragOperation> coreDragOperationMask(NSDragOperation operation)
+{
+    OptionSet<WebCore::DragOperation> result;
+    if (operation & NSDragOperationCopy)
+        result.add(WebCore::DragOperationCopy);
+    if (operation & NSDragOperationLink)
+        result.add(WebCore::DragOperationLink);
+    if (operation & NSDragOperationGeneric)
+        result.add(WebCore::DragOperationGeneric);
+    if (operation & NSDragOperationPrivate)
+        result.add(WebCore::DragOperationPrivate);
+    if (operation & NSDragOperationMove)
+        result.add(WebCore::DragOperationMove);
+    if (operation & NSDragOperationDelete)
+        result.add(WebCore::DragOperationDelete);
+    return result;
+}
+#endif // USE(APPKIT)
+
 } // namespace WebKit
index d443811..ce8f2f9 100644 (file)
@@ -1531,7 +1531,7 @@ void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
 {
     encoder << dragData.clientPosition();
     encoder << dragData.globalPosition();
-    encoder.encodeEnum(dragData.draggingSourceOperationMask());
+    encoder << dragData.draggingSourceOperationMask();
     encoder.encodeEnum(dragData.flags());
 #if PLATFORM(COCOA)
     encoder << dragData.pasteboardName();
@@ -1550,8 +1550,8 @@ bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
     if (!decoder.decode(globalPosition))
         return false;
 
-    DragOperation draggingSourceOperationMask;
-    if (!decoder.decodeEnum(draggingSourceOperationMask))
+    OptionSet<DragOperation> draggingSourceOperationMask;
+    if (!decoder.decode(draggingSourceOperationMask))
         return false;
 
     DragApplicationFlags applicationFlags;
index 38a066f..b5fcbf0 100644 (file)
@@ -52,7 +52,7 @@ public:
     explicit DragSource(GtkWidget*);
     ~DragSource();
 
-    void begin(WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&&);
+    void begin(WebCore::SelectionData&&, OptionSet<WebCore::DragOperation>, RefPtr<ShareableBitmap>&&);
 
 private:
     GtkWidget* m_webView { nullptr };
index 3ed4ccc..efdcef2 100644 (file)
@@ -106,7 +106,7 @@ DragSource::~DragSource()
     g_signal_handlers_disconnect_by_data(m_webView, this);
 }
 
-void DragSource::begin(SelectionData&& selectionData, DragOperation operation, RefPtr<ShareableBitmap>&& image)
+void DragSource::begin(SelectionData&& selectionData, OptionSet<DragOperation> operationMask, RefPtr<ShareableBitmap>&& image)
 {
     if (m_drag) {
         gtk_drag_cancel(m_drag.get());
@@ -129,7 +129,7 @@ void DragSource::begin(SelectionData&& selectionData, DragOperation operation, R
     if (m_selectionData->canSmartReplace())
         gtk_target_list_add(list.get(), gdk_atom_intern_static_string("application/vnd.webkitgtk.smartpaste"), 0, DragTargetType::SmartPaste);
 
-    m_drag = gtk_drag_begin_with_coordinates(m_webView, list.get(), dragOperationToGdkDragActions(operation), GDK_BUTTON_PRIMARY, nullptr, -1, -1);
+    m_drag = gtk_drag_begin_with_coordinates(m_webView, list.get(), dragOperationToGdkDragActions(operationMask), GDK_BUTTON_PRIMARY, nullptr, -1, -1);
     if (image) {
         RefPtr<cairo_surface_t> imageSurface(image->createCairoSurface());
         // Use the center of the drag image as hotspot.
index d8b4356..c6acb5a 100644 (file)
@@ -44,7 +44,7 @@ DragSource::~DragSource()
 {
 }
 
-void DragSource::begin(SelectionData&& selectionData, DragOperation operation, RefPtr<ShareableBitmap>&& image)
+void DragSource::begin(SelectionData&& selectionData, OptionSet<DragOperation> operationMask, RefPtr<ShareableBitmap>&& image)
 {
     if (m_drag) {
         gdk_drag_drop_done(m_drag.get(), FALSE);
@@ -89,7 +89,7 @@ void DragSource::begin(SelectionData&& selectionData, DragOperation operation, R
     auto* surface = gtk_native_get_surface(gtk_widget_get_native(m_webView));
     auto* device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(m_webView)));
     GRefPtr<GdkContentProvider> provider = adoptGRef(gdk_content_provider_new_union(providers.data(), providers.size()));
-    m_drag = adoptGRef(gdk_drag_begin(surface, device, provider.get(), dragOperationToGdkDragActions(operation), 0, 0));
+    m_drag = adoptGRef(gdk_drag_begin(surface, device, provider.get(), dragOperationToGdkDragActions(operationMask), 0, 0));
     g_signal_connect(m_drag.get(), "dnd-finished", G_CALLBACK(+[](GdkDrag* gtkDrag, gpointer userData) {
         auto& drag = *static_cast<DragSource*>(userData);
         if (drag.m_drag.get() != gtkDrag)
index 8c3b10e..a004500 100644 (file)
@@ -80,7 +80,7 @@ private:
     Optional<WebCore::IntPoint> m_position;
     unsigned m_dataRequestCount { 0 };
     Optional<WebCore::SelectionData> m_selectionData;
-    WebCore::DragOperation m_operation { WebCore::DragOperationNone };
+    Optional<WebCore::DragOperation> m_operation;
 #if USE(GTK4)
     GRefPtr<GCancellable> m_cancellable;
 #else
index c13b29b..8090eac 100644 (file)
@@ -217,7 +217,7 @@ void DropTarget::didPerformAction()
     ASSERT(page);
 
     auto operation = page->currentDragOperation();
-    if (operation == m_operation)
+    if ((!operation && !m_operation) || *operation == *m_operation)
         return;
 
     m_operation = operation;
@@ -229,7 +229,7 @@ void DropTarget::leaveTimerFired()
     auto* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_webView));
     ASSERT(page);
 
-    DragData dragData(&m_selectionData.value(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), DragOperationNone);
+    DragData dragData(&m_selectionData.value(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), { });
     page->dragExited(dragData);
     page->resetCurrentDragInformation();
 
index 51ca3e7..db1ec4f 100644 (file)
@@ -273,7 +273,7 @@ void DropTarget::didPerformAction()
     ASSERT(page);
 
     auto operation = page->currentDragOperation();
-    if (operation == m_operation)
+    if ((!operation && !m_operation) || operation == m_operation)
         return;
 
     m_operation = operation;
index 65e69c2..0aee4bc 100644 (file)
@@ -320,9 +320,9 @@ void PageClientImpl::didChangeContentSize(const IntSize& size)
 }
 
 #if ENABLE(DRAG_SUPPORT)
-void PageClientImpl::startDrag(SelectionData&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage)
+void PageClientImpl::startDrag(SelectionData&& selection, OptionSet<DragOperation> dragOperationMask, RefPtr<ShareableBitmap>&& dragImage)
 {
-    webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), WTFMove(selection), dragOperation, WTFMove(dragImage));
+    webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), WTFMove(selection), dragOperationMask, WTFMove(dragImage));
 }
 
 void PageClientImpl::didPerformDragControllerAction()
index ed39e74..2700998 100644 (file)
@@ -100,7 +100,7 @@ private:
     void selectionDidChange() override;
     RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&) override;
 #if ENABLE(DRAG_SUPPORT)
-    void startDrag(WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) override;
+    void startDrag(WebCore::SelectionData&&, OptionSet<WebCore::DragOperation>, RefPtr<ShareableBitmap>&& dragImage) override;
     void didPerformDragControllerAction() override;
 #endif
 
index 638ec1f..5cf42da 100644 (file)
@@ -2061,13 +2061,13 @@ void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase* webViewBase, const IntRe
 }
 
 #if ENABLE(DRAG_SUPPORT)
-void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, SelectionData&& selectionData, DragOperation dragOperation, RefPtr<ShareableBitmap>&& image)
+void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, SelectionData&& selectionData, OptionSet<DragOperation> dragOperationMask, RefPtr<ShareableBitmap>&& image)
 {
     WebKitWebViewBasePrivate* priv = webViewBase->priv;
     if (!priv->dragSource)
         priv->dragSource = makeUnique<DragSource>(GTK_WIDGET(webViewBase));
 
-    priv->dragSource->begin(WTFMove(selectionData), dragOperation, WTFMove(image));
+    priv->dragSource->begin(WTFMove(selectionData), dragOperationMask, WTFMove(image));
 
 #if !USE(GTK4)
     // A drag starting should prevent a double-click from happening. This might
index 1c4df12..eb7f86e 100644 (file)
@@ -82,7 +82,7 @@ void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase*);
 void webkitWebViewBasePageClosed(WebKitWebViewBase*);
 
 #if ENABLE(DRAG_SUPPORT)
-void webkitWebViewBaseStartDrag(WebKitWebViewBase*, WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<WebKit::ShareableBitmap>&&);
+void webkitWebViewBaseStartDrag(WebKitWebViewBase*, WebCore::SelectionData&&, OptionSet<WebCore::DragOperation>, RefPtr<WebKit::ShareableBitmap>&&);
 void webkitWebViewBaseDidPerformDragControllerAction(WebKitWebViewBase*);
 #endif
 
index 2e39ea6..69b62de 100644 (file)
@@ -3913,7 +3913,7 @@ void WebViewImpl::draggedImage(NSImage *, CGPoint endPoint, NSDragOperation oper
     sendDragEndToPage(endPoint, operation);
 }
 
-void WebViewImpl::sendDragEndToPage(CGPoint endPoint, NSDragOperation operation)
+void WebViewImpl::sendDragEndToPage(CGPoint endPoint, NSDragOperation dragOperationMask)
 {
     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     NSPoint windowImageLoc = [[m_view window] convertScreenToBase:NSPointFromCGPoint(endPoint)];
@@ -3923,7 +3923,7 @@ void WebViewImpl::sendDragEndToPage(CGPoint endPoint, NSDragOperation operation)
     // Prevent queued mouseDragged events from coming after the drag and fake mouseUp event.
     m_ignoresMouseDraggedEvents = true;
 
-    m_page->dragEnded(WebCore::IntPoint(windowMouseLoc), WebCore::IntPoint(WebCore::globalPoint(windowMouseLoc, [m_view window])), operation);
+    m_page->dragEnded(WebCore::IntPoint(windowMouseLoc), WebCore::IntPoint(WebCore::globalPoint(windowMouseLoc, [m_view window])), coreDragOperationMask(dragOperationMask));
 }
 
 static WebCore::DragApplicationFlags applicationFlagsForDrag(NSView *view, id <NSDraggingInfo> draggingInfo)
@@ -3947,7 +3947,7 @@ NSDragOperation WebViewImpl::draggingEntered(id <NSDraggingInfo> draggingInfo)
     WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
     WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, [m_view window]));
     auto dragDestinationActionMask = coreDragDestinationActionMask([m_view _web_dragDestinationActionForDraggingInfo:draggingInfo]);
-    auto dragOperationMask = static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask);
+    auto dragOperationMask = coreDragOperationMask(draggingInfo.draggingSourceOperationMask);
     WebCore::DragData dragData(draggingInfo, client, global, dragOperationMask, applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo), dragDestinationActionMask);
 
     m_page->resetCurrentDragInformation();
@@ -3956,18 +3956,42 @@ NSDragOperation WebViewImpl::draggingEntered(id <NSDraggingInfo> draggingInfo)
     return NSDragOperationCopy;
 }
 
+static NSDragOperation kit(Optional<WebCore::DragOperation> dragOperation)
+{
+    if (!dragOperation)
+        return NSDragOperationNone;
+
+    switch (*dragOperation) {
+    case WebCore::DragOperationCopy:
+        return NSDragOperationCopy;
+    case WebCore::DragOperationLink:
+        return NSDragOperationLink;
+    case WebCore::DragOperationGeneric:
+        return NSDragOperationGeneric;
+    case WebCore::DragOperationPrivate:
+        return NSDragOperationPrivate;
+    case WebCore::DragOperationMove:
+        return NSDragOperationMove;
+    case WebCore::DragOperationDelete:
+        return NSDragOperationDelete;
+    }
+
+    ASSERT_NOT_REACHED();
+    return NSDragOperationNone;
+}
+
 NSDragOperation WebViewImpl::draggingUpdated(id <NSDraggingInfo> draggingInfo)
 {
     WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
     WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, [m_view window]));
     auto dragDestinationActionMask = coreDragDestinationActionMask([m_view _web_dragDestinationActionForDraggingInfo:draggingInfo]);
-    auto dragOperationMask = static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask);
+    auto dragOperationMask = coreDragOperationMask(draggingInfo.draggingSourceOperationMask);
     WebCore::DragData dragData(draggingInfo, client, global, dragOperationMask, applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo), dragDestinationActionMask);
     m_page->dragUpdated(dragData, draggingInfo.draggingPasteboard.name);
 
     NSInteger numberOfValidItemsForDrop = m_page->currentDragNumberOfFilesToBeAccepted();
 
-    if (m_page->currentDragOperation() == WebCore::DragOperationNone)
+    if (!m_page->currentDragOperation())
         numberOfValidItemsForDrop = m_initialNumberOfValidItemsForDrop;
 
     NSDraggingFormation draggingFormation = NSDraggingFormationNone;
@@ -3979,14 +4003,14 @@ NSDragOperation WebViewImpl::draggingUpdated(id <NSDraggingInfo> draggingInfo)
     if (draggingInfo.draggingFormation != draggingFormation)
         [draggingInfo setDraggingFormation:draggingFormation];
 
-    return m_page->currentDragOperation();
+    return kit(m_page->currentDragOperation());
 }
 
 void WebViewImpl::draggingExited(id <NSDraggingInfo> draggingInfo)
 {
     WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
     WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, [m_view window]));
-    WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));
+    WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));
     m_page->dragExited(dragData, draggingInfo.draggingPasteboard.name);
     m_page->resetCurrentDragInformation();
     draggingInfo.numberOfValidItemsForDrop = m_initialNumberOfValidItemsForDrop;
@@ -4002,7 +4026,7 @@ bool WebViewImpl::performDragOperation(id <NSDraggingInfo> draggingInfo)
 {
     WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
     WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, [m_view window]));
-    WebCore::DragData *dragData = new WebCore::DragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));
+    WebCore::DragData *dragData = new WebCore::DragData(draggingInfo, client, global, coreDragOperationMask(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view.getAutoreleased(), draggingInfo));
 
     NSArray *types = draggingInfo.draggingPasteboard.types;
     SandboxExtension::Handle sandboxExtensionHandle;
index ac5d90e..2e66628 100644 (file)
@@ -250,7 +250,7 @@ public:
     
 #if ENABLE(DRAG_SUPPORT)
 #if PLATFORM(GTK)
-    virtual void startDrag(WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) = 0;
+    virtual void startDrag(WebCore::SelectionData&&, OptionSet<WebCore::DragOperation>, RefPtr<ShareableBitmap>&& dragImage) = 0;
 #else
     virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle&) { }
 #endif
index d3cd3b5..f1011ba 100644 (file)
@@ -2424,11 +2424,9 @@ void WebPageProxy::performDragControllerAction(DragControllerAction action, Drag
 #endif
 }
 
-void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const IntRect& insertionRect, const IntRect& editableElementRect)
+void WebPageProxy::didPerformDragControllerAction(Optional<WebCore::DragOperation> dragOperation, WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const IntRect& insertionRect, const IntRect& editableElementRect)
 {
-    MESSAGE_CHECK(m_process, dragOperation <= DragOperationDelete);
-
-    m_currentDragOperation = static_cast<DragOperation>(dragOperation);
+    m_currentDragOperation = dragOperation;
     m_currentDragHandlingMethod = dragHandlingMethod;
     m_currentDragIsOverFileInput = mouseIsOverFileInput;
     m_currentDragNumberOfFilesToBeAccepted = numberOfItemsToBeAccepted;
@@ -2438,20 +2436,20 @@ void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, WebCor
 }
 
 #if PLATFORM(GTK)
-void WebPageProxy::startDrag(SelectionData&& selectionData, uint64_t dragOperation, const ShareableBitmap::Handle& dragImageHandle)
+void WebPageProxy::startDrag(SelectionData&& selectionData, OptionSet<WebCore::DragOperation> dragOperationMask, const ShareableBitmap::Handle& dragImageHandle)
 {
     RefPtr<ShareableBitmap> dragImage = !dragImageHandle.isNull() ? ShareableBitmap::create(dragImageHandle) : nullptr;
-    pageClient().startDrag(WTFMove(selectionData), static_cast<WebCore::DragOperation>(dragOperation), WTFMove(dragImage));
+    pageClient().startDrag(WTFMove(selectionData), dragOperationMask, WTFMove(dragImage));
 
     didStartDrag();
 }
 #endif
 
-void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
+void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<WebCore::DragOperation> dragOperationMask)
 {
     if (!hasRunningProcess())
         return;
-    send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation));
+    send(Messages::WebPage::DragEnded(clientPosition, globalPosition, dragOperationMask));
     setDragCaretRect({ });
 }
 
@@ -2482,7 +2480,7 @@ void WebPageProxy::didEndDragging()
 
 void WebPageProxy::resetCurrentDragInformation()
 {
-    m_currentDragOperation = WebCore::DragOperationNone;
+    m_currentDragOperation = WTF::nullopt;
     m_currentDragHandlingMethod = DragHandlingMethod::None;
     m_currentDragIsOverFileInput = false;
     m_currentDragNumberOfFilesToBeAccepted = 0;
index c471260..87064cf 100644 (file)
@@ -1157,8 +1157,8 @@ public:
     void performDragOperation(WebCore::DragData&, const String& dragStorageName, SandboxExtension::Handle&&, SandboxExtension::HandleArray&&);
     void didPerformDragOperation(bool handled);
 
-    void didPerformDragControllerAction(uint64_t dragOperation, WebCore::DragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const WebCore::IntRect& insertionRect, const WebCore::IntRect& editableElementRect);
-    void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
+    void didPerformDragControllerAction(Optional<WebCore::DragOperation>, WebCore::DragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const WebCore::IntRect& insertionRect, const WebCore::IntRect& editableElementRect);
+    void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragOperation>);
     void didStartDrag();
     void dragCancelled();
     void setDragCaretRect(const WebCore::IntRect&);
@@ -1168,7 +1168,7 @@ public:
                          const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize);
 #endif
 #if PLATFORM(GTK)
-    void startDrag(WebCore::SelectionData&&, uint64_t dragOperation, const ShareableBitmap::Handle& dragImage);
+    void startDrag(WebCore::SelectionData&&, OptionSet<WebCore::DragOperation>, const ShareableBitmap::Handle& dragImage);
 #endif
 #endif
 
@@ -1227,7 +1227,7 @@ public:
     void launchInitialProcessIfNecessary();
 
 #if ENABLE(DRAG_SUPPORT)
-    WebCore::DragOperation currentDragOperation() const { return m_currentDragOperation; }
+    Optional<WebCore::DragOperation> currentDragOperation() const { return m_currentDragOperation; }
     WebCore::DragHandlingMethod currentDragHandlingMethod() const { return m_currentDragHandlingMethod; }
     bool currentDragIsOverFileInput() const { return m_currentDragIsOverFileInput; }
     unsigned currentDragNumberOfFilesToBeAccepted() const { return m_currentDragNumberOfFilesToBeAccepted; }
@@ -2608,7 +2608,7 @@ private:
 #if ENABLE(DRAG_SUPPORT)
     // Current drag destination details are delivered as an asynchronous response,
     // so we preserve them to be used when the next dragging delegate call is made.
-    WebCore::DragOperation m_currentDragOperation { WebCore::DragOperationNone };
+    Optional<WebCore::DragOperation> m_currentDragOperation;
     WebCore::DragHandlingMethod m_currentDragHandlingMethod { WebCore::DragHandlingMethod::None };
     bool m_currentDragIsOverFileInput { false };
     unsigned m_currentDragNumberOfFilesToBeAccepted { 0 };
index 491a353..83508e8 100644 (file)
@@ -310,7 +310,7 @@ messages -> WebPageProxy {
 
     # Drag and drop messages
 #if ENABLE(DRAG_SUPPORT)
-    DidPerformDragControllerAction(uint64_t dragOperation, enum:uint8_t WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect, WebCore::IntRect editableElementRect)
+    DidPerformDragControllerAction(Optional<WebCore::DragOperation> dragOperation, enum:uint8_t WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect, WebCore::IntRect editableElementRect)
     DidEndDragging();
 #endif
 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
@@ -318,7 +318,7 @@ messages -> WebPageProxy {
     SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
 #endif
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    StartDrag(WebCore::SelectionData selectionData, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
+    StartDrag(WebCore::SelectionData selectionData, OptionSet<WebCore::DragOperation> dragOperationMask, WebKit::ShareableBitmap::Handle dragImage)
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
index 5de28d2..292761c 100644 (file)
@@ -7289,7 +7289,7 @@ static BOOL shouldEnableDragInteractionForPolicy(_WKDragInteractionPolicy policy
         if (started) {
             // A client of the Objective C SPI or UIKit might have prevented the drag from beginning entirely in the UI process, in which case
             // we need to balance the `dragstart` event with a `dragend`.
-            _page->dragEnded(positionForDragEnd, positionForDragEnd, WebCore::DragOperationNone);
+            _page->dragEnded(positionForDragEnd, positionForDragEnd, { });
         }
     }
 }
@@ -7307,24 +7307,42 @@ static BOOL shouldEnableDragInteractionForPolicy(_WKDragInteractionPolicy policy
         *outGlobalPoint = locationInContentView;
 }
 
-static UIDropOperation dropOperationForWebCoreDragOperation(WebCore::DragOperation operation)
+static UIDropOperation dropOperationForWebCoreDragOperation(Optional<WebCore::DragOperation> operation)
 {
-    if (operation & WebCore::DragOperationMove)
-        return UIDropOperationMove;
-
-    if (operation & WebCore::DragOperationCopy)
-        return UIDropOperationCopy;
-
+    if (operation) {
+        if (*operation == WebCore::DragOperationMove)
+            return UIDropOperationMove;
+        if (*operation == WebCore::DragOperationCopy)
+            return UIDropOperationCopy;
+    }
     return UIDropOperationCancel;
 }
 
+static Optional<WebCore::DragOperation> coreDragOperationForUIDropOperation(UIDropOperation dropOperation)
+{
+    switch (dropOperation) {
+    case UIDropOperationCancel:
+        return WTF::nullopt;
+    case UIDropOperationForbidden:
+        return WebCore::DragOperationPrivate;
+    case UIDropOperationCopy:
+        return WebCore::DragOperationCopy;
+    case UIDropOperationMove:
+        return WebCore::DragOperationMove;
+    }
+    ASSERT_NOT_REACHED();
+    return WTF::nullopt;
+}
+
 - (WebCore::DragData)dragDataForDropSession:(id <UIDropSession>)session dragDestinationAction:(WKDragDestinationAction)dragDestinationAction
 {
     CGPoint global;
     CGPoint client;
     [self computeClientAndGlobalPointsForDropSession:session outClientPoint:&client outGlobalPoint:&global];
 
-    WebCore::DragOperation dragOperationMask = static_cast<WebCore::DragOperation>(session.allowsMoveOperation ? WebCore::DragOperationEvery : (WebCore::DragOperationEvery & ~WebCore::DragOperationMove));
+    auto dragOperationMask = WebCore::anyDragOperation();
+    if (!session.allowsMoveOperation)
+        dragOperationMask.remove(WebCore::DragOperationMove);
     return { session, WebCore::roundedIntPoint(client), WebCore::roundedIntPoint(global), dragOperationMask, WebCore::DragApplicationNone, WebKit::coreDragDestinationActionMask(dragDestinationAction) };
 }
 
@@ -7428,7 +7446,8 @@ static NSArray<NSItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
     CGPoint client;
     [self computeClientAndGlobalPointsForDropSession:dropSession outClientPoint:&client outGlobalPoint:&global];
     [self cleanUpDragSourceSessionState];
-    _page->dragEnded(WebCore::roundedIntPoint(client), WebCore::roundedIntPoint(global), _page->currentDragOperation());
+    auto currentDragOperation = _page->currentDragOperation();
+    _page->dragEnded(WebCore::roundedIntPoint(client), WebCore::roundedIntPoint(global), currentDragOperation ? *currentDragOperation : OptionSet<WebCore::DragOperation>({ }));
 }
 
 - (void)_didChangeDragCaretRect:(CGRect)previousRect currentRect:(CGRect)rect
@@ -8017,7 +8036,7 @@ static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt
             RELEASE_LOG(DragAndDrop, "Drag session ended at start: %p", session);
             // The lift was canceled, so -dropInteraction:sessionDidEnd: will never be invoked. This is the last chance to clean up.
             [protectedSelf cleanUpDragSourceSessionState];
-            page->dragEnded(positionForDragEnd, positionForDragEnd, WebCore::DragOperationNone);
+            page->dragEnded(positionForDragEnd, positionForDragEnd, { });
         }
 #if !RELEASE_LOG_DISABLED
         else
@@ -8052,7 +8071,7 @@ static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt
         return;
 
     [self cleanUpDragSourceSessionState];
-    _page->dragEnded(WebCore::roundedIntPoint(_dragDropInteractionState.adjustedPositionForDragEnd()), WebCore::roundedIntPoint(_dragDropInteractionState.adjustedPositionForDragEnd()), operation);
+    _page->dragEnded(WebCore::roundedIntPoint(_dragDropInteractionState.adjustedPositionForDragEnd()), WebCore::roundedIntPoint(_dragDropInteractionState.adjustedPositionForDragEnd()), coreDragOperationForUIDropOperation(operation));
 }
 
 - (UITargetedDragPreview *)dragInteraction:(UIDragInteraction *)interaction previewForCancellingItem:(UIDragItem *)item withDefault:(UITargetedDragPreview *)defaultPreview
@@ -8271,7 +8290,7 @@ static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt
     CGPoint client;
     [self computeClientAndGlobalPointsForDropSession:session outClientPoint:&client outGlobalPoint:&global];
     [self cleanUpDragSourceSessionState];
-    _page->dragEnded(WebCore::roundedIntPoint(client), WebCore::roundedIntPoint(global), WebCore::DragOperationNone);
+    _page->dragEnded(WebCore::roundedIntPoint(client), WebCore::roundedIntPoint(global), { });
 }
 
 #endif
index eed7b99..74f46cc 100644 (file)
@@ -75,7 +75,7 @@ void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame&)
 
     m_page->willStartDrag();
 
-    m_page->send(Messages::WebPageProxy::StartDrag(dataTransfer.pasteboard().selectionData(), dataTransfer.sourceOperation(), handle));
+    m_page->send(Messages::WebPageProxy::StartDrag(dataTransfer.pasteboard().selectionData(), dataTransfer.sourceOperationMask(), handle));
 }
 
 }; // namespace WebKit.
index 37a5d7d..3c17f90 100644 (file)
@@ -3945,22 +3945,22 @@ NotificationPermissionRequestManager* WebPage::notificationPermissionRequestMana
 #if ENABLE(DRAG_SUPPORT)
 
 #if PLATFORM(GTK)
-void WebPage::performDragControllerAction(DragControllerAction action, const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t draggingSourceOperationMask, SelectionData&& selectionData, uint32_t flags)
+void WebPage::performDragControllerAction(DragControllerAction action, const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<DragOperation> draggingSourceOperationMask, SelectionData&& selectionData, uint32_t flags)
 {
     if (!m_page) {
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }, { }));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(WTF::nullopt, DragHandlingMethod::None, false, 0, { }, { }));
         return;
     }
 
-    DragData dragData(&selectionData, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
+    DragData dragData(&selectionData, clientPosition, globalPosition, draggingSourceOperationMask, static_cast<DragApplicationFlags>(flags));
     switch (action) {
     case DragControllerAction::Entered: {
-        DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
+        auto resolvedDragOperation = m_page->dragController().dragEntered(dragData);
         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }, { }));
         return;
     }
     case DragControllerAction::Updated: {
-        DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
+        auto resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }, { }));
         return;
     }
@@ -3979,24 +3979,24 @@ void WebPage::performDragControllerAction(DragControllerAction action, const Int
 void WebPage::performDragControllerAction(DragControllerAction action, const WebCore::DragData& dragData, SandboxExtension::Handle&& sandboxExtensionHandle, SandboxExtension::HandleArray&& sandboxExtensionsHandleArray)
 {
     if (!m_page) {
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }, { }));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(WTF::nullopt, DragHandlingMethod::None, false, 0, { }, { }));
         return;
     }
 
     switch (action) {
     case DragControllerAction::Entered: {
-        DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
+        auto resolvedDragOperation = m_page->dragController().dragEntered(dragData);
         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates(), m_page->dragCaretController().editableElementRectInRootViewCoordinates()));
         return;
     }
     case DragControllerAction::Updated: {
-        DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
+        auto resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates(), m_page->dragCaretController().editableElementRectInRootViewCoordinates()));
         return;
     }
     case DragControllerAction::Exited:
         m_page->dragController().dragExited(dragData);
-        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }, { }));
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(WTF::nullopt, DragHandlingMethod::None, false, 0, { }, { }));
         return;
         
     case DragControllerAction::PerformDragOperation: {
@@ -4023,7 +4023,7 @@ void WebPage::performDragControllerAction(DragControllerAction action, const Web
 }
 #endif
 
-void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation)
+void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, OptionSet<WebCore::DragOperation> dragOperationMask)
 {
     IntPoint adjustedClientPosition(clientPosition.x() + m_page->dragController().dragOffset().x(), clientPosition.y() + m_page->dragController().dragOffset().y());
     IntPoint adjustedGlobalPosition(globalPosition.x() + m_page->dragController().dragOffset().x(), globalPosition.y() + m_page->dragController().dragOffset().y());
@@ -4034,7 +4034,7 @@ void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint glob
         return;
     // FIXME: These are fake modifier keys here, but they should be real ones instead.
     PlatformMouseEvent event(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), 0, WebCore::NoTap);
-    m_page->mainFrame().eventHandler().dragSourceEndedAt(event, (DragOperation)operation);
+    m_page->mainFrame().eventHandler().dragSourceEndedAt(event, dragOperationMask);
 
     send(Messages::WebPageProxy::DidEndDragging());
 
index 96368ac..a4b1578 100644 (file)
@@ -899,7 +899,7 @@ public:
     void restoreSelectionInFocusedEditableElement();
 
 #if ENABLE(DRAG_SUPPORT) && PLATFORM(GTK)
-    void performDragControllerAction(DragControllerAction, const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t draggingSourceOperationMask, WebCore::SelectionData&&, uint32_t flags);
+    void performDragControllerAction(DragControllerAction, const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragOperation> draggingSourceOperationMask, WebCore::SelectionData&&, uint32_t flags);
 #endif
 
 #if ENABLE(DRAG_SUPPORT) && !PLATFORM(GTK)
@@ -907,7 +907,7 @@ public:
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
-    void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
+    void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, OptionSet<WebCore::DragOperation>);
 
     void willPerformLoadDragDestinationAction();
     void mayPerformUploadDragDestinationAction();
index 538e657..ae92747 100644 (file)
@@ -309,14 +309,14 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
 
     # Drag and drop.
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    PerformDragControllerAction(enum:uint8_t WebKit::DragControllerAction action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WebCore::SelectionData selection, uint32_t flags)
+    PerformDragControllerAction(enum:uint8_t WebKit::DragControllerAction action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, OptionSet<WebCore::DragOperation> draggingSourceOperationMask, WebCore::SelectionData selection, uint32_t flags)
 #endif
 #if !PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
     PerformDragControllerAction(enum:uint8_t WebKit::DragControllerAction action, WebCore::DragData dragData, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::SandboxExtension::HandleArray sandboxExtensionsForUpload)
 #endif
 #if ENABLE(DRAG_SUPPORT)
     DidStartDrag()
-    DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation)
+    DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, OptionSet<WebCore::DragOperation> dragOperationMask)
     DragCancelled()
 #endif
 
index 9c3cccb..58034b7 100644 (file)
@@ -924,7 +924,7 @@ void WebPage::requestAdditionalItemsForDragSession(const IntPoint& clientPositio
     // is opaque to the web process, which only sees that the current drag has ended, and that a new one is beginning.
     PlatformMouseEvent event(clientPosition, globalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), 0, NoTap);
     m_page->dragController().dragEnded();
-    m_page->mainFrame().eventHandler().dragSourceEndedAt(event, DragOperationNone, MayExtendDragSession::Yes);
+    m_page->mainFrame().eventHandler().dragSourceEndedAt(event, { }, MayExtendDragSession::Yes);
 
     bool didHandleDrag = m_page->mainFrame().eventHandler().tryToBeginDragAtPoint(clientPosition, globalPosition);
     send(Messages::WebPageProxy::DidHandleAdditionalDragItemsRequest(didHandleDrag));
index 61c6e54..fd6aad4 100644 (file)
@@ -1,3 +1,45 @@
+2020-06-06  David Kilzer  <ddkilzer@apple.com>
+
+        Use OptionSet<DragOperation> for mask values
+        <https://webkit.org/b/212605>
+
+        Reviewed by Darin Adler.
+
+        In broad strokes:
+        - Replace use of DragOperation with OptionSet<DragOperation> or
+          Optional<DragOperation>.
+        - Rename function parameters and local variables to denote use
+          of mask values.
+        - Remove DragOperationNone enum value.
+        - Replace DragOperationEvery enum value with anyDragOperation().
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _dragSourceEndedAt:operation:]):
+        * WebView/WebHTMLView.mm:
+        (kit): Add conversion function.
+        (-[WebHTMLView draggingSourceOperationMaskForLocal:]):
+        (-[WebHTMLView draggingSession:sourceOperationMaskForDraggingContext:]):
+        * WebView/WebView.mm:
+        (coreDragOperationMask): Add conversion function.
+        (kit): Ditto.
+        - Map WebCore::DragOperationGeneric to _UIDragOperationMove
+          based on logic in WebCore.  All other WebCore::DragOperation
+          enum values map to _UIDragOperationNone.
+        (-[WebView dragDataForSession:client:global:operation:]):
+        (-[WebView _enteredDataInteraction:client:global:operation:]):
+        (-[WebView _updatedDataInteraction:client:global:operation:]):
+        (-[WebView draggingEntered:]):
+        (-[WebView draggingUpdated:]):
+        (-[WebView draggingExited:]):
+        (-[WebView performDragOperation:]):
+        * WebView/WebViewInternal.h:
+        (CocoaDragOperation):
+        - Add typedef so coreDragOperationMask() may be shared across
+          platforms.
+        (coreDragOperationMask): Add declaration.
+        (coreOptions):
+        - Remove redundant parameter name.
+
 2020-06-06  Jonathan Bedard  <jbedard@apple.com>
 
         WebKitLegacy: Link to framework stubs for watchOS and tvOS
index d4dea7c..b9eecdc 100644 (file)
@@ -942,7 +942,7 @@ static NSURL *createUniqueWebDataURL();
 }
 
 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
-- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation
+- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)dragOperationMask
 {
     if (!_private->coreFrame)
         return;
@@ -952,7 +952,7 @@ static NSURL *createUniqueWebDataURL();
     // FIXME: These are fake modifier keys here, but they should be real ones instead.
     WebCore::PlatformMouseEvent event(WebCore::IntPoint(windowLoc), WebCore::IntPoint(WebCore::globalPoint(windowLoc, [view->platformWidget() window])),
         WebCore::LeftButton, WebCore::PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap);
-    _private->coreFrame->eventHandler().dragSourceEndedAt(event, (WebCore::DragOperation)operation);
+    _private->coreFrame->eventHandler().dragSourceEndedAt(event, coreDragOperationMask(dragOperationMask));
 }
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
 
index 5e4a890..38e7909 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  *           (C) 2006, 2007 Graham Dennis (graham.dennis@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -4229,6 +4229,25 @@ static BOOL currentScrollIsBlit(NSView *clipView)
 #endif
 
 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
+
+static NSDragOperation kit(OptionSet<WebCore::DragOperation> operationMask)
+{
+    NSDragOperation result = NSDragOperationNone;
+    if (operationMask.contains(WebCore::DragOperationCopy))
+        result |= NSDragOperationCopy;
+    if (operationMask.contains(WebCore::DragOperationLink))
+        result |= NSDragOperationLink;
+    if (operationMask.contains(WebCore::DragOperationGeneric))
+        result |= NSDragOperationGeneric;
+    if (operationMask.contains(WebCore::DragOperationPrivate))
+        result |= NSDragOperationPrivate;
+    if (operationMask.contains(WebCore::DragOperationMove))
+        result |= NSDragOperationMove;
+    if (operationMask.contains(WebCore::DragOperationDelete))
+        result |= NSDragOperationDelete;
+    return result;
+}
+
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
 - (void)dragImage:(NSImage *)dragImage
                at:(NSPoint)at
@@ -4280,7 +4299,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if (!page)
         return NSDragOperationNone;
 
-    return (NSDragOperation)page->dragController().sourceDragOperation();
+    return kit(page->dragController().sourceDragOperationMask());
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -4386,7 +4405,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
     if (!page)
         return NSDragOperationNone;
 
-    return (NSDragOperation)page->dragController().sourceDragOperation();
+    return kit(page->dragController().sourceDragOperationMask());
 }
 
 - (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
index c5e9f25..097677d 100644 (file)
@@ -589,6 +589,92 @@ static OptionSet<WebCore::DragDestinationAction> coreDragDestinationActionMask(W
         result.add(WebCore::DragDestinationAction::Load);
     return result;
 }
+
+#if !USE(APPKIT)
+// See <UIKit/UIDragging_Private.h>.
+typedef NS_OPTIONS(NSUInteger, _UIDragOperation) {
+    _UIDragOperationNone = 0,
+    _UIDragOperationCopy = 1,
+    _UIDragOperationMove = 16,
+};
+#endif
+
+OptionSet<WebCore::DragOperation> coreDragOperationMask(CocoaDragOperation operation)
+{
+    OptionSet<WebCore::DragOperation> result;
+
+#if USE(APPKIT)
+    if (operation & NSDragOperationCopy)
+        result.add(WebCore::DragOperationCopy);
+    if (operation & NSDragOperationLink)
+        result.add(WebCore::DragOperationLink);
+    if (operation & NSDragOperationGeneric)
+        result.add(WebCore::DragOperationGeneric);
+    if (operation & NSDragOperationPrivate)
+        result.add(WebCore::DragOperationPrivate);
+    if (operation & NSDragOperationMove)
+        result.add(WebCore::DragOperationMove);
+    if (operation & NSDragOperationDelete)
+        result.add(WebCore::DragOperationDelete);
+#else
+    if (operation & _UIDragOperationCopy)
+        result.add(WebCore::DragOperationCopy);
+    if (operation & _UIDragOperationMove)
+        result.add(WebCore::DragOperationMove);
+#endif // USE(APPKIT)
+
+    return result;
+}
+
+#if USE(APPKIT)
+static NSDragOperation kit(Optional<WebCore::DragOperation> dragOperation)
+{
+    if (!dragOperation)
+        return NSDragOperationNone;
+
+    switch (*dragOperation) {
+    case WebCore::DragOperationCopy:
+        return NSDragOperationCopy;
+    case WebCore::DragOperationLink:
+        return NSDragOperationLink;
+    case WebCore::DragOperationGeneric:
+        return NSDragOperationGeneric;
+    case WebCore::DragOperationPrivate:
+        return NSDragOperationPrivate;
+    case WebCore::DragOperationMove:
+        return NSDragOperationMove;
+    case WebCore::DragOperationDelete:
+        return NSDragOperationDelete;
+    }
+
+    ASSERT_NOT_REACHED();
+    return NSDragOperationNone;
+}
+#else
+static _UIDragOperation kit(Optional<WebCore::DragOperation> dragOperation)
+{
+    if (!dragOperation)
+        return _UIDragOperationNone;
+
+    switch (*dragOperation) {
+    case WebCore::DragOperationCopy:
+        return _UIDragOperationCopy;
+    case WebCore::DragOperationLink:
+        return _UIDragOperationNone;
+    case WebCore::DragOperationGeneric:
+        return _UIDragOperationMove;
+    case WebCore::DragOperationPrivate:
+        return _UIDragOperationNone;
+    case WebCore::DragOperationMove:
+        return _UIDragOperationMove;
+    case WebCore::DragOperationDelete:
+        return _UIDragOperationNone;
+    }
+
+    ASSERT_NOT_REACHED();
+    return _UIDragOperationNone;
+}
+#endif // USE(APPKIT)
 #endif // ENABLE(DRAG_SUPPORT)
 
 WebCore::FindOptions coreOptions(WebFindOptions options)
@@ -1923,7 +2009,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 
 - (WebCore::DragData)dragDataForSession:(id <UIDropSession>)session client:(CGPoint)clientPosition global:(CGPoint)globalPosition operation:(uint64_t)operation
 {
-    auto dragOperationMask = static_cast<WebCore::DragOperation>(operation);
+    auto dragOperationMask = coreDragOperationMask(operation);
     auto dragDestinationActionMask = coreDragDestinationActionMask([self dragDestinationActionMaskForSession:session]);
     return { session, WebCore::roundedIntPoint(clientPosition), WebCore::roundedIntPoint(globalPosition), dragOperationMask, WebCore::DragApplicationNone, dragDestinationActionMask };
 }
@@ -1932,14 +2018,14 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 {
     WebThreadLock();
     auto dragData = [self dragDataForSession:session client:clientPosition global:globalPosition operation:operation];
-    return _private->page->dragController().dragEntered(dragData);
+    return kit(_private->page->dragController().dragEntered(dragData));
 }
 
 - (uint64_t)_updatedDataInteraction:(id <UIDropSession>)session client:(CGPoint)clientPosition global:(CGPoint)globalPosition operation:(uint64_t)operation
 {
     WebThreadLock();
     auto dragData = [self dragDataForSession:session client:clientPosition global:globalPosition operation:operation];
-    return _private->page->dragController().dragUpdated(dragData);
+    return kit(_private->page->dragController().dragUpdated(dragData));
 }
 
 - (void)_exitedDataInteraction:(id <UIDropSession>)session client:(CGPoint)clientPosition global:(CGPoint)globalPosition operation:(uint64_t)operation
@@ -6748,8 +6834,8 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     WebCore::IntPoint client([draggingInfo draggingLocation]);
     WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window]));
 
-    WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo], [self actionMaskForDraggingInfo:draggingInfo]);
-    return core(self)->dragController().dragEntered(dragData);
+    WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo], [self actionMaskForDraggingInfo:draggingInfo]);
+    return kit(core(self)->dragController().dragEntered(dragData));
 }
 
 - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
@@ -6761,8 +6847,8 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     WebCore::IntPoint client([draggingInfo draggingLocation]);
     WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window]));
 
-    WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo], [self actionMaskForDraggingInfo:draggingInfo]);
-    return page->dragController().dragUpdated(dragData);
+    WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo], [self actionMaskForDraggingInfo:draggingInfo]);
+    return kit(page->dragController().dragUpdated(dragData));
 }
 
 - (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
@@ -6773,7 +6859,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 
     WebCore::IntPoint client([draggingInfo draggingLocation]);
     WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window]));
-    WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+    WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     page->dragController().dragExited(dragData);
 }
 
@@ -6786,7 +6872,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 {
     WebCore::IntPoint client([draggingInfo draggingLocation]);
     WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window]));
-    auto* dragData = new WebCore::DragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+    auto* dragData = new WebCore::DragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
 
     NSArray* types = draggingInfo.draggingPasteboard.types;
     if (![types containsObject:WebArchivePboardType] && [types containsObject:WebCore::legacyFilesPromisePasteboardType()]) {
index 7d70c04..ea1f2f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Igalia S.L
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
 #ifdef __cplusplus
 
 #import <WebCore/AlternativeTextClient.h>
+#import <WebCore/DragActions.h>
 #import <WebCore/FindOptions.h>
 #import <WebCore/FloatRect.h>
 #import <WebCore/HTMLMediaElementEnums.h>
@@ -89,7 +90,17 @@ class WebSelectionServiceController;
 
 #ifdef __cplusplus
 
-WebCore::FindOptions coreOptions(WebFindOptions options);
+#if ENABLE(DRAG_SUPPORT)
+#if USE(APPKIT)
+using CocoaDragOperation = NSDragOperation;
+#else
+using CocoaDragOperation = uint64_t;
+#endif
+
+OptionSet<WebCore::DragOperation> coreDragOperationMask(CocoaDragOperation);
+#endif // ENABLE(DRAG_SUPPORT)
+
+WebCore::FindOptions coreOptions(WebFindOptions);
 
 OptionSet<WebCore::LayoutMilestone> coreLayoutMilestones(WebLayoutMilestones);
 WebLayoutMilestones kitLayoutMilestones(OptionSet<WebCore::LayoutMilestone>);
index 69275ee..34b4fb6 100644 (file)
@@ -1,3 +1,28 @@
+2020-06-06  David Kilzer  <ddkilzer@apple.com>
+
+        Use OptionSet<DragOperation> for mask values
+        <https://webkit.org/b/212605>
+
+        Reviewed by Darin Adler.
+
+        In broad strokes:
+        - Replace use of DragOperation with OptionSet<DragOperation> or
+          Optional<DragOperation>.
+        - Rename function parameters and local variables to denote use
+          of mask values.
+        - Remove DragOperationNone enum value.
+        - Replace DragOperationEvery enum value with anyDragOperation().
+
+        * WebCoreSupport/WebDragClient.cpp:
+        (draggingSourceOperationMaskToDragCursors):
+        (WebDragClient::startDrag):
+        * WebView.cpp:
+        (dragOperationToDragCursor):
+        (WebView::keyStateToDragOperation const):
+        (WebView::DragLeave):
+        * WebView.h:
+        (WebView::keyStateToDragOperation const):
+
 2020-06-01  David Kilzer  <ddkilzer@apple.com>
 
         Don't use casts to convert between WebCore::DragDestinationAction and {Web,WK}DragDestinationAction types
index 3132603..e56cdc9 100644 (file)
 
 using namespace WebCore;
 
-static DWORD draggingSourceOperationMaskToDragCursors(DragOperation op)
+static DWORD draggingSourceOperationMaskToDragCursors(OptionSet<DragOperation> operationMask)
 {
     DWORD result = DROPEFFECT_NONE;
-    if (op == DragOperationEvery)
+    if (operationMask == anyDragOperation())
         return DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOVE; 
-    if (op & DragOperationCopy)
+    if (operationMask.contains(DragOperationCopy))
         result |= DROPEFFECT_COPY; 
-    if (op & DragOperationLink)
+    if (operationMask.contains(DragOperationLink))
         result |= DROPEFFECT_LINK; 
-    if (op & DragOperationMove)
+    if (operationMask.contains(DragOperationMove))
         result |= DROPEFFECT_MOVE;
-    if (op & DragOperationGeneric)
+    if (operationMask.contains(DragOperationGeneric))
         result |= DROPEFFECT_MOVE;
     return result;
 }
@@ -152,7 +152,7 @@ void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame&
             }
         }
 
-        DWORD okEffect = draggingSourceOperationMaskToDragCursors(m_webView->page()->dragController().sourceDragOperation());
+        DWORD okEffect = draggingSourceOperationMaskToDragCursors(m_webView->page()->dragController().sourceDragOperationMask());
         DWORD effect = DROPEFFECT_NONE;
         COMPtr<IWebUIDelegate> ui;
         HRESULT hr = E_NOTIMPL;
@@ -164,7 +164,7 @@ void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame&
         if (hr == E_NOTIMPL)
             hr = DoDragDrop(dataObject.get(), source.get(), okEffect, &effect);
 
-        DragOperation operation = DragOperationNone;
+        OptionSet<DragOperation> operation;
         if (hr == DRAGDROP_S_DROP) {
             if (effect & DROPEFFECT_COPY)
                 operation = DragOperationCopy;
index 3bdee6b..42dcd28 100644 (file)
@@ -5842,38 +5842,42 @@ HRESULT WebView::visibleContentRect(_Out_ LPRECT rect)
     return S_OK;
 }
 
-static DWORD dragOperationToDragCursor(DragOperation op) {
-    DWORD res = DROPEFFECT_NONE;
-    if (op & DragOperationCopy) 
-        res = DROPEFFECT_COPY;
-    else if (op & DragOperationLink) 
-        res = DROPEFFECT_LINK;
-    else if (op & DragOperationMove) 
-        res = DROPEFFECT_MOVE;
-    else if (op & DragOperationGeneric) 
-        res = DROPEFFECT_MOVE; //This appears to be the Firefox behaviour
-    return res;
+static DWORD dragOperationToDragCursor(Optional<DragOperation> operation)
+{
+    if (!operation)
+        return DROPEFFECT_NONE;
+
+    DWORD result = DROPEFFECT_NONE;
+    if (*operation == DragOperationCopy)
+        result = DROPEFFECT_COPY;
+    else if (*operation == DragOperationLink)
+        result = DROPEFFECT_LINK;
+    else if (*operation == DragOperationMove)
+        result = DROPEFFECT_MOVE;
+    else if (*operation == DragOperationGeneric)
+        result = DROPEFFECT_MOVE; // This appears to be the Firefox behaviour.
+    return result;
 }
 
-DragOperation WebView::keyStateToDragOperation(DWORD grfKeyState) const
+OptionSet<DragOperation> WebView::keyStateToDragOperation(DWORD grfKeyState) const
 {
     if (!m_page)
-        return DragOperationNone;
+        return { };
 
     // Conforms to Microsoft's key combinations as documented for 
     // IDropTarget::DragOver. Note, grfKeyState is the current 
     // state of the keyboard modifier keys on the keyboard. See:
     // <http://msdn.microsoft.com/en-us/library/ms680129(VS.85).aspx>.
-    DragOperation operation = m_page->dragController().sourceDragOperation();
+    auto operationMask = m_page->dragController().sourceDragOperationMask();
 
     if ((grfKeyState & (MK_CONTROL | MK_SHIFT)) == (MK_CONTROL | MK_SHIFT))
-        operation = DragOperationLink;
+        operationMask = { DragOperationLink };
     else if ((grfKeyState & MK_CONTROL) == MK_CONTROL)
-        operation = DragOperationCopy;
+        operationMask = { DragOperationCopy };
     else if ((grfKeyState & MK_SHIFT) == MK_SHIFT)
-        operation = DragOperationGeneric;
+        operationMask = { DragOperationGeneric };
 
-    return operation;
+    return operationMask;
 }
 
 HRESULT WebView::DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
@@ -5919,8 +5923,7 @@ HRESULT WebView::DragLeave()
         m_dropTargetHelper->DragLeave();
 
     if (m_dragData) {
-        DragData data(m_dragData.get(), IntPoint(), IntPoint(), 
-            DragOperationNone);
+        DragData data(m_dragData.get(), IntPoint(), IntPoint(), { });
         m_page->dragController().dragExited(data);
         m_dragData = 0;
     }
index 1806698..7b22104 100644 (file)
@@ -555,7 +555,7 @@ private:
 
     void performLayeredWindowUpdate();
 
-    WebCore::DragOperation keyStateToDragOperation(DWORD grfKeyState) const;
+    OptionSet<WebCore::DragOperation> keyStateToDragOperation(DWORD grfKeyState) const;
 
     // FIXME: This variable is part of a workaround. The drop effect (pdwEffect) passed to Drop is incorrect. 
     // We set this variable in DragEnter and DragOver so that it can be used in Drop to set the correct drop effect.