Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1846)

Unified Diff: chrome/browser/resources/md_bookmarks/dnd_manager.js

Issue 2845243003: [MD Bookmarks] Fix drag and drop on Mac. (Closed)
Patch Set: fix test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/md_bookmarks/dnd_manager_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_bookmarks/dnd_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/dnd_manager.js b/chrome/browser/resources/md_bookmarks/dnd_manager.js
index 9f3d08988d50f7f687374a81d2551a053e623038..8bcc775184a8e8903bde7c095b2ea95df94b0e97 100644
--- a/chrome/browser/resources/md_bookmarks/dnd_manager.js
+++ b/chrome/browser/resources/md_bookmarks/dnd_manager.js
@@ -205,7 +205,7 @@ cr.define('bookmarks', function() {
* Used to instantly remove the indicator style in tests.
* @private {function((Function|null|string), number)}
*/
- this.setTimeout_ = window.setTimeout.bind(window);
+ this.setTimeout = window.setTimeout.bind(window);
}
DropIndicator.prototype = {
@@ -260,16 +260,10 @@ cr.define('bookmarks', function() {
// The use of a timeout is in order to reduce flickering as we move
// between valid drop targets.
window.clearTimeout(this.removeDropIndicatorTimer_);
- this.removeDropIndicatorTimer_ = this.setTimeout_(function() {
+ this.removeDropIndicatorTimer_ = this.setTimeout(function() {
this.removeDropIndicatorStyle();
}.bind(this), 100);
},
-
- disableTimeoutForTesting: function() {
- this.setTimeout_ = function(fn, timeout) {
- fn();
- };
- },
};
/**
@@ -288,6 +282,12 @@ cr.define('bookmarks', function() {
/** @private {Object<string, function(!Event)>} */
this.documentListeners_ = null;
+
+ /**
+ * Used to instantly clearDragData in tests.
+ * @private {function((Function|null|string), number)}
+ */
+ this.setTimeout = window.setTimeout.bind(window);
}
DNDManager.prototype = {
@@ -384,9 +384,14 @@ cr.define('bookmarks', function() {
/** @private */
clearDragData_: function() {
- this.dragInfo_.clearDragData();
- this.dropDestination_ = null;
- this.dropIndicator_.finish();
+ // Defer the clearing of the data so that the bookmark manager API's drop
+ // event doesn't clear the drop data before the web drop event has a
+ // chance to execute (on Mac).
+ this.setTimeout_(function() {
+ this.dragInfo_.clearDragData();
+ this.dropDestination_ = null;
+ this.dropIndicator_.finish();
+ }.bind(this), 0);
},
/**
@@ -614,6 +619,13 @@ cr.define('bookmarks', function() {
return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId)
},
+
+ disableTimeoutsForTesting: function() {
+ this.setTimeout_ = function(fn) {
+ fn();
+ };
+ this.dropIndicator_.setTimeout = this.setTimeout_;
+ }
};
return {
« no previous file with comments | « no previous file | chrome/test/data/webui/md_bookmarks/dnd_manager_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698