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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js

Issue 2346873005: [DevTools] Do not toggle tree element if there is a selection. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 this.treeOutline = null; 361 this.treeOutline = null;
362 this.parent = null; 362 this.parent = null;
363 this.previousSibling = null; 363 this.previousSibling = null;
364 this.nextSibling = null; 364 this.nextSibling = null;
365 365
366 this._listItemNode = createElement("li"); 366 this._listItemNode = createElement("li");
367 this._listItemNode.treeElement = this; 367 this._listItemNode.treeElement = this;
368 if (title) 368 if (title)
369 this.title = title; 369 this.title = title;
370 this._listItemNode.addEventListener("mousedown", this._handleMouseDown.bind( this), false); 370 this._listItemNode.addEventListener("mousedown", this._handleMouseDown.bind( this), false);
371 this._listItemNode.addEventListener("selectstart", this._treeElementSelectSt art.bind(this), false);
372 this._listItemNode.addEventListener("click", this._treeElementToggled.bind(t his), false); 371 this._listItemNode.addEventListener("click", this._treeElementToggled.bind(t his), false);
373 this._listItemNode.addEventListener("dblclick", this._handleDoubleClick.bind (this), false); 372 this._listItemNode.addEventListener("dblclick", this._handleDoubleClick.bind (this), false);
374 373
375 this._childrenListNode = createElement("ol"); 374 this._childrenListNode = createElement("ol");
376 this._childrenListNode.parentTreeElement = this; 375 this._childrenListNode.parentTreeElement = this;
377 this._childrenListNode.classList.add("children"); 376 this._childrenListNode.classList.add("children");
378 377
379 this._hidden = false; 378 this._hidden = false;
380 this._selectable = true; 379 this._selectable = true;
381 this.expanded = false; 380 this.expanded = false;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 if (!this.treeOutline || !this.treeOutline._renderSelection) 771 if (!this.treeOutline || !this.treeOutline._renderSelection)
773 return; 772 return;
774 if (!this._selectionElement) 773 if (!this._selectionElement)
775 this._selectionElement = createElementWithClass("div", "selection fi ll"); 774 this._selectionElement = createElementWithClass("div", "selection fi ll");
776 this._listItemNode.insertBefore(this._selectionElement, this.listItemEle ment.firstChild); 775 this._listItemNode.insertBefore(this._selectionElement, this.listItemEle ment.firstChild);
777 }, 776 },
778 777
779 /** 778 /**
780 * @param {!Event} event 779 * @param {!Event} event
781 */ 780 */
782 _treeElementSelectStart: function(event)
783 {
784 event.currentTarget._selectionStarted = true;
785 },
786
787 /**
788 * @param {!Event} event
789 */
790 _treeElementToggled: function(event) 781 _treeElementToggled: function(event)
791 { 782 {
792 var element = event.currentTarget; 783 var element = event.currentTarget;
793 if (element._selectionStarted) { 784 if (element.treeElement !== this || element.hasSelection())
pfeldman 2016/09/16 22:54:18 hasSelection returns true upon mouse down?
dgozman 2016/09/16 23:00:47 Correct.
794 delete element._selectionStarted;
795 var selection = element.getComponentSelection();
796 if (selection && !selection.isCollapsed && element.isSelfOrAncestor( selection.anchorNode) && element.isSelfOrAncestor(selection.focusNode))
797 return;
798 }
799
800 if (element.treeElement !== this)
801 return; 785 return;
802 786
803 var toggleOnClick = this.toggleOnClick && !this.selectable; 787 var toggleOnClick = this.toggleOnClick && !this.selectable;
804 var isInTriangle = this.isEventWithinDisclosureTriangle(event); 788 var isInTriangle = this.isEventWithinDisclosureTriangle(event);
805 if (!toggleOnClick && !isInTriangle) 789 if (!toggleOnClick && !isInTriangle)
806 return; 790 return;
807 791
808 if (event.target && event.target.enclosingNodeOrSelfWithNodeName("a")) 792 if (event.target && event.target.enclosingNodeOrSelfWithNodeName("a"))
809 return; 793 return;
810 794
(...skipping 12 matching lines...) Expand all
823 }, 807 },
824 808
825 /** 809 /**
826 * @param {!Event} event 810 * @param {!Event} event
827 */ 811 */
828 _handleMouseDown: function(event) 812 _handleMouseDown: function(event)
829 { 813 {
830 var element = event.currentTarget; 814 var element = event.currentTarget;
831 if (!element) 815 if (!element)
832 return; 816 return;
833 delete element._selectionStarted;
834
835 if (!this.selectable) 817 if (!this.selectable)
836 return; 818 return;
837 if (element.treeElement !== this) 819 if (element.treeElement !== this)
838 return; 820 return;
839 821
840 if (this.isEventWithinDisclosureTriangle(event)) 822 if (this.isEventWithinDisclosureTriangle(event))
841 return; 823 return;
842 824
843 this.selectOnMouseDown(event); 825 this.selectOnMouseDown(event);
844 }, 826 },
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 isEventWithinDisclosureTriangle: function(event) 1151 isEventWithinDisclosureTriangle: function(event)
1170 { 1152 {
1171 // FIXME: We should not use getComputedStyle(). For that we need to get rid of using ::before for disclosure triangle. (http://webk.it/74446) 1153 // FIXME: We should not use getComputedStyle(). For that we need to get rid of using ::before for disclosure triangle. (http://webk.it/74446)
1172 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi ngLeft; 1154 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi ngLeft;
1173 console.assert(paddingLeftValue.endsWith("px")); 1155 console.assert(paddingLeftValue.endsWith("px"));
1174 var computedLeftPadding = parseFloat(paddingLeftValue); 1156 var computedLeftPadding = parseFloat(paddingLeftValue);
1175 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; 1157 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
1176 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo ggleWidth && this._expandable; 1158 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo ggleWidth && this._expandable;
1177 } 1159 }
1178 } 1160 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698