Commit 569bccc1 authored by dgozman's avatar dgozman Committed by Commit bot

[DevTools] Do not toggle tree element if there is a selection.

This prevents the toggling when user just wanted to select text.
Note that simple click usually clears the selection and element will be toggled.

BUG=none

Review-Url: https://codereview.chromium.org/2346873005
Cr-Commit-Position: refs/heads/master@{#419353}
parent 9e0f12bd
......@@ -368,7 +368,6 @@ function TreeElement(title, expandable)
if (title)
this.title = title;
this._listItemNode.addEventListener("mousedown", this._handleMouseDown.bind(this), false);
this._listItemNode.addEventListener("selectstart", this._treeElementSelectStart.bind(this), false);
this._listItemNode.addEventListener("click", this._treeElementToggled.bind(this), false);
this._listItemNode.addEventListener("dblclick", this._handleDoubleClick.bind(this), false);
......@@ -776,28 +775,13 @@ TreeElement.prototype = {
this._listItemNode.insertBefore(this._selectionElement, this.listItemElement.firstChild);
},
/**
* @param {!Event} event
*/
_treeElementSelectStart: function(event)
{
event.currentTarget._selectionStarted = true;
},
/**
* @param {!Event} event
*/
_treeElementToggled: function(event)
{
var element = event.currentTarget;
if (element._selectionStarted) {
delete element._selectionStarted;
var selection = element.getComponentSelection();
if (selection && !selection.isCollapsed && element.isSelfOrAncestor(selection.anchorNode) && element.isSelfOrAncestor(selection.focusNode))
return;
}
if (element.treeElement !== this)
if (element.treeElement !== this || element.hasSelection())
return;
var toggleOnClick = this.toggleOnClick && !this.selectable;
......@@ -830,8 +814,6 @@ TreeElement.prototype = {
var element = event.currentTarget;
if (!element)
return;
delete element._selectionStarted;
if (!this.selectable)
return;
if (element.treeElement !== this)
......
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