| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 211 /** | 215 /** |
| 216 * @param {number} paddingSize |
| 217 */ |
| 218 setPaddingSize(paddingSize) { |
| 219 this._paddingSize = paddingSize; |
| 220 } |
| 221 |
| 222 /** |
| 212 * @param {!Event} event | 223 * @param {!Event} event |
| 213 */ | 224 */ |
| 214 _treeKeyDown(event) { | 225 _treeKeyDown(event) { |
| 215 if (event.target !== this.contentElement) | 226 if (event.target !== this.contentElement) |
| 216 return; | 227 return; |
| 217 | 228 |
| 218 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ct
rlKey) | 229 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ct
rlKey) |
| 219 return; | 230 return; |
| 220 | 231 |
| 221 var handled = false; | 232 var handled = false; |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 this._childrenListNode.classList.toggle('hidden', x); | 756 this._childrenListNode.classList.toggle('hidden', x); |
| 746 } | 757 } |
| 747 | 758 |
| 748 invalidateChildren() { | 759 invalidateChildren() { |
| 749 if (this._children) { | 760 if (this._children) { |
| 750 this.removeChildren(); | 761 this.removeChildren(); |
| 751 this._children = null; | 762 this._children = null; |
| 752 } | 763 } |
| 753 } | 764 } |
| 754 | 765 |
| 766 /** |
| 767 * @return {number} |
| 768 */ |
| 769 computeLeftMargin() { |
| 770 var treeElement = this.parent; |
| 771 var depth = 0; |
| 772 while (treeElement !== null) { |
| 773 depth++; |
| 774 treeElement = treeElement.parent; |
| 775 } |
| 776 |
| 777 return -(this.treeOutline._paddingSize * (depth - 1) + 4); |
| 778 } |
| 779 |
| 755 _ensureSelection() { | 780 _ensureSelection() { |
| 756 if (!this.treeOutline || !this.treeOutline._renderSelection) | 781 if (!this.treeOutline || !this.treeOutline._renderSelection) |
| 757 return; | 782 return; |
| 758 if (!this._selectionElement) | 783 if (!this._selectionElement) |
| 759 this._selectionElement = createElementWithClass('div', 'selection fill'); | 784 this._selectionElement = createElementWithClass('div', 'selection fill'); |
| 785 if (this.treeOutline._paddingSize) |
| 786 this._selectionElement.style.setProperty('margin-left', this.computeLeftMa
rgin() + 'px'); |
| 760 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement
.firstChild); | 787 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement
.firstChild); |
| 761 } | 788 } |
| 762 | 789 |
| 763 /** | 790 /** |
| 764 * @param {!Event} event | 791 * @param {!Event} event |
| 765 */ | 792 */ |
| 766 _treeElementToggled(event) { | 793 _treeElementToggled(event) { |
| 767 var element = event.currentTarget; | 794 var element = event.currentTarget; |
| 768 if (element.treeElement !== this || element.hasSelection()) | 795 if (element.treeElement !== this || element.hasSelection()) |
| 769 return; | 796 return; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe
ft; | 1204 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe
ft; |
| 1178 console.assert(paddingLeftValue.endsWith('px')); | 1205 console.assert(paddingLeftValue.endsWith('px')); |
| 1179 var computedLeftPadding = parseFloat(paddingLeftValue); | 1206 var computedLeftPadding = parseFloat(paddingLeftValue); |
| 1180 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 1207 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; |
| 1181 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog
gleWidth && this._expandable; | 1208 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog
gleWidth && this._expandable; |
| 1182 } | 1209 } |
| 1183 }; | 1210 }; |
| 1184 | 1211 |
| 1185 /** @const */ | 1212 /** @const */ |
| 1186 UI.TreeElement._ArrowToggleWidth = 10; | 1213 UI.TreeElement._ArrowToggleWidth = 10; |
| OLD | NEW |