56
56
this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
58
this.profilesListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("CPU PROFILES"), null, true);
59
this.sidebarTree.appendChild(this.profilesListTreeElement);
60
this.profilesListTreeElement.expand();
62
this.snapshotsListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("HEAP SNAPSHOTS"), null, true);
63
if (Preferences.heapProfilerPresent) {
64
this.sidebarTree.appendChild(this.snapshotsListTreeElement);
65
this.snapshotsListTreeElement.expand();
58
68
this.profileViews = document.createElement("div");
59
69
this.profileViews.id = "profile-views";
60
70
this.element.appendChild(this.profileViews);
62
this.enableToggleButton = document.createElement("button");
63
this.enableToggleButton.className = "enable-toggle-status-bar-item status-bar-item";
72
this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item");
64
73
this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind(this), false);
66
this.recordButton = document.createElement("button");
67
this.recordButton.title = WebInspector.UIString("Start profiling.");
68
this.recordButton.id = "record-profile-status-bar-item";
69
this.recordButton.className = "status-bar-item";
75
this.recordButton = new WebInspector.StatusBarButton(WebInspector.UIString("Start profiling."), "record-profile-status-bar-item");
70
76
this.recordButton.addEventListener("click", this._recordClicked.bind(this), false);
72
78
this.recording = false;
80
this.snapshotButton = new WebInspector.StatusBarButton(WebInspector.UIString("Take heap snapshot."), "heap-snapshot-status-bar-item");
81
this.snapshotButton.visible = Preferences.heapProfilerPresent;
82
this.snapshotButton.addEventListener("click", this._snapshotClicked.bind(this), false);
74
84
this.profileViewStatusBarItemsContainer = document.createElement("div");
75
85
this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items";
88
98
get statusBarItems()
90
return [this.enableToggleButton, this.recordButton, this.profileViewStatusBarItemsContainer];
100
return [this.enableToggleButton.element, this.recordButton.element, this.snapshotButton.element, this.profileViewStatusBarItemsContainer];
138
148
this.sidebarTreeElement.removeStyleClass("some-expandable");
140
this.sidebarTree.removeChildren();
150
this.profilesListTreeElement.removeChildren();
151
this.snapshotsListTreeElement.removeChildren();
141
152
this.profileViews.removeChildren();
143
154
this.profileViewStatusBarItemsContainer.removeChildren();
232
243
showView: function(view)
234
// Always use the treeProfile, since the heavy profile might be showing.
235
this.showProfile(view.profile.treeProfile);
245
this.showProfile(view.profile);
238
248
profileViewForProfile: function(profile)
268
278
groupNumber = ++this._profileGroupsForLinks[title];
270
if (groupNumber >= 2)
271
title += " " + WebInspector.UIString("Run %d", groupNumber);
281
// The title is used in the console message announcing that a profile has started so it gets
282
// incremented twice as often as it's displayed
283
title += " " + WebInspector.UIString("Run %d", groupNumber / 2);
296
308
searchMatchFound: function(view, matches)
298
// Always use the treeProfile, since the heavy profile might be showing.
299
view.profile.treeProfile._profilesTreeElement.searchMatches = matches;
310
view.profile._profilesTreeElement.searchMatches = matches;
302
313
searchCanceled: function(startingNewSearch)
317
328
this.recording = isProfiling;
319
330
if (isProfiling) {
320
this.recordButton.addStyleClass("toggled-on");
331
this.recordButton.toggled = true;
321
332
this.recordButton.title = WebInspector.UIString("Stop profiling.");
323
this.recordButton.removeStyleClass("toggled-on");
334
this.recordButton.toggled = false;
324
335
this.recordButton.title = WebInspector.UIString("Start profiling.");
341
var visibleView = this.visibleView;
342
if (visibleView && "resize" in visibleView)
343
visibleView.resize();
328
346
_updateInterface: function()
330
348
if (InspectorController.profilerEnabled()) {
331
349
this.enableToggleButton.title = WebInspector.UIString("Profiling enabled. Click to disable.");
332
this.enableToggleButton.addStyleClass("toggled-on");
333
this.recordButton.removeStyleClass("hidden");
350
this.enableToggleButton.toggled = true;
351
this.recordButton.visible = true;
352
if (Preferences.heapProfilerPresent)
353
this.snapshotButton.visible = true;
334
354
this.profileViewStatusBarItemsContainer.removeStyleClass("hidden");
335
355
this.panelEnablerView.visible = false;
337
357
this.enableToggleButton.title = WebInspector.UIString("Profiling disabled. Click to enable.");
338
this.enableToggleButton.removeStyleClass("toggled-on");
339
this.recordButton.addStyleClass("hidden");
358
this.enableToggleButton.toggled = false;
359
this.recordButton.visible = false;
360
this.snapshotButton.visible = false;
340
361
this.profileViewStatusBarItemsContainer.addStyleClass("hidden");
341
362
this.panelEnablerView.visible = true;
352
373
InspectorController.stopProfiling();
376
_snapshotClicked: function()
378
InspectorController.takeHeapSnapshot();
355
381
_enableProfiling: function()
357
383
if (InspectorController.profilerEnabled())
359
this._toggleProfiling();
385
this._toggleProfiling(this.panelEnablerView.alwaysEnabled);
362
_toggleProfiling: function()
388
_toggleProfiling: function(optionalAlways)
364
390
if (InspectorController.profilerEnabled())
365
InspectorController.disableProfiler();
391
InspectorController.disableProfiler(true);
367
InspectorController.enableProfiler();
393
InspectorController.enableProfiler(!!optionalAlways);
370
396
_populateProfiles: function()
372
if (this.sidebarTree.children.length)
398
// FIXME: This code needs to be adjusted when more profiling types are added.
399
// Currently defaults to CPU profiles.
400
var cpuProfiles = this.sidebarTree.children[0];
401
if (cpuProfiles.children.length)
375
404
var profiles = InspectorController.profiles();
379
408
this.addProfile(profile);
382
if (this.sidebarTree.children[0])
383
this.sidebarTree.children[0].select();
411
if (cpuProfiles.children[0])
412
cpuProfiles.children[0].select();
385
414
delete this._shouldPopulateProfiles;
424
453
this.profileViews.style.left = width + "px";
425
454
this.profileViewStatusBarItemsContainer.style.left = width + "px";
426
455
this.sidebarResizeElement.style.left = (width - 3) + "px";
457
var visibleView = this.visibleView;
458
if (visibleView && "resize" in visibleView)
459
visibleView.resize();