forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1055217-bypass-audio-nodes.patch
1491 lines (1387 loc) · 56.9 KB
/
1055217-bypass-audio-nodes.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 8e60e93ae0c4ea29d134ee6df2d763125c6654b8 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Thu, 15 Jan 2015 18:30:42 -0800
Subject: Bug 1055217 - Add front end for bypassing audio nodes in the
web audio editor. r=vp
diff --git a/browser/devtools/webaudioeditor/controller.js b/browser/devtools/webaudioeditor/controller.js
index 79d2105..4232c18 100644
--- a/browser/devtools/webaudioeditor/controller.js
+++ b/browser/devtools/webaudioeditor/controller.js
@@ -36,17 +36,17 @@ function shutdownWebAudioEditor() {
/**
* Functions handling target-related lifetime events.
*/
let WebAudioEditorController = {
/**
* Listen for events emitted by the current tab target.
*/
- initialize: function() {
+ initialize: Task.async(function* () {
telemetry.toolOpened("webaudioeditor");
this._onTabNavigated = this._onTabNavigated.bind(this);
this._onThemeChange = this._onThemeChange.bind(this);
gTarget.on("will-navigate", this._onTabNavigated);
gTarget.on("navigate", this._onTabNavigated);
gFront.on("start-context", this._onStartContext);
gFront.on("create-node", this._onCreateNode);
@@ -55,17 +55,20 @@ let WebAudioEditorController = {
gFront.on("disconnect-node", this._onDisconnectNode);
gFront.on("change-param", this._onChangeParam);
gFront.on("destroy-node", this._onDestroyNode);
// Hook into theme change so we can change
// the graph's marker styling, since we can't do this
// with CSS
gDevTools.on("pref-changed", this._onThemeChange);
- },
+
+ // Store the AudioNode definitions from the WebAudioFront
+ AUDIO_NODE_DEFINITION = yield gFront.getDefinition();
+ }),
/**
* Remove events emitted by the current tab target.
*/
destroy: function() {
telemetry.toolClosed("webaudioeditor");
gTarget.off("will-navigate", this._onTabNavigated);
gTarget.off("navigate", this._onTabNavigated);
diff --git a/browser/devtools/webaudioeditor/includes.js b/browser/devtools/webaudioeditor/includes.js
index db84a68..2e6b8ec 100644
--- a/browser/devtools/webaudioeditor/includes.js
+++ b/browser/devtools/webaudioeditor/includes.js
@@ -10,26 +10,31 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
const devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
const { require } = devtools;
let { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
let { EventTarget } = require("sdk/event/target");
+
const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
const { Class } = require("sdk/core/heritage");
const EventEmitter = require("devtools/toolkit/event-emitter");
const STRINGS_URI = "chrome://browser/locale/devtools/webaudioeditor.properties"
const L10N = new ViewHelpers.L10N(STRINGS_URI);
const Telemetry = require("devtools/shared/telemetry");
const telemetry = new Telemetry();
devtools.lazyImporter(this, "LineGraphWidget",
"resource:///modules/devtools/Graphs.jsm");
+// `AUDIO_NODE_DEFINITION` defined in the controller's initialization,
+// which describes all the properties of an AudioNode
+let AUDIO_NODE_DEFINITION;
+
// Override DOM promises with Promise.jsm helpers
const { defer, all } = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
/* Events fired on `window` to indicate state or actions*/
const EVENTS = {
// Fired when the first AudioNode has been created, signifying
// that the AudioContext is being used and should be tracked via the editor.
START_CONTEXT: "WebAudioEditor:StartContext",
diff --git a/browser/devtools/webaudioeditor/models.js b/browser/devtools/webaudioeditor/models.js
index 142a338..aa1975f 100644
--- a/browser/devtools/webaudioeditor/models.js
+++ b/browser/devtools/webaudioeditor/models.js
@@ -30,16 +30,22 @@ const AudioNodeModel = Class({
/**
* After instantiating the AudioNodeModel, calling `setup` caches values
* from the actor onto the model. In this case, only the type of audio node.
*
* @return promise
*/
setup: Task.async(function* () {
yield this.getType();
+
+ // Query bypass status on start up
+ this._bypassed = yield this.isBypassed();
+
+ // Store whether or not this node is bypassable in the first place
+ this.bypassable = !AUDIO_NODE_DEFINITION[this.type].unbypassable;
}),
/**
* A proxy for the underlying AudioNodeActor to fetch its type
* and subsequently assign the type to the instance.
*
* @return Promise->String
*/
@@ -71,16 +77,36 @@ const AudioNodeModel = Class({
* Clears out all internal connection data. Emits "disconnect" event.
*/
disconnect: function () {
this.connections.length = 0;
coreEmit(this, "disconnect", this);
},
/**
+ * Gets the bypass status of the audio node.
+ *
+ * @return Promise->Boolean
+ */
+ isBypassed: function () {
+ return this.actor.isBypassed();
+ },
+
+ /**
+ * Sets the bypass value of an AudioNode.
+ *
+ * @param Boolean enable
+ * @return Promise
+ */
+ bypass: function (enable) {
+ this._bypassed = enable;
+ return this.actor.bypass(enable).then(() => coreEmit(this, "bypass", this, enable));
+ },
+
+ /**
* Returns a promise that resolves to an array of objects containing
* both a `param` name property and a `value` property.
*
* @return Promise->Object
*/
getParams: function () {
return this.actor.getParams();
},
@@ -101,17 +127,18 @@ const AudioNodeModel = Class({
* the graph to be rendered.
*
* @param dagreD3.Digraph
*/
addToGraph: function (graph) {
graph.addNode(this.id, {
type: this.type,
label: this.type.replace(/Node$/, ""),
- id: this.id
+ id: this.id,
+ bypassed: this._bypassed
});
},
/**
* Takes a `dagreD3.Digraph` object and adds edges to
* the graph to be rendered. Separate from `addToGraph`,
* as while we depend on D3/Dagre's constraints, we cannot
* add edges for nodes that have not yet been added to the graph.
@@ -274,12 +301,12 @@ const AudioNodesCollection = Class({
_onModelEvent: function (eventName, node, ...args) {
if (eventName === "remove") {
// If a `remove` event from the model, remove it
// from the collection, and let the method handle the emitting on
// the collection
this.remove(node);
} else {
// Pipe the event to the collection
- coreEmit(this, eventName, [node].concat(args));
+ coreEmit(this, eventName, node, ...args);
}
}
});
diff --git a/browser/devtools/webaudioeditor/test/browser.ini b/browser/devtools/webaudioeditor/test/browser.ini
index 3012b7e..1b959d8 100644
--- a/browser/devtools/webaudioeditor/test/browser.ini
+++ b/browser/devtools/webaudioeditor/test/browser.ini
@@ -47,16 +47,17 @@ support-files =
[browser_wa_graph-render-03.js]
[browser_wa_graph-render-04.js]
[browser_wa_graph-render-05.js]
[browser_wa_graph-selected.js]
[browser_wa_graph-zoom.js]
[browser_wa_inspector.js]
[browser_wa_inspector-toggle.js]
+[browser_wa_inspector-bypass-01.js]
[browser_wa_properties-view.js]
[browser_wa_properties-view-edit-01.js]
skip-if = true # bug 1010423
[browser_wa_properties-view-edit-02.js]
skip-if = true # bug 1010423
[browser_wa_properties-view-media-nodes.js]
[browser_wa_properties-view-params.js]
diff --git a/browser/devtools/webaudioeditor/test/browser_audionode-actor-bypass.js b/browser/devtools/webaudioeditor/test/browser_audionode-actor-bypass.js
index 6b1606b..57ce888 100644
--- a/browser/devtools/webaudioeditor/test/browser_audionode-actor-bypass.js
+++ b/browser/devtools/webaudioeditor/test/browser_audionode-actor-bypass.js
@@ -10,19 +10,27 @@ add_task(function*() {
let [_, [destNode, oscNode, gainNode]] = yield Promise.all([
front.setup({ reload: true }),
get3(front, "create-node")
]);
is((yield gainNode.isBypassed()), false, "Nodes start off unbypassed.");
info("Calling node#bypass(true)");
- yield gainNode.bypass(true);
+ let isBypassed = yield gainNode.bypass(true);
+ is(isBypassed, true, "node.bypass(true) resolves to true");
is((yield gainNode.isBypassed()), true, "Node is now bypassed.");
info("Calling node#bypass(false)");
- yield gainNode.bypass(false);
+ isBypassed = yield gainNode.bypass(false);
+ is(isBypassed, false, "node.bypass(false) resolves to false");
is((yield gainNode.isBypassed()), false, "Node back to being unbypassed.");
+ info("Calling node#bypass(true) on unbypassable node");
+ isBypassed = yield destNode.bypass(true);
+
+ is(isBypassed, false, "node.bypass(true) resolves to false for unbypassable node");
+ is((yield gainNode.isBypassed()), false, "Unbypassable node is unaffect");
+
yield removeTab(target.tab);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js b/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js
index d211e1b..59aaf27 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js
@@ -15,41 +15,42 @@ add_task(function*() {
reload(target);
let [actors] = yield Promise.all([
get3(gFront, "create-node"),
waitForGraphRendered(panelWin, 3, 2)
]);
let nodeIds = actors.map(actor => actor.actorID);
+ let $tabbox = $("#web-audio-editor-tabs");
// Oscillator node
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
yield waitForInspectorRender(panelWin, EVENTS);
- click(panelWin, $("#automation-tab"));
+ $tabbox.selectedIndex = 1;
ok(isVisible($("#automation-graph-container")), "graph container should be visible");
ok(isVisible($("#automation-content")), "automation content should be visible");
ok(!isVisible($("#automation-no-events")), "no-events panel should not be visible");
ok(!isVisible($("#automation-empty")), "empty panel should not be visible");
// Gain node
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
yield waitForInspectorRender(panelWin, EVENTS);
- click(panelWin, $("#automation-tab"));
+ $tabbox.selectedIndex = 1;
- ok(!isVisible($("#automation-graph-container")), "graph container should be visible");
- ok(isVisible($("#automation-content")), "automation content should not be visible");
+ ok(!isVisible($("#automation-graph-container")), "graph container should not be visible");
+ ok(isVisible($("#automation-content")), "automation content should be visible");
ok(isVisible($("#automation-no-events")), "no-events panel should be visible");
ok(!isVisible($("#automation-empty")), "empty panel should not be visible");
// destination node
click(panelWin, findGraphNode(panelWin, nodeIds[0]));
yield waitForInspectorRender(panelWin, EVENTS);
- click(panelWin, $("#automation-tab"));
+ $tabbox.selectedIndex = 1;
ok(!isVisible($("#automation-graph-container")), "graph container should not be visible");
ok(!isVisible($("#automation-content")), "automation content should not be visible");
ok(!isVisible($("#automation-no-events")), "no-events panel should not be visible");
ok(isVisible($("#automation-empty")), "empty panel should be visible");
yield teardown(target);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_inspector-bypass-01.js b/browser/devtools/webaudioeditor/test/browser_wa_inspector-bypass-01.js
new file mode 100644
index 0000000..b6c2a06
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/browser_wa_inspector-bypass-01.js
@@ -0,0 +1,67 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that nodes are correctly bypassed when bypassing.
+ */
+
+add_task(function*() {
+ let { target, panel } = yield initWebAudioEditor(SIMPLE_CONTEXT_URL);
+ let { panelWin } = panel;
+ let { gFront, $, $$, EVENTS, gAudioNodes } = panelWin;
+
+ reload(target);
+
+ let [actors] = yield Promise.all([
+ get3(gFront, "create-node"),
+ waitForGraphRendered(panelWin, 3, 2)
+ ]);
+ let nodeIds = actors.map(actor => actor.actorID);
+
+ click(panelWin, findGraphNode(panelWin, nodeIds[1]));
+ // Wait for the node to be set as well as the inspector to come fully into the view
+ yield Promise.all([
+ waitForInspectorRender(panelWin, EVENTS),
+ once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED)
+ ]);
+
+ let $bypass = $("toolbarbutton.bypass");
+
+ is((yield actors[1].isBypassed()), false, "AudioNodeActor is not bypassed by default.")
+ is($bypass.checked, true, "Button is 'on' for normal nodes");
+ is($bypass.disabled, false, "Bypass button is not disabled for normal nodes");
+
+ command($bypass);
+ yield gAudioNodes.once("bypass");
+
+ is((yield actors[1].isBypassed()), true, "AudioNodeActor is bypassed.")
+ is($bypass.checked, false, "Button is 'off' when clicked");
+ is($bypass.disabled, false, "Bypass button is not disabled after click");
+ ok(findGraphNode(panelWin, nodeIds[1]).classList.contains("bypassed"),
+ "AudioNode has 'bypassed' class.");
+
+ command($bypass);
+ yield gAudioNodes.once("bypass");
+
+ is((yield actors[1].isBypassed()), false, "AudioNodeActor is no longer bypassed.")
+ is($bypass.checked, true, "Button is back on when clicked");
+ is($bypass.disabled, false, "Bypass button is not disabled after click");
+ ok(!findGraphNode(panelWin, nodeIds[1]).classList.contains("bypassed"),
+ "AudioNode no longer has 'bypassed' class.");
+
+ click(panelWin, findGraphNode(panelWin, nodeIds[0]));
+
+ yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+
+ is((yield actors[0].isBypassed()), false, "Unbypassable AudioNodeActor is not bypassed.");
+ is($bypass.checked, false, "Button is 'off' for unbypassable nodes");
+ is($bypass.disabled, true, "Bypass button is disabled for unbypassable nodes");
+
+ command($bypass);
+ is((yield actors[0].isBypassed()), false,
+ "Clicking button on unbypassable node does not change bypass state on actor.");
+ is($bypass.checked, false, "Button is still 'off' for unbypassable nodes");
+ is($bypass.disabled, true, "Bypass button is still disabled for unbypassable nodes");
+
+ yield teardown(target);
+});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js b/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js
index 917d00f..95d737e 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js
@@ -29,18 +29,16 @@ add_task(function*() {
yield once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED);
ok(InspectorView.isVisible(), "InspectorView shown after toggling.");
ok(isVisible($("#web-audio-editor-details-pane-empty")),
"InspectorView empty message should still be visible.");
ok(!isVisible($("#web-audio-editor-tabs")),
"InspectorView tabs view should still be hidden.");
- is($("#web-audio-inspector-title").value, "AudioNode Inspector",
- "Inspector should still have default title.");
// Close inspector pane
$("#inspector-pane-toggle").click();
yield once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED);
ok(!InspectorView.isVisible(), "InspectorView back to being hidden.");
// Open again to test node loading while open
@@ -54,13 +52,11 @@ add_task(function*() {
let nodeSet = once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
yield nodeSet;
ok(!isVisible($("#web-audio-editor-details-pane-empty")),
"Empty message hides even when loading node while open.");
ok(isVisible($("#web-audio-editor-tabs")),
"Switches to tab view when loading node while open.");
- is($("#web-audio-inspector-title").value, "Oscillator",
- "Inspector title updates when loading node while open.");
yield teardown(target);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_inspector.js b/browser/devtools/webaudioeditor/test/browser_wa_inspector.js
index ed845bc..8804e0a 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_inspector.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_inspector.js
@@ -22,40 +22,32 @@ add_task(function*() {
]);
let nodeIds = actors.map(actor => actor.actorID);
ok(!InspectorView.isVisible(), "InspectorView hidden on start.");
ok(isVisible($("#web-audio-editor-details-pane-empty")),
"InspectorView empty message should show when no node's selected.");
ok(!isVisible($("#web-audio-editor-tabs")),
"InspectorView tabs view should be hidden when no node's selected.");
- is($("#web-audio-inspector-title").value, "AudioNode Inspector",
- "Inspector should have default title when empty.");
// Wait for the node to be set as well as the inspector to come fully into the view
let nodeSet = Promise.all([
once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET),
once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED)
]);
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
yield nodeSet;
ok(InspectorView.isVisible(), "InspectorView shown once node selected.");
ok(!isVisible($("#web-audio-editor-details-pane-empty")),
"InspectorView empty message hidden when node selected.");
ok(isVisible($("#web-audio-editor-tabs")),
"InspectorView tabs view visible when node selected.");
- is($("#web-audio-inspector-title").value, "Oscillator",
- "Inspector should have the node title when a node is selected.");
-
is($("#web-audio-editor-tabs").selectedIndex, 0,
"default tab selected should be the parameters tab.");
nodeSet = once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
yield nodeSet;
- is($("#web-audio-inspector-title").value, "Gain",
- "Inspector title updates when a new node is selected.");
-
yield teardown(target);
});
diff --git a/browser/devtools/webaudioeditor/test/head.js b/browser/devtools/webaudioeditor/test/head.js
index fc9ea9f..9e3c7c0 100644
--- a/browser/devtools/webaudioeditor/test/head.js
+++ b/browser/devtools/webaudioeditor/test/head.js
@@ -313,16 +313,22 @@ function findGraphNode (win, node) {
function click (win, element) {
EventUtils.sendMouseEvent({ type: "click" }, element, win);
}
function mouseOver (win, element) {
EventUtils.sendMouseEvent({ type: "mouseover" }, element, win);
}
+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 isVisible (element) {
return !element.getAttribute("hidden");
}
/**
* Used in debugging, returns a promise that resolves in `n` milliseconds.
*/
function wait (n) {
diff --git a/browser/devtools/webaudioeditor/views/context.js b/browser/devtools/webaudioeditor/views/context.js
index bd3cbf6..f2160ac 100644
--- a/browser/devtools/webaudioeditor/views/context.js
+++ b/browser/devtools/webaudioeditor/views/context.js
@@ -31,39 +31,40 @@ const GRAPH_REDRAW_EVENTS = ["add", "connect", "disconnect", "remove"];
/**
* Functions handling the graph UI.
*/
let ContextView = {
/**
* Initialization function, called when the tool is started.
*/
initialize: function() {
- this._onGraphNodeClick = this._onGraphNodeClick.bind(this);
+ this._onGraphClick = this._onGraphClick.bind(this);
this._onThemeChange = this._onThemeChange.bind(this);
this._onStartContext = this._onStartContext.bind(this);
this._onEvent = this._onEvent.bind(this);
this.draw = debounce(this.draw.bind(this), GRAPH_DEBOUNCE_TIMER);
- $('#graph-target').addEventListener('click', this._onGraphNodeClick, false);
+ $("#graph-target").addEventListener("click", this._onGraphClick, false);
window.on(EVENTS.THEME_CHANGE, this._onThemeChange);
window.on(EVENTS.START_CONTEXT, this._onStartContext);
gAudioNodes.on("*", this._onEvent);
},
/**
* Destruction function, called when the tool is closed.
*/
destroy: function() {
// If the graph was rendered at all, then the handler
// for zooming in will be set. We must remove it to prevent leaks.
if (this._zoomBinding) {
this._zoomBinding.on("zoom", null);
}
- $('#graph-target').removeEventListener('click', this._onGraphNodeClick, false);
+ $("#graph-target").removeEventListener("click", this._onGraphClick, false);
+
window.off(EVENTS.THEME_CHANGE, this._onThemeChange);
window.off(EVENTS.START_CONTEXT, this._onStartContext);
gAudioNodes.off("*", this._onEvent);
},
/**
* Called when a page is reloaded and waiting for a "start-context" event
* and clears out old content
@@ -122,68 +123,68 @@ let ContextView = {
/**
* Takes an actorID and returns the corresponding DOM SVG element in the graph
*/
_getNodeByID: function (actorID) {
return $(".nodes > g[data-id='" + actorID + "']");
},
/**
+ * Sets the appropriate class on an SVG node when its bypass
+ * status is toggled.
+ */
+ _bypassNode: function (node, enabled) {
+ let el = this._getNodeByID(node.id);
+ el.classList[enabled ? "add" : "remove"]("bypassed");
+ },
+
+ /**
* This method renders the nodes currently available in `gAudioNodes` and is
* throttled to be called at most every `GRAPH_DEBOUNCE_TIMER` milliseconds.
* It's called whenever the audio context routing changes, after being debounced.
*/
draw: function () {
// Clear out previous SVG information
this.clearGraph();
let graph = new dagreD3.Digraph();
let renderer = new dagreD3.Renderer();
gAudioNodes.populateGraph(graph);
// Post-render manipulation of the nodes
let oldDrawNodes = renderer.drawNodes();
renderer.drawNodes(function(graph, root) {
let svgNodes = oldDrawNodes(graph, root);
- svgNodes.attr("class", (n) => {
- let node = graph.node(n);
- return "audionode type-" + node.type;
- });
- svgNodes.attr("data-id", (n) => {
+ svgNodes.each(function (n) {
let node = graph.node(n);
- return node.id;
+ let classString = "audionode type-" + node.type + (node.bypassed ? " bypassed" : "");
+ this.setAttribute("class", classString);
+ this.setAttribute("data-id", node.id);
+ this.setAttribute("data-type", node.type);
});
return svgNodes;
});
// Post-render manipulation of edges
- // TODO do all of this more efficiently, rather than
- // using the direct D3 helper utilities to loop over each
- // edge several times
let oldDrawEdgePaths = renderer.drawEdgePaths();
+ let defaultClasses = "edgePath enter";
+
renderer.drawEdgePaths(function(graph, root) {
let svgEdges = oldDrawEdgePaths(graph, root);
- svgEdges.attr("data-source", (n) => {
- let edge = graph.edge(n);
- return edge.source;
- });
- svgEdges.attr("data-target", (n) => {
- let edge = graph.edge(n);
- return edge.target;
- });
- svgEdges.attr("data-param", (n) => {
- let edge = graph.edge(n);
- return edge.param ? edge.param : null;
- });
- // We have to manually specify the default classes on the edges
- // as to not overwrite them
- let defaultClasses = "edgePath enter";
- svgEdges.attr("class", (n) => {
- let edge = graph.edge(n);
- return defaultClasses + (edge.param ? (" param-connection " + edge.param) : "");
+ svgEdges.each(function (e) {
+ let edge = graph.edge(e);
+
+ // We have to manually specify the default classes on the edges
+ // as to not overwrite them
+ let edgeClass = defaultClasses + (edge.param ? (" param-connection " + edge.param) : "");
+
+ this.setAttribute("data-source", edge.source);
+ this.setAttribute("data-target", edge.target);
+ this.setAttribute("data-param", edge.param ? edge.param : null);
+ this.setAttribute("class", edgeClass);
});
return svgEdges;
});
// Override Dagre-d3's post render function by passing in our own.
// This way we can leave styles out of it.
renderer.postRender((graph, root) => {
@@ -258,16 +259,21 @@ let ContextView = {
this.draw();
},
/**
* Called when `gAudioNodes` fires an event -- most events (listed
* in GRAPH_REDRAW_EVENTS) qualify as a redraw event.
*/
_onEvent: function (eventName, ...args) {
+ // If bypassing, just toggle the class on the SVG node
+ // rather than rerendering everything
+ if (eventName === "bypass") {
+ this._bypassNode.apply(this, args);
+ }
if (~GRAPH_REDRAW_EVENTS.indexOf(eventName)) {
this.draw();
}
},
/**
* Fired when the devtools theme changes.
*/
@@ -275,22 +281,22 @@ let ContextView = {
let markerColor = MARKER_STYLING[theme];
let marker = $("#arrowhead");
if (marker) {
marker.setAttribute("style", "fill: " + markerColor);
}
},
/**
- * Fired when a node in the svg graph is clicked. Used to handle triggering the AudioNodePane.
+ * Fired when a click occurs in the graph.
*
* @param Event e
* Click event.
*/
- _onGraphNodeClick: function (e) {
+ _onGraphClick: function (e) {
let node = findGraphNodeParent(e.target);
// If node not found (clicking outside of an audio node in the graph),
// then ignore this event
if (!node)
return;
let id = node.getAttribute("data-id");
diff --git a/browser/devtools/webaudioeditor/views/inspector.js b/browser/devtools/webaudioeditor/views/inspector.js
index 5818f2f..d5d1087 100644
--- a/browser/devtools/webaudioeditor/views/inspector.js
+++ b/browser/devtools/webaudioeditor/views/inspector.js
@@ -38,58 +38,67 @@ let InspectorView = {
this.bindToggle();
// Hide inspector view on startup
this.hideImmediately();
this._onNodeSelect = this._onNodeSelect.bind(this);
this._onDestroyNode = this._onDestroyNode.bind(this);
this._onResize = this._onResize.bind(this);
+ this._onCommandClick = this._onCommandClick.bind(this);
this.splitter.addEventListener("mouseup", this._onResize);
+ for (let $el of $$("#audio-node-toolbar toolbarbutton")) {
+ $el.addEventListener("command", this._onCommandClick);
+ }
window.on(EVENTS.UI_SELECT_NODE, this._onNodeSelect);
gAudioNodes.on("remove", this._onDestroyNode);
},
/**
* Destruction function called when the tool cleans up.
*/
destroy: function () {
this.unbindToggle();
this.splitter.removeEventListener("mouseup", this._onResize);
+
+ $("#audio-node-toolbar toolbarbutton").removeEventListener("command", this._onCommandClick);
+ for (let $el of $$("#audio-node-toolbar toolbarbutton")) {
+ $el.removeEventListener("command", this._onCommandClick);
+ }
window.off(EVENTS.UI_SELECT_NODE, this._onNodeSelect);
gAudioNodes.off("remove", this._onDestroyNode);
this.el = null;
this.button = null;
this.splitter = null;
},
/**
* Takes a AudioNodeView `node` and sets it as the current
* node and scaffolds the inspector view based off of the new node.
*/
- setCurrentAudioNode: function (node) {
+ setCurrentAudioNode: Task.async(function* (node) {
this._currentNode = node || null;
// If no node selected, set the inspector back to "no AudioNode selected"
// view.
if (!node) {
$("#web-audio-editor-details-pane-empty").removeAttribute("hidden");
$("#web-audio-editor-tabs").setAttribute("hidden", "true");
window.emit(EVENTS.UI_INSPECTOR_NODE_SET, null);
}
// Otherwise load up the tabs view and hide the empty placeholder
else {
$("#web-audio-editor-details-pane-empty").setAttribute("hidden", "true");
$("#web-audio-editor-tabs").removeAttribute("hidden");
- this._setTitle();
+ yield this._buildToolbar();
window.emit(EVENTS.UI_INSPECTOR_NODE_SET, this._currentNode.id);
}
- },
+ }),
/**
* Returns the current AudioNodeView.
*/
getCurrentAudioNode: function () {
return this._currentNode;
},
@@ -99,24 +108,35 @@ let InspectorView = {
resetUI: function () {
// Set current node to empty to load empty view
this.setCurrentAudioNode();
// Reset AudioNode inspector and hide
this.hideImmediately();
},
- /**
- * Sets the title of the Inspector view
- */
- _setTitle: function () {
- let node = this._currentNode;
- let title = node.type.replace(/Node$/, "");
- $("#web-audio-inspector-title").setAttribute("value", title);
- },
+ _buildToolbar: Task.async(function* () {
+ let node = this.getCurrentAudioNode();
+
+ let bypassable = node.bypassable;
+ let bypassed = yield node.isBypassed();
+ let button = $("#audio-node-toolbar .bypass");
+
+ if (!bypassable) {
+ button.setAttribute("disabled", true);
+ } else {
+ button.removeAttribute("disabled");
+ }
+
+ if (!bypassable || bypassed) {
+ button.removeAttribute("checked");
+ } else {
+ button.setAttribute("checked", true);
+ }
+ }),
/**
* Event handlers
*/
/**
* Called on EVENTS.UI_SELECT_NODE, and takes an actorID `id`
* and calls `setCurrentAudioNode` to scaffold the inspector view.
@@ -135,10 +155,31 @@ let InspectorView = {
/**
* Called when `DESTROY_NODE` is fired to remove the node from props view if
* it's currently selected.
*/
_onDestroyNode: function (node) {
if (this._currentNode && this._currentNode.id === node.id) {
this.setCurrentAudioNode(null);
}
+ },
+
+ _onCommandClick: function (e) {
+ let node = this.getCurrentAudioNode();
+ let button = e.target;
+ let command = button.getAttribute("data-command");
+ let checked = button.getAttribute("checked");
+
+ if (button.getAttribute("disabled")) {
+ return;
+ }
+
+ if (command === "bypass") {
+ if (checked) {
+ button.removeAttribute("checked");
+ node.bypass(true);
+ } else {
+ button.setAttribute("checked", true);
+ node.bypass(false);
+ }
+ }
}
};
diff --git a/browser/devtools/webaudioeditor/webaudioeditor.xul b/browser/devtools/webaudioeditor/webaudioeditor.xul
index fba415f..68052ec 100644
--- a/browser/devtools/webaudioeditor/webaudioeditor.xul
+++ b/browser/devtools/webaudioeditor/webaudioeditor.xul
@@ -1,17 +1,17 @@
<?xml version="1.0"?>
<!-- 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/. -->
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/content/devtools/widgets.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/devtools/common.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/devtools/widgets.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/devtools/webaudioeditor.css" type="text/css"?>
-<?xml-stylesheet href="chrome://browser/content/devtools/widgets.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % debuggerDTD SYSTEM "chrome://browser/locale/devtools/webaudioeditor.dtd">
%debuggerDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript;version=1.8"
@@ -74,26 +74,30 @@
xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph-target" transform="translate(20,20)"/>
</svg>
</vbox>
</box>
</hbox>
<splitter id="inspector-splitter" class="devtools-side-splitter"/>
<vbox id="web-audio-inspector" hidden="true">
- <hbox class="devtools-toolbar">
- <label id="web-audio-inspector-title" value="&webAudioEditorUI.inspectorTitle;"></label>
- </hbox>
<deck id="web-audio-editor-details-pane" flex="1">
<vbox id="web-audio-editor-details-pane-empty" flex="1">
<label value="&webAudioEditorUI.inspectorEmpty;"></label>
</vbox>
<tabbox id="web-audio-editor-tabs"
class="devtools-sidebar-tabs"
handleCtrlTab="false">
+ <toolbar id="audio-node-toolbar" class="devtools-toolbar">
+ <hbox class="devtools-toolbarbutton-group">
+ <toolbarbutton class="bypass devtools-toolbarbutton"
+ data-command="bypass"
+ tabindex="0"/>
+ </hbox>
+ </toolbar>
<tabs>
<tab id="properties-tab"
label="&webAudioEditorUI.tab.properties;"/>
<tab id="automation-tab"
label="&webAudioEditorUI.tab.automation;"/>
</tabs>
<tabpanels flex="1">
<!-- Properties Panel -->
diff --git a/browser/locales/en-US/chrome/browser/devtools/webaudioeditor.properties b/browser/locales/en-US/chrome/browser/devtools/webaudioeditor.properties
index 8018ec7..0f682e3 100644
--- a/browser/locales/en-US/chrome/browser/devtools/webaudioeditor.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/webaudioeditor.properties
@@ -28,8 +28,12 @@ ToolboxWebAudioEditor1.tooltip=Web Audio context visualizer and audio node inspe
# LOCALIZATION NOTE (collapseInspector): This is the tooltip for the button
# that collapses the inspector in the web audio tool UI.
collapseInspector=Collapse inspector
# LOCALIZATION NOTE (expandInspector): This is the tooltip for the button
# that expands the inspector in the web audio tool UI.
expandInspector=Expand inspector
+# LOCALIZATION NOTE (webAudioEditorTooltipBypass): This is the tooltip for the
+# button that bypasses an AudioNode
+webAudioEditorTooltipBypass=Bypass AudioNode
+
diff --git a/browser/themes/linux/jar.mn b/browser/themes/linux/jar.mn
index eb992a5..5c67954 100644
--- a/browser/themes/linux/jar.mn
+++ b/browser/themes/linux/jar.mn
@@ -224,16 +224,17 @@ browser.jar:
skin/classic/browser/devtools/controls.png (../shared/devtools/images/controls.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
skin/classic/browser/devtools/performance-icons.svg (../shared/devtools/images/performance-icons.svg)
skin/classic/browser/devtools/newtab.png (../shared/devtools/images/newtab.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
skin/classic/browser/devtools/newtab-inverted.png (../shared/devtools/images/newtab-inverted.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
* skin/classic/browser/devtools/widgets.css (devtools/widgets.css)
+ skin/classic/browser/devtools/power.svg (../shared/devtools/images/power.svg)
skin/classic/browser/devtools/filetype-dir-close.svg (../shared/devtools/images/filetypes/dir-close.svg)
skin/classic/browser/devtools/filetype-dir-open.svg (../shared/devtools/images/filetypes/dir-open.svg)
skin/classic/browser/devtools/filetype-globe.svg (../shared/devtools/images/filetypes/globe.svg)
skin/classic/browser/devtools/filetype-store.svg (../shared/devtools/images/filetypes/store.svg)
skin/classic/browser/devtools/commandline-icon.png (../shared/devtools/images/commandline-icon.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
skin/classic/browser/devtools/command-paintflashing.png (../shared/devtools/images/command-paintflashing.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
diff --git a/browser/themes/osx/jar.mn b/browser/themes/osx/jar.mn
index f3932b4..0dc7731 100644
--- a/browser/themes/osx/jar.mn
+++ b/browser/themes/osx/jar.mn
@@ -355,16 +355,17 @@ browser.jar:
skin/classic/browser/devtools/controls.png (../shared/devtools/images/controls.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
skin/classic/browser/devtools/performance-icons.svg (../shared/devtools/images/performance-icons.svg)
skin/classic/browser/devtools/newtab.png (../shared/devtools/images/newtab.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
skin/classic/browser/devtools/newtab-inverted.png (../shared/devtools/images/newtab-inverted.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
* skin/classic/browser/devtools/widgets.css (devtools/widgets.css)
+ skin/classic/browser/devtools/power.svg (../shared/devtools/images/power.svg)
skin/classic/browser/devtools/filetype-dir-close.svg (../shared/devtools/images/filetypes/dir-close.svg)
skin/classic/browser/devtools/filetype-dir-open.svg (../shared/devtools/images/filetypes/dir-open.svg)
skin/classic/browser/devtools/filetype-globe.svg (../shared/devtools/images/filetypes/globe.svg)
skin/classic/browser/devtools/filetype-store.svg (../shared/devtools/images/filetypes/store.svg)
skin/classic/browser/devtools/commandline-icon.png (../shared/devtools/images/commandline-icon.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
skin/classic/browser/devtools/command-paintflashing.png (../shared/devtools/images/command-paintflashing.png)
skin/classic/browser/devtools/[email protected] (../shared/devtools/images/[email protected])
diff --git a/browser/themes/shared/devtools/filters.svg b/browser/themes/shared/devtools/filters.svg
index 69c6bc3..916028b 100644
--- a/browser/themes/shared/devtools/filters.svg
+++ b/browser/themes/shared/devtools/filters.svg
@@ -8,9 +8,20 @@
</filter>
<filter id="invert-white" x="0%" y="0%" width="100%" height="100%" >
<feComponentTransfer>
<feFuncR type="table" tableValues=".6 0"/>
<feFuncG type="table" tableValues=".6 0"/>
<feFuncB type="table" tableValues=".6 0"/>
</feComponentTransfer>
</filter>
+
+ <!-- Web Audio Gradients -->
+ <linearGradient id="bypass-light" x1="6%" y1="8%" x2="12%" y2="12%" spreadMethod="repeat">
+ <stop offset="0%" stop-color="#f0f1f2"/> <!-- theme-toolbar-background -->
+ <stop offset="50%" stop-color="#fff"/>
+ </linearGradient>
+
+ <linearGradient id="bypass-dark" x1="6%" y1="8%" x2="12%" y2="12%" spreadMethod="repeat">
+ <stop offset="0%" stop-color="#343c45"/> <!-- theme-toolbar-background -->
+ <stop offset="50%" stop-color="transparent"/>
+ </linearGradient>
</svg>
diff --git a/browser/themes/shared/devtools/images/power.svg b/browser/themes/shared/devtools/images/power.svg
new file mode 100644
index 0000000..2888951
--- /dev/null
+++ b/browser/themes/shared/devtools/images/power.svg
@@ -0,0 +1,14 @@
+<!--
+Logo from raphaeljs.com, MIT License
+
+Copyright © 2008 Dmitry Baranovskiy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
+-->
+<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
+ <path stroke="#edf0f1" d="m10.89891,2.50043c-0.49827,-0.24134 -1.09841,-0.03411 -1.34129,0.46514c-0.24185,0.49928 -0.03311,1.09942 0.46517,1.34128c1.56306,0.76071 2.64193,2.36094 2.64092,4.21555c-0.00501,2.58626 -2.09749,4.6787 -4.68322,4.68321c-2.58623,-0.005 -4.67869,-2.09746 -4.68371,-4.68321c-0.001,-1.85561 1.07834,-3.45731 2.64294,-4.21654c0.49928,-0.24185 0.7065,-0.84201 0.46514,-1.34129c-0.24185,-0.49825 -0.84098,-0.70697 -1.34029,-0.46513c-2.23396,1.08135 -3.77446,3.37351 -3.77545,6.02296c0.00099,3.69518 2.99518,6.68989 6.69138,6.69088c3.6957,-0.00099 6.69037,-2.9957 6.69089,-6.69088c-0.00102,-2.64846 -1.53948,-4.9391 -3.77247,-6.02197zm-2.91842,4.9346c0.55398,0 1.00309,-0.44861 1.00309,-1.00357l0,-4.68373c0,-0.55446 -0.44911,-1.00309 -1.00309,-1.00309c-0.555,0 -1.00358,0.44911 -1.00358,1.00309l0,4.68321c0,0.55499 0.44858,1.00409 1.00358,1.00409z" stroke-width="0" fill="#edf0f1"/>
+</svg>
diff --git a/browser/themes/shared/devtools/webaudioeditor.inc.css b/browser/themes/shared/devtools/webaudioeditor.inc.css
index 6ad50d6..500af7c 100644
--- a/browser/themes/shared/devtools/webaudioeditor.inc.css
+++ b/browser/themes/shared/devtools/webaudioeditor.inc.css
@@ -76,38 +76,69 @@ g.edgePath.param-connection {
/* Audio Nodes */
.nodes rect {
stroke-width: 1px;
cursor: pointer;
}
.nodes rect {
stroke: var(--theme-tab-toolbar-background);
+}
+.theme-light rect {
+ fill: var(--theme-tab-toolbar-background);
+}
+.theme-dark rect {
fill: var(--theme-toolbar-background);
}