OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 244 |
245 /** | 245 /** |
246 * @override | 246 * @override |
247 * @return {!Array<!UI.ToolbarItem>} | 247 * @return {!Array<!UI.ToolbarItem>} |
248 */ | 248 */ |
249 syncToolbarItems() { | 249 syncToolbarItems() { |
250 var result = [this._perspectiveSelect, this._classNameFilter]; | 250 var result = [this._perspectiveSelect, this._classNameFilter]; |
251 if (this._profile.profileType() !== Profiler.ProfileTypeRegistry.instance.tr ackingHeapSnapshotProfileType) | 251 if (this._profile.profileType() !== Profiler.ProfileTypeRegistry.instance.tr ackingHeapSnapshotProfileType) |
252 result.push(this._baseSelect, this._filterSelect); | 252 result.push(this._baseSelect, this._filterSelect); |
253 result.push(this._selectedSizeText); | 253 result.push(this._selectedSizeText); |
254 this._updateControls(); | |
alph
2017/07/11 18:44:23
Oh, got it. Thanks!
So the title updates for olde
diana.suvorova
2017/07/11 19:19:53
I see. This makes sense. I went with option #2.
| |
254 return result; | 255 return result; |
255 } | 256 } |
256 | 257 |
257 /** | 258 /** |
258 * @override | 259 * @override |
259 */ | 260 */ |
260 willHide() { | 261 willHide() { |
261 this._currentSearchResultIndex = -1; | 262 this._currentSearchResultIndex = -1; |
262 this._popoverHelper.hidePopover(); | 263 this._popoverHelper.hidePopover(); |
263 } | 264 } |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 const multipleSnapshots = this._profiles().length > 1; | 601 const multipleSnapshots = this._profiles().length > 1; |
601 this._perspectiveSelect.removeOptions(); | 602 this._perspectiveSelect.removeOptions(); |
602 this._perspectives.forEach((perspective, index) => { | 603 this._perspectives.forEach((perspective, index) => { |
603 if (multipleSnapshots || perspective !== this._comparisonPerspective) | 604 if (multipleSnapshots || perspective !== this._comparisonPerspective) |
604 this._perspectiveSelect.createOption(perspective.title(), '', String(ind ex)); | 605 this._perspectiveSelect.createOption(perspective.title(), '', String(ind ex)); |
605 }); | 606 }); |
606 } | 607 } |
607 | 608 |
608 _updateBaseOptions() { | 609 _updateBaseOptions() { |
609 var list = this._profiles(); | 610 var list = this._profiles(); |
610 // We're assuming that snapshots can only be added. | 611 var selectedIndex = this._baseSelect.selectedIndex(); |
611 if (this._baseSelect.size() === list.length) | |
612 return; | |
613 | 612 |
614 for (var i = this._baseSelect.size(), n = list.length; i < n; ++i) { | 613 this._baseSelect.removeOptions(); |
615 var title = list[i].title; | 614 for (var item of list) |
616 this._baseSelect.createOption(title); | 615 this._baseSelect.createOption(item.title); |
617 } | 616 |
617 if (selectedIndex > -1) | |
618 this._baseSelect.setSelectedIndex(selectedIndex); | |
618 } | 619 } |
619 | 620 |
620 _updateFilterOptions() { | 621 _updateFilterOptions() { |
621 var list = this._profiles(); | 622 var list = this._profiles(); |
622 // We're assuming that snapshots can only be added. | 623 var selectedIndex = this._filterSelect.selectedIndex(); |
623 if (this._filterSelect.size() - 1 === list.length) | |
624 return; | |
625 | 624 |
626 if (!this._filterSelect.size()) | 625 this._filterSelect.removeOptions(); |
627 this._filterSelect.createOption(Common.UIString('All objects')); | 626 this._filterSelect.createOption(Common.UIString('All objects')); |
628 | 627 for (var i = 0; i < list.length; ++i) { |
629 for (var i = this._filterSelect.size() - 1, n = list.length; i < n; ++i) { | 628 var title; |
630 var title = list[i].title; | |
631 if (!i) | 629 if (!i) |
632 title = Common.UIString('Objects allocated before %s', title); | 630 title = Common.UIString('Objects allocated before %s', list[i].title); |
633 else | 631 else |
634 title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, title); | 632 title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, list[i].title); |
635 this._filterSelect.createOption(title); | 633 this._filterSelect.createOption(title); |
636 } | 634 } |
635 | |
636 if (selectedIndex > -1) | |
637 this._filterSelect.setSelectedIndex(selectedIndex); | |
637 } | 638 } |
638 | 639 |
639 _updateControls() { | 640 _updateControls() { |
640 this._updatePerspectiveOptions(); | 641 this._updatePerspectiveOptions(); |
641 this._updateBaseOptions(); | 642 this._updateBaseOptions(); |
642 this._updateFilterOptions(); | 643 this._updateFilterOptions(); |
643 } | 644 } |
644 | 645 |
645 /** | 646 /** |
646 * @param {!Common.Event} event | 647 * @param {!Common.Event} event |
647 */ | 648 */ |
648 _onReceiveSnapshot(event) { | 649 _onReceiveSnapshot(event) { |
649 this._updateControls(); | 650 this._updateControls(); |
651 var profile = event.data; | |
652 profile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged, this._updateControls, this); | |
650 } | 653 } |
651 | 654 |
652 /** | 655 /** |
653 * @param {!Common.Event} event | 656 * @param {!Common.Event} event |
654 */ | 657 */ |
655 _onProfileHeaderRemoved(event) { | 658 _onProfileHeaderRemoved(event) { |
656 var profile = event.data; | 659 var profile = event.data; |
660 profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileTitleChange d, this._updateControls, this); | |
661 | |
657 if (this._profile === profile) { | 662 if (this._profile === profile) { |
658 this.detach(); | 663 this.detach(); |
659 this._profile.profileType().removeEventListener( | 664 this._profile.profileType().removeEventListener( |
660 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnap shot, this); | 665 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnap shot, this); |
661 this._profile.profileType().removeEventListener( | 666 this._profile.profileType().removeEventListener( |
662 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeader Removed, this); | 667 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeader Removed, this); |
663 this.dispose(); | 668 this.dispose(); |
664 } else { | 669 } else { |
665 this._updateControls(); | 670 this._updateControls(); |
666 } | 671 } |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1974 frame.line - 1, frame.column - 1); | 1979 frame.line - 1, frame.column - 1); |
1975 frameDiv.appendChild(urlElement); | 1980 frameDiv.appendChild(urlElement); |
1976 } | 1981 } |
1977 } | 1982 } |
1978 | 1983 |
1979 clear() { | 1984 clear() { |
1980 this.element.removeChildren(); | 1985 this.element.removeChildren(); |
1981 this._linkifier.reset(); | 1986 this._linkifier.reset(); |
1982 } | 1987 } |
1983 }; | 1988 }; |
OLD | NEW |