Commit a0a0d1cd authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Chromium LUCI CQ

Remove Private, Generic and Delete drag operations

These operations are modeled after the corresponding values from
NSDragOperation, but they don't have any corresponding meaning on the
Web and neither are they used in the browser.

Bug: 1093536
Change-Id: I8d8770d2b234c835444c198b2639597c20b8a512
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562667Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#837013}
parent 280382d9
......@@ -13,12 +13,24 @@
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
#include "ui/base/dragdrop/cocoa_dnd_util.h"
#include "ui/base/dragdrop/drag_drop_types.h"
using remote_cocoa::mojom::DraggingInfo;
using remote_cocoa::mojom::SelectionDirection;
using remote_cocoa::mojom::Visibility;
using content::DropData;
// Ensure that the ui::DragDropTypes::DragOperation enum values stay in sync
// with NSDragOperation constants, since the code below uses
// NSDragOperationToDragOperation to filter invalid values.
#define STATIC_ASSERT_ENUM(a, b) \
static_assert(static_cast<int>(a) == static_cast<int>(b), \
"enum mismatch: " #a)
STATIC_ASSERT_ENUM(NSDragOperationNone, ui::DragDropTypes::DRAG_NONE);
STATIC_ASSERT_ENUM(NSDragOperationCopy, ui::DragDropTypes::DRAG_COPY);
STATIC_ASSERT_ENUM(NSDragOperationLink, ui::DragDropTypes::DRAG_LINK);
STATIC_ASSERT_ENUM(NSDragOperationMove, ui::DragDropTypes::DRAG_MOVE);
////////////////////////////////////////////////////////////////////////////////
// WebContentsViewCocoa
......@@ -72,7 +84,8 @@ using content::DropData;
ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES);
info->url.emplace(url);
}
info->operation_mask = [nsInfo draggingSourceOperationMask];
info->operation_mask = ui::DragDropTypes::NSDragOperationToDragOperation(
[nsInfo draggingSourceOperationMask]);
}
- (BOOL)allowsVibrancy {
......@@ -152,7 +165,9 @@ using content::DropData;
- (void)draggedImage:(NSImage*)anImage
endedAt:(NSPoint)screenPoint
operation:(NSDragOperation)operation {
[_dragSource endDragAt:screenPoint operation:operation];
[_dragSource
endDragAt:screenPoint
operation:ui::DragDropTypes::NSDragOperationToDragOperation(operation)];
// Might as well throw out this object now.
_dragSource.reset();
......
......@@ -48,10 +48,7 @@ using remote_cocoa::mojom::SelectionDirection;
STATIC_ASSERT_ENUM(NSDragOperationNone, blink::kDragOperationNone);
STATIC_ASSERT_ENUM(NSDragOperationCopy, blink::kDragOperationCopy);
STATIC_ASSERT_ENUM(NSDragOperationLink, blink::kDragOperationLink);
STATIC_ASSERT_ENUM(NSDragOperationGeneric, blink::kDragOperationGeneric);
STATIC_ASSERT_ENUM(NSDragOperationPrivate, blink::kDragOperationPrivate);
STATIC_ASSERT_ENUM(NSDragOperationMove, blink::kDragOperationMove);
STATIC_ASSERT_ENUM(NSDragOperationDelete, blink::kDragOperationDelete);
STATIC_ASSERT_ENUM(NSDragOperationEvery, blink::kDragOperationEvery);
namespace content {
......@@ -153,8 +150,7 @@ void WebContentsViewMac::StartDragging(
// The drag invokes a nested event loop, arrange to continue
// processing events.
base::CurrentThread::ScopedNestableTaskAllower allow;
NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations) &
~NSDragOperationGeneric;
NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations);
[drag_dest_ setDragStartTrackersForProcess:source_rwh->GetProcess()->GetID()];
drag_source_start_rwh_ = source_rwh->GetWeakPtr();
......
......@@ -8,10 +8,8 @@
namespace {
constexpr int allow_all =
blink::kDragOperationCopy | blink::kDragOperationLink |
blink::kDragOperationGeneric | blink::kDragOperationPrivate |
blink::kDragOperationMove | blink::kDragOperationDelete;
constexpr int allow_all = blink::kDragOperationCopy |
blink::kDragOperationLink | blink::kDragOperationMove;
} // namespace
......@@ -28,14 +26,8 @@ EnumTraits<blink::mojom::DragOperation, blink::DragOperation>::ToMojom(
return blink::mojom::DragOperation::kCopy;
case blink::kDragOperationLink:
return blink::mojom::DragOperation::kLink;
case blink::kDragOperationGeneric:
return blink::mojom::DragOperation::kGeneric;
case blink::kDragOperationPrivate:
return blink::mojom::DragOperation::kPrivate;
case blink::kDragOperationMove:
return blink::mojom::DragOperation::kMove;
case blink::kDragOperationDelete:
return blink::mojom::DragOperation::kDelete;
default:
// blink::kDragOperationEvery is not handled on purpose, as
// DragOperation should only represent a single operation.
......@@ -58,18 +50,9 @@ bool EnumTraits<blink::mojom::DragOperation, blink::DragOperation>::FromMojom(
case blink::mojom::DragOperation::kLink:
*out = blink::kDragOperationLink;
return true;
case blink::mojom::DragOperation::kGeneric:
*out = blink::kDragOperationGeneric;
return true;
case blink::mojom::DragOperation::kPrivate:
*out = blink::kDragOperationPrivate;
return true;
case blink::mojom::DragOperation::kMove:
*out = blink::kDragOperationMove;
return true;
case blink::mojom::DragOperation::kDelete:
*out = blink::kDragOperationDelete;
return true;
}
NOTREACHED();
return false;
......@@ -85,14 +68,8 @@ bool StructTraits<blink::mojom::AllowedDragOperationsDataView,
op_mask |= blink::kDragOperationCopy;
if (data.allow_link())
op_mask |= blink::kDragOperationLink;
if (data.allow_generic())
op_mask |= blink::kDragOperationGeneric;
if (data.allow_private())
op_mask |= blink::kDragOperationPrivate;
if (data.allow_move())
op_mask |= blink::kDragOperationMove;
if (data.allow_delete())
op_mask |= blink::kDragOperationDelete;
if (op_mask == allow_all)
op_mask = blink::kDragOperationEvery;
*out = static_cast<blink::DragOperationsMask>(op_mask);
......
......@@ -31,18 +31,9 @@ struct BLINK_COMMON_EXPORT
static bool allow_link(const blink::DragOperationsMask& op_mask) {
return op_mask & blink::kDragOperationLink;
}
static bool allow_generic(const blink::DragOperationsMask& op_mask) {
return op_mask & blink::kDragOperationGeneric;
}
static bool allow_private(const blink::DragOperationsMask& op_mask) {
return op_mask & blink::kDragOperationPrivate;
}
static bool allow_move(const blink::DragOperationsMask& op_mask) {
return op_mask & blink::kDragOperationMove;
}
static bool allow_delete(const blink::DragOperationsMask& op_mask) {
return op_mask & blink::kDragOperationDelete;
}
static bool Read(blink::mojom::AllowedDragOperationsDataView data,
blink::DragOperationsMask* out);
};
......
......@@ -37,18 +37,15 @@ namespace blink {
// "Verb" of a drag-and-drop operation as negotiated between the source and
// destination.
// (These constants match their equivalents in WebCore's DragActions.h and
// should not be renumbered.)
// TODO(hferreiro): replace this enum and the corresponding one in
// drag_actions.h with blink::mojom::DragOperation.
// These constants match their equivalents in NSDragOperation and
// should not be renumbered.
// TODO(https://crbug.com/1093536): replace this enum with
// blink::mojom::DragOperation.
enum DragOperation {
kDragOperationNone = 0,
kDragOperationCopy = 1,
kDragOperationLink = 2,
kDragOperationGeneric = 4,
kDragOperationPrivate = 8,
kDragOperationMove = 16,
kDragOperationDelete = 32,
kDragOperationEvery = UINT_MAX
};
......
......@@ -19,10 +19,7 @@ enum DragOperation {
kNone,
kCopy,
kLink,
kGeneric,
kPrivate,
kMove,
kDelete,
};
// This struct encodes what drag-and-drop operations are allowed. It's
......@@ -32,10 +29,7 @@ enum DragOperation {
struct AllowedDragOperations {
bool allow_copy;
bool allow_link;
bool allow_generic;
bool allow_private;
bool allow_move;
bool allow_delete;
};
// Used when dragging images, links, plain text, HTML content or other
......
......@@ -573,7 +573,6 @@ DragOperation DataTransfer::DestinationOperation() const {
}
void DataTransfer::SetSourceOperation(DragOperation op) {
DCHECK_NE(op, kDragOperationPrivate);
effect_allowed_ = ConvertDragOperationToEffectAllowed(op);
}
......
......@@ -14,11 +14,15 @@ namespace ui {
class COMPONENT_EXPORT(UI_BASE) DragDropTypes {
public:
// These constants match their equivalents in NSDragOperation and
// should not be renumbered.
// TODO(https://crbug.com/1093536): replace this enum with
// blink::mojom::DragOperation.
enum DragOperation {
DRAG_NONE = 0,
DRAG_MOVE = 1 << 0,
DRAG_COPY = 1 << 1,
DRAG_LINK = 1 << 2
DRAG_COPY = 1,
DRAG_LINK = 2,
DRAG_MOVE = 16,
};
#if defined(OS_WIN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment