Commit 697dcd50 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[dragdrop] Update setDropTarget_ comments and code

Use "directory" instead of "folder". Elaborate the Crostini comment re:
it is actually a fake entry. However, the reason why we need to change
immediately to its directory when it is a fake entry is not explained,
and is potentially no longer relevant now Crostini is controlled by an
enable flag looking at CL:2264086

No change in behavior, no new tests.

Bug: 1002394
Change-Id: Ida7177b052f6fcb8db47e6181ffc4c5d708604c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2275280Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784316}
parent e84844e2
...@@ -995,12 +995,13 @@ class FileTransferController { ...@@ -995,12 +995,13 @@ class FileTransferController {
return; return;
} }
// Set classes assuming domElement won't accept this drop. assert(destinationEntry.isDirectory);
// Assume the destination directory won't accept this drop.
domElement.classList.remove('accepts'); domElement.classList.remove('accepts');
domElement.classList.add('denies'); domElement.classList.add('denies');
// Disallow dropping a folder on itself. // Disallow dropping a directory on itself.
assert(destinationEntry.isDirectory);
const entries = this.selectionHandler_.selection.entries; const entries = this.selectionHandler_.selection.entries;
for (let i = 0; i < entries.length; i++) { for (let i = 0; i < entries.length; i++) {
if (util.isSameEntry(entries[i], destinationEntry)) { if (util.isSameEntry(entries[i], destinationEntry)) {
...@@ -1008,21 +1009,23 @@ class FileTransferController { ...@@ -1008,21 +1009,23 @@ class FileTransferController {
} }
} }
// Add accept class if the domElement can accept this drop. this.destinationEntry_ = destinationEntry;
// Add accept classes if the directory can accept this drop.
if (this.canPasteOrDrop_(clipboardData, destinationEntry)) { if (this.canPasteOrDrop_(clipboardData, destinationEntry)) {
domElement.classList.remove('denies'); domElement.classList.remove('denies');
domElement.classList.add('accepts'); domElement.classList.add('accepts');
} }
this.destinationEntry_ = destinationEntry; // Change directory immediately if it's a fake entry for Crostini.
// Change directory immediately for crostini, otherwise start timer.
if (destinationEntry.rootType === VolumeManagerCommon.RootType.CROSTINI) { if (destinationEntry.rootType === VolumeManagerCommon.RootType.CROSTINI) {
this.changeToDropTargetDirectory_(); this.changeToDropTargetDirectory_();
} else { return;
this.navigateTimer_ =
setTimeout(this.changeToDropTargetDirectory_.bind(this), 2000);
} }
// Change to the directory after the drag target hover time out.
const navigate = this.changeToDropTargetDirectory_.bind(this);
this.navigateTimer_ = setTimeout(navigate, 2000);
} }
/** /**
......
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