forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1032129-render-audioparam-connections.patch
639 lines (589 loc) · 23.4 KB
/
1032129-render-audioparam-connections.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
From 133b207db26bc472d27edd66d3d169b0f68029b5 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Wed, 13 Aug 2014 13:13:09 -0700
Subject: Bug 1032129 - Render AudioParam connections in web audio editor, r=vp
---
browser/devtools/webaudioeditor/test/browser.ini | 2 +
.../test/browser_wa_graph-render-04.js | 40 ++++++++++
.../test/doc_connect-multi-param.html | 32 ++++++++
browser/devtools/webaudioeditor/test/head.js | 16 +++-
.../webaudioeditor/webaudioeditor-controller.js | 91 +++++++++++++++-------
.../devtools/webaudioeditor/webaudioeditor-view.js | 60 +++++++++++---
.../themes/shared/devtools/webaudioeditor.inc.css | 28 +++++++
7 files changed, 226 insertions(+), 43 deletions(-)
create mode 100644 browser/devtools/webaudioeditor/test/browser_wa_graph-render-04.js
create mode 100644 browser/devtools/webaudioeditor/test/doc_connect-multi-param.html
diff --git a/browser/devtools/webaudioeditor/test/browser.ini b/browser/devtools/webaudioeditor/test/browser.ini
index 84dca5d..697cfd4 100644
--- a/browser/devtools/webaudioeditor/test/browser.ini
+++ b/browser/devtools/webaudioeditor/test/browser.ini
@@ -4,16 +4,17 @@ support-files =
doc_simple-context.html
doc_complex-context.html
doc_simple-node-creation.html
doc_buffer-and-array.html
doc_media-node-creation.html
doc_destroy-nodes.html
doc_connect-toggle.html
doc_connect-param.html
+ doc_connect-multi-param.html
440hz_sine.ogg
head.js
[browser_audionode-actor-get-set-param.js]
[browser_audionode-actor-get-type.js]
[browser_audionode-actor-get-params-01.js]
[browser_audionode-actor-get-params-02.js]
[browser_audionode-actor-get-param-flags.js]
@@ -28,16 +29,17 @@ support-files =
[browser_wa_reset-01.js]
[browser_wa_reset-02.js]
[browser_wa_reset-03.js]
[browser_wa_graph-click.js]
[browser_wa_graph-render-01.js]
[browser_wa_graph-render-02.js]
[browser_wa_graph-render-03.js]
+[browser_wa_graph-render-04.js]
[browser_wa_graph-markers.js]
[browser_wa_graph-selected.js]
[browser_wa_graph-zoom.js]
[browser_wa_inspector.js]
[browser_wa_inspector-toggle.js]
[browser_wa_properties-view.js]
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_graph-render-04.js b/browser/devtools/webaudioeditor/test/browser_wa_graph-render-04.js
new file mode 100644
index 0000000..493a9ba
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/browser_wa_graph-render-04.js
@@ -0,0 +1,40 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests audio param connection rendering.
+ */
+
+function spawnTest() {
+ let [target, debuggee, panel] = yield initWebAudioEditor(CONNECT_MULTI_PARAM_URL);
+ let { panelWin } = panel;
+ let { gFront, $, $$, EVENTS } = panelWin;
+
+ let started = once(gFront, "start-context");
+
+ reload(target);
+
+ let [actors] = yield Promise.all([
+ getN(gFront, "create-node", 5),
+ waitForGraphRendered(panelWin, 5, 2, 3)
+ ]);
+
+ let nodeIDs = actors.map(actor => actor.actorID);
+
+ let [, carrier, gain, mod1, mod2] = nodeIDs;
+
+ let edges = [
+ [mod1, gain, "gain", "mod1 -> gain[gain]"],
+ [mod2, carrier, "frequency", "mod2 -> carrier[frequency]"],
+ [mod2, carrier, "detune", "mod2 -> carrier[detune]"]
+ ];
+
+ edges.forEach(([source, target, param, msg], i) => {
+ let edge = findGraphEdge(panelWin, source, target, param);
+ ok(edge.classList.contains("param-connection"), "edge is classified as a param-connection");
+ });
+
+ yield teardown(panel);
+ finish();
+}
+
diff --git a/browser/devtools/webaudioeditor/test/doc_connect-multi-param.html b/browser/devtools/webaudioeditor/test/doc_connect-multi-param.html
new file mode 100644
index 0000000..ed4bd84
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/doc_connect-multi-param.html
@@ -0,0 +1,32 @@
+<!-- Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!doctype html>
+
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <title>Web Audio Editor test page</title>
+ </head>
+
+ <body>
+
+ <script type="text/javascript;version=1.8">
+ "use strict";
+
+ let ctx = new AudioContext();
+ let carrier = ctx.createOscillator();
+ let gain = ctx.createGain();
+ let modulator = ctx.createOscillator();
+ let modulator2 = ctx.createOscillator();
+ carrier.connect(gain);
+ gain.connect(ctx.destination);
+ modulator.connect(gain.gain);
+ modulator2.connect(carrier.frequency);
+ modulator2.connect(carrier.detune);
+ modulator.start(0);
+ modulator2.start(0);
+ carrier.start(0);
+ </script>
+ </body>
+
+</html>
diff --git a/browser/devtools/webaudioeditor/test/head.js b/browser/devtools/webaudioeditor/test/head.js
index ec4aa4a..2a69ae1 100644
--- a/browser/devtools/webaudioeditor/test/head.js
+++ b/browser/devtools/webaudioeditor/test/head.js
@@ -24,16 +24,17 @@ const EXAMPLE_URL = "http://example.com/browser/browser/devtools/webaudioeditor/
const SIMPLE_CONTEXT_URL = EXAMPLE_URL + "doc_simple-context.html";
const COMPLEX_CONTEXT_URL = EXAMPLE_URL + "doc_complex-context.html";
const SIMPLE_NODES_URL = EXAMPLE_URL + "doc_simple-node-creation.html";
const MEDIA_NODES_URL = EXAMPLE_URL + "doc_media-node-creation.html";
const BUFFER_AND_ARRAY_URL = EXAMPLE_URL + "doc_buffer-and-array.html";
const DESTROY_NODES_URL = EXAMPLE_URL + "doc_destroy-nodes.html";
const CONNECT_TOGGLE_URL = EXAMPLE_URL + "doc_connect-toggle.html";
const CONNECT_PARAM_URL = EXAMPLE_URL + "doc_connect-param.html";
+const CONNECT_MULTI_PARAM_URL = EXAMPLE_URL + "doc_connect-multi-param.html";
// All tests are asynchronous.
waitForExplicitFinish();
let gToolEnabled = Services.prefs.getBoolPref("devtools.webaudioeditor.enabled");
registerCleanupFunction(() => {
info("finish() was called, cleaning up...");
@@ -199,21 +200,25 @@ function get2Spread (front, eventName) { return getN(front, eventName, 2, true);
function get3Spread (front, eventName) { return getN(front, eventName, 3, true); }
function getNSpread (front, eventName, count) { return getN(front, eventName, count, true); }
/**
* Waits for the UI_GRAPH_RENDERED event to fire, but only
* resolves when the graph was rendered with the correct count of
* nodes and edges.
*/
-function waitForGraphRendered (front, nodeCount, edgeCount) {
+function waitForGraphRendered (front, nodeCount, edgeCount, paramEdgeCount) {
let deferred = Promise.defer();
let eventName = front.EVENTS.UI_GRAPH_RENDERED;
- front.on(eventName, function onGraphRendered (_, nodes, edges) {
- if (nodes === nodeCount && edges === edgeCount) {
+ front.on(eventName, function onGraphRendered (_, nodes, edges, pEdges) {
+ info(nodes);
+ info(edges)
+ info(pEdges);
+ let paramEdgesDone = paramEdgeCount ? paramEdgeCount === pEdges : true;
+ if (nodes === nodeCount && edges === edgeCount && paramEdgesDone) {
front.off(eventName, onGraphRendered);
deferred.resolve();
}
});
return deferred.promise;
}
function checkVariableView (view, index, hash, description = "") {
@@ -285,18 +290,21 @@ function modifyVariableView (win, view, index, prop, value) {
deferred.resolve();
if (eventName === win.EVENTS.UI_SET_PARAM_ERROR)
deferred.reject();
}
return deferred.promise;
}
-function findGraphEdge (win, source, target) {
+function findGraphEdge (win, source, target, param) {
let selector = ".edgePaths .edgePath[data-source='" + source + "'][data-target='" + target + "']";
+ if (param) {
+ selector += "[data-param='" + param + "']";
+ }
return win.document.querySelector(selector);
}
function findGraphNode (win, node) {
let selector = ".nodes > g[data-id='" + node + "']";
return win.document.querySelector(selector);
}
diff --git a/browser/devtools/webaudioeditor/webaudioeditor-controller.js b/browser/devtools/webaudioeditor/webaudioeditor-controller.js
index b8a801f9..7460e31 100644
--- a/browser/devtools/webaudioeditor/webaudioeditor-controller.js
+++ b/browser/devtools/webaudioeditor/webaudioeditor-controller.js
@@ -59,31 +59,32 @@ const EVENTS = {
// When the inspector is finished rendering in or out of view.
UI_INSPECTOR_TOGGLED: "WebAudioEditor:UIInspectorToggled",
// When an audio node is finished loading in the Properties tab.
UI_PROPERTIES_TAB_RENDERED: "WebAudioEditor:UIPropertiesTabRendered",
// When the Audio Context graph finishes rendering.
// Is called with two arguments, first representing number of nodes
- // rendered, second being the number of edges rendered.
+ // rendered, second being the number of edge connections rendering (not counting
+ // param edges), followed by the count of the param edges rendered.
UI_GRAPH_RENDERED: "WebAudioEditor:UIGraphRendered"
};
/**
* The current target and the Web Audio Editor front, set by this tool's host.
*/
let gToolbox, gTarget, gFront;
/**
* Track an array of audio nodes
*/
let AudioNodes = [];
-let AudioNodeConnections = new WeakMap();
-
+let AudioNodeConnections = new WeakMap(); // <AudioNodeView, Set<AudioNodeView>>
+let AudioParamConnections = new WeakMap(); // <AudioNodeView, Object>
// Light representation wrapping an AudioNode actor with additional properties
function AudioNodeView (actor) {
this.actor = actor;
this.id = actor.actorID;
}
// A proxy for the underlying AudioNodeActor to fetch its type
@@ -104,19 +105,37 @@ AudioNodeView.prototype.connect = function (destination) {
// Don't duplicate add.
if (!connections.has(destination)) {
connections.add(destination);
return true;
}
return false;
};
+// Helper method to create connections in the AudioNodeConnections
+// WeakMap for rendering. Returns a boolean indicating
+// if the connection was successfully created. Will return `false`
+// when the connection was previously made.
+AudioNodeView.prototype.connectParam = function (destination, param) {
+ let connections = AudioParamConnections.get(this) || {};
+ AudioParamConnections.set(this, connections);
+
+ let params = connections[destination.id] = connections[destination.id] || [];
+
+ if (!~params.indexOf(param)) {
+ params.push(param);
+ return true;
+ }
+ return false;
+};
+
// Helper method to remove audio connections from the current AudioNodeView
AudioNodeView.prototype.disconnect = function () {
AudioNodeConnections.set(this, new Set());
+ AudioParamConnections.set(this, {});
};
// Returns a promise that resolves to an array of objects containing
// both a `param` name property and a `value` property.
AudioNodeView.prototype.getParams = function () {
return this.actor.getParams();
};
@@ -154,49 +173,53 @@ let WebAudioEditorController = {
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);
gFront.on("connect-node", this._onConnectNode);
+ gFront.on("connect-param", this._onConnectParam);
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);
// Set up events to refresh the Graph view
window.on(EVENTS.CREATE_NODE, this._onUpdatedContext);
window.on(EVENTS.CONNECT_NODE, this._onUpdatedContext);
window.on(EVENTS.DISCONNECT_NODE, this._onUpdatedContext);
window.on(EVENTS.DESTROY_NODE, this._onUpdatedContext);
+ window.on(EVENTS.CONNECT_PARAM, this._onUpdatedContext);
},
/**
* Remove events emitted by the current tab target.
*/
destroy: function() {
telemetry.toolClosed("webaudioeditor");
gTarget.off("will-navigate", this._onTabNavigated);
gTarget.off("navigate", this._onTabNavigated);
gFront.off("start-context", this._onStartContext);
gFront.off("create-node", this._onCreateNode);
gFront.off("connect-node", this._onConnectNode);
+ gFront.off("connect-param", this._onConnectParam);
gFront.off("disconnect-node", this._onDisconnectNode);
gFront.off("change-param", this._onChangeParam);
gFront.off("destroy-node", this._onDestroyNode);
window.off(EVENTS.CREATE_NODE, this._onUpdatedContext);
window.off(EVENTS.CONNECT_NODE, this._onUpdatedContext);
window.off(EVENTS.DISCONNECT_NODE, this._onUpdatedContext);
window.off(EVENTS.DESTROY_NODE, this._onUpdatedContext);
+ window.off(EVENTS.CONNECT_PARAM, this._onUpdatedContext);
gDevTools.off("pref-changed", this._onThemeChange);
},
/**
* Called when page is reloaded to show the reload notice and waiting
* for an audio context notice.
*/
reset: function () {
@@ -286,48 +309,32 @@ let WebAudioEditorController = {
}
}
},
/**
* Called when a node is connected to another node.
*/
_onConnectNode: Task.async(function* ({ source: sourceActor, dest: destActor }) {
- // Since node create and connect are probably executed back to back,
- // and the controller's `_onCreateNode` needs to look up type,
- // the edge creation could be called before the graph node is actually
- // created. This way, we can check and listen for the event before
- // adding an edge.
let [source, dest] = yield waitForNodeCreation(sourceActor, destActor);
// Connect nodes, and only emit if it's a new connection.
if (source.connect(dest)) {
window.emit(EVENTS.CONNECT_NODE, source.id, dest.id);
}
+ }),
- function waitForNodeCreation (sourceActor, destActor) {
- let deferred = defer();
- let source = getViewNodeByActor(sourceActor);
- let dest = getViewNodeByActor(destActor);
-
- if (!source || !dest)
- window.on(EVENTS.CREATE_NODE, function createNodeListener (_, id) {
- let createdNode = getViewNodeById(id);
- if (equalActors(sourceActor, createdNode.actor))
- source = createdNode;
- if (equalActors(destActor, createdNode.actor))
- dest = createdNode;
- if (source && dest) {
- window.off(EVENTS.CREATE_NODE, createNodeListener);
- deferred.resolve([source, dest]);
- }
- });
- else
- deferred.resolve([source, dest]);
- return deferred.promise;
+ /**
+ * Called when a node is conneceted to another node's AudioParam.
+ */
+ _onConnectParam: Task.async(function* ({ source: sourceActor, dest: destActor, param }) {
+ let [source, dest] = yield waitForNodeCreation(sourceActor, destActor);
+
+ if (source.connectParam(dest, param)) {
+ window.emit(EVENTS.CONNECT_PARAM, source.id, dest.id, param);
}
}),
/**
* Called when a node is disconnected.
*/
_onDisconnectNode: function(nodeActor) {
let node = getViewNodeByActor(nodeActor);
@@ -374,8 +381,36 @@ function getViewNodeByActor (actor) {
}
/**
* Returns the corresponding ViewNode by actorID
*/
function getViewNodeById (id) {
return getViewNodeByActor({ actorID: id });
}
+
+// Since node create and connect are probably executed back to back,
+// and the controller's `_onCreateNode` needs to look up type,
+// the edge creation could be called before the graph node is actually
+// created. This way, we can check and listen for the event before
+// adding an edge.
+function waitForNodeCreation (sourceActor, destActor) {
+ let deferred = defer();
+ let eventName = EVENTS.CREATE_NODE;
+ let source = getViewNodeByActor(sourceActor);
+ let dest = getViewNodeByActor(destActor);
+
+ if (!source || !dest)
+ window.on(eventName, function createNodeListener (_, id) {
+ let createdNode = getViewNodeById(id);
+ if (equalActors(sourceActor, createdNode.actor))
+ source = createdNode;
+ if (equalActors(destActor, createdNode.actor))
+ dest = createdNode;
+ if (source && dest) {
+ window.off(eventName, createNodeListener);
+ deferred.resolve([source, dest]);
+ }
+ });
+ else
+ deferred.resolve([source, dest]);
+ return deferred.promise;
+}
diff --git a/browser/devtools/webaudioeditor/webaudioeditor-view.js b/browser/devtools/webaudioeditor/webaudioeditor-view.js
index 8b69fc4..8bcf4b3 100644
--- a/browser/devtools/webaudioeditor/webaudioeditor-view.js
+++ b/browser/devtools/webaudioeditor/webaudioeditor-view.js
@@ -139,44 +139,66 @@ let WebAudioGraphView = {
* Takes an actorID and returns the corresponding DOM SVG element in the graph
*/
_getNodeByID: function (actorID) {
return $(".nodes > g[data-id='" + actorID + "']");
},
/**
* `draw` renders the ViewNodes currently available in `AudioNodes` with `AudioNodeConnections`,
- * and is throttled to be called at most every `GRAPH_DEBOUNCE_TIMER` milliseconds. Is called
- * whenever the audio context routing changes, after being debounced.
+ * and `AudioParamConnections` and is throttled to be called at most every
+ * `GRAPH_DEBOUNCE_TIMER` milliseconds. Is called whenever the audio context routing changes,
+ * after being debounced.
*/
draw: function () {
// Clear out previous SVG information
this.clearGraph();
let graph = new dagreD3.Digraph();
+ // An array of duples/tuples of pairs [sourceNode, destNode, param].
+ // `param` is optional, indicating a connection to an AudioParam, rather than
+ // an other AudioNode.
let edges = [];
AudioNodes.forEach(node => {
// Add node to graph
graph.addNode(node.id, {
type: node.type, // Just for storing type data
label: node.type.replace(/Node$/, ""), // Displayed in SVG node
id: node.id // Identification
});
// Add all of the connections from this node to the edge array to be added
// after all the nodes are added, otherwise edges will attempted to be created
// for nodes that have not yet been added
AudioNodeConnections.get(node, new Set()).forEach(dest => edges.push([node, dest]));
+ let paramConnections = AudioParamConnections.get(node, {});
+ Object.keys(paramConnections).forEach(destId => {
+ let dest = getViewNodeById(destId);
+ let connections = paramConnections[destId] || [];
+ connections.forEach(param => edges.push([node, dest, param]));
+ });
});
- edges.forEach(([node, dest]) => graph.addEdge(null, node.id, dest.id, {
- source: node.id,
- target: dest.id
- }));
+ edges.forEach(([node, dest, param]) => {
+ let options = {
+ source: node.id,
+ target: dest.id
+ };
+
+ // Only add `label` if `param` specified, as this is an AudioParam connection then.
+ // `label` adds the magic to render with dagre-d3, and `param` is just more explicitly
+ // the param, ignoring implementation details.
+ if (param) {
+ options.label = param;
+ options.param = param;
+ }
+
+ graph.addEdge(null, node.id, dest.id, options);
+ });
let renderer = new dagreD3.Renderer();
// Post-render manipulation of the nodes
let oldDrawNodes = renderer.drawNodes();
renderer.drawNodes(function(graph, root) {
let svgNodes = oldDrawNodes(graph, root);
svgNodes.attr("class", (n) => {
@@ -186,28 +208,43 @@ let WebAudioGraphView = {
svgNodes.attr("data-id", (n) => {
let node = graph.node(n);
return node.id;
});
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();
renderer.drawEdgePaths(function(graph, root) {
- let svgNodes = oldDrawEdgePaths(graph, root);
- svgNodes.attr("data-source", (n) => {
+ let svgEdges = oldDrawEdgePaths(graph, root);
+ svgEdges.attr("data-source", (n) => {
let edge = graph.edge(n);
return edge.source;
});
- svgNodes.attr("data-target", (n) => {
+ svgEdges.attr("data-target", (n) => {
let edge = graph.edge(n);
return edge.target;
});
- return svgNodes;
+ 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) : "");
+ });
+
+ 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) => {
// We have to manually set the marker styling since we cannot
// do this currently with CSS, although it is in spec for SVG2
// https://svgwg.org/svg2-draft/painting.html#VertexMarkerProperties
@@ -235,17 +272,18 @@ let WebAudioGraphView = {
// Reselect the previously selected audio node
let currentNode = WebAudioInspectorView.getCurrentAudioNode();
if (currentNode) {
this.focusNode(currentNode.id);
}
// Fire an event upon completed rendering
- window.emit(EVENTS.UI_GRAPH_RENDERED, AudioNodes.length, edges.length);
+ let paramEdgeCount = edges.filter(p => !!p[2]).length;
+ window.emit(EVENTS.UI_GRAPH_RENDERED, AudioNodes.length, edges.length - paramEdgeCount, paramEdgeCount);
});
let layout = dagreD3.layout().rankDir("LR");
renderer.layout(layout).run(graph, d3.select("#graph-target"));
// Handle the sliding and zooming of the graph,
// store as `this._zoomBinding` so we can unbind during destruction
if (!this._zoomBinding) {
diff --git a/browser/themes/shared/devtools/webaudioeditor.inc.css b/browser/themes/shared/devtools/webaudioeditor.inc.css
index 4d2665e..95faced 100644
--- a/browser/themes/shared/devtools/webaudioeditor.inc.css
+++ b/browser/themes/shared/devtools/webaudioeditor.inc.css
@@ -48,16 +48,44 @@ svg {
.theme-dark .edgePath path {
stroke: #b6babf; /* Grey foreground text */
}
.theme-light .edgePath path {
stroke: #aaaaaa; /* Splitters */
}
+/* AudioParam connection edges */
+g.edgePath.param-connection {
+ stroke-dasharray: 5,5;
+}
+
+.theme-dark .edgePath.param-connection path {
+ stroke: #b6babf; /* Grey foreground text */
+}
+.theme-light .edgePath.param-connection path {
+ stroke: #aaaaaa; /* Splitters */
+}
+
+/* Labels in AudioParam connection should have background that match
+ * the main background so there's whitespace around the label, on top of the
+ * dotted lines. */
+.theme-dark g.edgeLabel rect {
+ fill: #14171a;
+}
+.theme-light g.edgeLabel rect {
+ fill: #fcfcfc; /* Background - Editor */
+}
+.theme-dark g.edgeLabel tspan {
+ fill: #b6babf; /* Grey foreground text */
+}
+.theme-light g.edgeLabel tspan {
+ fill: #585959; /* Grey foreground text */
+}
+
/* Audio Nodes */
.nodes rect {
stroke-width: 1px;
cursor: pointer;
}
.theme-dark .nodes rect {
stroke: #252c33; /* Tab toolbar */
--
1.8.4.2