Commit bf5e7305 authored by einbinder's avatar einbinder Committed by Commit bot

DevTools: Sources: Use URL over content for drag and drop on files.

This lets you drag files into the url bar to open them.

BUG=none

Review-Url: https://codereview.chromium.org/2566753003
Cr-Commit-Position: refs/heads/master@{#437950}
parent 80f26da6
......@@ -950,22 +950,9 @@ Sources.NavigatorSourceTreeElement = class extends TreeElement {
this.listItemElement.draggable = true;
this.listItemElement.addEventListener('click', this._onclick.bind(this), false);
this.listItemElement.addEventListener('contextmenu', this._handleContextMenuEvent.bind(this), false);
this.listItemElement.addEventListener('mousedown', this._onmousedown.bind(this), false);
this.listItemElement.addEventListener('dragstart', this._ondragstart.bind(this), false);
}
_onmousedown(event) {
if (event.which === 1) // Warm-up data for drag'n'drop
this._uiSourceCode.requestContent().then(callback.bind(this));
/**
* @param {?string} content
* @this {Sources.NavigatorSourceTreeElement}
*/
function callback(content) {
this._warmedUpContent = content;
}
}
_shouldRenameOnMouseDown() {
if (!this._uiSourceCode.canRename())
return false;
......@@ -992,10 +979,12 @@ Sources.NavigatorSourceTreeElement = class extends TreeElement {
}
}
/**
* @param {!DragEvent} event
*/
_ondragstart(event) {
event.dataTransfer.setData('text/plain', this._warmedUpContent);
event.dataTransfer.setData('text/plain', this._uiSourceCode.url());
event.dataTransfer.effectAllowed = 'copy';
return true;
}
/**
......
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