Bug 1913600 - Adjust drag'n'drop handling of compose window after bug 1851536. r=mkmelin
Since https://phabricator.services.mozilla.com/D193762 has landed, multiple selected contacts with display names that are dragged into the compose window are treated as attachments. This patch excludes dragged items containing the "text/x-moz-address" flavor from being checked for valid attachments and handles them directly. Differential Revision: https://phabricator.services.mozilla.com/D222539 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8463264f73
Коммит
e69b857558
|
@ -84,6 +84,7 @@ async function doDragToComposeWindow(sourceIndices, expectedPills) {
|
|||
);
|
||||
|
||||
cardsList.selectedIndices = sourceIndices;
|
||||
const transitionPromise = BrowserTestUtils.waitForTransition(composeDocument);
|
||||
const [result, dataTransfer] = EventUtils.synthesizeDragOver(
|
||||
cardsList.getRowAtIndex(sourceIndices[0]),
|
||||
toAddrInput,
|
||||
|
@ -92,6 +93,13 @@ async function doDragToComposeWindow(sourceIndices, expectedPills) {
|
|||
abWindow,
|
||||
composeWindow
|
||||
);
|
||||
await transitionPromise;
|
||||
// Test that dragged contacts are not incorrectly recognized as attachments.
|
||||
Assert.ok(
|
||||
!composeDocument
|
||||
.getElementById("dropAttachmentOverlay")
|
||||
.classList.contains("show")
|
||||
);
|
||||
EventUtils.synthesizeDropAfterDragOver(
|
||||
result,
|
||||
dataTransfer,
|
||||
|
|
|
@ -9895,12 +9895,10 @@ var envelopeDragObserver = {
|
|||
* attachments to handle the various drag&drop actions.
|
||||
*
|
||||
* @param {Event} event - The drag-and-drop event being performed.
|
||||
* @param {boolean} isDropping - If the action was performed from the onDrop
|
||||
* method and it needs to handle pills creation.
|
||||
*
|
||||
* @returns {nsIMsgAttachment[]} - The array of valid attachments.
|
||||
*/
|
||||
getValidAttachments(event, isDropping) {
|
||||
getValidAttachments(event) {
|
||||
const attachments = [];
|
||||
const dt = event.dataTransfer;
|
||||
const dataList = [];
|
||||
|
@ -10005,18 +10003,6 @@ var envelopeDragObserver = {
|
|||
);
|
||||
break;
|
||||
}
|
||||
// Process address: Drop it into recipient field.
|
||||
case "text/x-moz-address": {
|
||||
// Process the drop only if the message body wasn't the target and we
|
||||
// called this method from the onDrop() method.
|
||||
if (event.target.baseURI != "about:blank?compose" && isDropping) {
|
||||
DropRecipient(event.target, data);
|
||||
// Prevent the default behaviour which drops the address text into
|
||||
// the widget.
|
||||
event.preventDefault();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the attachment and add it to attachments array.
|
||||
|
@ -10130,7 +10116,7 @@ var envelopeDragObserver = {
|
|||
// outcome of this drop action, but users can still copy and paste the image
|
||||
// in the editor to cirumvent this potential issue.
|
||||
const editor = GetCurrentEditor();
|
||||
const attachments = this.getValidAttachments(event, true);
|
||||
const attachments = this.getValidAttachments(event);
|
||||
|
||||
for (const attachment of attachments) {
|
||||
if (!attachment?.url) {
|
||||
|
@ -10189,7 +10175,23 @@ var envelopeDragObserver = {
|
|||
return;
|
||||
}
|
||||
|
||||
const attachments = this.getValidAttachments(event, true);
|
||||
// Handle address book entries directly, as they may also contain flavors
|
||||
// that qualify as attachments.
|
||||
if (event.dataTransfer.mozTypesAt(0).contains("text/x-moz-address")) {
|
||||
if (event.target.baseURI != "about:blank?compose") {
|
||||
// Process address: Drop it into recipient field.
|
||||
DropRecipient(
|
||||
event.target,
|
||||
event.dataTransfer.mozGetDataAt("text/x-moz-address", 0)
|
||||
);
|
||||
// Prevent the default behaviour which drops the address text into
|
||||
// the widget.
|
||||
event.preventDefault();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const attachments = this.getValidAttachments(event);
|
||||
|
||||
// Interrupt if we don't have anything to attach.
|
||||
if (!attachments.length) {
|
||||
|
@ -10267,8 +10269,11 @@ var envelopeDragObserver = {
|
|||
this.detectHoveredOverlay(event.target.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DROP_FLAVORS.some(f => event.dataTransfer.types.includes(f))) {
|
||||
// Excluding dragged address book entries, check for valid attachments.
|
||||
if (
|
||||
!event.dataTransfer.mozTypesAt(0).contains("text/x-moz-address") &&
|
||||
DROP_FLAVORS.some(f => event.dataTransfer.types.includes(f))
|
||||
) {
|
||||
// Show the drop overlay only if we dragged files or supported types.
|
||||
const attachments = this.getValidAttachments(event);
|
||||
if (attachments.length) {
|
||||
|
@ -10315,8 +10320,6 @@ var envelopeDragObserver = {
|
|||
this.isNotDraggingOnlyImages(event.dataTransfer) ||
|
||||
!gMsgCompose.composeHTML)
|
||||
);
|
||||
} else {
|
||||
DragAddressOverTargetControl(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,34 +91,3 @@ const abResultsPaneObserver = {
|
|||
event.stopPropagation();
|
||||
},
|
||||
};
|
||||
|
||||
function DragAddressOverTargetControl() {
|
||||
var dragSession = Cc["@mozilla.org/widget/dragservice;1"]
|
||||
.getService(Ci.nsIDragService)
|
||||
.getCurrentSession();
|
||||
|
||||
if (!dragSession.isDataFlavorSupported("text/x-moz-address")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(
|
||||
Ci.nsITransferable
|
||||
);
|
||||
trans.init(getLoadContext());
|
||||
trans.addDataFlavor("text/x-moz-address");
|
||||
|
||||
var canDrop = true;
|
||||
|
||||
for (var i = 0; i < dragSession.numDropItems; ++i) {
|
||||
dragSession.getData(trans, i);
|
||||
var dataObj = {};
|
||||
var bestFlavor = {};
|
||||
try {
|
||||
trans.getAnyTransferData(bestFlavor, dataObj);
|
||||
} catch (ex) {
|
||||
canDrop = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dragSession.canDrop = canDrop;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче