forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1077458-waterfall-view-perf.patch
1101 lines (1040 loc) · 36.6 KB
/
1077458-waterfall-view-perf.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From bceb8a2295e08eb53858850196549765930b61e7 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Tue, 2 Dec 2014 19:51:39 -0800
Subject: Bug 1077458 - Implement marker's waterfall view in new performance tool, with details view toggling between waterfall and call tree views. r=vp
diff --git a/browser/devtools/jar.mn b/browser/devtools/jar.mn
index b899990..55c1c44 100644
--- a/browser/devtools/jar.mn
+++ b/browser/devtools/jar.mn
@@ -88,16 +88,17 @@ browser.jar:
content/browser/devtools/ui-profile.js (profiler/ui-profile.js)
#ifdef MOZ_DEVTOOLS_PERFTOOLS
content/browser/devtools/performance.xul (performance/performance.xul)
content/browser/devtools/performance/controller.js (performance/controller.js)
content/browser/devtools/performance/views/main.js (performance/views/main.js)
content/browser/devtools/performance/views/overview.js (performance/views/overview.js)
content/browser/devtools/performance/views/details.js (performance/views/details.js)
content/browser/devtools/performance/views/call-tree.js (performance/views/call-tree.js)
+ content/browser/devtools/performance/views/waterfall.js (performance/views/waterfall.js)
#endif
content/browser/devtools/responsivedesign/resize-commands.js (responsivedesign/resize-commands.js)
content/browser/devtools/commandline.css (commandline/commandline.css)
content/browser/devtools/commandlineoutput.xhtml (commandline/commandlineoutput.xhtml)
content/browser/devtools/commandlinetooltip.xhtml (commandline/commandlinetooltip.xhtml)
content/browser/devtools/commandline/commands-index.js (commandline/commands-index.js)
content/browser/devtools/framework/toolbox-window.xul (framework/toolbox-window.xul)
content/browser/devtools/framework/toolbox-options.xul (framework/toolbox-options.xul)
diff --git a/browser/devtools/performance/controller.js b/browser/devtools/performance/controller.js
index b18b6e2..c5e6007 100644
--- a/browser/devtools/performance/controller.js
+++ b/browser/devtools/performance/controller.js
@@ -18,16 +18,20 @@ devtools.lazyRequireGetter(this, "EventEmitter",
devtools.lazyRequireGetter(this, "DevToolsUtils",
"devtools/toolkit/DevToolsUtils");
devtools.lazyRequireGetter(this, "FramerateFront",
"devtools/server/actors/framerate", true);
devtools.lazyRequireGetter(this, "L10N",
"devtools/profiler/global", true);
devtools.lazyImporter(this, "LineGraphWidget",
"resource:///modules/devtools/Graphs.jsm");
+devtools.lazyRequireGetter(this, "Waterfall",
+ "devtools/timeline/waterfall", true);
+devtools.lazyRequireGetter(this, "MarkerDetails",
+ "devtools/timeline/marker-details", true);
devtools.lazyRequireGetter(this, "CallView",
"devtools/profiler/tree-view", true);
devtools.lazyRequireGetter(this, "ThreadNode",
"devtools/profiler/tree-model", true);
// Events emitted by the `PerformanceController`
const EVENTS = {
// When a recording is started or stopped via the controller
@@ -42,18 +46,24 @@ const EVENTS = {
// Emitted by the OverviewView when more data has been rendered
OVERVIEW_RENDERED: "Performance:UI:OverviewRendered",
// Emitted by the OverviewView when a range has been selected in the graphs
OVERVIEW_RANGE_SELECTED: "Performance:UI:OverviewRangeSelected",
// Emitted by the OverviewView when a selection range has been removed
OVERVIEW_RANGE_CLEARED: "Performance:UI:OverviewRangeCleared",
+ // Emitted by the DetailsView when a subview is selected
+ DETAILS_VIEW_SELECTED: "Performance:UI:DetailsViewSelected",
+
// Emitted by the CallTreeView when a call tree has been rendered
- CALL_TREE_RENDERED: "Performance:UI:CallTreeRendered"
+ CALL_TREE_RENDERED: "Performance:UI:CallTreeRendered",
+
+ // Emitted by the WaterfallView when it has been rendered
+ WATERFALL_RENDERED: "Performance:UI:WaterfallRendered"
};
/**
* The current target and the profiler connection, set by this tool's host.
*/
let gToolbox, gTarget, gFront;
/**
@@ -107,41 +117,54 @@ let PerformanceController = {
initialize: function() {
this.startRecording = this.startRecording.bind(this);
this.stopRecording = this.stopRecording.bind(this);
this._onTimelineData = this._onTimelineData.bind(this);
PerformanceView.on(EVENTS.UI_START_RECORDING, this.startRecording);
PerformanceView.on(EVENTS.UI_STOP_RECORDING, this.stopRecording);
gFront.on("ticks", this._onTimelineData);
+ gFront.on("markers", this._onTimelineData);
},
/**
* Remove events handled by the PerformanceController
*/
destroy: function() {
PerformanceView.off(EVENTS.UI_START_RECORDING, this.startRecording);
PerformanceView.off(EVENTS.UI_STOP_RECORDING, this.stopRecording);
+ gFront.off("ticks", this._onTimelineData);
+ gFront.off("markers", this._onTimelineData);
},
/**
* Starts recording with the PerformanceFront. Emits `EVENTS.RECORDING_STARTED`
* when the front is starting to record.
*/
startRecording: Task.async(function *() {
- yield gFront.startRecording();
- this.emit(EVENTS.RECORDING_STARTED);
+ // Save local start time for use with faking the endTime
+ // if not returned from the timeline actor
+ this._localStartTime = performance.now();
+
+ let startTime = this._startTime = yield gFront.startRecording();
+ this.emit(EVENTS.RECORDING_STARTED, startTime);
}),
/**
* Stops recording with the PerformanceFront. Emits `EVENTS.RECORDING_STOPPED`
* when the front stops recording.
*/
stopRecording: Task.async(function *() {
let results = yield gFront.stopRecording();
+ // If `endTime` is not yielded from timeline actor (< Fx36),
+ // fake an endTime
+ if (!results.endTime) {
+ this._endTime = results.endTime = this._startTime + (performance.now() - this._localStartTime);
+ }
+
this.emit(EVENTS.RECORDING_STOPPED, results);
}),
/**
* Fired whenever the gFront emits a ticks, memory, or markers event.
*/
_onTimelineData: function (eventName, ...data) {
this.emit(EVENTS.TIMELINE_DATA, eventName, ...data);
diff --git a/browser/devtools/performance/modules/front.js b/browser/devtools/performance/modules/front.js
index ffd1fda..723008a 100644
--- a/browser/devtools/performance/modules/front.js
+++ b/browser/devtools/performance/modules/front.js
@@ -232,39 +232,45 @@ PerformanceFront.prototype = {
} else {
this._profilingStartTime = currentTime;
this.emit("profiler-already-active");
}
// The timeline actor is target-dependent, so just make sure
// it's recording.
let withMemory = showTimelineMemory();
- yield this._request("timeline", "start", { withTicks: true, withMemory: withMemory });
+
+ // Return start time from timeline actor
+ let startTime = yield this._request("timeline", "start", { withTicks: true, withMemory: withMemory });
+ this._startTime = startTime;
+
+ return { startTime };
}),
/**
* Manually ends the current recording session.
*
* @return object
* A promise that is resolved once recording has stopped,
* with the profiler and timeline data.
*/
stopRecording: Task.async(function*() {
// We'll need to filter out all samples that fall out of current profile's
// range. This is necessary because the profiler is continuously running.
let profilerData = yield this._request("profiler", "getProfile");
filterSamples(profilerData, this._profilingStartTime);
offsetSampleTimes(profilerData, this._profilingStartTime);
- yield this._request("timeline", "stop");
+ let endTime = this._endTime = yield this._request("timeline", "stop");
// Join all the acquired data and return it for outside consumers.
return {
recordingDuration: profilerData.currentTime - this._profilingStartTime,
- profilerData: profilerData
+ profilerData: profilerData,
+ endTime: endTime
};
}),
/**
* Overrides the options sent to the built-in profiler module when activating,
* such as the maximum entries count, the sampling interval etc.
*
* Used in tests and for older backend implementations.
diff --git a/browser/devtools/performance/performance.xul b/browser/devtools/performance/performance.xul
index e475948..a6fbb7d 100644
--- a/browser/devtools/performance/performance.xul
+++ b/browser/devtools/performance/performance.xul
@@ -14,16 +14,17 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://browser/content/devtools/theme-switching.js"/>
<script type="application/javascript" src="performance/controller.js"/>
<script type="application/javascript" src="performance/views/main.js"/>
<script type="application/javascript" src="performance/views/overview.js"/>
<script type="application/javascript" src="performance/views/details.js"/>
<script type="application/javascript" src="performance/views/call-tree.js"/>
+ <script type="application/javascript" src="performance/views/waterfall.js"/>
<vbox class="theme-body" flex="1">
<toolbar id="performance-toolbar" class="devtools-toolbar">
<hbox id="performance-toolbar-controls-recordings" class="devtools-toolbarbutton-group">
<toolbarbutton id="record-button"
class="devtools-toolbarbutton"
tooltiptext="&profilerUI.recordButton.tooltip;"/>
<toolbarbutton id="clear-button"
@@ -39,20 +40,38 @@
</toolbar>
<splitter class="devtools-horizontal-splitter" />
<box id="overview-pane"
class="devtools-responsive-container"
flex="1">
<vbox id="time-framerate" flex="1"/>
</box>
<splitter class="devtools-horizontal-splitter" />
- <box id="details-pane"
+ <toolbar id="details-toolbar" class="devtools-toolbar">
+ <hbox class="devtools-toolbarbutton-group">
+ <toolbarbutton id="select-waterfall-view"
+ class="devtools-toolbarbutton"
+ tooltiptext="waterfall"
+ data-view="waterfall" />
+ <toolbarbutton id="select-calltree-view"
+ class="devtools-toolbarbutton"
+ tooltiptext="calltree"
+ data-view="calltree" />
+ </hbox>
+ </toolbar>
+ <deck id="details-pane"
class="devtools-responsive-container"
flex="1">
- <vbox class="call-tree" flex="1">
+ <hbox id="waterfall-view" flex="1">
+ <vbox id="waterfall-graph" flex="1" />
+ <splitter class="devtools-side-splitter"/>
+ <vbox id="waterfall-details" class="theme-sidebar" width="150" height="150"/>
+ </hbox>
+
+ <vbox id="calltree-view" class="call-tree" flex="1">
<hbox class="call-tree-headers-container">
<label class="plain call-tree-header"
type="duration"
crop="end"
value="&profilerUI.table.totalDuration;"/>
<label class="plain call-tree-header"
type="percentage"
crop="end"
@@ -71,11 +90,11 @@
value="&profilerUI.table.samples;"/>
<label class="plain call-tree-header"
type="function"
crop="end"
value="&profilerUI.table.function;"/>
</hbox>
<vbox class="call-tree-cells-container" flex="1"/>
</vbox>
- </box>
+ </deck>
</vbox>
</window>
diff --git a/browser/devtools/performance/test/browser.ini b/browser/devtools/performance/test/browser.ini
index dff4fc4..6e56842 100644
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -4,16 +4,17 @@ subsuite = devtools
support-files =
doc_simple-test.html
head.js
# Commented out tests are profiler tests
# that need to be moved over to performance tool
[browser_perf-aaa-run-first-leaktest.js]
+[browser_perf-front.js]
[browser_perf-front-basic-timeline-01.js]
[browser_perf-front-basic-profiler-01.js]
# bug 1077464
#[browser_perf-front-profiler-01.js]
[browser_perf-front-profiler-02.js]
[browser_perf-front-profiler-03.js]
[browser_perf-front-profiler-04.js]
# bug 1077464
@@ -27,10 +28,13 @@ support-files =
# bug 1077464
#[browser_perf-shared-connection-04.js]
[browser_perf-data-samples.js]
[browser_perf-data-massaging-01.js]
[browser_perf-ui-recording.js]
[browser_perf-overview-render-01.js]
[browser_perf-overview-render-02.js]
[browser_perf-overview-selection.js]
+
+[browser_perf-details.js]
[browser_perf-details-calltree-render-01.js]
[browser_perf-details-calltree-render-02.js]
+[browser_perf-details-waterfall-render-01.js]
diff --git a/browser/devtools/performance/test/browser_perf-details-waterfall-render-01.js b/browser/devtools/performance/test/browser_perf-details-waterfall-render-01.js
new file mode 100644
index 0000000..571bfe8
--- /dev/null
+++ b/browser/devtools/performance/test/browser_perf-details-waterfall-render-01.js
@@ -0,0 +1,26 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the waterfall view renders content after recording.
+ */
+function spawnTest () {
+ let { panel } = yield initPerformance(SIMPLE_URL);
+ let { EVENTS, WaterfallView } = panel.panelWin;
+
+ yield startRecording(panel);
+
+ yield waitUntil(() => WaterfallView._markers.length);
+
+ let rendered = once(WaterfallView, EVENTS.WATERFALL_RENDERED);
+
+ yield stopRecording(panel);
+
+ yield rendered;
+ ok(true, "WaterfallView rendered after recording is stopped.");
+
+ ok(WaterfallView._markers.length, "WaterfallView contains markers");
+
+ yield teardown(panel);
+ finish();
+}
diff --git a/browser/devtools/performance/test/browser_perf-details.js b/browser/devtools/performance/test/browser_perf-details.js
new file mode 100644
index 0000000..8dfc289
--- /dev/null
+++ b/browser/devtools/performance/test/browser_perf-details.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the details view toggles subviews.
+ */
+function spawnTest () {
+ let { panel } = yield initPerformance(SIMPLE_URL);
+ let { EVENTS, $, DetailsView, document: doc } = panel.panelWin;
+
+ info("views on startup");
+ checkViews(DetailsView, doc, "waterfall");
+
+ // Select calltree view
+ let viewChanged = onceSpread(DetailsView, EVENTS.DETAILS_VIEW_SELECTED);
+ command($("toolbarbutton[data-view='calltree']"));
+ let [_, viewName] = yield viewChanged;
+ is(viewName, "calltree", "DETAILS_VIEW_SELECTED fired with view name");
+ checkViews(DetailsView, doc, "calltree");
+
+ // Select waterfall view
+ viewChanged = onceSpread(DetailsView, EVENTS.DETAILS_VIEW_SELECTED);
+ command($("toolbarbutton[data-view='waterfall']"));
+ [_, viewName] = yield viewChanged;
+ is(viewName, "waterfall", "DETAILS_VIEW_SELECTED fired with view name");
+ checkViews(DetailsView, doc, "waterfall");
+
+
+ yield teardown(panel);
+ finish();
+}
+
+function checkViews (DetailsView, doc, currentView) {
+ for (let viewName in DetailsView.views) {
+ let view = DetailsView.views[viewName].el;
+ let button = doc.querySelector("toolbarbutton[data-view='" + viewName + "']");
+
+ if (viewName === currentView) {
+ ok(!view.getAttribute("hidden"), view + " view displayed");
+ ok(button.getAttribute("checked"), view + " button checked");
+ } else {
+ ok(view.getAttribute("hidden"), view + " view hidden");
+ ok(!button.getAttribute("checked"), view + " button not checked");
+ }
+ }
+}
diff --git a/browser/devtools/performance/test/browser_perf-front.js b/browser/devtools/performance/test/browser_perf-front.js
new file mode 100644
index 0000000..a39a5ba
--- /dev/null
+++ b/browser/devtools/performance/test/browser_perf-front.js
@@ -0,0 +1,27 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test basic functionality of PerformanceFront, emitting start and endtime values
+ */
+
+let WAIT = 1000;
+
+function spawnTest () {
+ let { target, front } = yield initBackend(SIMPLE_URL);
+
+ let { startTime } = yield front.startRecording();
+
+ ok(typeof startTime === "number", "front.startRecording() emits start time");
+
+ yield busyWait(WAIT);
+
+ let { endTime } = yield front.stopRecording();
+
+ ok(typeof endTime === "number", "front.stopRecording() emits end time");
+ ok(endTime > startTime, "endTime is after startTime");
+
+ yield removeTab(target.tab);
+ finish();
+
+}
diff --git a/browser/devtools/performance/test/head.js b/browser/devtools/performance/test/head.js
index b2f9498..25ae10f 100644
--- a/browser/devtools/performance/test/head.js
+++ b/browser/devtools/performance/test/head.js
@@ -206,33 +206,39 @@ function* consoleProfileEnd(connection) {
}
function busyWait(time) {
let start = Date.now();
let stack;
while (Date.now() - start < time) { stack = Components.stack; }
}
-function idleWait(time) {
- return DevToolsUtils.waitForTime(time);
+function command (button) {
+ let ev = button.ownerDocument.createEvent("XULCommandEvent");
+ ev.initCommandEvent("command", true, true, button.ownerDocument.defaultView, 0, false, false, false, false, null);
+ button.dispatchEvent(ev);
+}
+
+function click (win, button) {
+ EventUtils.sendMouseEvent({ type: "click" }, button, win);
}
function* startRecording(panel) {
let win = panel.panelWin;
let clicked = panel.panelWin.PerformanceView.once(win.EVENTS.UI_START_RECORDING);
let started = panel.panelWin.PerformanceController.once(win.EVENTS.RECORDING_STARTED);
let button = win.$("#record-button");
ok(!button.hasAttribute("checked"),
"The record button should not be checked yet.");
ok(!button.hasAttribute("locked"),
"The record button should not be locked yet.");
- EventUtils.sendMouseEvent({ type: "click" }, button, win);
+ click(win, button);
yield clicked;
ok(button.hasAttribute("checked"),
"The record button should now be checked.");
ok(button.hasAttribute("locked"),
"The record button should be locked.");
@@ -250,17 +256,17 @@ function* stopRecording(panel) {
let ended = panel.panelWin.PerformanceController.once(win.EVENTS.RECORDING_STOPPED);
let button = win.$("#record-button");
ok(button.hasAttribute("checked"),
"The record button should already be checked.");
ok(!button.hasAttribute("locked"),
"The record button should not be locked yet.");
- EventUtils.sendMouseEvent({ type: "click" }, button, win);
+ click(win, button);
yield clicked;
ok(!button.hasAttribute("checked"),
"The record button should not be checked.");
ok(button.hasAttribute("locked"),
"The record button should be locked.");
diff --git a/browser/devtools/performance/views/details.js b/browser/devtools/performance/views/details.js
index 4ba01d4..9319c24 100644
--- a/browser/devtools/performance/views/details.js
+++ b/browser/devtools/performance/views/details.js
@@ -1,39 +1,74 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
+const DEFAULT_DETAILS_SUBVIEW = "waterfall";
+
/**
* Details view containing profiler call tree. Manages
* subviews and toggles visibility between them.
*/
let DetailsView = {
/**
+ * Name to index mapping of subviews, used by selecting view.
+ */
+ viewIndexes: {
+ waterfall: 0,
+ calltree: 1
+ },
+
+ /**
* Sets up the view with event binding, initializes
* subviews.
*/
- initialize: function () {
- this.views = {
- callTree: CallTreeView
- };
-
- // Initialize subviews
- return promise.all([
- CallTreeView.initialize()
- ]);
+ initialize: Task.async(function *() {
+ this.el = $("#details-pane");
+
+ this._onViewToggle = this._onViewToggle.bind(this);
+
+ for (let button of $$("toolbarbutton[data-view]", $("#details-toolbar"))) {
+ button.addEventListener("command", this._onViewToggle);
+ }
+
+ yield CallTreeView.initialize();
+ yield WaterfallView.initialize();
+ this.selectView(DEFAULT_DETAILS_SUBVIEW);
+ }),
+
+ /**
+ * Select one of the DetailView's subviews to be rendered,
+ * hiding the others.
+ *
+ * @params {String} selectedView
+ * Name of the view to be shown.
+ */
+ selectView: function (selectedView) {
+ this.el.selectedIndex = this.viewIndexes[selectedView];
+ this.emit(EVENTS.DETAILS_VIEW_SELECTED, selectedView);
+ },
+
+ /**
+ * Called when a view button is clicked.
+ */
+ _onViewToggle: function (e) {
+ this.selectView(e.target.getAttribute("data-view"));
},
/**
* Unbinds events, destroys subviews.
*/
- destroy: function () {
- return promise.all([
- CallTreeView.destroy()
- ]);
- }
+ destroy: Task.async(function *() {
+ for (let button of $$("toolbarbutton[data-view]", $("#details-toolbar"))) {
+ button.removeEventListener("command", this._onViewToggle);
+ }
+
+ yield CallTreeView.destroy();
+ yield WaterfallView.destroy();
+ })
};
/**
* Convenient way of emitting events from the view.
*/
EventEmitter.decorate(DetailsView);
diff --git a/browser/devtools/performance/views/waterfall.js b/browser/devtools/performance/views/waterfall.js
new file mode 100644
index 0000000..9039f12
--- /dev/null
+++ b/browser/devtools/performance/views/waterfall.js
@@ -0,0 +1,116 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+/**
+ * Waterfall view controlled by DetailsView.
+ */
+let WaterfallView = {
+ _startTime: 0,
+ _endTime: 0,
+ _markers: [],
+
+ /**
+ * Sets up the view with event binding.
+ */
+ initialize: Task.async(function *() {
+ this.el = $("#waterfall-view");
+ this._stop = this._stop.bind(this);
+ this._start = this._start.bind(this);
+ this._onTimelineData = this._onTimelineData.bind(this);
+ this._onMarkerSelected = this._onMarkerSelected.bind(this);
+ this._onResize = this._onResize.bind(this);
+
+ this.graph = new Waterfall($("#waterfall-graph"), $("#details-pane"));
+ this.markerDetails = new MarkerDetails($("#waterfall-details"), $("#waterfall-view > splitter"));
+
+ this.graph.on("selected", this._onMarkerSelected);
+ this.graph.on("unselected", this._onMarkerSelected);
+ this.markerDetails.on("resize", this._onResize);
+
+ PerformanceController.on(EVENTS.RECORDING_STARTED, this._start);
+ PerformanceController.on(EVENTS.RECORDING_STOPPED, this._stop);
+ PerformanceController.on(EVENTS.TIMELINE_DATA, this._onTimelineData);
+ yield this.graph.recalculateBounds();
+ }),
+
+ /**
+ * Unbinds events.
+ */
+ destroy: function () {
+ this.graph.off("selected", this._onMarkerSelected);
+ this.graph.off("unselected", this._onMarkerSelected);
+ this.markerDetails.off("resize", this._onResize);
+
+ PerformanceController.off(EVENTS.RECORDING_STARTED, this._start);
+ PerformanceController.off(EVENTS.RECORDING_STOPPED, this._stop);
+ PerformanceController.off(EVENTS.TIMELINE_DATA, this._onTimelineData);
+ },
+
+ render: Task.async(function *() {
+ yield this.graph.recalculateBounds();
+ this.graph.setData(this._markers, this._startTime, this._startTime, this._endTime);
+ this.emit(EVENTS.WATERFALL_RENDERED);
+ }),
+
+ /**
+ * Event handlers
+ */
+
+ /**
+ * Called when recording starts.
+ */
+ _start: function (_, { startTime }) {
+ this._startTime = startTime;
+ this._endTime = startTime;
+ this.graph.clearView();
+ },
+
+ /**
+ * Called when recording stops.
+ */
+ _stop: Task.async(function *(_, { endTime }) {
+ this._endTime = endTime;
+ this._markers = this._markers.sort((a,b) => (a.start > b.start));
+ this.render();
+ }),
+
+ /**
+ * Called when a marker is selected in the waterfall view,
+ * updating the markers detail view.
+ */
+ _onMarkerSelected: function (event, marker) {
+ if (event === "selected") {
+ this.markerDetails.render(marker);
+ }
+ if (event === "unselected") {
+ this.markerDetails.empty();
+ }
+ },
+
+ /**
+ * Called when the marker details view is resized.
+ */
+ _onResize: function () {
+ this.render();
+ },
+
+ /**
+ * Called when the TimelineFront has new data for
+ * framerate, markers or memory, and stores the data
+ * to be plotted subsequently.
+ */
+ _onTimelineData: function (_, eventName, ...data) {
+ if (eventName === "markers") {
+ let [markers, endTime] = data;
+ Array.prototype.push.apply(this._markers, markers);
+ }
+ }
+};
+
+
+/**
+ * Convenient way of emitting events from the view.
+ */
+EventEmitter.decorate(WaterfallView);
diff --git a/browser/devtools/timeline/timeline.js b/browser/devtools/timeline/timeline.js
index 2324f85..73f67c0 100644
--- a/browser/devtools/timeline/timeline.js
+++ b/browser/devtools/timeline/timeline.js
@@ -246,18 +246,18 @@ let TimelineController = {
* Functions handling the timeline frontend view.
*/
let TimelineView = {
/**
* Initialization function, called when the tool is started.
*/
initialize: Task.async(function*() {
this.markersOverview = new MarkersOverview($("#markers-overview"));
- this.waterfall = new Waterfall($("#timeline-waterfall"));
- this.markerDetails = new MarkerDetails($("#timeline-waterfall-details"));
+ this.waterfall = new Waterfall($("#timeline-waterfall"), $("#timeline-pane"));
+ this.markerDetails = new MarkerDetails($("#timeline-waterfall-details"), $("#timeline-waterfall-container > splitter"));
this._onSelecting = this._onSelecting.bind(this);
this._onRefresh = this._onRefresh.bind(this);
this.markersOverview.on("selecting", this._onSelecting);
this.markersOverview.on("refresh", this._onRefresh);
this.markerDetails.on("resize", this._onRefresh);
this._onMarkerSelected = this._onMarkerSelected.bind(this);
@@ -268,18 +268,20 @@ let TimelineView = {
yield this.waterfall.recalculateBounds();
}),
/**
* Destruction function, called when the tool is closed.
*/
destroy: function() {
this.markerDetails.off("resize", this._onRefresh);
+ this.markerDetails.destroy();
this.waterfall.off("selected", this._onMarkerSelected);
this.waterfall.off("unselected", this._onMarkerSelected);
+ this.waterfall.destroy();
this.markersOverview.off("selecting", this._onSelecting);
this.markersOverview.off("refresh", this._onRefresh);
this.markersOverview.destroy();
// The memory overview graph is not always available.
if (this.memoryOverview) {
this.memoryOverview.destroy();
}
diff --git a/browser/devtools/timeline/widgets/marker-details.js b/browser/devtools/timeline/widgets/marker-details.js
index 4972350..01cb442 100644
--- a/browser/devtools/timeline/widgets/marker-details.js
+++ b/browser/devtools/timeline/widgets/marker-details.js
@@ -17,29 +17,32 @@ loader.lazyRequireGetter(this, "TIMELINE_BLUEPRINT",
loader.lazyRequireGetter(this, "EventEmitter",
"devtools/toolkit/event-emitter");
/**
* A detailed view for one single marker.
*
* @param nsIDOMNode parent
* The parent node holding the view.
+ * @param nsIDOMNode splitter
+ * The splitter node that the resize event is bound to.
*/
-function MarkerDetails(parent) {
+function MarkerDetails(parent, splitter) {
EventEmitter.decorate(this);
this._document = parent.ownerDocument;
this._parent = parent;
- this._splitter = this._document.querySelector("#timeline-waterfall-container > splitter");
+ this._splitter = splitter;
this._splitter.addEventListener("mouseup", () => this.emit("resize"));
}
MarkerDetails.prototype = {
destroy: function() {
this.empty();
this._parent = null;
+ this._splitter = null;
},
/**
* Clears the view.
*/
empty: function() {
this._parent.innerHTML = "";
},
diff --git a/browser/devtools/timeline/widgets/waterfall.js b/browser/devtools/timeline/widgets/waterfall.js
index d0839ba..951d0e3 100644
--- a/browser/devtools/timeline/widgets/waterfall.js
+++ b/browser/devtools/timeline/widgets/waterfall.js
@@ -43,21 +43,24 @@ const WATERFALL_MARKER_BAR_WIDTH_MIN = 5; // px
const WATERFALL_ROWCOUNT_ONPAGEUPDOWN = 10;
/**
* A detailed waterfall view for the timeline data.
*
* @param nsIDOMNode parent
* The parent node holding the waterfall.
+ * @param nsIDOMNode container
+ * The container node that key events should be bound to.
*/
-function Waterfall(parent) {
+function Waterfall(parent, container) {
EventEmitter.decorate(this);
this._parent = parent;
this._document = parent.ownerDocument;
+ this._container = container;
this._fragment = this._document.createDocumentFragment();
this._outstandingMarkers = [];
this._headerContents = this._document.createElement("hbox");
this._headerContents.className = "waterfall-header-contents";
this._parent.appendChild(this._headerContents);
this._listContents = this._document.createElement("vbox");
@@ -73,19 +76,25 @@ function Waterfall(parent) {
this._l10n = L10N;
this._blueprint = TIMELINE_BLUEPRINT;
this._setNamedTimeout = setNamedTimeout;
this._clearNamedTimeout = clearNamedTimeout;
// Selected row index. By default, we want the first
// row to be selected.
this._selectedRowIdx = 0;
+
+ // Default rowCount
+ this.rowCount = WATERFALL_ROWCOUNT_ONPAGEUPDOWN;
}
Waterfall.prototype = {
+ destroy: function() {
+ this._parent = this._document = this._container = null;
+ },
/**
* Populates this view with the provided data source.
*
* @param array markers
* A list of markers received from the controller.
* @param number timeEpoch
* The absolute time (in milliseconds) when the recording started.
* @param number startTime
@@ -105,17 +114,17 @@ Waterfall.prototype = {
this._buildMarkers(this._listContents, markers, startTime, endTime, dataScale);
this.selectRow(this._selectedRowIdx);
},
/**
* Keybindings.
*/
setupKeys: function() {
- let pane = this._document.querySelector("#timeline-pane");
+ let pane = this._container;
pane.parentNode.parentNode.addEventListener("keydown", e => {
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_UP) {
e.preventDefault();
this.selectNearestRow(this._selectedRowIdx - 1);
}
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_DOWN) {
e.preventDefault();
this.selectNearestRow(this._selectedRowIdx + 1);
@@ -125,21 +134,21 @@ Waterfall.prototype = {
this.selectNearestRow(0);
}
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_END) {
e.preventDefault();
this.selectNearestRow(this._listContents.children.length);
}
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_PAGE_UP) {
e.preventDefault();
- this.selectNearestRow(this._selectedRowIdx - WATERFALL_ROWCOUNT_ONPAGEUPDOWN);
+ this.selectNearestRow(this._selectedRowIdx - this.rowCount);
}
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_PAGE_DOWN) {
e.preventDefault();
- this.selectNearestRow(this._selectedRowIdx + WATERFALL_ROWCOUNT_ONPAGEUPDOWN);
+ this.selectNearestRow(this._selectedRowIdx + this.rowCount);
}
}, true);
},
/**
* Depopulates this view.
*/
clearView: function() {
diff --git a/browser/themes/shared/devtools/performance.inc.css b/browser/themes/shared/devtools/performance.inc.css
index c059b81..28a18e5 100644
--- a/browser/themes/shared/devtools/performance.inc.css
+++ b/browser/themes/shared/devtools/performance.inc.css
@@ -28,16 +28,27 @@
#record-button[checked] {
list-style-image: url(profiler-stopwatch-checked.svg);
}
#record-button[locked] {
pointer-events: none;
}
+/* Details Panel */
+
+#select-waterfall-view {
+ list-style-image: url(performance-icons.svg#waterfall);
+}
+
+#select-calltree-view {
+ list-style-image: url(performance-icons.svg#call-tree);
+}
+
+
/* Profile call tree */
.theme-dark .call-tree-headers-container {
border-top: 1px solid #000;
}
.theme-light .call-tree-headers-container {
border-top: 1px solid #aaa;
@@ -250,8 +261,153 @@
.call-tree-item:hover .call-tree-zoom:hover {
opacity: 0;
}
.call-tree-category {
transform: scale(0.75);
transform-origin: center right;
}
+
+/**
+ * Details Waterfall Styles
+ */
+
+.waterfall-list-contents {
+ /* Hack: force hardware acceleration */
+ transform: translateZ(1px);
+ overflow-x: hidden;
+ overflow-y: auto;
+}
+
+.waterfall-header-contents {
+ overflow-x: hidden;
+}
+
+.waterfall-background-ticks {
+ /* Background created on a <canvas> in js. */
+ /* @see browser/devtools/timeline/widgets/waterfall.js */
+ background-image: -moz-element(#waterfall-background);
+ background-repeat: repeat-y;
+ background-position: -1px center;
+}
+
+.waterfall-marker-container[is-spacer] {
+ pointer-events: none;
+}
+
+.theme-dark .waterfall-marker-container:not([is-spacer]):nth-child(2n) {
+ background-color: rgba(255,255,255,0.03);
+}
+
+.theme-light .waterfall-marker-container:not([is-spacer]):nth-child(2n) {
+ background-color: rgba(128,128,128,0.03);
+}
+
+.theme-dark .waterfall-marker-container:hover {
+ background-color: rgba(255,255,255,0.1) !important;
+}
+
+.theme-light .waterfall-marker-container:hover {
+ background-color: rgba(128,128,128,0.1) !important;
+}
+
+.waterfall-marker-item {
+ overflow: hidden;
+}
+
+.waterfall-sidebar {
+ -moz-border-end: 1px solid;
+}
+
+.theme-dark .waterfall-sidebar {
+ -moz-border-end-color: #000;
+}
+
+.theme-light .waterfall-sidebar {
+ -moz-border-end-color: #aaa;
+}
+
+.waterfall-marker-container:hover > .waterfall-sidebar {
+ background-color: transparent;
+}
+
+.waterfall-header-name {
+ padding: 4px;
+}
+
+.waterfall-header-tick {
+ width: 100px;
+ font-size: 9px;
+ transform-origin: left center;
+}
+
+.theme-dark .waterfall-header-tick {
+ color: #a9bacb;
+}