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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 | 
| 45 this.contentElement = this._rootElement._childrenListNode; | 45 this.contentElement = this._rootElement._childrenListNode; | 
| 46 this.contentElement.addEventListener('keydown', this._treeKeyDown.bind(this) , true); | 46 this.contentElement.addEventListener('keydown', this._treeKeyDown.bind(this) , true); | 
| 47 this.contentElement.addEventListener('focus', setFocused.bind(this, true), f alse); | 47 this.contentElement.addEventListener('focus', setFocused.bind(this, true), f alse); | 
| 48 this.contentElement.addEventListener('blur', setFocused.bind(this, false), f alse); | 48 this.contentElement.addEventListener('blur', setFocused.bind(this, false), f alse); | 
| 49 | 49 | 
| 50 this.setFocusable(!nonFocusable); | 50 this.setFocusable(!nonFocusable); | 
| 51 | 51 | 
| 52 this.element = this.contentElement; | 52 this.element = this.contentElement; | 
| 53 | 53 | 
| 54 // Adjust to allow computing margin-left for the selection element. | |
| 55 // Check the padding-left for the li element for correct value. | |
| 56 this._paddingSize = 0; | |
| 57 | |
| 54 /** | 58 /** | 
| 55 * @param {boolean} isFocused | 59 * @param {boolean} isFocused | 
| 56 * @this {UI.TreeOutline} | 60 * @this {UI.TreeOutline} | 
| 57 */ | 61 */ | 
| 58 function setFocused(isFocused) { | 62 function setFocused(isFocused) { | 
| 59 this._focused = isFocused; | 63 this._focused = isFocused; | 
| 60 if (this.selectedTreeElement) | 64 if (this.selectedTreeElement) | 
| 61 this.selectedTreeElement._setFocused(this._focused); | 65 this.selectedTreeElement._setFocused(this._focused); | 
| 62 } | 66 } | 
| 63 } | 67 } | 
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 while (nextSelectedElement && !nextSelectedElement.selectable) | 205 while (nextSelectedElement && !nextSelectedElement.selectable) | 
| 202 nextSelectedElement = nextSelectedElement.traverseNextTreeElement(!this.ex pandTreeElementsWhenArrowing); | 206 nextSelectedElement = nextSelectedElement.traverseNextTreeElement(!this.ex pandTreeElementsWhenArrowing); | 
| 203 if (nextSelectedElement) { | 207 if (nextSelectedElement) { | 
| 204 nextSelectedElement.reveal(); | 208 nextSelectedElement.reveal(); | 
| 205 nextSelectedElement.select(false, true); | 209 nextSelectedElement.select(false, true); | 
| 206 return true; | 210 return true; | 
| 207 } | 211 } | 
| 208 return false; | 212 return false; | 
| 209 } | 213 } | 
| 210 | 214 | 
| 215 setPaddingSize(paddingSize) { | |
| 
 
dgozman
2017/01/19 23:12:45
JSDoc please.
 
aboxhall
2017/01/20 04:25:00
Done.
 
 | |
| 216 this._paddingSize = paddingSize; | |
| 217 } | |
| 218 | |
| 211 /** | 219 /** | 
| 212 * @param {!Event} event | 220 * @param {!Event} event | 
| 213 */ | 221 */ | 
| 214 _treeKeyDown(event) { | 222 _treeKeyDown(event) { | 
| 215 if (event.target !== this.contentElement) | 223 if (event.target !== this.contentElement) | 
| 216 return; | 224 return; | 
| 217 | 225 | 
| 218 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ct rlKey) | 226 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ct rlKey) | 
| 219 return; | 227 return; | 
| 220 | 228 | 
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 this._childrenListNode.classList.toggle('hidden', x); | 753 this._childrenListNode.classList.toggle('hidden', x); | 
| 746 } | 754 } | 
| 747 | 755 | 
| 748 invalidateChildren() { | 756 invalidateChildren() { | 
| 749 if (this._children) { | 757 if (this._children) { | 
| 750 this.removeChildren(); | 758 this.removeChildren(); | 
| 751 this._children = null; | 759 this._children = null; | 
| 752 } | 760 } | 
| 753 } | 761 } | 
| 754 | 762 | 
| 763 /** | |
| 764 * @return {number} | |
| 765 */ | |
| 766 computeLeftMargin() { | |
| 767 var treeElement = this.parent; | |
| 768 var depth = 0; | |
| 769 while (treeElement !== null) { | |
| 770 depth++; | |
| 771 treeElement = treeElement.parent; | |
| 772 } | |
| 773 | |
| 774 return -(this.treeOutline._paddingSize * (depth - 1) + 4); | |
| 775 } | |
| 776 | |
| 755 _ensureSelection() { | 777 _ensureSelection() { | 
| 756 if (!this.treeOutline || !this.treeOutline._renderSelection) | 778 if (!this.treeOutline || !this.treeOutline._renderSelection) | 
| 757 return; | 779 return; | 
| 758 if (!this._selectionElement) | 780 if (!this._selectionElement) | 
| 759 this._selectionElement = createElementWithClass('div', 'selection fill'); | 781 this._selectionElement = createElementWithClass('div', 'selection fill'); | 
| 782 if (this.treeOutline._paddingSize) | |
| 783 this._selectionElement.style.setProperty('margin-left', this.computeLeftMa rgin() + 'px'); | |
| 760 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement .firstChild); | 784 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement .firstChild); | 
| 761 } | 785 } | 
| 762 | 786 | 
| 763 /** | 787 /** | 
| 764 * @param {!Event} event | 788 * @param {!Event} event | 
| 765 */ | 789 */ | 
| 766 _treeElementToggled(event) { | 790 _treeElementToggled(event) { | 
| 767 var element = event.currentTarget; | 791 var element = event.currentTarget; | 
| 768 if (element.treeElement !== this || element.hasSelection()) | 792 if (element.treeElement !== this || element.hasSelection()) | 
| 769 return; | 793 return; | 
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; | 1201 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; | 
| 1178 console.assert(paddingLeftValue.endsWith('px')); | 1202 console.assert(paddingLeftValue.endsWith('px')); | 
| 1179 var computedLeftPadding = parseFloat(paddingLeftValue); | 1203 var computedLeftPadding = parseFloat(paddingLeftValue); | 
| 1180 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 1204 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 
| 1181 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; | 1205 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; | 
| 1182 } | 1206 } | 
| 1183 }; | 1207 }; | 
| 1184 | 1208 | 
| 1185 /** @const */ | 1209 /** @const */ | 
| 1186 UI.TreeElement._ArrowToggleWidth = 10; | 1210 UI.TreeElement._ArrowToggleWidth = 10; | 
| OLD | NEW |