Changeset 117581 in webkit
- Timestamp:
- May 18, 2012 6:30:40 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r117580 r117581 1 2012-05-18 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: remove unnecessary indirection from profile types 4 https://bugs.webkit.org/show_bug.cgi?id=86845 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/profiler/heap-snapshot-test.js: 9 (initialize_HeapSnapshotTest): 10 1 11 2012-05-18 Zoltan Arvai <zarvai@inf.u-szeged.hu> 2 12 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js
r117234 r117581 514 514 var uid = InspectorTest._nextUid++; 515 515 var snapshot = generator(); 516 var profile = new WebInspector.HeapProfileHeader(UserInitiatedProfileName + "." + uid, uid, snapshot.maxJSObjectId); 516 var profileType = WebInspector.panels.profiles.getProfileType(WebInspector.HeapSnapshotProfileType.TypeId); 517 var profile = profileType.createProfile({ 518 title: UserInitiatedProfileName + "." + uid, 519 uid: uid, 520 maxJSObjectId: snapshot.maxJSObjectId 521 }); 517 522 delete snapshot.maxJSObjectId; 518 523 function pushGeneratedSnapshot(typeId, uid) … … 526 531 InspectorTest.override(ProfilerAgent, "getProfile", pushGeneratedSnapshot); 527 532 InspectorTest._takeAndOpenSnapshotCallback = callback; 528 var profileType = WebInspector.panels.profiles.getProfileType(profile.typeId);529 profile = profileType.createProfile(profile);530 533 WebInspector.panels.profiles.addProfileHeader(profile); 531 534 WebInspector.panels.profiles.showProfile(profile); -
trunk/Source/WebCore/ChangeLog
r117579 r117581 1 2012-05-18 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: remove unnecessary indirection from profile types 4 https://bugs.webkit.org/show_bug.cgi?id=86845 5 6 Reviewed by Pavel Feldman. 7 8 Introduced CSSProfileHeader and CPUProfileHeader, moved view creation from 9 the type to corresponding profile headers. Removed some inderection and 10 private fields assigned in random places. Added type annotations. 11 12 * inspector/front-end/CPUProfileView.js: 13 (WebInspector.CPUProfileType.prototype.createTemporaryProfile): 14 (WebInspector.CPUProfileType.prototype.createProfile): 15 (WebInspector.CPUProfileHeader): 16 (WebInspector.CPUProfileHeader.prototype.createSidebarTreeElement): 17 (WebInspector.CPUProfileHeader.prototype.createView): 18 * inspector/front-end/CSSSelectorProfileView.js: 19 (WebInspector.CSSSelectorProfileType.prototype.stopRecordingProfile): 20 (WebInspector.CSSSelectorProfileType.prototype.createTemporaryProfile): 21 (WebInspector.CSSSelectorProfileType.prototype.createProfile): 22 (WebInspector.CSSProfileHeader): 23 (WebInspector.CSSProfileHeader.prototype.createSidebarTreeElement): 24 (WebInspector.CSSProfileHeader.prototype.createView): 25 * inspector/front-end/HeapSnapshotView.js: 26 (WebInspector.HeapSnapshotProfileType.prototype.createTemporaryProfile): 27 (WebInspector.HeapSnapshotProfileType.prototype.createProfile): 28 (WebInspector.HeapProfileHeader): 29 (WebInspector.HeapProfileHeader.prototype.createSidebarTreeElement): 30 (WebInspector.HeapProfileHeader.prototype.createView): 31 (WebInspector.HeapProfileHeader.prototype.load): 32 (WebInspector.HeapProfileHeader.prototype.saveToFile): 33 * inspector/front-end/ProfileLauncherView.js: 34 (WebInspector.ProfileLauncherView): 35 (WebInspector.ProfileLauncherView.prototype.addProfileType): 36 (WebInspector.ProfileLauncherView.prototype._profileTypeChanged): 37 * inspector/front-end/ProfilesPanel.js: 38 (WebInspector.ProfileType): 39 (WebInspector.ProfileHeader): 40 (WebInspector.ProfileHeader.prototype.profileType): 41 (WebInspector.ProfileHeader.prototype.createSidebarTreeElement): 42 (WebInspector.ProfileHeader.prototype.existingView): 43 (WebInspector.ProfileHeader.prototype.view): 44 (WebInspector.ProfileHeader.prototype.createView): 45 (WebInspector.ProfilesPanel.prototype._reset): 46 (WebInspector.ProfilesPanel.prototype.addProfileHeader): 47 (WebInspector.ProfilesPanel.prototype._removeProfileHeader): 48 (WebInspector.ProfilesPanel.prototype.showProfile): 49 (WebInspector.ProfilesPanel.prototype.getProfiles): 50 (WebInspector.ProfilesPanel.prototype.findTemporaryProfile): 51 (WebInspector.ProfilesPanel.prototype._searchableViews): 52 * inspector/front-end/View.js: 53 (WebInspector.View._assert): 54 1 55 2012-05-18 Kentaro Hara <haraken@chromium.org> 2 56 -
trunk/Source/WebCore/inspector/front-end/CPUProfileView.js
r117272 r117581 101 101 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.DefaultFormatter(30)); 102 102 103 ProfilerAgent.getProfile(this.profile. typeId, this.profile.uid, profileCallback.bind(this));103 ProfilerAgent.getProfile(this.profile.profileType().id, this.profile.uid, profileCallback.bind(this)); 104 104 } 105 105 … … 613 613 }, 614 614 615 createSidebarTreeElementForProfile: function(profile)616 {617 return new WebInspector.ProfileSidebarTreeElement(profile, WebInspector.UIString("Profile %d"), "profile-sidebar-tree-item");618 },619 620 createView: function(profile)621 {622 return new WebInspector.CPUProfileView(profile);623 },624 625 615 /** 626 616 * @override … … 631 621 { 632 622 title = title || WebInspector.UIString("Recording\u2026"); 633 return new WebInspector. ProfileHeader(WebInspector.CPUProfileType.TypeId, title);623 return new WebInspector.CPUProfileHeader(this, title); 634 624 }, 635 625 … … 641 631 createProfile: function(profile) 642 632 { 643 return new WebInspector. ProfileHeader(profile.typeId, profile.title, profile.uid);633 return new WebInspector.CPUProfileHeader(this, profile.title, profile.uid); 644 634 } 645 635 } 646 636 647 637 WebInspector.CPUProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; 638 639 /** 640 * @constructor 641 * @extends {WebInspector.ProfileHeader} 642 * @param {WebInspector.CPUProfileType} type 643 * @param {string} title 644 * @param {number=} uid 645 */ 646 WebInspector.CPUProfileHeader = function(type, title, uid) 647 { 648 WebInspector.ProfileHeader.call(this, type, title, uid); 649 } 650 651 WebInspector.CPUProfileHeader.prototype = { 652 /** 653 * @override 654 */ 655 createSidebarTreeElement: function() 656 { 657 return new WebInspector.ProfileSidebarTreeElement(this, WebInspector.UIString("Profile %d"), "profile-sidebar-tree-item"); 658 }, 659 660 /** 661 * @override 662 */ 663 createView: function() 664 { 665 return new WebInspector.CPUProfileView(this); 666 } 667 } 668 669 WebInspector.CPUProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; -
trunk/Source/WebCore/inspector/front-end/CSSSelectorProfileView.js
r116855 r117581 28 28 * @extends WebInspector.DataGridNode 29 29 * @param {WebInspector.CSSSelectorProfileView} profileView 30 * @param {CSSAgent.SelectorProfile} data 30 31 */ 31 32 WebInspector.CSSSelectorDataGridNode = function(profileView, data) … … 333 334 stopRecordingProfile: function() 334 335 { 336 /** 337 * @param {?Protocol.Error} error 338 * @param {CSSAgent.SelectorProfile} profile 339 */ 335 340 function callback(error, profile) 336 341 { … … 338 343 return; 339 344 340 profile.uid = this._profileUid++;341 profile.title = WebInspector.UIString("Profile %d", profile.uid) + String.sprintf(" (%s)", Number.secondsToString(profile.totalTime / 1000));342 profile.typeId = WebInspector.CSSSelectorProfileType.TypeId;343 WebInspector.panels.profiles.addProfileHeader(profile );345 var uid = this._profileUid++; 346 var title = WebInspector.UIString("Profile %d", uid) + String.sprintf(" (%s)", Number.secondsToString(profile.totalTime / 1000)); 347 var profileHeader = new WebInspector.CSSProfileHeader(this, title, uid, profile); 348 WebInspector.panels.profiles.addProfileHeader(profileHeader); 344 349 WebInspector.panels.profiles.setRecordingProfile(WebInspector.CSSSelectorProfileType.TypeId, false); 345 350 } … … 347 352 this._recording = false; 348 353 CSSAgent.stopSelectorProfiler(callback.bind(this)); 349 },350 351 createSidebarTreeElementForProfile: function(profile)352 {353 return new WebInspector.ProfileSidebarTreeElement(profile, profile.title, "profile-sidebar-tree-item");354 },355 356 createView: function(profile)357 {358 return new WebInspector.CSSSelectorProfileView(profile);359 354 }, 360 355 … … 367 362 { 368 363 title = title || WebInspector.UIString("Recording\u2026"); 369 return new WebInspector. ProfileHeader(WebInspector.CSSSelectorProfileType.TypeId, title);364 return new WebInspector.CSSProfileHeader(this, title); 370 365 }, 371 366 372 367 /** 373 368 * @override 374 * @param { ProfilerAgent.ProfileHeader} profile369 * @param {CSSAgent.SelectorProfile} profile 375 370 * @return {WebInspector.ProfileHeader} 376 371 */ 377 372 createProfile: function(profile) 378 373 { 379 return new WebInspector.ProfileHeader(profile.typeId, profile.title, profile.uid);374 throw new Error("Unreachable"); 380 375 } 381 376 } 382 377 383 378 WebInspector.CSSSelectorProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; 379 380 381 /** 382 * @constructor 383 * @extends {WebInspector.ProfileHeader} 384 * @param {WebInspector.CSSSelectorProfileType} type 385 * @param {string} title 386 * @param {number=} uid 387 * @param {CSSAgent.SelectorProfile=} protocolData 388 */ 389 WebInspector.CSSProfileHeader = function(type, title, uid, protocolData) 390 { 391 WebInspector.ProfileHeader.call(this, type, title, uid); 392 this._protocolData = protocolData; 393 } 394 395 WebInspector.CSSProfileHeader.prototype = { 396 /** 397 * @override 398 */ 399 createSidebarTreeElement: function() 400 { 401 return new WebInspector.ProfileSidebarTreeElement(this, this.title, "profile-sidebar-tree-item"); 402 }, 403 404 /** 405 * @override 406 */ 407 createView: function() 408 { 409 var profile = /** @type {CSSAgent.SelectorProfile} */this._protocolData; 410 return new WebInspector.CSSSelectorProfileView(profile); 411 } 412 } 413 414 WebInspector.CSSProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js
r117272 r117581 757 757 }, 758 758 759 createSidebarTreeElementForProfile: function(profile)760 {761 return new WebInspector.ProfileSidebarTreeElement(profile, WebInspector.UIString("Snapshot %d"), "heap-snapshot-sidebar-tree-item");762 },763 764 createView: function(profile)765 {766 return new WebInspector.HeapSnapshotView(WebInspector.panels.profiles, profile);767 },768 769 759 /** 770 760 * @override … … 775 765 { 776 766 title = title || WebInspector.UIString("Snapshotting\u2026"); 777 return new WebInspector.HeapProfileHeader(t itle);767 return new WebInspector.HeapProfileHeader(this, title); 778 768 }, 779 769 … … 785 775 createProfile: function(profile) 786 776 { 787 return new WebInspector.HeapProfileHeader( profile.title, profile.uid, profile.maxJSObjectId || 0);777 return new WebInspector.HeapProfileHeader(this, profile.title, profile.uid, profile.maxJSObjectId || 0); 788 778 } 789 779 } … … 794 784 * @constructor 795 785 * @extends {WebInspector.ProfileHeader} 786 * @param {WebInspector.HeapSnapshotProfileType} type 796 787 * @param {string} title 797 788 * @param {number=} uid 798 789 * @param {number=} maxJSObjectId 799 790 */ 800 WebInspector.HeapProfileHeader = function(t itle, uid, maxJSObjectId)791 WebInspector.HeapProfileHeader = function(type, title, uid, maxJSObjectId) 801 792 { 802 WebInspector.ProfileHeader.call(this, WebInspector.HeapSnapshotProfileType.TypeId, title, uid);793 WebInspector.ProfileHeader.call(this, type, title, uid); 803 794 this.maxJSObjectId = maxJSObjectId; 804 795 /** … … 814 805 815 806 WebInspector.HeapProfileHeader.prototype = { 807 /** 808 * @override 809 */ 810 createSidebarTreeElement: function() 811 { 812 return new WebInspector.ProfileSidebarTreeElement(this, WebInspector.UIString("Snapshot %d"), "heap-snapshot-sidebar-tree-item"); 813 }, 814 815 /** 816 * @override 817 */ 818 createView: function() 819 { 820 return new WebInspector.HeapSnapshotView(WebInspector.panels.profiles, this); 821 }, 822 816 823 snapshotProxy: function() 817 824 { … … 836 843 this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"); 837 844 this.sidebarElement.wait = true; 838 ProfilerAgent.getProfile(this. typeId, this.uid);845 ProfilerAgent.getProfile(this.profileType().id, this.uid); 839 846 } 840 847 }, … … 930 937 WebInspector.fileManager.removeEventListener(WebInspector.FileManager.EventTypes.SavedURL, startSavingSnapshot, this); 931 938 WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventTypes.AppendedToURL, this._saveStatusUpdate, this); 932 ProfilerAgent.getProfile(this. typeId, this.uid);939 ProfilerAgent.getProfile(this.profileType().id, this.uid); 933 940 } 934 941 -
trunk/Source/WebCore/inspector/front-end/ProfileLauncherView.js
r103765 r117581 39 39 this._panel = profilesPanel; 40 40 this._profileRunning = false; 41 this._optionIdPrefix = "profile-type-";42 41 43 42 this.element.addStyleClass("profile-launcher-view"); … … 53 52 this._profileTypeSelectorForm = this._contentElement.createChild("form"); 54 53 this._contentElement.createChild("div", "flexible-space"); 55 56 this._boundProfileTypeChangeListener = this._profileTypeChanged.bind(this);57 54 58 55 this._controlButton = this._contentElement.createChild("button", "control-profiling"); … … 72 69 }, 73 70 71 /** 72 * @param {WebInspector.ProfileType} profileType 73 */ 74 74 addProfileType: function(profileType) 75 75 { … … 81 81 optionElement.type = "radio"; 82 82 optionElement.name = "profile-type"; 83 var optionId = this._optionIdPrefix + profileType.id;84 optionElement.id = optionId;85 83 if (checked) { 86 84 optionElement.checked = checked; 87 85 this.dispatchEventToListeners(WebInspector.ProfileLauncherView.EventTypes.ProfileTypeSelected, profileType); 88 86 } 89 optionElement.addEventListener("change", this._ boundProfileTypeChangeListener, false);87 optionElement.addEventListener("change", this._profileTypeChanged.bind(this, profileType), false); 90 88 var descriptionElement = labelElement.createChild("p"); 91 89 descriptionElement.textContent = profileType.description; … … 110 108 }, 111 109 112 _profileTypeChanged: function(event) 110 /** 111 * @param {WebInspector.ProfileType} profileType 112 */ 113 _profileTypeChanged: function(profileType, event) 113 114 { 114 var selectedProfileType = this._panel.getProfileType(event.target.id.substring(this._optionIdPrefix.length)); 115 this.dispatchEventToListeners(WebInspector.ProfileLauncherView.EventTypes.ProfileTypeSelected, selectedProfileType); 115 this.dispatchEventToListeners(WebInspector.ProfileLauncherView.EventTypes.ProfileTypeSelected, profileType); 116 116 }, 117 117 -
trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js
r117234 r117581 33 33 this._id = id; 34 34 this._name = name; 35 /** 36 * @type {WebInspector.SidebarSectionTreeElement} 37 */ 38 this.treeElement = null; 35 39 } 36 40 … … 66 70 }, 67 71 68 viewForProfile: function(profile)69 {70 if (!profile._profileView)71 profile._profileView = this.createView(profile);72 return profile._profileView;73 },74 75 72 reset: function() 76 73 { … … 80 77 { 81 78 return ""; 82 },83 84 // Must be implemented by subclasses.85 createView: function(profile)86 {87 throw new Error("Needs implemented.");88 },89 90 // Must be implemented by subclasses.91 createSidebarTreeElementForProfile: function(profile)92 {93 throw new Error("Needs implemented.");94 79 }, 95 80 … … 125 110 /** 126 111 * @constructor 127 * @param { string} profileType112 * @param {WebInspector.ProfileType} profileType 128 113 * @param {string} title 129 114 * @param {number=} uid … … 131 116 WebInspector.ProfileHeader = function(profileType, title, uid) 132 117 { 133 this. typeId = profileType,118 this._profileType = profileType; 134 119 this.title = title; 135 120 if (uid === undefined) { … … 144 129 145 130 WebInspector.ProfileHeader.prototype = { 131 profileType: function() 132 { 133 return this._profileType; 134 }, 135 136 /** 137 * Must be implemented by subclasses. 138 * @return {WebInspector.ProfileSidebarTreeElement} 139 */ 140 createSidebarTreeElement: function() 141 { 142 throw new Error("Needs implemented."); 143 }, 144 145 existingView: function() 146 { 147 return this._view; 148 }, 149 150 view: function() 151 { 152 if (!this._view) 153 this._view = this.createView(); 154 return this._view; 155 }, 156 157 createView: function() 158 { 159 throw new Error("Not implemented."); 160 }, 161 146 162 /** 147 163 * @param {Function} callback … … 335 351 336 352 for (var i = 0; i < this._profiles.length; ++i) { 337 var view = this._profiles[i]. _profileView;353 var view = this._profiles[i].existingView(); 338 354 if (view) { 339 355 view.detach(); … … 341 357 view.dispose(); 342 358 } 343 344 delete this._profiles[i]._profileView;345 359 } 346 360 delete this.visibleView; … … 444 458 addProfileHeader: function(profile) 445 459 { 446 this._removeTemporaryProfile(profile. typeId);447 448 var typeId = profile.typeId;449 var profileType = this.getProfileType(typeId);460 this._removeTemporaryProfile(profile.profileType().id); 461 462 var profileType = profile.profileType(); 463 var typeId = profileType.id; 450 464 var sidebarParent = profileType.treeElement; 451 465 sidebarParent.hidden = false; … … 453 467 var alternateTitle; 454 468 455 profile.__profilesPanelProfileType = profileType;456 469 this._profiles.push(profile); 457 470 this._profilesIdMap[this._makeKey(profile.uid, typeId)] = profile; … … 493 506 } 494 507 495 var profileTreeElement = profile Type.createSidebarTreeElementForProfile(profile);508 var profileTreeElement = profile.createSidebarTreeElement(); 496 509 profile.sidebarElement = profileTreeElement; 497 510 profileTreeElement.small = small; … … 513 526 _removeProfileHeader: function(profile) 514 527 { 515 var typeId = profile.typeId; 516 var profileType = this.getProfileType(typeId); 517 var sidebarParent = profileType.treeElement; 528 var sidebarParent = profile.profileType().treeElement; 518 529 519 530 for (var i = 0; i < this._profiles.length; ++i) { … … 524 535 } 525 536 } 526 delete this._profilesIdMap[this._makeKey(profile.uid, typeId)];527 528 var profileTitleKey = this._makeTitleKey(profile.title, typeId);537 delete this._profilesIdMap[this._makeKey(profile.uid, profile.profileType().id)]; 538 539 var profileTitleKey = this._makeTitleKey(profile.title, profile.profileType().id); 529 540 delete this._profileGroups[profileTitleKey]; 530 541 … … 532 543 533 544 if (!profile.isTemporary) 534 ProfilerAgent.removeProfile(profile. typeId, profile.uid);545 ProfilerAgent.removeProfile(profile.profileType().id, profile.uid); 535 546 536 547 // No other item will be selected if there aren't any other profiles, so … … 550 561 this.closeVisibleView(); 551 562 552 var view = profile. __profilesPanelProfileType.viewForProfile(profile);563 var view = profile.view(); 553 564 554 565 view.show(this.profileViews); … … 578 589 for (var i = 0; i < profilesCount; ++i) { 579 590 var profile = this._profiles[i]; 580 if (!profile.isTemporary && profile. typeId === typeId)591 if (!profile.isTemporary && profile.profileType().id === typeId) 581 592 result.push(profile); 582 593 } … … 596 607 if (profile.maxJSObjectId >= snapshotObjectId) { 597 608 this.showProfile(profile); 598 profile. _profileView.changeView(viewName, function() {599 profile. _profileView.dataGrid.highlightObjectByHeapSnapshotId(snapshotObjectId);609 profile.view().changeView(viewName, function() { 610 profile.view().dataGrid.highlightObjectByHeapSnapshotId(snapshotObjectId); 600 611 }); 601 612 break; … … 612 623 var profilesCount = this._profiles.length; 613 624 for (var i = 0; i < profilesCount; ++i) 614 if (this._profiles[i]. typeId === typeId && this._profiles[i].isTemporary)625 if (this._profiles[i].profileType().id === typeId && this._profiles[i].isTemporary) 615 626 return this._profiles[i]; 616 627 return null; … … 628 639 629 640 /** 630 * @param { WebInspector.ProfileHeader} profile641 * @param {ProfilerAgent.ProfileHeader} profile 631 642 */ 632 643 hasProfile: function(profile) … … 877 888 for (var i = 0; i < profilesLength; ++i) { 878 889 var profile = this._profiles[i]; 879 var view = profile. __profilesPanelProfileType.viewForProfile(profile);890 var view = profile.view(); 880 891 if (!view.performSearch || view === visibleView) 881 892 continue; … … 977 988 return; 978 989 990 /** 991 * @param {?string} error 992 * @param {Array.<ProfilerAgent.ProfileHeader>} profileHeaders 993 */ 979 994 function populateCallback(error, profileHeaders) { 980 995 if (error) -
trunk/Source/WebCore/inspector/front-end/View.js
r114740 r117581 397 397 if (!condition) { 398 398 console.trace(); 399 console.error("assert: " + new Error().stack); 399 400 throw new Error(message); 400 401 }
Note: See TracChangeset
for help on using the changeset viewer.