~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
    this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
57
57
 
 
58
    this.profilesListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("CPU PROFILES"), null, true);
 
59
    this.sidebarTree.appendChild(this.profilesListTreeElement);
 
60
    this.profilesListTreeElement.expand();
 
61
 
 
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();
 
66
    }
 
67
 
58
68
    this.profileViews = document.createElement("div");
59
69
    this.profileViews.id = "profile-views";
60
70
    this.element.appendChild(this.profileViews);
61
71
 
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);
65
74
 
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);
71
77
 
72
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(this), false);
 
83
 
74
84
    this.profileViewStatusBarItemsContainer = document.createElement("div");
75
85
    this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items";
76
86
 
87
97
 
88
98
    get statusBarItems()
89
99
    {
90
 
        return [this.enableToggleButton, this.recordButton, this.profileViewStatusBarItemsContainer];
 
100
        return [this.enableToggleButton.element, this.recordButton.element, this.snapshotButton.element, this.profileViewStatusBarItemsContainer];
91
101
    },
92
102
 
93
103
    show: function()
137
147
 
138
148
        this.sidebarTreeElement.removeStyleClass("some-expandable");
139
149
 
140
 
        this.sidebarTree.removeChildren();
 
150
        this.profilesListTreeElement.removeChildren();
 
151
        this.snapshotsListTreeElement.removeChildren();
141
152
        this.profileViews.removeChildren();
142
153
 
143
154
        this.profileViewStatusBarItemsContainer.removeChildren();
155
166
        this._profiles.push(profile);
156
167
        this._profilesIdMap[profile.uid] = profile;
157
168
 
158
 
        var sidebarParent = this.sidebarTree;
 
169
        var sidebarParent = this.profilesListTreeElement;
159
170
        var small = false;
160
171
        var alternateTitle;
161
172
 
218
229
        view.show(this.profileViews);
219
230
 
220
231
        profile._profilesTreeElement.select(true);
221
 
        profile._profilesTreeElement.reveal()
 
232
        profile._profilesTreeElement.reveal();
222
233
 
223
234
        this.visibleView = view;
224
235
 
231
242
 
232
243
    showView: function(view)
233
244
    {
234
 
        // Always use the treeProfile, since the heavy profile might be showing.
235
 
        this.showProfile(view.profile.treeProfile);
 
245
        this.showProfile(view.profile);
236
246
    },
237
247
 
238
248
    profileViewForProfile: function(profile)
267
277
 
268
278
            groupNumber = ++this._profileGroupsForLinks[title];
269
279
 
270
 
            if (groupNumber >= 2)
271
 
                title += " " + WebInspector.UIString("Run %d", groupNumber);
 
280
            if (groupNumber > 2)
 
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);
272
284
        }
273
285
        
274
286
        return title;
295
307
 
296
308
    searchMatchFound: function(view, matches)
297
309
    {
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;
300
311
    },
301
312
 
302
313
    searchCanceled: function(startingNewSearch)
317
328
        this.recording = isProfiling;
318
329
 
319
330
        if (isProfiling) {
320
 
            this.recordButton.addStyleClass("toggled-on");
 
331
            this.recordButton.toggled = true;
321
332
            this.recordButton.title = WebInspector.UIString("Stop profiling.");
322
333
        } else {
323
 
            this.recordButton.removeStyleClass("toggled-on");
 
334
            this.recordButton.toggled = false;
324
335
            this.recordButton.title = WebInspector.UIString("Start profiling.");
325
336
        }
326
337
    },
 
338
    
 
339
    resize: function()
 
340
    {
 
341
        var visibleView = this.visibleView;
 
342
        if (visibleView && "resize" in visibleView)
 
343
            visibleView.resize();
 
344
    },
327
345
 
328
346
    _updateInterface: function()
329
347
    {
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;
336
356
        } else {
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;
342
363
        }
352
373
            InspectorController.stopProfiling();
353
374
    },
354
375
 
 
376
    _snapshotClicked: function()
 
377
    {
 
378
        InspectorController.takeHeapSnapshot();
 
379
    },
 
380
 
355
381
    _enableProfiling: function()
356
382
    {
357
383
        if (InspectorController.profilerEnabled())
358
384
            return;
359
 
        this._toggleProfiling();
 
385
        this._toggleProfiling(this.panelEnablerView.alwaysEnabled);
360
386
    },
361
387
 
362
 
    _toggleProfiling: function()
 
388
    _toggleProfiling: function(optionalAlways)
363
389
    {
364
390
        if (InspectorController.profilerEnabled())
365
 
            InspectorController.disableProfiler();
 
391
            InspectorController.disableProfiler(true);
366
392
        else
367
 
            InspectorController.enableProfiler();
 
393
            InspectorController.enableProfiler(!!optionalAlways);
368
394
    },
369
395
 
370
396
    _populateProfiles: function()
371
397
    {
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)
373
402
            return;
374
403
 
375
404
        var profiles = InspectorController.profiles();
379
408
            this.addProfile(profile);
380
409
        }
381
410
 
382
 
        if (this.sidebarTree.children[0])
383
 
            this.sidebarTree.children[0].select();
 
411
        if (cpuProfiles.children[0])
 
412
            cpuProfiles.children[0].select();
384
413
 
385
414
        delete this._shouldPopulateProfiles;
386
415
    },
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";
 
456
        
 
457
        var visibleView = this.visibleView;
 
458
        if (visibleView && "resize" in visibleView)
 
459
            visibleView.resize();
427
460
    }
428
461
}
429
462