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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 this.sidebarResizeElement.className = "sidebar-resizer-vertical"; | 48 this.sidebarResizeElement.className = "sidebar-resizer-vertical"; |
49 this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDr
agging.bind(this), false); | 49 this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDr
agging.bind(this), false); |
50 this.element.appendChild(this.sidebarResizeElement); | 50 this.element.appendChild(this.sidebarResizeElement); |
51 | 51 |
52 this.sidebarTreeElement = document.createElement("ol"); | 52 this.sidebarTreeElement = document.createElement("ol"); |
53 this.sidebarTreeElement.className = "sidebar-tree"; | 53 this.sidebarTreeElement.className = "sidebar-tree"; |
54 this.sidebarElement.appendChild(this.sidebarTreeElement); | 54 this.sidebarElement.appendChild(this.sidebarTreeElement); |
55 | 55 |
56 this.sidebarTree = new TreeOutline(this.sidebarTreeElement); | 56 this.sidebarTree = new TreeOutline(this.sidebarTreeElement); |
57 | 57 |
| 58 this.profilesListTreeElement = new WebInspector.SidebarSectionTreeElement(We
bInspector.UIString("CPU PROFILES"), null, true); |
| 59 this.sidebarTree.appendChild(this.profilesListTreeElement); |
| 60 this.profilesListTreeElement.expand(); |
| 61 |
| 62 this.snapshotsListTreeElement = new WebInspector.SidebarSectionTreeElement(W
ebInspector.UIString("HEAP SNAPSHOTS"), null, true); |
| 63 if (Preferences.heapProfilerPresent) { |
| 64 this.sidebarTree.appendChild(this.snapshotsListTreeElement); |
| 65 this.snapshotsListTreeElement.expand(); |
| 66 } |
| 67 |
58 this.profileViews = document.createElement("div"); | 68 this.profileViews = document.createElement("div"); |
59 this.profileViews.id = "profile-views"; | 69 this.profileViews.id = "profile-views"; |
60 this.element.appendChild(this.profileViews); | 70 this.element.appendChild(this.profileViews); |
61 | 71 |
62 this.enableToggleButton = document.createElement("button"); | 72 this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggl
e-status-bar-item"); |
63 this.enableToggleButton.className = "enable-toggle-status-bar-item status-ba
r-item"; | |
64 this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind
(this), false); | 73 this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind
(this), false); |
65 | 74 |
66 this.recordButton = document.createElement("button"); | 75 this.recordButton = new WebInspector.StatusBarButton(WebInspector.UIString("
Start profiling."), "record-profile-status-bar-item"); |
67 this.recordButton.title = WebInspector.UIString("Start profiling."); | |
68 this.recordButton.id = "record-profile-status-bar-item"; | |
69 this.recordButton.className = "status-bar-item"; | |
70 this.recordButton.addEventListener("click", this._recordClicked.bind(this),
false); | 76 this.recordButton.addEventListener("click", this._recordClicked.bind(this),
false); |
71 | 77 |
72 this.recording = false; | 78 this.recording = false; |
73 | 79 |
| 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(thi
s), false); |
| 83 |
74 this.profileViewStatusBarItemsContainer = document.createElement("div"); | 84 this.profileViewStatusBarItemsContainer = document.createElement("div"); |
75 this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items"
; | 85 this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items"
; |
76 | 86 |
77 this.reset(); | 87 this.reset(); |
78 } | 88 } |
79 | 89 |
80 WebInspector.ProfilesPanel.prototype = { | 90 WebInspector.ProfilesPanel.prototype = { |
81 toolbarItemClass: "profiles", | 91 toolbarItemClass: "profiles", |
82 | 92 |
83 get toolbarItemLabel() | 93 get toolbarItemLabel() |
84 { | 94 { |
85 return WebInspector.UIString("Profiles"); | 95 return WebInspector.UIString("Profiles"); |
86 }, | 96 }, |
87 | 97 |
88 get statusBarItems() | 98 get statusBarItems() |
89 { | 99 { |
90 return [this.enableToggleButton, this.recordButton, this.profileViewStat
usBarItemsContainer]; | 100 return [this.enableToggleButton.element, this.recordButton.element, this
.snapshotButton.element, this.profileViewStatusBarItemsContainer]; |
91 }, | 101 }, |
92 | 102 |
93 show: function() | 103 show: function() |
94 { | 104 { |
95 WebInspector.Panel.prototype.show.call(this); | 105 WebInspector.Panel.prototype.show.call(this); |
96 this._updateSidebarWidth(); | 106 this._updateSidebarWidth(); |
97 if (this._shouldPopulateProfiles) | 107 if (this._shouldPopulateProfiles) |
98 this._populateProfiles(); | 108 this._populateProfiles(); |
99 }, | 109 }, |
100 | 110 |
(...skipping 29 matching lines...) Expand all Loading... |
130 delete this.currentQuery; | 140 delete this.currentQuery; |
131 this.searchCanceled(); | 141 this.searchCanceled(); |
132 | 142 |
133 this._profiles = []; | 143 this._profiles = []; |
134 this._profilesIdMap = {}; | 144 this._profilesIdMap = {}; |
135 this._profileGroups = {}; | 145 this._profileGroups = {}; |
136 this._profileGroupsForLinks = {} | 146 this._profileGroupsForLinks = {} |
137 | 147 |
138 this.sidebarTreeElement.removeStyleClass("some-expandable"); | 148 this.sidebarTreeElement.removeStyleClass("some-expandable"); |
139 | 149 |
140 this.sidebarTree.removeChildren(); | 150 this.profilesListTreeElement.removeChildren(); |
| 151 this.snapshotsListTreeElement.removeChildren(); |
141 this.profileViews.removeChildren(); | 152 this.profileViews.removeChildren(); |
142 | 153 |
143 this.profileViewStatusBarItemsContainer.removeChildren(); | 154 this.profileViewStatusBarItemsContainer.removeChildren(); |
144 | 155 |
145 this._updateInterface(); | 156 this._updateInterface(); |
146 }, | 157 }, |
147 | 158 |
148 handleKeyEvent: function(event) | 159 handleKeyEvent: function(event) |
149 { | 160 { |
150 this.sidebarTree.handleKeyEvent(event); | 161 this.sidebarTree.handleKeyEvent(event); |
151 }, | 162 }, |
152 | 163 |
153 addProfile: function(profile) | 164 addProfile: function(profile) |
154 { | 165 { |
155 this._profiles.push(profile); | 166 this._profiles.push(profile); |
156 this._profilesIdMap[profile.uid] = profile; | 167 this._profilesIdMap[profile.uid] = profile; |
157 | 168 |
158 var sidebarParent = this.sidebarTree; | 169 var sidebarParent = this.profilesListTreeElement; |
159 var small = false; | 170 var small = false; |
160 var alternateTitle; | 171 var alternateTitle; |
161 | 172 |
162 if (profile.title.indexOf(UserInitiatedProfileName) !== 0) { | 173 if (profile.title.indexOf(UserInitiatedProfileName) !== 0) { |
163 if (!(profile.title in this._profileGroups)) | 174 if (!(profile.title in this._profileGroups)) |
164 this._profileGroups[profile.title] = []; | 175 this._profileGroups[profile.title] = []; |
165 | 176 |
166 var group = this._profileGroups[profile.title]; | 177 var group = this._profileGroups[profile.title]; |
167 group.push(profile); | 178 group.push(profile); |
168 | 179 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 { | 270 { |
260 title = unescape(title); | 271 title = unescape(title); |
261 if (title.indexOf(UserInitiatedProfileName) === 0) { | 272 if (title.indexOf(UserInitiatedProfileName) === 0) { |
262 title = WebInspector.UIString("Profile %d", title.substring(UserInit
iatedProfileName.length + 1)); | 273 title = WebInspector.UIString("Profile %d", title.substring(UserInit
iatedProfileName.length + 1)); |
263 } else { | 274 } else { |
264 if (!(title in this._profileGroupsForLinks)) | 275 if (!(title in this._profileGroupsForLinks)) |
265 this._profileGroupsForLinks[title] = 0; | 276 this._profileGroupsForLinks[title] = 0; |
266 | 277 |
267 groupNumber = ++this._profileGroupsForLinks[title]; | 278 groupNumber = ++this._profileGroupsForLinks[title]; |
268 | 279 |
269 if (groupNumber >= 2) | 280 if (groupNumber > 2) |
270 title += " " + WebInspector.UIString("Run %d", groupNumber); | 281 // The title is used in the console message announcing that a pr
ofile has started so it gets |
| 282 // incremented twice as often as it's displayed |
| 283 title += " " + WebInspector.UIString("Run %d", groupNumber / 2); |
271 } | 284 } |
272 | 285 |
273 return title; | 286 return title; |
274 }, | 287 }, |
275 | 288 |
276 get searchableViews() | 289 get searchableViews() |
277 { | 290 { |
278 var views = []; | 291 var views = []; |
279 | 292 |
280 const visibleView = this.visibleView; | 293 const visibleView = this.visibleView; |
(...skipping 27 matching lines...) Expand all Loading... |
308 var profile = this._profiles[i]; | 321 var profile = this._profiles[i]; |
309 profile._profilesTreeElement.searchMatches = 0; | 322 profile._profilesTreeElement.searchMatches = 0; |
310 } | 323 } |
311 }, | 324 }, |
312 | 325 |
313 setRecordingProfile: function(isProfiling) | 326 setRecordingProfile: function(isProfiling) |
314 { | 327 { |
315 this.recording = isProfiling; | 328 this.recording = isProfiling; |
316 | 329 |
317 if (isProfiling) { | 330 if (isProfiling) { |
318 this.recordButton.addStyleClass("toggled-on"); | 331 this.recordButton.toggled = true; |
319 this.recordButton.title = WebInspector.UIString("Stop profiling."); | 332 this.recordButton.title = WebInspector.UIString("Stop profiling."); |
320 } else { | 333 } else { |
321 this.recordButton.removeStyleClass("toggled-on"); | 334 this.recordButton.toggled = false; |
322 this.recordButton.title = WebInspector.UIString("Start profiling."); | 335 this.recordButton.title = WebInspector.UIString("Start profiling."); |
323 } | 336 } |
324 }, | 337 }, |
| 338 |
| 339 resize: function() |
| 340 { |
| 341 var visibleView = this.visibleView; |
| 342 if (visibleView && "resize" in visibleView) |
| 343 visibleView.resize(); |
| 344 }, |
325 | 345 |
326 _updateInterface: function() | 346 _updateInterface: function() |
327 { | 347 { |
328 if (InspectorController.profilerEnabled()) { | 348 if (InspectorController.profilerEnabled()) { |
329 this.enableToggleButton.title = WebInspector.UIString("Profiling ena
bled. Click to disable."); | 349 this.enableToggleButton.title = WebInspector.UIString("Profiling ena
bled. Click to disable."); |
330 this.enableToggleButton.addStyleClass("toggled-on"); | 350 this.enableToggleButton.toggled = true; |
331 this.recordButton.removeStyleClass("hidden"); | 351 this.recordButton.visible = true; |
| 352 if (Preferences.heapProfilerPresent) |
| 353 this.snapshotButton.visible = true; |
332 this.profileViewStatusBarItemsContainer.removeStyleClass("hidden"); | 354 this.profileViewStatusBarItemsContainer.removeStyleClass("hidden"); |
333 this.panelEnablerView.visible = false; | 355 this.panelEnablerView.visible = false; |
334 } else { | 356 } else { |
335 this.enableToggleButton.title = WebInspector.UIString("Profiling dis
abled. Click to enable."); | 357 this.enableToggleButton.title = WebInspector.UIString("Profiling dis
abled. Click to enable."); |
336 this.enableToggleButton.removeStyleClass("toggled-on"); | 358 this.enableToggleButton.toggled = false; |
337 this.recordButton.addStyleClass("hidden"); | 359 this.recordButton.visible = false; |
| 360 this.snapshotButton.visible = false; |
338 this.profileViewStatusBarItemsContainer.addStyleClass("hidden"); | 361 this.profileViewStatusBarItemsContainer.addStyleClass("hidden"); |
339 this.panelEnablerView.visible = true; | 362 this.panelEnablerView.visible = true; |
340 } | 363 } |
341 }, | 364 }, |
342 | 365 |
343 _recordClicked: function() | 366 _recordClicked: function() |
344 { | 367 { |
345 this.recording = !this.recording; | 368 this.recording = !this.recording; |
346 | 369 |
347 if (this.recording) | 370 if (this.recording) |
348 InspectorController.startProfiling(); | 371 InspectorController.startProfiling(); |
349 else | 372 else |
350 InspectorController.stopProfiling(); | 373 InspectorController.stopProfiling(); |
351 }, | 374 }, |
352 | 375 |
| 376 _snapshotClicked: function() |
| 377 { |
| 378 InspectorController.takeHeapSnapshot(); |
| 379 }, |
| 380 |
353 _enableProfiling: function() | 381 _enableProfiling: function() |
354 { | 382 { |
355 if (InspectorController.profilerEnabled()) | 383 if (InspectorController.profilerEnabled()) |
356 return; | 384 return; |
357 this._toggleProfiling(); | 385 this._toggleProfiling(this.panelEnablerView.alwaysEnabled); |
358 }, | 386 }, |
359 | 387 |
360 _toggleProfiling: function() | 388 _toggleProfiling: function(optionalAlways) |
361 { | 389 { |
362 if (InspectorController.profilerEnabled()) | 390 if (InspectorController.profilerEnabled()) |
363 InspectorController.disableProfiler(); | 391 InspectorController.disableProfiler(true); |
364 else | 392 else |
365 InspectorController.enableProfiler(); | 393 InspectorController.enableProfiler(!!optionalAlways); |
366 }, | 394 }, |
367 | 395 |
368 _populateProfiles: function() | 396 _populateProfiles: function() |
369 { | 397 { |
370 if (this.sidebarTree.children.length) | 398 if (this.sidebarTree.children.length) |
371 return; | 399 return; |
372 | 400 |
373 var profiles = InspectorController.profiles(); | 401 var profiles = InspectorController.profiles(); |
374 var profilesLength = profiles.length; | 402 var profilesLength = profiles.length; |
375 for (var i = 0; i < profilesLength; ++i) { | 403 for (var i = 0; i < profilesLength; ++i) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 width = this._currentSidebarWidth; | 443 width = this._currentSidebarWidth; |
416 | 444 |
417 width = Number.constrain(width, Preferences.minSidebarWidth, window.inne
rWidth / 2); | 445 width = Number.constrain(width, Preferences.minSidebarWidth, window.inne
rWidth / 2); |
418 | 446 |
419 this._currentSidebarWidth = width; | 447 this._currentSidebarWidth = width; |
420 | 448 |
421 this.sidebarElement.style.width = width + "px"; | 449 this.sidebarElement.style.width = width + "px"; |
422 this.profileViews.style.left = width + "px"; | 450 this.profileViews.style.left = width + "px"; |
423 this.profileViewStatusBarItemsContainer.style.left = width + "px"; | 451 this.profileViewStatusBarItemsContainer.style.left = width + "px"; |
424 this.sidebarResizeElement.style.left = (width - 3) + "px"; | 452 this.sidebarResizeElement.style.left = (width - 3) + "px"; |
| 453 |
| 454 var visibleView = this.visibleView; |
| 455 if (visibleView && "resize" in visibleView) |
| 456 visibleView.resize(); |
425 } | 457 } |
426 } | 458 } |
427 | 459 |
428 WebInspector.ProfilesPanel.prototype.__proto__ = WebInspector.Panel.prototype; | 460 WebInspector.ProfilesPanel.prototype.__proto__ = WebInspector.Panel.prototype; |
429 | 461 |
430 WebInspector.ProfileSidebarTreeElement = function(profile) | 462 WebInspector.ProfileSidebarTreeElement = function(profile) |
431 { | 463 { |
432 this.profile = profile; | 464 this.profile = profile; |
433 | 465 |
434 if (this.profile.title.indexOf(UserInitiatedProfileName) === 0) | 466 if (this.profile.title.indexOf(UserInitiatedProfileName) === 0) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 525 } |
494 | 526 |
495 WebInspector.ProfileGroupSidebarTreeElement.prototype = { | 527 WebInspector.ProfileGroupSidebarTreeElement.prototype = { |
496 onselect: function() | 528 onselect: function() |
497 { | 529 { |
498 WebInspector.panels.profiles.showProfile(this.children[this.children.len
gth - 1].profile); | 530 WebInspector.panels.profiles.showProfile(this.children[this.children.len
gth - 1].profile); |
499 } | 531 } |
500 } | 532 } |
501 | 533 |
502 WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.S
idebarTreeElement.prototype; | 534 WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.S
idebarTreeElement.prototype; |
OLD | NEW |