summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-21 22:11:55 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-21 22:11:55 +0000
commit74d5df984cbf526927bdd0fb58074538ac955424 (patch)
tree91ce4f63c89477991f03b814ac4841d9487b2305
parentd45c189b98e9f6fea5547e20c6e5668404de3dab (diff)
downloadchromium_src-74d5df984cbf526927bdd0fb58074538ac955424.zip
chromium_src-74d5df984cbf526927bdd0fb58074538ac955424.tar.gz
chromium_src-74d5df984cbf526927bdd0fb58074538ac955424.tar.bz2
Bookmark Manager: Fix issue where we the user could drop text on the bmm.
The problem was that we were not clearing the |dragData| so if it ever got set by doing drag and drop, further drag and drop of non bookarks used the old drag data so the UI code thought you were able to drop the old dragged bookmarks. BUG=42241 TEST=Do some drag and dropping in the bmm. Then start to rename a folder in the tree. Now drag the selected text in the text input. You should not be able to drop this text in the tree nor on the list but you should be able to drop the text on the search text input. Review URL: http://codereview.chromium.org/1733007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45250 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/bookmark_manager/main.html37
1 files changed, 15 insertions, 22 deletions
diff --git a/chrome/browser/resources/bookmark_manager/main.html b/chrome/browser/resources/bookmark_manager/main.html
index ad947b0..5adfcc0 100644
--- a/chrome/browser/resources/bookmark_manager/main.html
+++ b/chrome/browser/resources/bookmark_manager/main.html
@@ -626,8 +626,6 @@ var dnd = {
* @param {Event} e The dragstart event.
*/
handleDragStart: function(e) {
- // console.log(e.type);
-
// Determine the selected bookmarks.
var target = e.target;
var draggedItems = [];
@@ -662,8 +660,6 @@ var dnd = {
},
handleDragEnter: function(e) {
- // console.log(e.type);
-
e.preventDefault();
},
@@ -672,14 +668,17 @@ var dnd = {
* @param {Event} e The dragover event.
*/
handleDragOver: function(e) {
- // console.log(e.type);
+ // TODO(arv): This function is way too long. Please refactor it.
- // The default operation is to allow dropping links etc to do navigation.
- // We never want to do that for the bookmark manager.
- e.preventDefault();
+ // Allow DND on text inputs.
+ if (e.target.tagName != 'INPUT') {
+ // The default operation is to allow dropping links etc to do navigation.
+ // We never want to do that for the bookmark manager.
+ e.preventDefault();
- // Set to none. This will get set to something if we can do the drop.
- e.dataTransfer.dropEffect = 'none';
+ // Set to none. This will get set to something if we can do the drop.
+ e.dataTransfer.dropEffect = 'none';
+ }
if (!this.dragData)
return;
@@ -846,14 +845,10 @@ var dnd = {
},
handleDragLeave: function(e) {
- // console.log(e.type);
-
this.hideDropOverlay_();
},
handleDrop: function(e) {
- // console.log(e.type);
-
if (this.dropDestination && this.dragData) {
var dropPos = this.dropDestination.dropPos;
var relatedNode = this.dropDestination.relatedNode;
@@ -876,12 +871,7 @@ var dnd = {
this.hideDropOverlay_();
},
- handleDrag: function(e) {
- // console.log(e.type);
- },
-
- handleDragEnd: function(e) {
- // console.log(e.type);
+ clearDragData: function() {
this.dragData = null;
},
@@ -890,16 +880,19 @@ var dnd = {
},
init: function() {
+ var boundClearData = cr.bind(this.clearDragData, this);
+
document.addEventListener('dragstart', cr.bind(this.handleDragStart, this));
document.addEventListener('dragenter', cr.bind(this.handleDragEnter, this));
document.addEventListener('dragover', cr.bind(this.handleDragOver, this));
document.addEventListener('dragleave', cr.bind(this.handleDragLeave, this));
document.addEventListener('drop', cr.bind(this.handleDrop, this));
- document.addEventListener('dragend', cr.bind(this.handleDragEnd, this));
- document.addEventListener('drag', cr.bind(this.handleDrag, this));
+ document.addEventListener('dragend', boundClearData);
chrome.experimental.bookmarkManager.onDragEnter.addListener(cr.bind(
this.handleChromeDragEnter, this));
+ chrome.experimental.bookmarkManager.onDragLeave.addListener(boundClearData);
+ chrome.experimental.bookmarkManager.onDrop.addListener(boundClearData);
}
};