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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 this._popoverHelper.setHasPadding(true); | 159 this._popoverHelper.setHasPadding(true); |
160 this.element.addEventListener('scroll', this._popoverHelper.hidePopover.bind
(this._popoverHelper), true); | 160 this.element.addEventListener('scroll', this._popoverHelper.hidePopover.bind
(this._popoverHelper), true); |
161 | 161 |
162 this._currentPerspectiveIndex = 0; | 162 this._currentPerspectiveIndex = 0; |
163 this._currentPerspective = this._perspectives[0]; | 163 this._currentPerspective = this._perspectives[0]; |
164 this._currentPerspective.activate(this); | 164 this._currentPerspective.activate(this); |
165 this._dataGrid = this._currentPerspective.masterGrid(this); | 165 this._dataGrid = this._currentPerspective.masterGrid(this); |
166 | 166 |
167 this._populate(); | 167 this._populate(); |
168 this._searchThrottler = new Common.Throttler(0); | 168 this._searchThrottler = new Common.Throttler(0); |
| 169 |
| 170 for (var existingProfile of this._profiles()) |
| 171 existingProfile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitl
eChanged, this._updateControls, this); |
169 } | 172 } |
170 | 173 |
171 /** | 174 /** |
172 * @return {!UI.SearchableView} | 175 * @return {!UI.SearchableView} |
173 */ | 176 */ |
174 searchableView() { | 177 searchableView() { |
175 return this._searchableView; | 178 return this._searchableView; |
176 } | 179 } |
177 | 180 |
178 /** | 181 /** |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 const multipleSnapshots = this._profiles().length > 1; | 603 const multipleSnapshots = this._profiles().length > 1; |
601 this._perspectiveSelect.removeOptions(); | 604 this._perspectiveSelect.removeOptions(); |
602 this._perspectives.forEach((perspective, index) => { | 605 this._perspectives.forEach((perspective, index) => { |
603 if (multipleSnapshots || perspective !== this._comparisonPerspective) | 606 if (multipleSnapshots || perspective !== this._comparisonPerspective) |
604 this._perspectiveSelect.createOption(perspective.title(), '', String(ind
ex)); | 607 this._perspectiveSelect.createOption(perspective.title(), '', String(ind
ex)); |
605 }); | 608 }); |
606 } | 609 } |
607 | 610 |
608 _updateBaseOptions() { | 611 _updateBaseOptions() { |
609 var list = this._profiles(); | 612 var list = this._profiles(); |
610 // We're assuming that snapshots can only be added. | 613 var selectedIndex = this._baseSelect.selectedIndex(); |
611 if (this._baseSelect.size() === list.length) | |
612 return; | |
613 | 614 |
614 for (var i = this._baseSelect.size(), n = list.length; i < n; ++i) { | 615 this._baseSelect.removeOptions(); |
615 var title = list[i].title; | 616 for (var item of list) |
616 this._baseSelect.createOption(title); | 617 this._baseSelect.createOption(item.title); |
617 } | 618 |
| 619 if (selectedIndex > -1) |
| 620 this._baseSelect.setSelectedIndex(selectedIndex); |
618 } | 621 } |
619 | 622 |
620 _updateFilterOptions() { | 623 _updateFilterOptions() { |
621 var list = this._profiles(); | 624 var list = this._profiles(); |
622 // We're assuming that snapshots can only be added. | 625 var selectedIndex = this._filterSelect.selectedIndex(); |
623 if (this._filterSelect.size() - 1 === list.length) | |
624 return; | |
625 | 626 |
626 if (!this._filterSelect.size()) | 627 this._filterSelect.removeOptions(); |
627 this._filterSelect.createOption(Common.UIString('All objects')); | 628 this._filterSelect.createOption(Common.UIString('All objects')); |
628 | 629 for (var i = 0; i < list.length; ++i) { |
629 for (var i = this._filterSelect.size() - 1, n = list.length; i < n; ++i) { | 630 var title; |
630 var title = list[i].title; | |
631 if (!i) | 631 if (!i) |
632 title = Common.UIString('Objects allocated before %s', title); | 632 title = Common.UIString('Objects allocated before %s', list[i].title); |
633 else | 633 else |
634 title = Common.UIString('Objects allocated between %s and %s', list[i -
1].title, title); | 634 title = Common.UIString('Objects allocated between %s and %s', list[i -
1].title, list[i].title); |
635 this._filterSelect.createOption(title); | 635 this._filterSelect.createOption(title); |
636 } | 636 } |
| 637 |
| 638 if (selectedIndex > -1) |
| 639 this._filterSelect.setSelectedIndex(selectedIndex); |
637 } | 640 } |
638 | 641 |
639 _updateControls() { | 642 _updateControls() { |
640 this._updatePerspectiveOptions(); | 643 this._updatePerspectiveOptions(); |
641 this._updateBaseOptions(); | 644 this._updateBaseOptions(); |
642 this._updateFilterOptions(); | 645 this._updateFilterOptions(); |
643 } | 646 } |
644 | 647 |
645 /** | 648 /** |
646 * @param {!Common.Event} event | 649 * @param {!Common.Event} event |
647 */ | 650 */ |
648 _onReceiveSnapshot(event) { | 651 _onReceiveSnapshot(event) { |
649 this._updateControls(); | 652 this._updateControls(); |
| 653 var profile = event.data; |
| 654 profile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged,
this._updateControls, this); |
650 } | 655 } |
651 | 656 |
652 /** | 657 /** |
653 * @param {!Common.Event} event | 658 * @param {!Common.Event} event |
654 */ | 659 */ |
655 _onProfileHeaderRemoved(event) { | 660 _onProfileHeaderRemoved(event) { |
656 var profile = event.data; | 661 var profile = event.data; |
| 662 profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileTitleChange
d, this._updateControls, this); |
| 663 |
657 if (this._profile === profile) { | 664 if (this._profile === profile) { |
658 this.detach(); | 665 this.detach(); |
659 this._profile.profileType().removeEventListener( | 666 this._profile.profileType().removeEventListener( |
660 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnap
shot, this); | 667 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnap
shot, this); |
661 this._profile.profileType().removeEventListener( | 668 this._profile.profileType().removeEventListener( |
662 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeader
Removed, this); | 669 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeader
Removed, this); |
663 this.dispose(); | 670 this.dispose(); |
664 } else { | 671 } else { |
665 this._updateControls(); | 672 this._updateControls(); |
666 } | 673 } |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 frame.line - 1, frame.column - 1); | 1981 frame.line - 1, frame.column - 1); |
1975 frameDiv.appendChild(urlElement); | 1982 frameDiv.appendChild(urlElement); |
1976 } | 1983 } |
1977 } | 1984 } |
1978 | 1985 |
1979 clear() { | 1986 clear() { |
1980 this.element.removeChildren(); | 1987 this.element.removeChildren(); |
1981 this._linkifier.reset(); | 1988 this._linkifier.reset(); |
1982 } | 1989 } |
1983 }; | 1990 }; |
OLD | NEW |