Modified: trunk/Source/WebCore/ChangeLog (90560 => 90561)
--- trunk/Source/WebCore/ChangeLog 2011-07-07 14:18:01 UTC (rev 90560)
+++ trunk/Source/WebCore/ChangeLog 2011-07-07 16:20:12 UTC (rev 90561)
@@ -1,3 +1,18 @@
+2011-07-07 Pavel Feldman <pfeld...@chromium.org>
+
+ Web Inspector: prevent default action during drag'n'drop in the Elements panel.
+ https://bugs.webkit.org/show_bug.cgi?id=64081
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/front-end/ElementsTreeOutline.js:
+ (WebInspector.ElementsTreeOutline):
+ (WebInspector.ElementsTreeOutline.prototype._ondragstart):
+ (WebInspector.ElementsTreeOutline.prototype._ondragover):
+ (WebInspector.ElementsTreeOutline.prototype._ondragend):
+ * inspector/front-end/treeoutline.js:
+ (TreeOutline.prototype.treeElementFromPoint):
+
2011-07-07 Nikolas Zimmermann <nzimmerm...@rim.com>
Move remaining enums out of SVG*Element classes
Modified: trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js (90560 => 90561)
--- trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js 2011-07-07 14:18:01 UTC (rev 90560)
+++ trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js 2011-07-07 16:20:12 UTC (rev 90561)
@@ -36,6 +36,7 @@
this.element.addEventListener("dragstart", this._ondragstart.bind(this), false);
this.element.addEventListener("dragover", this._ondragover.bind(this), false);
this.element.addEventListener("dragleave", this._ondragleave.bind(this), false);
+ this.element.addEventListener("drop", this._ondrop.bind(this), false);
this.element.addEventListener("dragend", this._ondragend.bind(this), false);
TreeOutline.call(this, this.element);
@@ -275,7 +276,7 @@
return false;
event.dataTransfer.setData("text/plain", treeElement.listItemElement.textContent);
- event.dataTransfer.effectAllowed = "copy";
+ event.dataTransfer.effectAllowed = "copyMove";
this._nodeBeingDragged = treeElement.representedObject;
WebInspector.highlightDOMNode(0);
@@ -285,48 +286,33 @@
_ondragover: function(event)
{
- this._clearDragOverTreeElementMarker();
-
if (!this._nodeBeingDragged)
- return;
+ return false;
var treeElement = this._treeElementFromEvent(event);
if (!this._isValidDragSourceOrTarget(treeElement))
- return;
+ return false;
var node = treeElement.representedObject;
while (node) {
if (node === this._nodeBeingDragged)
- return;
+ return false;
node = node.parentNode;
}
treeElement.updateSelection();
treeElement.listItemElement.addStyleClass("elements-drag-over");
this._dragOverTreeElement = treeElement;
+ event.preventDefault();
+ event.dataTransfer.dropEffect = 'move';
+ return false;
},
_ondragleave: function(event)
{
this._clearDragOverTreeElementMarker();
-
- if (!this._nodeBeingDragged)
- return;
-
- var treeElement = this._treeElementFromEvent(event);
- if (!this._isValidDragSourceOrTarget(treeElement))
- return false;
-
- var node = treeElement.representedObject;
- while (node) {
- if (node === this._nodeBeingDragged)
- return;
- node = node.parentNode;
- }
-
- treeElement.updateSelection();
- treeElement.listItemElement.addStyleClass("elements-drag-over");
- this._dragOverTreeElement = treeElement;
+ event.preventDefault();
+ return false;
},
_isValidDragSourceOrTarget: function(treeElement)
@@ -347,17 +333,19 @@
return true;
},
- _ondragend: function(event)
+ _ondrop: function(event)
{
- if (this._nodeBeingDragged && this._dragOverTreeElement) {
+ event.preventDefault();
+ var treeElement = this._treeElementFromEvent(event);
+ if (this._nodeBeingDragged && treeElement) {
var parentNode;
var anchorNode;
- if (this._dragOverTreeElement._elementCloseTag) {
+ if (treeElement._elementCloseTag) {
// Drop onto closing tag -> insert as last child.
- parentNode = this._dragOverTreeElement.representedObject;
+ parentNode = treeElement.representedObject;
} else {
- var dragTargetNode = this._dragOverTreeElement.representedObject;
+ var dragTargetNode = treeElement.representedObject;
parentNode = dragTargetNode.parentNode;
anchorNode = dragTargetNode;
}
@@ -374,7 +362,13 @@
}
this._nodeBeingDragged.moveTo(parentNode, anchorNode, callback.bind(this));
}
-
+
+ delete this._nodeBeingDragged;
+ },
+
+ _ondragend: function(event)
+ {
+ event.preventDefault();
this._clearDragOverTreeElementMarker();
delete this._nodeBeingDragged;
},
Modified: trunk/Source/WebCore/inspector/front-end/treeoutline.js (90560 => 90561)
--- trunk/Source/WebCore/inspector/front-end/treeoutline.js 2011-07-07 14:18:01 UTC (rev 90560)
+++ trunk/Source/WebCore/inspector/front-end/treeoutline.js 2011-07-07 16:20:12 UTC (rev 90561)
@@ -332,6 +332,9 @@
TreeOutline.prototype.treeElementFromPoint = function(x, y)
{
var node = this._childrenListNode.ownerDocument.elementFromPoint(x, y);
+ if (!node)
+ return null;
+
var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"]);
if (listNode)
return listNode.parentTreeElement || listNode.treeElement;