Commit 902f0291 authored by dbeam@chromium.org's avatar dbeam@chromium.org

Moving where I'm doing dropEffect normalization.

BUG=95719
R=estade@chromium.org
TEST=Drag a tile element over the trash or navdot on Windows and check the
e.dataTransfer.dropEffect in TilePage#onDragEnd_.

Review URL: http://codereview.chromium.org/7951011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102239 0039d316-1c4b-4281-b951-d872f2087c98
parent c41da691
......@@ -719,9 +719,9 @@ cr.define('ntp4', function() {
setDropEffect: function(dataTransfer) {
var tile = ntp4.getCurrentlyDraggingTile();
if (tile && tile.querySelector('.app'))
dataTransfer.dropEffect = 'move';
ntp4.setCurrentDropEffect(dataTransfer, 'move');
else
dataTransfer.dropEffect = 'copy';
ntp4.setCurrentDropEffect(dataTransfer, 'copy');
},
};
......
......@@ -507,9 +507,9 @@ cr.define('ntp4', function() {
setDropEffect: function(dataTransfer) {
var tile = ntp4.getCurrentlyDraggingTile();
if (tile && tile.querySelector('.bookmark'))
dataTransfer.dropEffect = 'move';
ntp4.setCurrentDropEffect(dataTransfer, 'move');
else
dataTransfer.dropEffect = 'copy';
ntp4.setCurrentDropEffect(dataTransfer, 'copy');
},
/** @inheritDoc */
......
......@@ -203,7 +203,7 @@ cr.define('ntp4', function() {
e.preventDefault();
if (!this.dragWrapper_.isCurrentDragTarget)
e.dataTransfer.dropEffect = 'none';
ntp4.setCurrentDropEffect(e.dataTransfer, 'none');
else
this.page_.setDropEffect(e.dataTransfer);
},
......
......@@ -19,6 +19,19 @@ cr.define('ntp4', function() {
ntp4.leaveRearrangeMode();
}
/**
* Changes the current dropEffect of a drag. This modifies the native cursor
* and serves as an indicator of what we should do at the end of the drag as
* well as give indication to the user if a drop would succeed if they let go.
* @param {DataTransfer} dataTransfer A dataTransfer object from a drag event.
* @param {string} effect A drop effect to change to (i.e. copy, move, none).
*/
function setCurrentDropEffect(dataTransfer, effect) {
dataTransfer.dropEffect = effect;
if (currentlyDraggingTile)
currentlyDraggingTile.lastDropEffect = dataTransfer.dropEffect;
}
/**
* Creates a new Tile object. Tiles wrap content on a TilePage, providing
* some styling and drag functionality.
......@@ -161,8 +174,8 @@ cr.define('ntp4', function() {
} else if (tilePage) {
// TODO(dbeam): Until we fix dropEffect to the correct behavior it will
// differ on windows - crbug.com/39399. That's why we use the custom
// tilePage.lastDropEffect_ instead of e.dataTransfer.dropEffect.
if (tilePage.selected && tilePage.lastDropEffect_ != 'copy') {
// this.lastDropEffect instead of e.dataTransfer.dropEffect.
if (tilePage.selected && this.lastDropEffect != 'copy') {
// The drag clone can still be hidden from the last drag move event.
this.dragClone.hidden = false;
// The tile's contents may have moved following the respositioning;
......@@ -183,6 +196,7 @@ cr.define('ntp4', function() {
}
}
delete this.lastDropEffect;
this.landedOnTrash = false;
},
......@@ -931,8 +945,6 @@ cr.define('ntp4', function() {
if (newDragIndex < 0 || newDragIndex >= this.tileElements_.length)
newDragIndex = this.dragItemIndex_;
this.updateDropIndicator_(newDragIndex);
this.lastDropEffect_ = e.dataTransfer.dropEffect;
},
/**
......@@ -1071,6 +1083,7 @@ cr.define('ntp4', function() {
return {
getCurrentlyDraggingTile: getCurrentlyDraggingTile,
setCurrentDropEffect: setCurrentDropEffect,
TilePage: TilePage,
};
});
......@@ -43,8 +43,8 @@ cr.define('ntp4', function() {
doDragOver: function(e) {
ntp4.getCurrentlyDraggingTile().dragClone.classList.add(
'hovering-on-trash');
ntp4.setCurrentDropEffect(e.dataTransfer, 'move');
e.preventDefault();
e.dataTransfer.dropEffect = 'move';
},
/**
......
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