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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 | 604 |
| 605 if (typeof x === 'string') { | 605 if (typeof x === 'string') { |
| 606 this._titleElement.textContent = x; | 606 this._titleElement.textContent = x; |
| 607 this.tooltip = x; | 607 this.tooltip = x; |
| 608 } else { | 608 } else { |
| 609 this._titleElement = x; | 609 this._titleElement = x; |
| 610 this.tooltip = ''; | 610 this.tooltip = ''; |
| 611 } | 611 } |
| 612 | 612 |
| 613 this._listItemNode.removeChildren(); | 613 this._listItemNode.removeChildren(); |
| 614 if (this._iconElement) | |
| 615 this._listItemNode.appendChild(this._iconElement); | |
| 616 if (this._leadingIconsElement) | 614 if (this._leadingIconsElement) |
| 617 this._listItemNode.appendChild(this._leadingIconsElement); | 615 this._listItemNode.appendChild(this._leadingIconsElement); |
| 618 this._listItemNode.appendChild(this._titleElement); | 616 this._listItemNode.appendChild(this._titleElement); |
| 619 if (this._trailingIconsElement) | 617 if (this._trailingIconsElement) |
| 620 this._listItemNode.appendChild(this._trailingIconsElement); | 618 this._listItemNode.appendChild(this._trailingIconsElement); |
| 621 this._ensureSelection(); | 619 this._ensureSelection(); |
| 622 } | 620 } |
| 623 | 621 |
| 624 /** | 622 /** |
| 625 * @return {string} | 623 * @return {string} |
| 626 */ | 624 */ |
| 627 titleAsText() { | 625 titleAsText() { |
| 628 if (!this._title) | 626 if (!this._title) |
| 629 return ''; | 627 return ''; |
| 630 if (typeof this._title === 'string') | 628 if (typeof this._title === 'string') |
| 631 return this._title; | 629 return this._title; |
| 632 return this._title.textContent; | 630 return this._title.textContent; |
| 633 } | 631 } |
| 634 | 632 |
| 635 /** | 633 /** |
| 636 * @param {!UI.InplaceEditor.Config} editingConfig | 634 * @param {!UI.InplaceEditor.Config} editingConfig |
| 637 */ | 635 */ |
| 638 startEditingTitle(editingConfig) { | 636 startEditingTitle(editingConfig) { |
| 639 UI.InplaceEditor.startEditing(this._titleElement, editingConfig); | 637 UI.InplaceEditor.startEditing(this._titleElement, editingConfig); |
| 640 this.treeOutline._shadowRoot.getSelection().setBaseAndExtent(this._titleElem ent, 0, this._titleElement, 1); | 638 this.treeOutline._shadowRoot.getSelection().setBaseAndExtent(this._titleElem ent, 0, this._titleElement, 1); |
| 641 } | 639 } |
| 642 | 640 |
| 643 createIcon() { | |
|
dgozman
2017/01/30 16:47:52
Nice!
| |
| 644 if (!this._iconElement) { | |
| 645 this._iconElement = createElementWithClass('div', 'icon'); | |
| 646 this._listItemNode.insertBefore(this._iconElement, this._listItemNode.firs tChild); | |
| 647 this._ensureSelection(); | |
| 648 } | |
| 649 } | |
| 650 | |
| 651 /** | 641 /** |
| 652 * @param {!Array<!UI.Icon>} icons | 642 * @param {!Array<!UI.Icon>} icons |
| 653 */ | 643 */ |
| 654 setLeadingIcons(icons) { | 644 setLeadingIcons(icons) { |
| 655 if (!this._leadingIconsElement && !icons.length) | 645 if (!this._leadingIconsElement && !icons.length) |
| 656 return; | 646 return; |
| 657 if (!this._leadingIconsElement) { | 647 if (!this._leadingIconsElement) { |
| 658 this._leadingIconsElement = createElementWithClass('div', 'leading-icons') ; | 648 this._leadingIconsElement = createElementWithClass('div', 'leading-icons') ; |
| 659 this._leadingIconsElement.classList.add('icons-container'); | 649 this._leadingIconsElement.classList.add('icons-container'); |
| 660 this._listItemNode.insertBefore(this._leadingIconsElement, this._titleElem ent); | 650 this._listItemNode.insertBefore(this._leadingIconsElement, this._titleElem ent); |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; | 1194 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; |
| 1205 console.assert(paddingLeftValue.endsWith('px')); | 1195 console.assert(paddingLeftValue.endsWith('px')); |
| 1206 var computedLeftPadding = parseFloat(paddingLeftValue); | 1196 var computedLeftPadding = parseFloat(paddingLeftValue); |
| 1207 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 1197 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; |
| 1208 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; | 1198 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; |
| 1209 } | 1199 } |
| 1210 }; | 1200 }; |
| 1211 | 1201 |
| 1212 /** @const */ | 1202 /** @const */ |
| 1213 UI.TreeElement._ArrowToggleWidth = 10; | 1203 UI.TreeElement._ArrowToggleWidth = 10; |
| OLD | NEW |