Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 this._titleContainer = this._titlesElement.createChild('span', 'title-contai ner'); | 605 this._titleContainer = this._titlesElement.createChild('span', 'title-contai ner'); |
| 606 this._titleElement = this._titleContainer.createChild('span', 'title'); | 606 this._titleElement = this._titleContainer.createChild('span', 'title'); |
| 607 this._subtitleElement = this._titlesElement.createChild('span', 'subtitle'); | 607 this._subtitleElement = this._titlesElement.createChild('span', 'subtitle'); |
| 608 | 608 |
| 609 this._titleElement.textContent = profile.title; | 609 this._titleElement.textContent = profile.title; |
| 610 this._className = className; | 610 this._className = className; |
| 611 this._small = false; | 611 this._small = false; |
| 612 this._dataDisplayDelegate = dataDisplayDelegate; | 612 this._dataDisplayDelegate = dataDisplayDelegate; |
| 613 this.profile = profile; | 613 this.profile = profile; |
| 614 profile.addEventListener(Profiler.ProfileHeader.Events.UpdateStatus, this._u pdateStatus, this); | 614 profile.addEventListener(Profiler.ProfileHeader.Events.UpdateStatus, this._u pdateStatus, this); |
| 615 profile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged, this._updateTitle, this); | |
| 615 if (profile.canSaveToFile()) | 616 if (profile.canSaveToFile()) |
| 616 this._createSaveLink(); | 617 this._createSaveLink(); |
| 617 else | 618 else |
| 618 profile.addEventListener(Profiler.ProfileHeader.Events.ProfileReceived, th is._onProfileReceived, this); | 619 profile.addEventListener(Profiler.ProfileHeader.Events.ProfileReceived, th is._onProfileReceived, this); |
| 619 } | 620 } |
| 620 | 621 |
| 621 _createSaveLink() { | 622 _createSaveLink() { |
| 622 this._saveLinkElement = this._titleContainer.createChild('span', 'save-link' ); | 623 this._saveLinkElement = this._titleContainer.createChild('span', 'save-link' ); |
| 623 this._saveLinkElement.textContent = Common.UIString('Save'); | 624 this._saveLinkElement.textContent = Common.UIString('Save'); |
| 624 this._saveLinkElement.addEventListener('click', this._saveProfile.bind(this) , false); | 625 this._saveLinkElement.addEventListener('click', this._saveProfile.bind(this) , false); |
| 625 } | 626 } |
| 626 | 627 |
| 627 _onProfileReceived(event) { | 628 _onProfileReceived(event) { |
| 628 this._createSaveLink(); | 629 this._createSaveLink(); |
| 629 } | 630 } |
| 630 | 631 |
| 631 /** | 632 /** |
| 632 * @param {!Common.Event} event | 633 * @param {!Common.Event} event |
| 633 */ | 634 */ |
| 634 _updateStatus(event) { | 635 _updateStatus(event) { |
| 635 var statusUpdate = event.data; | 636 var statusUpdate = event.data; |
| 636 if (statusUpdate.subtitle !== null) { | 637 if (statusUpdate.subtitle !== null) { |
| 637 this._subtitleElement.textContent = statusUpdate.subtitle || ''; | 638 this._subtitleElement.textContent = statusUpdate.subtitle || ''; |
| 638 this._titlesElement.classList.toggle('no-subtitle', !statusUpdate.subtitle ); | 639 this._titlesElement.classList.toggle('no-subtitle', !statusUpdate.subtitle ); |
| 639 } | 640 } |
| 640 if (typeof statusUpdate.wait === 'boolean' && this.listItemElement) | 641 if (typeof statusUpdate.wait === 'boolean' && this.listItemElement) |
| 641 this.listItemElement.classList.toggle('wait', statusUpdate.wait); | 642 this.listItemElement.classList.toggle('wait', statusUpdate.wait); |
| 642 } | 643 } |
| 643 | 644 |
| 645 /** | |
| 646 * @override | |
|
alph
2017/07/10 21:16:30
@param {!Event} event
diana.suvorova
2017/07/11 16:54:26
thanks!
| |
| 647 * @return {boolean} | |
| 648 */ | |
| 649 ondblclick(event) { | |
| 650 if (this._editing) | |
| 651 return false; | |
| 652 this._startEditing(/** @type {!Element} */ (event.target)); | |
| 653 return false; | |
| 654 } | |
| 655 | |
| 656 /** | |
| 657 * @param {!Element} eventTarget | |
| 658 */ | |
| 659 _startEditing(eventTarget) { | |
| 660 var container = eventTarget.enclosingNodeOrSelfWithClass('title-container'); | |
|
alph
2017/07/10 21:16:30
Can you please attach the editor to the title elem
diana.suvorova
2017/07/11 16:54:26
Yes, thanks for suggesting this. It is much cleane
| |
| 661 if (!container) | |
| 662 return; | |
| 663 container.textContent = this.profile.title; | |
| 664 var config = new UI.InplaceEditor.Config(this._editingCommitted.bind(this), this._editingCancelled.bind(this)); | |
| 665 this._editing = UI.InplaceEditor.startEditing(container, config); | |
| 666 } | |
| 667 | |
| 668 /** | |
| 669 * @param {!Element} container | |
| 670 * @param {string} newTitle | |
| 671 * @param {string} oldTitle | |
| 672 */ | |
| 673 _editingCommitted(container, newTitle, oldTitle) { | |
|
alph
2017/07/10 21:16:31
you can drop oldTitle args as it's not used.
diana.suvorova
2017/07/11 16:54:26
gone
| |
| 674 delete this._editing; | |
| 675 | |
| 676 this.profile.setTitle(newTitle); | |
| 677 } | |
| 678 | |
| 679 _editingCancelled() { | |
| 680 delete this._editing; | |
| 681 this._updateTitle(); | |
| 682 } | |
| 683 | |
| 684 _updateTitle() { | |
| 685 if (this._titleContainer.getElementsByClassName('save-link').length === 0) | |
| 686 this._createSaveLink(); | |
| 687 this._titleElement.textContent = this.profile.title; | |
| 688 } | |
| 689 | |
| 644 dispose() { | 690 dispose() { |
| 645 this.profile.removeEventListener(Profiler.ProfileHeader.Events.UpdateStatus, this._updateStatus, this); | 691 this.profile.removeEventListener(Profiler.ProfileHeader.Events.UpdateStatus, this._updateStatus, this); |
| 646 this.profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileReceiv ed, this._onProfileReceived, this); | 692 this.profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileReceiv ed, this._onProfileReceived, this); |
| 693 this.profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileTitleC hanged, this._updateTitle, this); | |
| 647 } | 694 } |
| 648 | 695 |
| 649 /** | 696 /** |
| 650 * @override | 697 * @override |
| 651 * @return {boolean} | 698 * @return {boolean} |
| 652 */ | 699 */ |
| 653 onselect() { | 700 onselect() { |
| 654 this._dataDisplayDelegate.showProfile(this.profile); | 701 this._dataDisplayDelegate.showProfile(this.profile); |
| 655 return true; | 702 return true; |
| 656 } | 703 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 * @param {string} actionId | 862 * @param {string} actionId |
| 816 * @return {boolean} | 863 * @return {boolean} |
| 817 */ | 864 */ |
| 818 handleAction(context, actionId) { | 865 handleAction(context, actionId) { |
| 819 var panel = UI.context.flavor(Profiler.JSProfilerPanel); | 866 var panel = UI.context.flavor(Profiler.JSProfilerPanel); |
| 820 console.assert(panel && panel instanceof Profiler.JSProfilerPanel); | 867 console.assert(panel && panel instanceof Profiler.JSProfilerPanel); |
| 821 panel.toggleRecord(); | 868 panel.toggleRecord(); |
| 822 return true; | 869 return true; |
| 823 } | 870 } |
| 824 }; | 871 }; |
| OLD | NEW |