Diff
Modified: trunk/Source/WTF/ChangeLog (262912 => 262913)
--- trunk/Source/WTF/ChangeLog 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WTF/ChangeLog 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1,3 +1,19 @@
+2020-06-11 David Kilzer <[email protected]>
+
+ [IPC] Adopt enum class for DragSourceAction
+ <https://webkit.org/b/212885>
+ <rdar://problem/64094134>
+
+ Reviewed by Darin Adler.
+
+ * wtf/OptionSet.h:
+ (WTF::OptionSet::hasExactlyOneBitSet const): Add.
+ - Move here from WebCore::ExactlyOneBitSet() in
+ Source/WebCore/page/EventHandler.cpp.
+ (WTF::OptionSet::toSingleValue const): Add.
+ - Use hasExactlyOneBitSet() to determine whether exactly one
+ enum bitmask value can be returned.
+
2020-06-11 Geoffrey Garen <[email protected]>
[Cocoa] Build callOnMainThread on WTF::RunLoop rather than on a timer
Modified: trunk/Source/WTF/wtf/OptionSet.h (262912 => 262913)
--- trunk/Source/WTF/wtf/OptionSet.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WTF/wtf/OptionSet.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -205,6 +205,16 @@
m_storage &= ~optionSet.m_storage;
}
+ constexpr bool hasExactlyOneBitSet() const
+ {
+ return m_storage && !(m_storage & (m_storage - 1));
+ }
+
+ constexpr Optional<E> toSingleValue() const
+ {
+ return hasExactlyOneBitSet() ? Optional<E>(static_cast<E>(m_storage)) : WTF::nullopt;
+ }
+
constexpr friend bool operator==(OptionSet lhs, OptionSet rhs)
{
return lhs.m_storage == rhs.m_storage;
Modified: trunk/Source/WebCore/ChangeLog (262912 => 262913)
--- trunk/Source/WebCore/ChangeLog 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/ChangeLog 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1,3 +1,65 @@
+2020-06-11 David Kilzer <[email protected]>
+
+ [IPC] Adopt enum class for DragSourceAction
+ <https://webkit.org/b/212885>
+ <rdar://problem/64094134>
+
+ Reviewed by Darin Adler.
+
+ Summary:
+ - Convert DragSourceAction to enum class.
+ - Remove DragSourceActionNone by using Optional<> and
+ OptionSet<> (as dictated by how the code used the value).
+ - Remove DragSourceActionAny and replace (as needed) with
+ anyDragSourceAction(). (Some--but not all--uses were removed.)
+ - Add both WTF::EnumTraits<> and WTF::OptionSetTraits<> for
+ DragSourceAction since both Optional<> and OptionSet<> are
+ used with IPC.
+
+ * loader/EmptyClients.cpp:
+ * page/DragActions.h:
+ (WebCore::DragSourceAction):
+ - Convert to enum class.
+ (WebCore::anyDragSourceAction): Add.
+ - Replaces WebCore::DragSourceActionAny.
+ (WTF::EnumTraits<WebCore::DragSourceAction>): Add.
+ (WTF::OptionSetTraits<WebCore::DragSourceAction>): Add.
+ * page/DragClient.h:
+ * page/DragController.cpp:
+ (WebCore::DragController::delegateDragSourceAction):
+ (WebCore::DragController::draggableElement const):
+ (WebCore::DragController::prepareForDragStart const):
+ (WebCore::DragController::startDrag):
+ (WebCore::DragController::doSystemDrag):
+ - Use OptionSet<>::toSingleValue() and add ASSERT() that it does
+ not return WTF::nullopt.
+ * page/DragController.h:
+ (WebCore::DragController::dragSourceAction const):
+ * page/DragState.h:
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::updateDragSourceActionsAllowed const):
+ (WebCore::EventHandler::dragHysteresisExceeded const):
+ - Use OptionSet<>::toSingleValue() and add ASSERT() that it does
+ not return WTF::nullopt.
+ - Remove case statements for DragSourceActionNone and
+ DragSourceActionAny, along with ASSERT_NOT_REACHED(). The
+ ASSERT() for toSingleValue() replaces the DragSourceActionNone
+ case.
+ (WebCore::EventHandler::didStartDrag):
+ (WebCore::ExactlyOneBitSet): Delete.
+ - Move to WTF::OptionSet<>::hasExactlyOneBitSet().
+ (WebCore::EventHandler::handleDrag):
+ - Add code to #ifndef NDEBUG/#endif instead of modifying
+ dragState().type in-place since it seemed weird to modify it
+ just to check an ASSERT(), even though it was overwritten
+ immediately after that.
+ * page/EventHandler.h:
+ * platform/DragItem.h:
+ (WebCore::DragItem::encode const):
+ (WebCore::DragItem::decode):
+ - Stop using decodeEnum()/encodeEnum() with
+ Optional<DragSourceAction>.
+
2020-06-11 Youenn Fablet <[email protected]>
End a remote MediaStreamTrack if its source is ended
Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (262912 => 262913)
--- trunk/Source/WebCore/loader/EmptyClients.cpp 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp 2020-06-11 18:54:13 UTC (rev 262913)
@@ -178,7 +178,7 @@
class EmptyDragClient final : public DragClient {
void willPerformDragDestinationAction(DragDestinationAction, const DragData&) final { }
void willPerformDragSourceAction(DragSourceAction, const IntPoint&, DataTransfer&) final { }
- DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) final { return DragSourceActionNone; }
+ OptionSet<DragSourceAction> dragSourceActionMaskForPoint(const IntPoint&) final { return { }; }
void startDrag(DragItem, DataTransfer&, Frame&) final { }
};
Modified: trunk/Source/WebCore/page/DragActions.h (262912 => 262913)
--- trunk/Source/WebCore/page/DragActions.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/DragActions.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -44,22 +44,36 @@
return OptionSet<DragDestinationAction> { DragDestinationAction::DHTML, DragDestinationAction::Edit, DragDestinationAction::Load };
}
-// WebCoreDragSourceAction should be kept in sync with WebDragSourceAction.
-typedef enum {
- DragSourceActionNone = 0,
- DragSourceActionDHTML = 1,
- DragSourceActionImage = 2,
- DragSourceActionLink = 4,
- DragSourceActionSelection = 8,
+// See WebDragSourceAction.
+enum class DragSourceAction : uint8_t {
+ DHTML = 1,
+ Image = 2,
+ Link = 4,
+ Selection = 8,
#if ENABLE(ATTACHMENT_ELEMENT)
- DragSourceActionAttachment = 16,
+ Attachment = 16,
#endif
#if ENABLE(INPUT_TYPE_COLOR)
- DragSourceActionColor = 32,
+ Color = 32,
#endif
- DragSourceActionAny = UINT_MAX
-} DragSourceAction;
+};
+constexpr OptionSet<DragSourceAction> anyDragSourceAction()
+{
+ return OptionSet<DragSourceAction> {
+ DragSourceAction::DHTML,
+ DragSourceAction::Image,
+ DragSourceAction::Link,
+ DragSourceAction::Selection
+#if ENABLE(ATTACHMENT_ELEMENT)
+ , DragSourceAction::Attachment
+#endif
+#if ENABLE(INPUT_TYPE_COLOR)
+ , DragSourceAction::Color
+#endif
+ };
+}
+
// See NSDragOperation, _UIDragOperation and UIDropOperation.
enum class DragOperation : uint8_t {
Copy = 1,
@@ -108,6 +122,22 @@
>;
};
+template<> struct EnumTraits<WebCore::DragSourceAction> {
+ using values = EnumValues<
+ WebCore::DragSourceAction,
+ WebCore::DragSourceAction::DHTML,
+ WebCore::DragSourceAction::Image,
+ WebCore::DragSourceAction::Link,
+ WebCore::DragSourceAction::Selection
+#if ENABLE(ATTACHMENT_ELEMENT)
+ , WebCore::DragSourceAction::Attachment
+#endif
+#if ENABLE(INPUT_TYPE_COLOR)
+ , WebCore::DragSourceAction::Color
+#endif
+ >;
+};
+
template<> struct OptionSetTraits<WebCore::DragDestinationAction> {
using values = OptionSetValues<
WebCore::DragDestinationAction,
@@ -129,4 +159,20 @@
>;
};
+template<> struct OptionSetTraits<WebCore::DragSourceAction> {
+ using values = OptionSetValues<
+ WebCore::DragSourceAction,
+ WebCore::DragSourceAction::DHTML,
+ WebCore::DragSourceAction::Image,
+ WebCore::DragSourceAction::Link,
+ WebCore::DragSourceAction::Selection
+#if ENABLE(ATTACHMENT_ELEMENT)
+ , WebCore::DragSourceAction::Attachment
+#endif
+#if ENABLE(INPUT_TYPE_COLOR)
+ , WebCore::DragSourceAction::Color
+#endif
+ >;
+};
+
} // namespace WTF
Modified: trunk/Source/WebCore/page/DragClient.h (262912 => 262913)
--- trunk/Source/WebCore/page/DragClient.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/DragClient.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -50,7 +50,7 @@
virtual void willPerformDragDestinationAction(DragDestinationAction, const DragData&) = 0;
virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, DataTransfer&) = 0;
virtual void didConcludeEditDrag() { }
- virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0;
+ virtual OptionSet<DragSourceAction> dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0;
virtual void startDrag(DragItem, DataTransfer&, Frame&) = 0;
virtual void dragEnded() { }
Modified: trunk/Source/WebCore/page/DragController.cpp (262912 => 262913)
--- trunk/Source/WebCore/page/DragController.cpp 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/DragController.cpp 2020-06-11 18:54:13 UTC (rev 262913)
@@ -483,7 +483,7 @@
return DragHandlingMethod::None;
}
-DragSourceAction DragController::delegateDragSourceAction(const IntPoint& rootViewPoint)
+OptionSet<DragSourceAction> DragController::delegateDragSourceAction(const IntPoint& rootViewPoint)
{
m_dragSourceAction = client().dragSourceActionMaskForPoint(rootViewPoint);
return m_dragSourceAction;
@@ -769,7 +769,7 @@
Element* DragController::draggableElement(const Frame* sourceFrame, Element* startElement, const IntPoint& dragOrigin, DragState& state) const
{
- state.type = (sourceFrame->selection().contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone;
+ state.type = sourceFrame->selection().contains(dragOrigin) ? DragSourceAction::Selection : OptionSet<DragSourceAction>({ });
if (!startElement)
return nullptr;
#if ENABLE(ATTACHMENT_ELEMENT)
@@ -783,7 +783,7 @@
}
if (!isAttachmentElementInCurrentSelection || isSingleAttachmentSelection) {
- state.type = DragSourceActionAttachment;
+ state.type = DragSourceAction::Attachment;
return attachment.get();
}
}
@@ -795,32 +795,32 @@
continue;
UserDrag dragMode = renderer->style().userDrag();
- if ((m_dragSourceAction & DragSourceActionDHTML) && dragMode == UserDrag::Element) {
- state.type = static_cast<DragSourceAction>(state.type | DragSourceActionDHTML);
+ if (m_dragSourceAction.contains(DragSourceAction::DHTML) && dragMode == UserDrag::Element) {
+ state.type.add(DragSourceAction::DHTML);
return element;
}
if (dragMode == UserDrag::Auto) {
- if ((m_dragSourceAction & DragSourceActionImage)
+ if ((m_dragSourceAction.contains(DragSourceAction::Image))
&& is<HTMLImageElement>(*element)
&& imageElementIsDraggable(downcast<HTMLImageElement>(*element), *sourceFrame)) {
- state.type = static_cast<DragSourceAction>(state.type | DragSourceActionImage);
+ state.type.add(DragSourceAction::Image);
return element;
}
- if ((m_dragSourceAction & DragSourceActionLink) && isDraggableLink(*element)) {
- state.type = static_cast<DragSourceAction>(state.type | DragSourceActionLink);
+ if (m_dragSourceAction.contains(DragSourceAction::Link) && isDraggableLink(*element)) {
+ state.type.add(DragSourceAction::Link);
return element;
}
#if ENABLE(ATTACHMENT_ELEMENT)
- if ((m_dragSourceAction & DragSourceActionAttachment)
+ if (m_dragSourceAction.contains(DragSourceAction::Attachment)
&& is<HTMLAttachmentElement>(*element)
&& downcast<HTMLAttachmentElement>(*element).file()) {
- state.type = static_cast<DragSourceAction>(state.type | DragSourceActionAttachment);
+ state.type.add(DragSourceAction::Attachment);
return element;
}
#endif
#if ENABLE(INPUT_TYPE_COLOR)
- if ((m_dragSourceAction & DragSourceActionColor) && isEnabledColorInput(*element)) {
- state.type = static_cast<DragSourceAction>(state.type | DragSourceActionColor);
+ if (m_dragSourceAction.contains(DragSourceAction::Color) && isEnabledColorInput(*element)) {
+ state.type.add(DragSourceAction::Color);
return element;
}
#endif
@@ -828,7 +828,7 @@
}
// We either have nothing to drag or we have a selection and we're not over a draggable element.
- if (state.type & DragSourceActionSelection && m_dragSourceAction & DragSourceActionSelection)
+ if (state.type.contains(DragSourceAction::Selection) && m_dragSourceAction.contains(DragSourceAction::Selection))
return startElement;
return nullptr;
@@ -901,7 +901,7 @@
return IntPoint(xpos, ypos);
}
-void DragController::prepareForDragStart(Frame& source, DragSourceAction action, Element& element, DataTransfer& dataTransfer, const IntPoint& dragOrigin) const
+void DragController::prepareForDragStart(Frame& source, OptionSet<DragSourceAction> actionMask, Element& element, DataTransfer& dataTransfer, const IntPoint& dragOrigin) const
{
#if !PLATFORM(WIN)
Ref<Frame> protector(source);
@@ -911,7 +911,7 @@
auto& pasteboard = dataTransfer.pasteboard();
auto& editor = source.editor();
- if (action == DragSourceActionSelection) {
+ if (actionMask == DragSourceAction::Selection) {
if (enclosingTextFormControl(source.selection().selection().start()))
pasteboard.writePlainText(editor.selectedTextForDataTransfer(), Pasteboard::CannotSmartReplace);
else
@@ -921,18 +921,18 @@
auto* image = getImage(element);
auto imageURL = hitTestResult->absoluteImageURL();
- if ((action & DragSourceActionImage) && !imageURL.isEmpty() && image && !image->isNull()) {
+ if (actionMask.contains(DragSourceAction::Image) && !imageURL.isEmpty() && image && !image->isNull()) {
editor.writeImageToPasteboard(pasteboard, element, imageURL, { });
return;
}
auto linkURL = hitTestResult->absoluteLinkURL();
- if ((action & DragSourceActionLink) && !linkURL.isEmpty() && source.document()->securityOrigin().canDisplay(linkURL))
+ if (actionMask.contains(DragSourceAction::Link) && !linkURL.isEmpty() && source.document()->securityOrigin().canDisplay(linkURL))
editor.copyURL(linkURL, hitTestResult->textContent().simplifyWhiteSpace(), pasteboard);
#else
// FIXME: Make this work on Windows by implementing Editor::writeSelectionToPasteboard and Editor::writeImageToPasteboard.
UNUSED_PARAM(source);
- UNUSED_PARAM(action);
+ UNUSED_PARAM(actionMask);
UNUSED_PARAM(element);
UNUSED_PARAM(dataTransfer);
UNUSED_PARAM(dragOrigin);
@@ -983,7 +983,7 @@
ASSERT(state.dataTransfer);
DataTransfer& dataTransfer = *state.dataTransfer;
- if (state.type == DragSourceActionDHTML) {
+ if (state.type == DragSourceAction::DHTML) {
dragImage = DragImage { dataTransfer.createDragImage(dragImageOffset) };
// We allow DHTML/JS to set the drag image, even if its a link, image or text we're dragging.
// This is in the spirit of the IE API, which allows overriding of pasteboard data and DragOp.
@@ -993,7 +993,7 @@
}
}
- if (state.type == DragSourceActionSelection || !imageURL.isEmpty() || !linkURL.isEmpty()) {
+ if (state.type == DragSourceAction::Selection || !imageURL.isEmpty() || !linkURL.isEmpty()) {
// 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
@@ -1007,7 +1007,7 @@
IntRect dragImageBounds;
Image* image = getImage(element);
- if (state.type == DragSourceActionSelection) {
+ if (state.type == DragSourceAction::Selection) {
PasteboardWriterData pasteboardWriterData;
if (hasData == HasNonDefaultPasteboardData::No) {
@@ -1049,7 +1049,7 @@
src.editor().didWriteSelectionToPasteboard();
}
- client().willPerformDragSourceAction(DragSourceActionSelection, dragOrigin, dataTransfer);
+ client().willPerformDragSourceAction(DragSourceAction::Selection, dragOrigin, dataTransfer);
if (!dragImage) {
TextIndicatorData textIndicator;
dragImage = DragImage { dissolveDragImageToFraction(createDragImageForSelection(src, textIndicator), DragImageAlpha) };
@@ -1072,7 +1072,7 @@
dragItem.image = WTFMove(dragImage);
dragItem.data = ""
- beginDrag(WTFMove(dragItem), src, dragOrigin, mouseDraggedPoint, dataTransfer, DragSourceActionSelection);
+ beginDrag(WTFMove(dragItem), src, dragOrigin, mouseDraggedPoint, dataTransfer, DragSourceAction::Selection);
return true;
}
@@ -1082,7 +1082,7 @@
return false;
}
- if (!imageURL.isEmpty() && image && !image->isNull() && (m_dragSourceAction & DragSourceActionImage)) {
+ if (!imageURL.isEmpty() && image && !image->isNull() && m_dragSourceAction.contains(DragSourceAction::Image)) {
// We shouldn't be starting a drag for an image that can't provide an extension.
// This is an early detection for problems encountered later upon drop.
ASSERT(!image->filenameExtension().isEmpty());
@@ -1101,7 +1101,7 @@
declareAndWriteDragImage(dataTransfer, element, !linkURL.isEmpty() ? linkURL : imageURL, hitTestResult->altDisplayString());
}
- client().willPerformDragSourceAction(DragSourceActionImage, dragOrigin, dataTransfer);
+ client().willPerformDragSourceAction(DragSourceAction::Image, dragOrigin, dataTransfer);
if (!dragImage)
doImageDrag(element, dragOrigin, hitTestResult->imageRect(), src, m_dragOffset, state, WTFMove(attachmentInfo));
@@ -1113,7 +1113,7 @@
return true;
}
- if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)) {
+ if (!linkURL.isEmpty() && m_dragSourceAction.contains(DragSourceAction::Link)) {
PasteboardWriterData pasteboardWriterData;
String textContentWithSimplifiedWhiteSpace = hitTestResult->textContent().simplifyWhiteSpace();
@@ -1145,7 +1145,7 @@
src.selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));
}
- client().willPerformDragSourceAction(DragSourceActionLink, dragOrigin, dataTransfer);
+ client().willPerformDragSourceAction(DragSourceAction::Link, dragOrigin, dataTransfer);
if (!dragImage) {
TextIndicatorData textIndicator;
dragImage = DragImage { createDragImageForLink(element, linkURL, textContentWithSimplifiedWhiteSpace, textIndicator, src.settings().fontRenderingMode(), m_page.deviceScaleFactor()) };
@@ -1168,13 +1168,13 @@
dragItem.image = WTFMove(dragImage);
dragItem.data = ""
- beginDrag(WTFMove(dragItem), src, dragOrigin, mouseDraggedPoint, dataTransfer, DragSourceActionSelection);
+ beginDrag(WTFMove(dragItem), src, dragOrigin, mouseDraggedPoint, dataTransfer, DragSourceAction::Selection);
return true;
}
#if ENABLE(ATTACHMENT_ELEMENT)
- if (is<HTMLAttachmentElement>(element) && m_dragSourceAction & DragSourceActionAttachment) {
+ if (is<HTMLAttachmentElement>(element) && m_dragSourceAction.contains(DragSourceAction::Attachment)) {
auto& attachment = downcast<HTMLAttachmentElement>(element);
auto* attachmentRenderer = attachment.renderer();
@@ -1196,7 +1196,7 @@
#endif
}
- client().willPerformDragSourceAction(DragSourceActionAttachment, dragOrigin, dataTransfer);
+ client().willPerformDragSourceAction(DragSourceAction::Attachment, dragOrigin, dataTransfer);
if (!dragImage) {
TextIndicatorData textIndicator;
@@ -1220,7 +1220,7 @@
#if ENABLE(INPUT_TYPE_COLOR)
bool isColorControl = is<HTMLInputElement>(state.source) && downcast<HTMLInputElement>(*state.source).isColorControl();
- if (isColorControl && m_dragSourceAction & DragSourceActionColor) {
+ if (isColorControl && m_dragSourceAction.contains(DragSourceAction::Color)) {
auto& input = downcast<HTMLInputElement>(*state.source);
auto color = input.valueAsColor();
@@ -1231,15 +1231,15 @@
dragImageOffset = IntPoint { dragImageSize(dragImage.get()) };
dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOffset, false);
- client().willPerformDragSourceAction(DragSourceActionColor, dragOrigin, dataTransfer);
+ client().willPerformDragSourceAction(DragSourceAction::Color, dragOrigin, dataTransfer);
doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state, { });
return true;
}
#endif
- if (state.type == DragSourceActionDHTML && dragImage) {
- ASSERT(m_dragSourceAction & DragSourceActionDHTML);
- client().willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, dataTransfer);
+ if (state.type == DragSourceAction::DHTML && dragImage) {
+ ASSERT(m_dragSourceAction.contains(DragSourceAction::DHTML));
+ client().willPerformDragSourceAction(DragSourceAction::DHTML, dragOrigin, dataTransfer);
doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state, { });
return true;
}
@@ -1329,7 +1329,8 @@
DragItem item;
item.image = WTFMove(image);
- item.sourceAction = state.type;
+ ASSERT(state.type.hasExactlyOneBitSet());
+ item.sourceAction = state.type.toSingleValue();
item.promisedAttachmentInfo = WTFMove(promisedAttachmentInfo);
auto eventPositionInRootViewCoordinates = frame.view()->contentsToRootView(eventPos);
@@ -1339,7 +1340,7 @@
item.dragLocationInWindowCoordinates = viewProtector->contentsToWindow(item.dragLocationInContentCoordinates);
if (auto element = state.source) {
auto dataTransferImageElement = state.dataTransfer->dragImageElement();
- if (state.type == DragSourceActionDHTML) {
+ if (state.type == DragSourceAction::DHTML) {
// If the drag image has been customized, fall back to positioning the preview relative to the drag event location.
IntSize dragPreviewSize;
if (dataTransferImageElement)
Modified: trunk/Source/WebCore/page/DragController.h (262912 => 262913)
--- trunk/Source/WebCore/page/DragController.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/DragController.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -76,12 +76,12 @@
const URL& draggingImageURL() const { return m_draggingImageURL; }
void setDragOffset(const IntPoint& offset) { m_dragOffset = offset; }
const IntPoint& dragOffset() const { return m_dragOffset; }
- DragSourceAction dragSourceAction() const { return m_dragSourceAction; }
+ OptionSet<DragSourceAction> dragSourceAction() const { return m_dragSourceAction; }
DragHandlingMethod dragHandlingMethod() const { return m_dragHandlingMethod; }
Document* documentUnderMouse() const { return m_documentUnderMouse.get(); }
OptionSet<DragDestinationAction> dragDestinationActionMask() const { return m_dragDestinationActionMask; }
- DragSourceAction delegateDragSourceAction(const IntPoint& rootViewPoint);
+ OptionSet<DragSourceAction> delegateDragSourceAction(const IntPoint& rootViewPoint);
Element* draggableElement(const Frame*, Element* start, const IntPoint&, DragState&) const;
WEBCORE_EXPORT void dragEnded();
@@ -94,7 +94,7 @@
WEBCORE_EXPORT void finalizeDroppedImagePlaceholder(HTMLImageElement&);
WEBCORE_EXPORT void insertDroppedImagePlaceholdersAtCaret(const Vector<IntSize>& imageSizes);
- void prepareForDragStart(Frame& sourceFrame, DragSourceAction, Element& sourceElement, DataTransfer&, const IntPoint& dragOrigin) const;
+ void prepareForDragStart(Frame& sourceFrame, OptionSet<DragSourceAction>, Element& sourceElement, DataTransfer&, const IntPoint& dragOrigin) const;
bool startDrag(Frame& src, const DragState&, OptionSet<DragOperation>, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin, HasNonDefaultPasteboardData);
static const IntSize& maxDragImageSize();
@@ -154,7 +154,7 @@
DragHandlingMethod m_dragHandlingMethod { DragHandlingMethod::None };
OptionSet<DragDestinationAction> m_dragDestinationActionMask;
- DragSourceAction m_dragSourceAction { DragSourceActionNone };
+ OptionSet<DragSourceAction> m_dragSourceAction;
bool m_didInitiateDrag { false };
OptionSet<DragOperation> m_sourceDragOperationMask; // Set in startDrag when a drag starts from a mouse down within WebKit.
IntPoint m_dragOffset;
Modified: trunk/Source/WebCore/page/DragState.h (262912 => 262913)
--- trunk/Source/WebCore/page/DragState.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/DragState.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -35,7 +35,7 @@
struct DragState {
RefPtr<Element> source; // Element that may be a drag source, for the current mouse gesture.
bool shouldDispatchEvents;
- DragSourceAction type;
+ OptionSet<DragSourceAction> type; // Should be Optional<>. See Bug 213086.
RefPtr<DataTransfer> dataTransfer; // Used on only the source side of dragging.
};
Modified: trunk/Source/WebCore/page/EventHandler.cpp (262912 => 262913)
--- trunk/Source/WebCore/page/EventHandler.cpp 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1190,15 +1190,15 @@
}
#if ENABLE(DRAG_SUPPORT)
-DragSourceAction EventHandler::updateDragSourceActionsAllowed() const
+OptionSet<DragSourceAction> EventHandler::updateDragSourceActionsAllowed() const
{
Page* page = m_frame.page();
if (!page)
- return DragSourceActionNone;
+ return { };
FrameView* view = m_frame.view();
if (!view)
- return DragSourceActionNone;
+ return { };
return page->dragController().delegateDragSourceAction(view->contentsToRootView(m_mouseDownContentsPosition));
}
@@ -3647,35 +3647,36 @@
bool EventHandler::dragHysteresisExceeded(const FloatPoint& dragViewportLocation) const
{
+ auto dragOperation = dragState().type.toSingleValue();
+ ASSERT(dragOperation);
int threshold = GeneralDragHysteresis;
- switch (dragState().type) {
- case DragSourceActionSelection:
- threshold = TextDragHysteresis;
- break;
- case DragSourceActionImage:
+ if (dragOperation) {
+ switch (*dragOperation) {
+ case DragSourceAction::Selection:
+ threshold = TextDragHysteresis;
+ break;
+ case DragSourceAction::Image:
#if ENABLE(ATTACHMENT_ELEMENT)
- case DragSourceActionAttachment:
+ case DragSourceAction::Attachment:
#endif
- threshold = ImageDragHysteresis;
- break;
- case DragSourceActionLink:
- threshold = LinkDragHysteresis;
- break;
+ threshold = ImageDragHysteresis;
+ break;
+ case DragSourceAction::Link:
+ threshold = LinkDragHysteresis;
+ break;
#if ENABLE(INPUT_TYPE_COLOR)
- case DragSourceActionColor:
- threshold = ColorDragHystersis;
- break;
+ case DragSourceAction::Color:
+ threshold = ColorDragHystersis;
+ break;
#endif
- case DragSourceActionDHTML:
- break;
- case DragSourceActionNone:
- case DragSourceActionAny:
- ASSERT_NOT_REACHED();
+ case DragSourceAction::DHTML:
+ break;
+ }
}
-
+
return mouseMovementExceedsThreshold(dragViewportLocation, threshold);
}
-
+
void EventHandler::invalidateDataTransfer()
{
if (!dragState().dataTransfer)
@@ -3715,7 +3716,7 @@
return;
Optional<SimpleRange> draggedContentRange;
- if (dragState().type & DragSourceActionSelection)
+ if (dragState().type.contains(DragSourceAction::Selection))
draggedContentRange = m_frame.selection().selection().toNormalizedRange();
else
draggedContentRange = makeRangeSelectingNode(*dragSource);
@@ -3775,11 +3776,6 @@
return !dispatchDragEvent(eventNames().dragstartEvent, *dragState().source, m_mouseDownEvent, dataTransfer) && !m_frame.selection().selection().isInPasswordField();
}
-static bool ExactlyOneBitSet(DragSourceAction n)
-{
- return n && !(n & (n - 1));
-}
-
RefPtr<Element> EventHandler::draggedElement() const
{
return dragState().source;
@@ -3803,7 +3799,7 @@
// Careful that the drag starting logic stays in sync with eventMayStartDrag().
if (m_mouseDownMayStartDrag && !dragState().source) {
- dragState().shouldDispatchEvents = (updateDragSourceActionsAllowed() & DragSourceActionDHTML);
+ dragState().shouldDispatchEvents = updateDragSourceActionsAllowed().contains(DragSourceAction::DHTML);
// Try to find an element that wants to be dragged.
HitTestResult result(m_mouseDownContentsPosition);
@@ -3814,17 +3810,17 @@
if (!dragState().source)
m_mouseDownMayStartDrag = false; // no element is draggable
else
- m_dragMayStartSelectionInstead = (dragState().type & DragSourceActionSelection);
+ m_dragMayStartSelectionInstead = dragState().type.contains(DragSourceAction::Selection);
}
// For drags starting in the selection, the user must wait between the mousedown and mousedrag,
// or else we bail on the dragging stuff and allow selection to occur
- if (m_mouseDownMayStartDrag && m_dragMayStartSelectionInstead && (dragState().type & DragSourceActionSelection) && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) {
+ if (m_mouseDownMayStartDrag && m_dragMayStartSelectionInstead && dragState().type.contains(DragSourceAction::Selection) && event.event().timestamp() - m_mouseDownTimestamp < TextDragDelay) {
ASSERT(event.event().type() == PlatformEvent::MouseMoved);
- if ((dragState().type & DragSourceActionImage)) {
+ if (dragState().type.contains(DragSourceAction::Image)) {
// ... unless the mouse is over an image, then we start dragging just the image
- dragState().type = DragSourceActionImage;
- } else if (!(dragState().type & (DragSourceActionDHTML | DragSourceActionLink))) {
+ dragState().type = DragSourceAction::Image;
+ } else if (!dragState().type.containsAny({ DragSourceAction::DHTML, DragSourceAction::Link })) {
// ... but only bail if we're not over an unselectable element.
m_mouseDownMayStartDrag = false;
dragState().source = nullptr;
@@ -3845,11 +3841,15 @@
return !mouseDownMayStartSelect() && !m_mouseDownMayStartAutoscroll;
ASSERT(dragState().source);
- if (!ExactlyOneBitSet(dragState().type)) {
- ASSERT(dragState().type & DragSourceActionSelection);
- ASSERT(ExactlyOneBitSet(static_cast<DragSourceAction>(dragState().type & ~DragSourceActionSelection)));
+ if (!dragState().type.hasExactlyOneBitSet()) {
+ ASSERT(dragState().type.contains(DragSourceAction::Selection));
+#ifndef NDEBUG
+ auto actionMaskCopy = dragState().type;
+ actionMaskCopy.remove(DragSourceAction::Selection);
+ ASSERT(actionMaskCopy.hasExactlyOneBitSet());
+#endif
- dragState().type = DragSourceActionSelection;
+ dragState().type = DragSourceAction::Selection;
}
// We are starting a text/image/url drag, so the cursor should be an arrow
@@ -3881,7 +3881,7 @@
hasNonDefaultPasteboardData = HasNonDefaultPasteboardData::Yes;
dragState().dataTransfer->moveDragState(WTFMove(dragStartDataTransfer));
- if (dragState().source && dragState().type == DragSourceActionDHTML && !dragState().dataTransfer->hasDragImage()) {
+ if (dragState().source && dragState().type == DragSourceAction::DHTML && !dragState().dataTransfer->hasDragImage()) {
dragState().source->document().updateStyleIfNeeded();
if (auto* renderer = dragState().source->renderer()) {
auto absolutePosition = renderer->localToAbsolute();
Modified: trunk/Source/WebCore/page/EventHandler.h (262912 => 262913)
--- trunk/Source/WebCore/page/EventHandler.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/page/EventHandler.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -465,7 +465,7 @@
void defaultArrowEventHandler(FocusDirection, KeyboardEvent&);
#if ENABLE(DRAG_SUPPORT)
- DragSourceAction updateDragSourceActionsAllowed() const;
+ OptionSet<DragSourceAction> updateDragSourceActionsAllowed() const;
bool supportsSelectionUpdatesOnMouseDrag() const;
#endif
Modified: trunk/Source/WebCore/platform/DragItem.h (262912 => 262913)
--- trunk/Source/WebCore/platform/DragItem.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebCore/platform/DragItem.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -41,7 +41,7 @@
// Where the image should be positioned relative to the cursor.
FloatPoint imageAnchorPoint;
- DragSourceAction sourceAction { DragSourceActionNone };
+ Optional<DragSourceAction> sourceAction;
IntPoint eventPositionInContentCoordinates;
IntPoint dragLocationInContentCoordinates;
IntPoint dragLocationInWindowCoordinates;
@@ -61,7 +61,7 @@
{
// FIXME(173815): We should encode and decode PasteboardWriterData and platform drag image data
// here too, as part of moving off of the legacy dragging codepath.
- encoder.encodeEnum(sourceAction);
+ encoder << sourceAction;
encoder << imageAnchorPoint << eventPositionInContentCoordinates << dragLocationInContentCoordinates << dragLocationInWindowCoordinates << title << url << dragPreviewFrameInRootViewCoordinates;
bool hasIndicatorData = image.hasIndicatorData();
encoder << hasIndicatorData;
@@ -77,7 +77,7 @@
template<class Decoder>
bool DragItem::decode(Decoder& decoder, DragItem& result)
{
- if (!decoder.decodeEnum(result.sourceAction))
+ if (!decoder.decode(result.sourceAction))
return false;
if (!decoder.decode(result.imageAnchorPoint))
return false;
Modified: trunk/Source/WebKit/ChangeLog (262912 => 262913)
--- trunk/Source/WebKit/ChangeLog 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/ChangeLog 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1,3 +1,46 @@
+2020-06-11 David Kilzer <[email protected]>
+
+ [IPC] Adopt enum class for DragSourceAction
+ <https://webkit.org/b/212885>
+ <rdar://problem/64094134>
+
+ Reviewed by Darin Adler.
+
+ Summary:
+ - Convert argument parameters from uint64_t to
+ OptionSet<DragSourceAction>.
+ - Convert DragSourceAction to OptionSet<DragSourceAction>.
+
+ * Scripts/webkit/messages.py:
+ - Map DragSourceAction enum to DragActions.h header.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/DragDropInteractionState.h:
+ * UIProcess/ios/DragDropInteractionState.mm:
+ (WebKit::shouldUseDragImageToCreatePreviewForDragSource):
+ (WebKit::shouldUseVisiblePathToCreatePreviewForDragSource):
+ (WebKit::shouldUseTextIndicatorToCreatePreviewForDragSource):
+ (WebKit::canUpdatePreviewForActiveDragSource):
+ (WebKit::DragDropInteractionState::anyActiveDragSourceIs const):
+ (WebKit::DragDropInteractionState::stageDragItem):
+ (WebKit::DragDropInteractionState::hasStagedDragSource const):
+ (WebKit::DragDropInteractionState::updatePreviewsForActiveDragSources):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _startDrag:item:]):
+ (-[WKContentView _allowedDragSourceActions]):
+ (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::requestDragStart):
+ (WebKit::WebPageProxy::requestAdditionalItemsForDragSession):
+ * WebProcess/WebCoreSupport/WebDragClient.cpp:
+ (WebKit::WebDragClient::dragSourceActionMaskForPoint):
+ * WebProcess/WebCoreSupport/WebDragClient.h:
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::allowedDragSourceActions const):
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::requestDragStart):
+ (WebKit::WebPage::requestAdditionalItemsForDragSession):
+
2020-06-11 Eric Carlson <[email protected]>
[Cocoa] MediaUsageManagerCocoa should use a different USVideoUsage initializer
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (262912 => 262913)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2020-06-11 18:54:13 UTC (rev 262913)
@@ -591,6 +591,7 @@
'WebKit::DocumentEditingContextRequest': ['"DocumentEditingContext.h"'],
'WebCore::DragHandlingMethod': ['<WebCore/DragActions.h>'],
'WebCore::DragOperation': ['<WebCore/DragActions.h>'],
+ 'WebCore::DragSourceAction': ['<WebCore/DragActions.h>'],
'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'],
'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'],
'WebCore::ShareDataWithParsedURL': ['<WebCore/ShareData.h>'],
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (262912 => 262913)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -833,8 +833,8 @@
#if ENABLE(DRAG_SUPPORT)
void didHandleDragStartRequest(bool started);
void didHandleAdditionalDragItemsRequest(bool added);
- void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, WebCore::DragSourceAction allowedActions);
- void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, WebCore::DragSourceAction allowedActions);
+ void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask);
+ void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask);
void insertDroppedImagePlaceholders(const Vector<WebCore::IntSize>&, CompletionHandler<void(const Vector<WebCore::IntRect>&, Optional<WebCore::TextIndicatorData>)>&& reply);
void willReceiveEditDragSnapshot();
void didReceiveEditDragSnapshot(Optional<WebCore::TextIndicatorData>);
Modified: trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.h (262912 => 262913)
--- trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -46,7 +46,7 @@
namespace WebKit {
struct DragSourceState {
- WebCore::DragSourceAction action { WebCore::DragSourceActionNone };
+ OptionSet<WebCore::DragSourceAction> action;
CGPoint adjustedOrigin { CGPointZero };
CGRect dragPreviewFrameInRootViewCoordinates { CGRectZero };
RetainPtr<UIImage> image;
Modified: trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm (262912 => 262913)
--- trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm 2020-06-11 18:54:13 UTC (rev 262913)
@@ -99,11 +99,11 @@
return false;
#if ENABLE(INPUT_TYPE_COLOR)
- if (source.action & DragSourceActionColor)
+ if (source.action.contains(DragSourceAction::Color))
return true;
#endif
- return source.action & (DragSourceActionDHTML | DragSourceActionImage);
+ return source.action.containsAny({ DragSourceAction::DHTML, DragSourceAction::Image });
}
static bool shouldUseVisiblePathToCreatePreviewForDragSource(const DragSourceState& source)
@@ -112,7 +112,7 @@
return false;
#if ENABLE(INPUT_TYPE_COLOR)
- if (source.action & DragSourceActionColor)
+ if (source.action.contains(DragSourceAction::Color))
return true;
#endif
@@ -124,11 +124,11 @@
if (!source.indicatorData)
return false;
- if (source.action & (DragSourceActionLink | DragSourceActionSelection))
+ if (source.action.containsAny({ DragSourceAction::Link, DragSourceAction::Selection }))
return true;
#if ENABLE(ATTACHMENT_ELEMENT)
- if (source.action & DragSourceActionAttachment)
+ if (source.action.contains(DragSourceAction::Attachment))
return true;
#endif
@@ -141,11 +141,11 @@
return false;
#if ENABLE(INPUT_TYPE_COLOR)
- if (source.action & DragSourceActionColor)
+ if (source.action.contains(DragSourceAction::Color))
return true;
#endif
- if (source.action & DragSourceActionLink && !(source.action & DragSourceActionImage))
+ if (source.action.contains(DragSourceAction::Link) && !source.action.contains(DragSourceAction::Image))
return true;
return false;
@@ -167,7 +167,7 @@
bool DragDropInteractionState::anyActiveDragSourceIs(WebCore::DragSourceAction action) const
{
for (auto& source : m_activeDragSources) {
- if (source.action & action)
+ if (source.action.contains(action))
return true;
}
return false;
@@ -342,7 +342,7 @@
m_adjustedPositionForDragEnd = item.eventPositionInContentCoordinates;
m_stagedDragSource = {{
- static_cast<DragSourceAction>(item.sourceAction),
+ item.sourceAction,
item.eventPositionInContentCoordinates,
item.dragPreviewFrameInRootViewCoordinates,
dragImage,
@@ -357,7 +357,7 @@
bool DragDropInteractionState::hasStagedDragSource() const
{
- return m_stagedDragSource && stagedDragSource().action != WebCore::DragSourceActionNone;
+ return m_stagedDragSource && !stagedDragSource().action.isEmpty();
}
void DragDropInteractionState::clearStagedDragSource(DidBecomeActive didBecomeActive)
@@ -393,7 +393,7 @@
if (!dragItem)
continue;
- if (source.action & DragSourceActionLink) {
+ if (source.action.contains(DragSourceAction::Link)) {
dragItem.previewProvider = [title = retainPtr((NSString *)source.linkTitle), url = "" *)source.linkURL), center = source.adjustedOrigin] () -> UIDragPreview * {
UIURLDragPreviewView *previewView = [UIURLDragPreviewView viewWithTitle:title.get() URL:url.get()];
previewView.center = center;
@@ -402,7 +402,7 @@
};
}
#if ENABLE(INPUT_TYPE_COLOR)
- else if (source.action & DragSourceActionColor) {
+ else if (source.action.contains(DragSourceAction::Color)) {
dragItem.previewProvider = [image = source.image] () -> UIDragPreview * {
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image.get()] autorelease];
UIDragPreviewParameters *parameters = [[[UIDragPreviewParameters alloc] initWithTextLineRects:@[ [NSValue valueWithCGRect:[imageView bounds]] ]] autorelease];
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (262912 => 262913)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-06-11 18:54:13 UTC (rev 262913)
@@ -7253,7 +7253,7 @@
- (void)_startDrag:(RetainPtr<CGImageRef>)image item:(const WebCore::DragItem&)item
{
- ASSERT(item.sourceAction != WebCore::DragSourceActionNone);
+ ASSERT(item.sourceAction);
if (item.promisedAttachmentInfo)
[self _prepareToDragPromisedAttachment:item.promisedAttachmentInfo];
@@ -7554,12 +7554,12 @@
return WKDragDestinationActionAny & ~WKDragDestinationActionLoad;
}
-- (WebCore::DragSourceAction)_allowedDragSourceActions
+- (OptionSet<WebCore::DragSourceAction>)_allowedDragSourceActions
{
- auto allowedActions = WebCore::DragSourceActionAny;
+ auto allowedActions = WebCore::anyDragSourceAction();
if (!self.isFirstResponder || !_suppressSelectionAssistantReasons.isEmpty()) {
// Don't allow starting a drag on a selection when selection views are not visible.
- allowedActions = static_cast<WebCore::DragSourceAction>(allowedActions & ~WebCore::DragSourceActionSelection);
+ allowedActions.remove(WebCore::DragSourceAction::Selection);
}
return allowedActions;
}
@@ -8030,7 +8030,7 @@
- (void)dragInteraction:(UIDragInteraction *)interaction willAnimateLiftWithAnimator:(id <UIDragAnimating>)animator session:(id <UIDragSession>)session
{
RELEASE_LOG(DragAndDrop, "Drag session willAnimateLiftWithAnimator: %p", session);
- if (_dragDropInteractionState.anyActiveDragSourceIs(WebCore::DragSourceActionSelection)) {
+ if (_dragDropInteractionState.anyActiveDragSourceIs(WebCore::DragSourceAction::Selection)) {
[self cancelActiveTextInteractionGestures];
if (!_shouldRestoreCalloutBarAfterDrop) {
// FIXME: This SPI should be renamed in UIKit to reflect a more general purpose of hiding interaction assistant controls.
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (262912 => 262913)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1257,16 +1257,16 @@
pageClient().didHandleAdditionalDragItemsRequest(added);
}
-void WebPageProxy::requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, WebCore::DragSourceAction allowedActions)
+void WebPageProxy::requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask)
{
if (hasRunningProcess())
- m_process->send(Messages::WebPage::RequestDragStart(clientPosition, globalPosition, allowedActions), m_webPageID);
+ m_process->send(Messages::WebPage::RequestDragStart(clientPosition, globalPosition, allowedActionsMask), m_webPageID);
}
-void WebPageProxy::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition, WebCore::DragSourceAction allowedActions)
+void WebPageProxy::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask)
{
if (hasRunningProcess())
- m_process->send(Messages::WebPage::RequestAdditionalItemsForDragSession(clientPosition, globalPosition, allowedActions), m_webPageID);
+ m_process->send(Messages::WebPage::RequestAdditionalItemsForDragSession(clientPosition, globalPosition, allowedActionsMask), m_webPageID);
}
void WebPageProxy::insertDroppedImagePlaceholders(const Vector<IntSize>& imageSizes, CompletionHandler<void(const Vector<IntRect>&, Optional<WebCore::TextIndicatorData>)>&& completionHandler)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.cpp (262912 => 262913)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.cpp 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.cpp 2020-06-11 18:54:13 UTC (rev 262913)
@@ -45,7 +45,7 @@
{
}
-DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
+OptionSet<DragSourceAction> WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
{
return m_page->allowedDragSourceActions();
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.h (262912 => 262913)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -45,7 +45,7 @@
private:
void willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&) override;
void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&) override;
- WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
+ OptionSet<WebCore::DragSourceAction> dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&) override;
void didConcludeEditDrag() override;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (262912 => 262913)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -915,7 +915,7 @@
void willStartDrag() { ASSERT(!m_isStartingDrag); m_isStartingDrag = true; }
void didStartDrag();
void dragCancelled();
- WebCore::DragSourceAction allowedDragSourceActions() const { return m_allowedDragSourceActions; }
+ OptionSet<WebCore::DragSourceAction> allowedDragSourceActions() const { return m_allowedDragSourceActions; }
#endif
void beginPrinting(WebCore::FrameIdentifier, const PrintInfo&);
@@ -1406,8 +1406,8 @@
#endif
#if PLATFORM(IOS_FAMILY) && ENABLE(DATA_INTERACTION)
- void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t allowedActions);
- void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t allowedActions);
+ void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask);
+ void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask);
void insertDroppedImagePlaceholders(const Vector<WebCore::IntSize>&, CompletionHandler<void(const Vector<WebCore::IntRect>&, Optional<WebCore::TextIndicatorData>)>&& reply);
void computeAndSendEditDragSnapshot();
#endif
@@ -1933,7 +1933,7 @@
#if ENABLE(DRAG_SUPPORT)
bool m_isStartingDrag { false };
- WebCore::DragSourceAction m_allowedDragSourceActions { WebCore::DragSourceActionAny };
+ OptionSet<WebCore::DragSourceAction> m_allowedDragSourceActions { WebCore::anyDragSourceAction() };
#endif
#if ENABLE(DRAG_SUPPORT) && PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (262912 => 262913)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-06-11 18:54:13 UTC (rev 262913)
@@ -321,8 +321,8 @@
#endif
#if PLATFORM(IOS_FAMILY) && ENABLE(DRAG_SUPPORT)
- RequestDragStart(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t allowedActions)
- RequestAdditionalItemsForDragSession(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t allowedActions)
+ RequestDragStart(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask)
+ RequestAdditionalItemsForDragSession(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask)
InsertDroppedImagePlaceholders(Vector<WebCore::IntSize> imageSize) -> (Vector<WebCore::IntRect> dropPreviewRects, Optional<WebCore::TextIndicatorData> textIndicator) Async
DidConcludeDrop()
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (262912 => 262913)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-06-11 18:54:13 UTC (rev 262913)
@@ -909,16 +909,16 @@
}
#if ENABLE(DATA_INTERACTION)
-void WebPage::requestDragStart(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t allowedActions)
+void WebPage::requestDragStart(const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask)
{
- SetForScope<WebCore::DragSourceAction> allowedActionsForScope(m_allowedDragSourceActions, static_cast<WebCore::DragSourceAction>(allowedActions));
+ SetForScope<OptionSet<WebCore::DragSourceAction>> allowedActionsForScope(m_allowedDragSourceActions, allowedActionsMask);
bool didStart = m_page->mainFrame().eventHandler().tryToBeginDragAtPoint(clientPosition, globalPosition);
send(Messages::WebPageProxy::DidHandleDragStartRequest(didStart));
}
-void WebPage::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t allowedActions)
+void WebPage::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition, OptionSet<WebCore::DragSourceAction> allowedActionsMask)
{
- SetForScope<WebCore::DragSourceAction> allowedActionsForScope(m_allowedDragSourceActions, static_cast<WebCore::DragSourceAction>(allowedActions));
+ SetForScope<OptionSet<WebCore::DragSourceAction>> allowedActionsForScope(m_allowedDragSourceActions, allowedActionsMask);
// To augment the platform drag session with additional items, end the current drag session and begin a new drag session with the new drag item.
// This process is opaque to the UI process, which still maintains the old drag item in its drag session. Similarly, this persistent drag session
// is opaque to the web process, which only sees that the current drag has ended, and that a new one is beginning.
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (262912 => 262913)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1,3 +1,30 @@
+2020-06-11 David Kilzer <[email protected]>
+
+ [IPC] Adopt enum class for DragSourceAction
+ <https://webkit.org/b/212885>
+ <rdar://problem/64094134>
+
+ Reviewed by Darin Adler.
+
+ Summary:
+ - Add and use conversion functions between
+ OptionSet<WebCore::DragSourceAction> and WebDragSourceAction.
+ - Update method signatures.
+
+ * WebCoreSupport/WebDragClient.h:
+ * WebCoreSupport/WebDragClient.mm:
+ (coreDragSourceActionMask): Add.
+ (WebDragClient::dragSourceActionMaskForPoint):
+ (WebDragClient::willPerformDragSourceAction):
+ (WebDragClient::startDrag):
+ * WebView/WebView.mm:
+ (kit): Add.
+ - Convert from Optional<WebCore::DragSourceAction> to
+ WebDragSourceAction.
+ (-[WebView _startDrag:]):
+ * WebView/WebViewInternal.h:
+ (kit): Add declaration to reuse function in WebDragClient.mm.
+
2020-06-10 Geoffrey Garen <[email protected]>
Some style improvements to main thread code
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.h (262912 => 262913)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -38,7 +38,7 @@
void willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&) override;
void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&) override;
- WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
+ OptionSet<WebCore::DragSourceAction> dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&) override;
void beginDrag(WebCore::DragItem, WebCore::Frame&, const WebCore::IntPoint& mouseDownPosition, const WebCore::IntPoint& mouseDraggedPosition, WebCore::DataTransfer&, WebCore::DragSourceAction) override;
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.mm (262912 => 262913)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.mm 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.mm 2020-06-11 18:54:13 UTC (rev 262913)
@@ -68,6 +68,22 @@
#if PLATFORM(MAC)
+static OptionSet<WebCore::DragSourceAction> coreDragSourceActionMask(WebDragSourceAction action)
+{
+ OptionSet<WebCore::DragSourceAction> result;
+
+ if (action & WebDragSourceActionDHTML)
+ result.add(WebCore::DragSourceAction::DHTML);
+ if (action & WebDragSourceActionImage)
+ result.add(WebCore::DragSourceAction::Image);
+ if (action & WebDragSourceActionLink)
+ result.add(WebCore::DragSourceAction::Link);
+ if (action & WebDragSourceActionSelection)
+ result.add(WebCore::DragSourceAction::Selection);
+
+ return result;
+}
+
static WebDragDestinationAction kit(WebCore::DragDestinationAction action)
{
switch (action) {
@@ -104,15 +120,15 @@
}
-WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& rootViewPoint)
+OptionSet<WebCore::DragSourceAction> WebDragClient::dragSourceActionMaskForPoint(const IntPoint& rootViewPoint)
{
NSPoint viewPoint = [m_webView _convertPointFromRootView:rootViewPoint];
- return (DragSourceAction)[[m_webView _UIDelegateForwarder] webView:m_webView dragSourceActionMaskForPoint:viewPoint];
+ return coreDragSourceActionMask([[m_webView _UIDelegateForwarder] webView:m_webView dragSourceActionMaskForPoint:viewPoint]);
}
void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction action, const WebCore::IntPoint& mouseDownPoint, WebCore::DataTransfer& dataTransfer)
{
- [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:dataTransfer.pasteboard().name()]];
+ [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:kit(action) fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:dataTransfer.pasteboard().name()]];
}
void WebDragClient::startDrag(DragItem dragItem, DataTransfer& dataTransfer, Frame& frame)
@@ -124,7 +140,7 @@
if (![htmlView.get() isKindOfClass:[WebHTMLView class]])
return;
- NSEvent *event = dragItem.sourceAction == DragSourceActionLink ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];
+ NSEvent *event = (dragItem.sourceAction && *dragItem.sourceAction == DragSourceAction::Link) ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];
WebHTMLView* topHTMLView = getTopHTMLView(&frame);
RetainPtr<WebHTMLView> topViewProtector = topHTMLView;
@@ -197,9 +213,9 @@
{
}
-WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
+OptionSet<WebCore::DragSourceAction> WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
{
- return DragSourceActionNone;
+ return { };
}
void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&)
@@ -232,9 +248,9 @@
{
}
-WebCore::DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
+OptionSet<WebCore::DragSourceAction> WebDragClient::dragSourceActionMaskForPoint(const IntPoint&)
{
- return DragSourceActionAny;
+ return WebCore::anyDragSourceAction();
}
void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction, const IntPoint&, DataTransfer&)
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (262912 => 262913)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-06-11 18:54:13 UTC (rev 262913)
@@ -675,6 +675,34 @@
return _UIDragOperationNone;
}
#endif // USE(APPKIT)
+
+WebDragSourceAction kit(Optional<WebCore::DragSourceAction> action)
+{
+ if (!action)
+ return WebDragSourceActionNone;
+
+ switch (*action) {
+ case WebCore::DragSourceAction::DHTML:
+ return WebDragSourceActionDHTML;
+ case WebCore::DragSourceAction::Image:
+ return WebDragSourceActionImage;
+ case WebCore::DragSourceAction::Link:
+ return WebDragSourceActionLink;
+ case WebCore::DragSourceAction::Selection:
+ return WebDragSourceActionSelection;
+#if ENABLE(ATTACHMENT_ELEMENT)
+ case WebCore::DragSourceAction::Attachment:
+ break;
+#endif
+#if ENABLE(INPUT_TYPE_COLOR)
+ case WebCore::DragSourceAction::Color:
+ break;
+#endif
+ }
+
+ ASSERT_NOT_REACHED();
+ return WebDragSourceActionNone;
+}
#endif // ENABLE(DRAG_SUPPORT)
WebCore::FindOptions coreOptions(WebFindOptions options)
@@ -1960,7 +1988,7 @@
_private->draggedLinkURL = dragItem.url.isEmpty() ? nil : (NSURL *)dragItem.url;
_private->draggedLinkTitle = dragItem.title.isEmpty() ? nil : (NSString *)dragItem.title;
_private->dragPreviewFrameInRootViewCoordinates = dragItem.dragPreviewFrameInRootViewCoordinates;
- _private->dragSourceAction = static_cast<WebDragSourceAction>(dragItem.sourceAction);
+ _private->dragSourceAction = kit(dragItem.sourceAction);
}
- (CGRect)_dataInteractionCaretRect
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h (262912 => 262913)
--- trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -32,6 +32,7 @@
#import "WebPreferences.h"
#import "WebViewPrivate.h"
#import "WebTypesInternal.h"
+#import "WebUIDelegate.h"
#ifdef __cplusplus
@@ -98,6 +99,8 @@
#endif
OptionSet<WebCore::DragOperation> coreDragOperationMask(CocoaDragOperation);
+
+WebDragSourceAction kit(Optional<WebCore::DragSourceAction>);
#endif // ENABLE(DRAG_SUPPORT)
WebCore::FindOptions coreOptions(WebFindOptions);
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (262912 => 262913)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2020-06-11 18:54:13 UTC (rev 262913)
@@ -1,3 +1,26 @@
+2020-06-11 David Kilzer <[email protected]>
+
+ [IPC] Adopt enum class for DragSourceAction
+ <https://webkit.org/b/212885>
+ <rdar://problem/64094134>
+
+ Reviewed by Darin Adler.
+
+ Summary:
+ - Add and use conversion functions between
+ OptionSet<WebCore::DragSourceAction> and WebDragSourceAction.
+ - Update method signatures.
+
+ * WebCoreSupport/WebDragClient.cpp:
+ (coreDragSourceActionMask): Add.
+ (kit): Add.
+ - Convert from WebCore::DragSourceAction to WebDragSourceAction.
+ (WebDragClient::dragSourceActionMaskForPoint):
+ (WebDragClient::willPerformDragSourceAction):
+ (WebDragClient::startDrag):
+ * WebCoreSupport/WebDragClient.h:
+ (WebDragClient::dragSourceActionMaskForPoint):
+
2020-06-10 Geoffrey Garen <[email protected]>
Some style improvements to main thread code
Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.cpp (262912 => 262913)
--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.cpp 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.cpp 2020-06-11 18:54:13 UTC (rev 262913)
@@ -72,6 +72,46 @@
return WebDragDestinationActionNone;
}
+static OptionSet<DragSourceAction> coreDragSourceActionMask(WebDragSourceAction actionMask)
+{
+ OptionSet<DragSourceAction> result;
+
+ if (actionMask & WebDragSourceActionDHTML)
+ result.add(DragSourceAction::DHTML);
+ if (actionMask & WebDragSourceActionImage)
+ result.add(DragSourceAction::Image);
+ if (actionMask & WebDragSourceActionLink)
+ result.add(DragSourceAction::Link);
+ if (actionMask & WebDragSourceActionSelection)
+ result.add(DragSourceAction::Selection);
+
+ return result;
+}
+
+static WebDragSourceAction kit(DragSourceAction action)
+{
+ switch (action) {
+ case DragSourceAction::DHTML:
+ return WebDragSourceActionDHTML;
+ case DragSourceAction::Image:
+ return WebDragSourceActionImage;
+ case DragSourceAction::Link:
+ return WebDragSourceActionLink;
+ case DragSourceAction::Selection:
+ return WebDragSourceActionSelection;
+#if ENABLE(ATTACHMENT_ELEMENT)
+ case DragSourceAction::Attachment:
+ break;
+#endif
+#if ENABLE(INPUT_TYPE_COLOR)
+ case DragSourceAction::Color:
+ break;
+#endif
+ }
+ ASSERT_NOT_REACHED();
+ return WebDragSourceActionNone;
+}
+
WebDragClient::WebDragClient(WebView* webView)
: m_webView(webView)
{
@@ -87,14 +127,14 @@
delegateRef->willPerformDragDestinationAction(m_webView, kit(action), dragData.platformData());
}
-DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
+OptionSet<DragSourceAction> WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
{
COMPtr<IWebUIDelegate> delegateRef = 0;
- WebDragSourceAction action = ""
+ WebDragSourceAction actionMask = WebDragSourceActionAny;
POINT localpt = core(m_webView)->mainFrame().view()->windowToContents(windowPoint);
if (SUCCEEDED(m_webView->uiDelegate(&delegateRef)))
- delegateRef->dragSourceActionMaskForPoint(m_webView, &localpt, &action);
- return (DragSourceAction)action;
+ delegateRef->dragSourceActionMaskForPoint(m_webView, &localpt, &actionMask);
+ return coreDragSourceActionMask(actionMask);
}
void WebDragClient::willPerformDragSourceAction(DragSourceAction action, const IntPoint& intPoint, DataTransfer& dataTransfer)
@@ -107,7 +147,7 @@
COMPtr<IDataObject> dataObject = dataTransfer.pasteboard().dataObject();
COMPtr<IDataObject> newDataObject;
- HRESULT result = uiDelegate->willPerformDragSourceAction(m_webView, static_cast<WebDragSourceAction>(action), &point, dataObject.get(), &newDataObject);
+ HRESULT result = uiDelegate->willPerformDragSourceAction(m_webView, kit(action), &point, dataObject.get(), &newDataObject);
if (result == S_OK && newDataObject != dataObject)
const_cast<Pasteboard&>(dataTransfer.pasteboard()).setExternalDataObject(newDataObject.get());
}
@@ -143,7 +183,7 @@
sdi.hbmpDragImage = image.get();
sdi.ptOffset.x = dragPoint.x() - imageOrigin.x();
sdi.ptOffset.y = dragPoint.y() - imageOrigin.y();
- if (item.sourceAction == DragSourceActionLink)
+ if (item.sourceAction && *item.sourceAction == DragSourceAction::Link)
sdi.ptOffset.y = b.bmHeight - sdi.ptOffset.y;
helper->InitializeFromBitmap(&sdi, dataObject.get());
Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.h (262912 => 262913)
--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.h 2020-06-11 18:47:14 UTC (rev 262912)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDragClient.h 2020-06-11 18:54:13 UTC (rev 262913)
@@ -37,7 +37,7 @@
public:
WebDragClient(WebView*);
- virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint&);
+ virtual OptionSet<WebCore::DragSourceAction> dragSourceActionMaskForPoint(const WebCore::IntPoint&);
virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&);
virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&);
virtual void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&);