Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 * @param {(string|!Node)=} title | 312 * @param {(string|!Node)=} title | 
| 313 * @param {boolean=} expandable | 313 * @param {boolean=} expandable | 
| 314 */ | 314 */ | 
| 315 constructor(title, expandable) { | 315 constructor(title, expandable) { | 
| 316 /** @type {?UI.TreeOutline} */ | 316 /** @type {?UI.TreeOutline} */ | 
| 317 this.treeOutline = null; | 317 this.treeOutline = null; | 
| 318 this.parent = null; | 318 this.parent = null; | 
| 319 this.previousSibling = null; | 319 this.previousSibling = null; | 
| 320 this.nextSibling = null; | 320 this.nextSibling = null; | 
| 321 | 321 | 
| 322 /** Adjust based on your CSS; check the padding-left for the list element */ | |
| 323 this.paddingSize = 12; | |
| 324 | |
| 322 this._listItemNode = createElement('li'); | 325 this._listItemNode = createElement('li'); | 
| 323 this._titleElement = this._listItemNode.createChild('span', 'tree-element-ti tle'); | 326 this._titleElement = this._listItemNode.createChild('span', 'tree-element-ti tle'); | 
| 324 this._listItemNode.treeElement = this; | 327 this._listItemNode.treeElement = this; | 
| 325 if (title) | 328 if (title) | 
| 326 this.title = title; | 329 this.title = title; | 
| 327 this._listItemNode.addEventListener('mousedown', this._handleMouseDown.bind( this), false); | 330 this._listItemNode.addEventListener('mousedown', this._handleMouseDown.bind( this), false); | 
| 328 this._listItemNode.addEventListener('click', this._treeElementToggled.bind(t his), false); | 331 this._listItemNode.addEventListener('click', this._treeElementToggled.bind(t his), false); | 
| 329 this._listItemNode.addEventListener('dblclick', this._handleDoubleClick.bind (this), false); | 332 this._listItemNode.addEventListener('dblclick', this._handleDoubleClick.bind (this), false); | 
| 330 | 333 | 
| 331 this._childrenListNode = createElement('ol'); | 334 this._childrenListNode = createElement('ol'); | 
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 this._childrenListNode.classList.toggle('hidden', x); | 748 this._childrenListNode.classList.toggle('hidden', x); | 
| 746 } | 749 } | 
| 747 | 750 | 
| 748 invalidateChildren() { | 751 invalidateChildren() { | 
| 749 if (this._children) { | 752 if (this._children) { | 
| 750 this.removeChildren(); | 753 this.removeChildren(); | 
| 751 this._children = null; | 754 this._children = null; | 
| 752 } | 755 } | 
| 753 } | 756 } | 
| 754 | 757 | 
| 758 /** | |
| 759 * @return {number} | |
| 760 */ | |
| 761 _computeLeftIndent() { | |
| 762 var treeElement = this.parent; | |
| 763 var depth = 0; | |
| 764 while (treeElement !== null) { | |
| 765 depth++; | |
| 766 treeElement = treeElement.parent; | |
| 767 } | |
| 768 | |
| 769 return this.paddingSize * (depth - 1) + 4; | |
| 770 } | |
| 771 | |
| 755 _ensureSelection() { | 772 _ensureSelection() { | 
| 756 if (!this.treeOutline || !this.treeOutline._renderSelection) | 773 if (!this.treeOutline || !this.treeOutline._renderSelection) | 
| 757 return; | 774 return; | 
| 758 if (!this._selectionElement) | 775 if (!this._selectionElement) | 
| 759 this._selectionElement = createElementWithClass('div', 'selection fill'); | 776 this._selectionElement = createElementWithClass('div', 'selection fill'); | 
| 777 this._selectionElement.style.setProperty('margin-left', (-this._computeLeftI ndent()) + 'px'); | |
| 
 
dgozman
2017/01/09 23:21:22
Why do you need this? Can we just copy this code t
 
aboxhall
2017/01/11 00:11:48
The issue is that the "selection" element keeps th
 
 | |
| 760 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement .firstChild); | 778 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement .firstChild); | 
| 761 } | 779 } | 
| 762 | 780 | 
| 763 /** | 781 /** | 
| 764 * @param {!Event} event | 782 * @param {!Event} event | 
| 765 */ | 783 */ | 
| 766 _treeElementToggled(event) { | 784 _treeElementToggled(event) { | 
| 767 var element = event.currentTarget; | 785 var element = event.currentTarget; | 
| 768 if (element.treeElement !== this || element.hasSelection()) | 786 if (element.treeElement !== this || element.hasSelection()) | 
| 769 return; | 787 return; | 
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; | 1195 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; | 
| 1178 console.assert(paddingLeftValue.endsWith('px')); | 1196 console.assert(paddingLeftValue.endsWith('px')); | 
| 1179 var computedLeftPadding = parseFloat(paddingLeftValue); | 1197 var computedLeftPadding = parseFloat(paddingLeftValue); | 
| 1180 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 1198 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 
| 1181 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; | 1199 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; | 
| 1182 } | 1200 } | 
| 1183 }; | 1201 }; | 
| 1184 | 1202 | 
| 1185 /** @const */ | 1203 /** @const */ | 
| 1186 UI.TreeElement._ArrowToggleWidth = 10; | 1204 UI.TreeElement._ArrowToggleWidth = 10; | 
| OLD | NEW |