Title: [265307] trunk
Revision
265307
Author
cdu...@apple.com
Date
2020-08-05 15:18:28 -0700 (Wed, 05 Aug 2020)

Log Message

Add constructor for DynamicsCompressorNode
https://bugs.webkit.org/show_bug.cgi?id=215180

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/webaudio/idlharness.https.window-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-dynamics-compressor-connections-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt:

Source/WebCore:

Add constructor for DynamicsCompressorNode:
- https://webaudio.github.io/web-audio-api/#dynamicscompressornode

This patch also add a new handleAudioNodeOptions() member function to
AudioNode to avoid code duplication and every node constructor.

No new tests, rebaselined existing tests.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/webaudio/AnalyserNode.cpp:
(WebCore::AnalyserNode::create):
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::initializeDefaultNodeOptions):
(WebCore::AudioNode::handleAudioNodeOptions):
* Modules/webaudio/AudioNode.h:
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::createDynamicsCompressor):
* Modules/webaudio/BiquadFilterNode.cpp:
(WebCore::BiquadFilterNode::create):
* Modules/webaudio/ChannelMergerNode.cpp:
(WebCore::ChannelMergerNode::create):
* Modules/webaudio/ChannelSplitterNode.cpp:
(WebCore::ChannelSplitterNode::create):
* Modules/webaudio/ConvolverNode.cpp:
(WebCore::ConvolverNode::create):
(WebCore::ConvolverNode::ConvolverNode):
* Modules/webaudio/DefaultAudioDestinationNode.cpp:
(WebCore::DefaultAudioDestinationNode::DefaultAudioDestinationNode):
* Modules/webaudio/DelayNode.cpp:
(WebCore::DelayNode::create):
* Modules/webaudio/DynamicsCompressorNode.cpp:
(WebCore::DynamicsCompressorNode::create):
(WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
(WebCore::DynamicsCompressorNode::setChannelCount):
(WebCore::DynamicsCompressorNode::setChannelCountMode):
* Modules/webaudio/DynamicsCompressorNode.h:
* Modules/webaudio/DynamicsCompressorNode.idl:
* Modules/webaudio/DynamicsCompressorOptions.h: Copied from Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl.
* Modules/webaudio/DynamicsCompressorOptions.idl: Copied from Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl.
* Modules/webaudio/GainNode.cpp:
(WebCore::GainNode::create):
* Modules/webaudio/OscillatorNode.cpp:
(WebCore::OscillatorNode::create):
* Modules/webaudio/PannerNode.cpp:
(WebCore::PannerNode::create):
(WebCore::PannerNode::PannerNode):
* Modules/webaudio/WaveShaperNode.cpp:
(WebCore::WaveShaperNode::create):
* Modules/webaudio/WebKitAudioPannerNode.cpp:
(WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265306 => 265307)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-05 22:18:28 UTC (rev 265307)
@@ -1,5 +1,18 @@
 2020-08-05  Chris Dumez  <cdu...@apple.com>
 
+        Add constructor for DynamicsCompressorNode
+        https://bugs.webkit.org/show_bug.cgi?id=215180
+
+        Reviewed by Geoffrey Garen.
+
+        Rebaseline WPT tests now that more checks are passing.
+
+        * web-platform-tests/webaudio/idlharness.https.window-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-dynamics-compressor-connections-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt:
+
+2020-08-05  Chris Dumez  <cdu...@apple.com>
+
         Add constructor to ConvolverNode
         https://bugs.webkit.org/show_bug.cgi?id=215169
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt (265306 => 265307)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-05 22:18:28 UTC (rev 265307)
@@ -679,7 +679,7 @@
 PASS AudioNode interface: new DelayNode(context) must inherit property "channelCountMode" with the proper type 
 PASS AudioNode interface: new DelayNode(context) must inherit property "channelInterpretation" with the proper type 
 PASS DynamicsCompressorNode interface: existence and properties of interface object 
-FAIL DynamicsCompressorNode interface object length assert_equals: wrong value for DynamicsCompressorNode.length expected 1 but got 0
+PASS DynamicsCompressorNode interface object length 
 PASS DynamicsCompressorNode interface object name 
 PASS DynamicsCompressorNode interface: existence and properties of interface prototype object 
 PASS DynamicsCompressorNode interface: existence and properties of interface prototype object's "constructor" property 
@@ -690,37 +690,37 @@
 PASS DynamicsCompressorNode interface: attribute reduction 
 PASS DynamicsCompressorNode interface: attribute attack 
 PASS DynamicsCompressorNode interface: attribute release 
-FAIL DynamicsCompressorNode must be primary interface of new DynamicsCompressorNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL Stringification of new DynamicsCompressorNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "threshold" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "knee" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "ratio" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "reduction" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "attack" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "release" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling connect(AudioParam, optional unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect()" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling disconnect(unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioNode)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioParam)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioParam) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioParam, unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "context" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "numberOfInputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "numberOfOutputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelCount" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelCountMode" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
-FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
+PASS DynamicsCompressorNode must be primary interface of new DynamicsCompressorNode(context) 
+PASS Stringification of new DynamicsCompressorNode(context) 
+PASS DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "threshold" with the proper type 
+PASS DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "knee" with the proper type 
+PASS DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "ratio" with the proper type 
+FAIL DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "reduction" with the proper type assert_equals: expected "number" but got "object"
+PASS DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "attack" with the proper type 
+PASS DynamicsCompressorNode interface: new DynamicsCompressorNode(context) must inherit property "release" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type 
+PASS AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type 
+PASS AudioNode interface: calling connect(AudioParam, optional unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect()" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioNode)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioNode) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioNode, unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioParam)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioParam) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioParam, unsigned long) on new DynamicsCompressorNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "context" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "numberOfInputs" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "numberOfOutputs" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelCount" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelCountMode" with the proper type 
+PASS AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelInterpretation" with the proper type 
 PASS GainNode interface: existence and properties of interface object 
 PASS GainNode interface object length 
 PASS GainNode interface object name 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-dynamics-compressor-connections-expected.txt (265306 => 265307)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-dynamics-compressor-connections-expected.txt	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-dynamics-compressor-connections-expected.txt	2020-08-05 22:18:28 UTC (rev 265307)
@@ -1,20 +1,55 @@
 
 PASS # AUDIT TASK RUNNER STARTED. 
-FAIL Executing "attack" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'refNode[paramName]')"
-FAIL Executing "knee" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'refNode[paramName]')"
-FAIL Executing "ratio" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'refNode[paramName]')"
-FAIL Executing "release" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'refNode[paramName]')"
-FAIL Executing "threshold" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'refNode[paramName]')"
+FAIL Executing "attack" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'mod.start')"
+FAIL Executing "knee" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'mod.start')"
+FAIL Executing "ratio" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'mod.start')"
+FAIL Executing "release" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'mod.start')"
+FAIL Executing "threshold" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'mod.start')"
 PASS Audit report 
 PASS > [attack] Dynamics compressor attack 
-FAIL X attack: refNode = new DynamicsCompressorNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')". assert_true: expected true got false
+PASS   attack: refNode = new DynamicsCompressorNode(context) did not throw an exception. 
+PASS   attack: tstNode = new DynamicsCompressorNode(context, {"attack":0}) did not throw an exception. 
+PASS   attack: refNode[attack].setValueAtTime(refNode[attack].minValue, 0) did not throw an exception. 
+PASS   attack: refNode[attack].linearRampToValueAtTime(refNode[attack].minValue, 0.25) did not throw an exception. 
+FAIL X attack: mod = new ConstantSourceNode(context, {offset: 0}) incorrectly threw ReferenceError: "Can't find variable: ConstantSourceNode". assert_true: expected true got false
+FAIL X attack: mod.offset.setValueAtTime(0, 0) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X attack: mod.offset.linearRampToValueAtTime(1, 0.25) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X attack: mod.connect(tstNode[attack]) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.connect')". assert_true: expected true got false
 PASS > [knee] Dynamics compressor knee 
-FAIL X knee: refNode = new DynamicsCompressorNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')". assert_true: expected true got false
+PASS   knee: refNode = new DynamicsCompressorNode(context) did not throw an exception. 
+PASS   knee: tstNode = new DynamicsCompressorNode(context, {"knee":0}) did not throw an exception. 
+PASS   knee: refNode[knee].setValueAtTime(refNode[knee].minValue, 0) did not throw an exception. 
+PASS   knee: refNode[knee].linearRampToValueAtTime(refNode[knee].minValue, 0.25) did not throw an exception. 
+FAIL X knee: mod = new ConstantSourceNode(context, {offset: 0}) incorrectly threw ReferenceError: "Can't find variable: ConstantSourceNode". assert_true: expected true got false
+FAIL X knee: mod.offset.setValueAtTime(0, 0) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X knee: mod.offset.linearRampToValueAtTime(40, 0.25) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X knee: mod.connect(tstNode[knee]) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.connect')". assert_true: expected true got false
 PASS > [ratio] Dynamics compressor ratio 
-FAIL X ratio: refNode = new DynamicsCompressorNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')". assert_true: expected true got false
+PASS   ratio: refNode = new DynamicsCompressorNode(context) did not throw an exception. 
+PASS   ratio: tstNode = new DynamicsCompressorNode(context, {"ratio":1}) did not throw an exception. 
+PASS   ratio: refNode[ratio].setValueAtTime(refNode[ratio].minValue, 0) did not throw an exception. 
+PASS   ratio: refNode[ratio].linearRampToValueAtTime(refNode[ratio].minValue, 0.25) did not throw an exception. 
+FAIL X ratio: mod = new ConstantSourceNode(context, {offset: 0}) incorrectly threw ReferenceError: "Can't find variable: ConstantSourceNode". assert_true: expected true got false
+FAIL X ratio: mod.offset.setValueAtTime(0, 0) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X ratio: mod.offset.linearRampToValueAtTime(19, 0.25) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X ratio: mod.connect(tstNode[ratio]) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.connect')". assert_true: expected true got false
 PASS > [release] Dynamics compressor release 
-FAIL X release: refNode = new DynamicsCompressorNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')". assert_true: expected true got false
+PASS   release: refNode = new DynamicsCompressorNode(context) did not throw an exception. 
+PASS   release: tstNode = new DynamicsCompressorNode(context, {"release":0}) did not throw an exception. 
+PASS   release: refNode[release].setValueAtTime(refNode[release].minValue, 0) did not throw an exception. 
+PASS   release: refNode[release].linearRampToValueAtTime(refNode[release].minValue, 0.25) did not throw an exception. 
+FAIL X release: mod = new ConstantSourceNode(context, {offset: 0}) incorrectly threw ReferenceError: "Can't find variable: ConstantSourceNode". assert_true: expected true got false
+FAIL X release: mod.offset.setValueAtTime(0, 0) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X release: mod.offset.linearRampToValueAtTime(1, 0.25) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X release: mod.connect(tstNode[release]) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.connect')". assert_true: expected true got false
 PASS > [threshold] Dynamics compressor threshold 
-FAIL X threshold: refNode = new DynamicsCompressorNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')". assert_true: expected true got false
+PASS   threshold: refNode = new DynamicsCompressorNode(context) did not throw an exception. 
+PASS   threshold: tstNode = new DynamicsCompressorNode(context, {"threshold":-100}) did not throw an exception. 
+PASS   threshold: refNode[threshold].setValueAtTime(refNode[threshold].minValue, 0) did not throw an exception. 
+PASS   threshold: refNode[threshold].linearRampToValueAtTime(refNode[threshold].minValue, 0.25) did not throw an exception. 
+FAIL X threshold: mod = new ConstantSourceNode(context, {offset: 0}) incorrectly threw ReferenceError: "Can't find variable: ConstantSourceNode". assert_true: expected true got false
+FAIL X threshold: mod.offset.setValueAtTime(0, 0) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X threshold: mod.offset.linearRampToValueAtTime(100, 0.25) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.offset')". assert_true: expected true got false
+FAIL X threshold: mod.connect(tstNode[threshold]) incorrectly threw TypeError: "undefined is not an object (evaluating 'mod.connect')". assert_true: expected true got false
 FAIL # AUDIT TASK RUNNER FINISHED: 5 out of 5 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt (265306 => 265307)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt	2020-08-05 22:18:28 UTC (rev 265307)
@@ -2,25 +2,64 @@
 PASS # AUDIT TASK RUNNER STARTED. 
 PASS Executing "initialize" 
 PASS Executing "invalid constructor" 
-FAIL Executing "default constructor" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.numberOfInputs')"
-FAIL Executing "test AudioNodeOptions" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node[options.testAttribute]')"
-FAIL Executing "constructor with options" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.threshold')"
+PASS Executing "default constructor" 
+PASS Executing "test AudioNodeOptions" 
+PASS Executing "constructor with options" 
 PASS Audit report 
 PASS > [initialize]  
 PASS   context = new OfflineAudioContext(...) did not throw an exception. 
 PASS < [initialize] All assertions passed. (total 1 assertions) 
 PASS > [invalid constructor]  
-PASS   new DynamicsCompressorNode() threw TypeError: "function is not a constructor (evaluating 'new window[name]()')". 
-PASS   new DynamicsCompressorNode(1) threw TypeError: "function is not a constructor (evaluating 'new window[name](1)')". 
-PASS   new DynamicsCompressorNode(context, 42) threw TypeError: "function is not a constructor (evaluating 'new window[name](context, 42)')". 
+PASS   new DynamicsCompressorNode() threw TypeError: "Not enough arguments". 
+PASS   new DynamicsCompressorNode(1) threw TypeError: "Argument 1 ('context') to the DynamicsCompressorNode constructor must be an instance of BaseAudioContext". 
+PASS   new DynamicsCompressorNode(context, 42) threw TypeError: "Type error". 
 PASS < [invalid constructor] All assertions passed. (total 3 assertions) 
 PASS > [default constructor]  
-FAIL X node0 = new DynamicsCompressorNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[name](context, options.constructorOptions)')". assert_true: expected true got false
-FAIL X node0 instanceof DynamicsCompressorNode is not equal to true. Got false. assert_true: expected true got false
+PASS   node0 = new DynamicsCompressorNode(context) did not throw an exception. 
+PASS   node0 instanceof DynamicsCompressorNode is equal to true. 
+PASS   node0.numberOfInputs is equal to 1. 
+PASS   node0.numberOfOutputs is equal to 1. 
+PASS   node0.channelCount is equal to 2. 
+PASS   node0.channelCountMode is equal to clamped-max. 
+PASS   node0.channelInterpretation is equal to speakers. 
+PASS   node0.threshold.value is equal to -24. 
+PASS   node0.knee.value is equal to 30. 
+PASS   node0.ratio.value is equal to 12. 
+PASS   node0.reduction.value is equal to 0. 
+PASS   node0.attack.value is equal to 0.003000000026077032. 
+PASS   node0.release.value is equal to 0.25. 
+PASS < [default constructor] All assertions passed. (total 13 assertions) 
 PASS > [test AudioNodeOptions]  
-FAIL X new DynamicsCompressorNode(c, {"channelCount":1}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context, options.nodeOptions)')". assert_true: expected true got false
+PASS   new DynamicsCompressorNode(c, {"channelCount":1}) did not throw an exception. 
+PASS   node.channelCount is equal to 1. 
+PASS   new DynamicsCompressorNode(c, {"channelCount":2}) did not throw an exception. 
+PASS   node.channelCount is equal to 2. 
+PASS   new DynamicsCompressorNode(c, {"channelCount":0}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new DynamicsCompressorNode(c, {"channelCount":3}) threw NotSupportedError: "DynamicsCompressorNode's channel count cannot be greater than 2". 
+PASS   new DynamicsCompressorNode(c, {"channelCount":99}) threw NotSupportedError: "DynamicsCompressorNode's channel count cannot be greater than 2". 
+PASS   new DynamicsCompressorNode(c, {"channelCountMode":"clamped-max"}) did not throw an exception. 
+PASS   node.channelCountMode is equal to clamped-max. 
+PASS   new DynamicsCompressorNode(c, {"channelCountMode":"explicit"}) did not throw an exception. 
+PASS   node.channelCountMode is equal to explicit. 
+PASS   new DynamicsCompressorNode(c, {"channelCountMode":"max"}) threw NotSupportedError: "DynamicsCompressorNode's channel count mode cannot be set to 'max'". 
+PASS   new DynamicsCompressorNode(c, {"channelCountMode":"foobar"}) threw TypeError: "Type error". 
+PASS   new DynamicsCompressorNode(c, {"channelInterpretation":"speakers"}) did not throw an exception. 
+PASS   node.channelInterpretation is equal to speakers. 
+PASS   new DynamicsCompressorNode(c, {"channelInterpretation":"discrete"}) did not throw an exception. 
+PASS   node.channelInterpretation is equal to discrete. 
+PASS   new DynamicsCompressorNode(c, {"channelInterpretation":"foobar"}) threw TypeError: "Type error". 
+PASS < [test AudioNodeOptions] All assertions passed. (total 18 assertions) 
 PASS > [constructor with options]  
-FAIL X node1 = new DynamicsCompressorNode(c, {"threshold":-33,"knee":15,"ratio":7,"attack":0.625,"release":0.125}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new DynamicsCompressorNode(context, options)')". assert_true: expected true got false
-FAIL X node1 instanceof DynamicsCompressorNode is not equal to true. Got false. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 3 out of 5 tasks were failed. assert_true: expected true got false
+PASS   node1 = new DynamicsCompressorNode(c, {"threshold":-33,"knee":15,"ratio":7,"attack":0.625,"release":0.125}) did not throw an exception. 
+PASS   node1 instanceof DynamicsCompressorNode is equal to true. 
+PASS   node1.threshold.value is equal to -33. 
+PASS   node1.knee.value is equal to 15. 
+PASS   node1.ratio.value is equal to 7. 
+PASS   node1.attack.value is equal to 0.625. 
+PASS   node1.release.value is equal to 0.125. 
+PASS   node1.channelCount is equal to 2. 
+PASS   node1.channelCountMode is equal to clamped-max. 
+PASS   node1.channelInterpretation is equal to speakers. 
+PASS < [constructor with options] All assertions passed. (total 10 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 5 tasks ran successfully. 
 

Modified: trunk/Source/WebCore/CMakeLists.txt (265306 => 265307)


--- trunk/Source/WebCore/CMakeLists.txt	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-08-05 22:18:28 UTC (rev 265307)
@@ -479,6 +479,7 @@
     Modules/webaudio/DelayOptions.idl
     Modules/webaudio/DistanceModelType.idl
     Modules/webaudio/DynamicsCompressorNode.idl
+    Modules/webaudio/DynamicsCompressorOptions.idl
     Modules/webaudio/GainNode.idl
     Modules/webaudio/GainOptions.idl
     Modules/webaudio/MediaElementAudioSourceNode.idl

Modified: trunk/Source/WebCore/ChangeLog (265306 => 265307)


--- trunk/Source/WebCore/ChangeLog	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/ChangeLog	2020-08-05 22:18:28 UTC (rev 265307)
@@ -1,5 +1,69 @@
 2020-08-05  Chris Dumez  <cdu...@apple.com>
 
+        Add constructor for DynamicsCompressorNode
+        https://bugs.webkit.org/show_bug.cgi?id=215180
+
+        Reviewed by Geoffrey Garen.
+
+        Add constructor for DynamicsCompressorNode:
+        - https://webaudio.github.io/web-audio-api/#dynamicscompressornode
+
+        This patch also add a new handleAudioNodeOptions() member function to
+        AudioNode to avoid code duplication and every node constructor.
+
+        No new tests, rebaselined existing tests.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/webaudio/AnalyserNode.cpp:
+        (WebCore::AnalyserNode::create):
+        * Modules/webaudio/AudioNode.cpp:
+        (WebCore::AudioNode::AudioNode):
+        (WebCore::AudioNode::initializeDefaultNodeOptions):
+        (WebCore::AudioNode::handleAudioNodeOptions):
+        * Modules/webaudio/AudioNode.h:
+        * Modules/webaudio/BaseAudioContext.cpp:
+        (WebCore::BaseAudioContext::createDynamicsCompressor):
+        * Modules/webaudio/BiquadFilterNode.cpp:
+        (WebCore::BiquadFilterNode::create):
+        * Modules/webaudio/ChannelMergerNode.cpp:
+        (WebCore::ChannelMergerNode::create):
+        * Modules/webaudio/ChannelSplitterNode.cpp:
+        (WebCore::ChannelSplitterNode::create):
+        * Modules/webaudio/ConvolverNode.cpp:
+        (WebCore::ConvolverNode::create):
+        (WebCore::ConvolverNode::ConvolverNode):
+        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
+        (WebCore::DefaultAudioDestinationNode::DefaultAudioDestinationNode):
+        * Modules/webaudio/DelayNode.cpp:
+        (WebCore::DelayNode::create):
+        * Modules/webaudio/DynamicsCompressorNode.cpp:
+        (WebCore::DynamicsCompressorNode::create):
+        (WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
+        (WebCore::DynamicsCompressorNode::setChannelCount):
+        (WebCore::DynamicsCompressorNode::setChannelCountMode):
+        * Modules/webaudio/DynamicsCompressorNode.h:
+        * Modules/webaudio/DynamicsCompressorNode.idl:
+        * Modules/webaudio/DynamicsCompressorOptions.h: Copied from Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl.
+        * Modules/webaudio/DynamicsCompressorOptions.idl: Copied from Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl.
+        * Modules/webaudio/GainNode.cpp:
+        (WebCore::GainNode::create):
+        * Modules/webaudio/OscillatorNode.cpp:
+        (WebCore::OscillatorNode::create):
+        * Modules/webaudio/PannerNode.cpp:
+        (WebCore::PannerNode::create):
+        (WebCore::PannerNode::PannerNode):
+        * Modules/webaudio/WaveShaperNode.cpp:
+        (WebCore::WaveShaperNode::create):
+        * Modules/webaudio/WebKitAudioPannerNode.cpp:
+        (WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
+2020-08-05  Chris Dumez  <cdu...@apple.com>
+
         Add constructor to ConvolverNode
         https://bugs.webkit.org/show_bug.cgi?id=215169
 

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (265306 => 265307)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-08-05 22:18:28 UTC (rev 265307)
@@ -328,6 +328,7 @@
 $(PROJECT_DIR)/Modules/webaudio/DelayOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/DistanceModelType.idl
 $(PROJECT_DIR)/Modules/webaudio/DynamicsCompressorNode.idl
+$(PROJECT_DIR)/Modules/webaudio/DynamicsCompressorOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/GainNode.idl
 $(PROJECT_DIR)/Modules/webaudio/GainOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/MediaElementAudioSourceNode.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (265306 => 265307)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-08-05 22:18:28 UTC (rev 265307)
@@ -550,6 +550,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDragEvent.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDynamicsCompressorNode.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDynamicsCompressorNode.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDynamicsCompressorOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDynamicsCompressorOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSEXTBlendMinMax.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSEXTBlendMinMax.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSEXTColorBufferFloat.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (265306 => 265307)


--- trunk/Source/WebCore/DerivedSources.make	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/DerivedSources.make	2020-08-05 22:18:28 UTC (rev 265307)
@@ -411,6 +411,7 @@
     $(WebCore)/Modules/webaudio/DelayOptions.idl \
     $(WebCore)/Modules/webaudio/DistanceModelType.idl \
     $(WebCore)/Modules/webaudio/DynamicsCompressorNode.idl \
+    $(WebCore)/Modules/webaudio/DynamicsCompressorOptions.idl \
     $(WebCore)/Modules/webaudio/GainNode.idl \
     $(WebCore)/Modules/webaudio/GainOptions.idl \
     $(WebCore)/Modules/webaudio/MediaElementAudioSourceNode.idl \

Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -45,18 +45,10 @@
     
     auto analyser = adoptRef(*new AnalyserNode(context));
     
-    auto result = analyser->setChannelCount(options.channelCount.valueOr(2));
+    auto result = analyser->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
     
-    result = analyser->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
-    if (result.hasException())
-        return result.releaseException();
-    
-    result = analyser->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-    
     result = analyser->setMinMaxDecibels(options.minDecibels, options.maxDecibels);
     if (result.hasException())
         return result.releaseException();

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -30,6 +30,7 @@
 
 #include "AudioContext.h"
 #include "AudioNodeInput.h"
+#include "AudioNodeOptions.h"
 #include "AudioNodeOutput.h"
 #include "AudioParam.h"
 #include "Logging.h"
@@ -105,9 +106,6 @@
     , m_logger(context.logger())
     , m_logIdentifier(context.nextAudioNodeLogIdentifier())
 #endif
-    , m_channelCount(2)
-    , m_channelCountMode(ChannelCountMode::Max)
-    , m_channelInterpretation(ChannelInterpretation::Speakers)
 {
     ALWAYS_LOG(LOGIDENTIFIER);
     
@@ -321,6 +319,13 @@
         input->changedOutputs();
 }
 
+void AudioNode::initializeDefaultNodeOptions(unsigned count, ChannelCountMode mode, WebCore::ChannelInterpretation interpretation)
+{
+    m_channelCount = count;
+    m_channelCountMode = mode;
+    m_channelInterpretation = interpretation;
+}
+
 EventTargetInterface AudioNode::eventTargetInterface() const
 {
     return AudioNodeEventTargetInterfaceType;
@@ -544,6 +549,23 @@
     }
 }
 
+ExceptionOr<void> AudioNode::handleAudioNodeOptions(const AudioNodeOptions& options, const DefaultAudioNodeOptions& defaults)
+{
+    auto result = setChannelCount(options.channelCount.valueOr(defaults.channelCount));
+    if (result.hasException())
+        return result.releaseException();
+
+    result = setChannelCountMode(options.channelCountMode.valueOr(defaults.channelCountMode));
+    if (result.hasException())
+        return result.releaseException();
+
+    result = setChannelInterpretation(options.channelInterpretation.valueOr(defaults.channelInterpretation));
+    if (result.hasException())
+        return result.releaseException();
+
+    return { };
+}
+
 #if DEBUG_AUDIONODE_REFERENCES
 
 bool AudioNode::s_isNodeCountInitialized = false;

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.h (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.h	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.h	2020-08-05 22:18:28 UTC (rev 265307)
@@ -186,6 +186,14 @@
     // Inputs and outputs must be created before the AudioNode is initialized.
     void addInput(std::unique_ptr<AudioNodeInput>);
     void addOutput(std::unique_ptr<AudioNodeOutput>);
+
+    struct DefaultAudioNodeOptions {
+        unsigned channelCount;
+        ChannelCountMode channelCountMode;
+        ChannelInterpretation channelInterpretation;
+    };
+
+    ExceptionOr<void> handleAudioNodeOptions(const AudioNodeOptions&, const DefaultAudioNodeOptions&);
     
     // Called by processIfNecessary() to cause all parts of the rendering graph connected to us to process.
     // Each rendering quantum, the audio data for each of the AudioNode's inputs will be available after this method is called.
@@ -202,6 +210,8 @@
     WTFLogChannel& logChannel() const final;
 #endif
 
+    void initializeDefaultNodeOptions(unsigned count, ChannelCountMode, ChannelInterpretation);
+
 private:
     // EventTarget
     EventTargetInterface eventTargetInterface() const override;
@@ -241,10 +251,9 @@
     const void* m_logIdentifier;
 #endif
 
-protected:
-    unsigned m_channelCount;
-    ChannelCountMode m_channelCountMode;
-    ChannelInterpretation m_channelInterpretation;
+    unsigned m_channelCount { 2 };
+    ChannelCountMode m_channelCountMode { ChannelCountMode::Max };
+    ChannelInterpretation m_channelInterpretation { ChannelInterpretation::Speakers };
 };
 
 String convertEnumerationToString(AudioNode::NodeType);

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -526,11 +526,7 @@
     ALWAYS_LOG(LOGIDENTIFIER);
     
     ASSERT(isMainThread());
-    if (m_isStopScheduled)
-        return Exception { InvalidStateError };
-
-    lazyInitialize();
-    return DynamicsCompressorNode::create(*this, sampleRate());
+    return DynamicsCompressorNode::create(*this);
 }
 
 ExceptionOr<Ref<AnalyserNode>> BaseAudioContext::createAnalyser()

Modified: trunk/Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -42,18 +42,10 @@
 
     auto node = adoptRef(*new BiquadFilterNode(context));
 
-    auto result = node->setChannelCount(options.channelCount.valueOr(2));
+    auto result = node->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
 
-    result = node->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = node->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-
     node->setType(options.type);
     node->q().setValue(options.Q);
     node->detune().setValue(options.detune);

Modified: trunk/Source/WebCore/Modules/webaudio/ChannelMergerNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/ChannelMergerNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/ChannelMergerNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -55,18 +55,10 @@
     
     auto merger = adoptRef(*new ChannelMergerNode(context, context.sampleRate(), options.numberOfInputs));
     
-    auto result = merger->setChannelCount(options.channelCount.valueOr(1));
+    auto result = merger->handleAudioNodeOptions(options, { 1, ChannelCountMode::Explicit, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
     
-    result = merger->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Explicit));
-    if (result.hasException())
-        return result.releaseException();
-    
-    result = merger->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-    
     return merger;
 }
 

Modified: trunk/Source/WebCore/Modules/webaudio/ChannelSplitterNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/ChannelSplitterNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/ChannelSplitterNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -49,18 +49,10 @@
     
     auto splitter = adoptRef(*new ChannelSplitterNode(context, context.sampleRate(), options.numberOfOutputs));
     
-    auto result = splitter->setChannelCount(options.channelCount.valueOr(options.numberOfOutputs));
+    auto result = splitter->handleAudioNodeOptions(options, { options.numberOfOutputs, ChannelCountMode::Explicit, ChannelInterpretation::Discrete });
     if (result.hasException())
         return result.releaseException();
     
-    result = splitter->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Explicit));
-    if (result.hasException())
-        return result.releaseException();
-    
-    result = splitter->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Discrete));
-    if (result.hasException())
-        return result.releaseException();
-    
     return splitter;
 }
 

Modified: trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -56,18 +56,10 @@
 
     auto node = adoptRef(*new ConvolverNode(context));
 
-    auto result = node->setChannelCount(options.channelCount.valueOr(2));
+    auto result = node->handleAudioNodeOptions(options, { 2, ChannelCountMode::ClampedMax, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
 
-    result = node->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::ClampedMax));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = node->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-
     result = node->setBuffer(WTFMove(options.buffer));
     if (result.hasException())
         return result.releaseException();
@@ -84,11 +76,6 @@
 
     addInput(makeUnique<AudioNodeInput>(this));
     addOutput(makeUnique<AudioNodeOutput>(this, 2));
-
-    // Node-specific default mixing rules.
-    m_channelCount = 2;
-    m_channelCountMode = ChannelCountMode::ClampedMax;
-    m_channelInterpretation = ChannelInterpretation::Speakers;
     
     initialize();
 }

Modified: trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -46,10 +46,7 @@
 DefaultAudioDestinationNode::DefaultAudioDestinationNode(BaseAudioContext& context, Optional<float> sampleRate)
     : AudioDestinationNode(context, sampleRate.valueOr(AudioDestination::hardwareSampleRate()))
 {
-    // Node-specific default mixing rules.
-    m_channelCount = 2;
-    m_channelCountMode = ChannelCountMode::Explicit;
-    m_channelInterpretation = ChannelInterpretation::Speakers;
+    initializeDefaultNodeOptions(2, ChannelCountMode::Explicit, ChannelInterpretation::Speakers);
 }
 
 DefaultAudioDestinationNode::~DefaultAudioDestinationNode()

Modified: trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -57,18 +57,10 @@
 
     auto delayNode = adoptRef(*new DelayNode(context, options.maxDelayTime));
 
-    auto result = delayNode->setChannelCount(options.channelCount.valueOr(2));
+    auto result = delayNode->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
 
-    result = delayNode->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = delayNode->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-
     delayNode->delayTime().setValue(options.delayTime);
 
     return delayNode;

Modified: trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, Google Inc. All rights reserved.
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,21 +42,36 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(DynamicsCompressorNode);
 
-DynamicsCompressorNode::DynamicsCompressorNode(BaseAudioContext& context, float sampleRate)
-    : AudioNode(context, sampleRate)
+ExceptionOr<Ref<DynamicsCompressorNode>> DynamicsCompressorNode::create(BaseAudioContext& context, const DynamicsCompressorOptions& options)
 {
+    if (context.isStopped())
+        return Exception { InvalidStateError };
+
+    context.lazyInitialize();
+
+    auto node = adoptRef(*new DynamicsCompressorNode(context, options));
+
+    auto result = node->handleAudioNodeOptions(options, { 2, ChannelCountMode::ClampedMax, ChannelInterpretation::Speakers });
+    if (result.hasException())
+        return result.releaseException();
+
+    return node;
+}
+
+DynamicsCompressorNode::DynamicsCompressorNode(BaseAudioContext& context, const DynamicsCompressorOptions& options)
+    : AudioNode(context, context.sampleRate())
+    , m_threshold(AudioParam::create(context, "threshold"_s, options.threshold, -100, 0))
+    , m_knee(AudioParam::create(context, "knee"_s, options.knee, 0, 40))
+    , m_ratio(AudioParam::create(context, "ratio"_s, options.ratio, 1, 20))
+    , m_reduction(AudioParam::create(context, "reduction"_s, 0, -20, 0))
+    , m_attack(AudioParam::create(context, "attack"_s, options.attack, 0, 1))
+    , m_release(AudioParam::create(context, "release"_s, options.release, 0, 1))
+{
     setNodeType(NodeTypeDynamicsCompressor);
 
     addInput(makeUnique<AudioNodeInput>(this));
     addOutput(makeUnique<AudioNodeOutput>(this, defaultNumberOfOutputChannels));
 
-    m_threshold = AudioParam::create(context, "threshold", -24, -100, 0);
-    m_knee = AudioParam::create(context, "knee", 30, 0, 40);
-    m_ratio = AudioParam::create(context, "ratio", 12, 1, 20);
-    m_reduction = AudioParam::create(context, "reduction", 0, -20, 0);
-    m_attack = AudioParam::create(context, "attack", 0.003, 0, 1);
-    m_release = AudioParam::create(context, "release", 0.250, 0, 1);
-
     initialize();
 }
 
@@ -120,6 +136,20 @@
     return m_dynamicsCompressor->latencyTime();
 }
 
+ExceptionOr<void> DynamicsCompressorNode::setChannelCount(unsigned count)
+{
+    if (count > 2)
+        return Exception { NotSupportedError, "DynamicsCompressorNode's channel count cannot be greater than 2"_s };
+    return AudioNode::setChannelCount(count);
+}
+
+ExceptionOr<void> DynamicsCompressorNode::setChannelCountMode(ChannelCountMode mode)
+{
+    if (mode == ChannelCountMode::Max)
+        return Exception { NotSupportedError, "DynamicsCompressorNode's channel count mode cannot be set to 'max'"_s };
+    return AudioNode::setChannelCountMode(mode);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.h (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.h	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.h	2020-08-05 22:18:28 UTC (rev 265307)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, Google Inc. All rights reserved.
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +27,7 @@
 
 #include "AudioNode.h"
 #include "AudioParam.h"
+#include "DynamicsCompressorOptions.h"
 #include <memory>
 
 namespace WebCore {
@@ -35,10 +37,7 @@
 class DynamicsCompressorNode final : public AudioNode {
     WTF_MAKE_ISO_ALLOCATED(DynamicsCompressorNode);
 public:
-    static Ref<DynamicsCompressorNode> create(BaseAudioContext& context, float sampleRate)
-    {
-        return adoptRef(*new DynamicsCompressorNode(context, sampleRate));
-    }
+    static ExceptionOr<Ref<DynamicsCompressorNode>> create(BaseAudioContext&, const DynamicsCompressorOptions& = { });
 
     virtual ~DynamicsCompressorNode();
 
@@ -49,28 +48,31 @@
     void uninitialize() override;
 
     // Static compression curve parameters.
-    AudioParam* threshold() { return m_threshold.get(); }
-    AudioParam* knee() { return m_knee.get(); }
-    AudioParam* ratio() { return m_ratio.get(); }
-    AudioParam* attack() { return m_attack.get(); }
-    AudioParam* release() { return m_release.get(); }
+    AudioParam& threshold() { return m_threshold.get(); }
+    AudioParam& knee() { return m_knee.get(); }
+    AudioParam& ratio() { return m_ratio.get(); }
+    AudioParam& attack() { return m_attack.get(); }
+    AudioParam& release() { return m_release.get(); }
 
     // Amount by which the compressor is currently compressing the signal in decibels.
-    AudioParam* reduction() { return m_reduction.get(); }
+    AudioParam& reduction() { return m_reduction.get(); }
 
+    ExceptionOr<void> setChannelCount(unsigned) final;
+    ExceptionOr<void> setChannelCountMode(ChannelCountMode) final;
+
 private:
     double tailTime() const override;
     double latencyTime() const override;
 
-    DynamicsCompressorNode(BaseAudioContext&, float sampleRate);
+    DynamicsCompressorNode(BaseAudioContext&, const DynamicsCompressorOptions&);
 
     std::unique_ptr<DynamicsCompressor> m_dynamicsCompressor;
-    RefPtr<AudioParam> m_threshold;
-    RefPtr<AudioParam> m_knee;
-    RefPtr<AudioParam> m_ratio;
-    RefPtr<AudioParam> m_reduction;
-    RefPtr<AudioParam> m_attack;
-    RefPtr<AudioParam> m_release;
+    Ref<AudioParam> m_threshold;
+    Ref<AudioParam> m_knee;
+    Ref<AudioParam> m_ratio;
+    Ref<AudioParam> m_reduction;
+    Ref<AudioParam> m_attack;
+    Ref<AudioParam> m_release;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl	2020-08-05 22:18:28 UTC (rev 265307)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, Google Inc. All rights reserved.
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,10 +27,14 @@
     Conditional=WEB_AUDIO,
     JSGenerateToJSObject
 ] interface DynamicsCompressorNode : AudioNode {
+    [MayThrowException, EnabledBySetting=ModernUnprefixedWebAudio] constructor (BaseAudioContext context, optional DynamicsCompressorOptions options);
+
     readonly attribute AudioParam threshold; // in Decibels
     readonly attribute AudioParam knee; // in Decibels
     readonly attribute AudioParam ratio; // unit-less
-    readonly attribute AudioParam reduction; // in Decibels
     readonly attribute AudioParam attack; // in Seconds
     readonly attribute AudioParam release; // in Seconds
+
+    // FIXME: The following attribute should use float type.
+    readonly attribute AudioParam reduction; // in Decibels
 };

Copied: trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorOptions.h (from rev 265306, trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl) (0 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorOptions.h	2020-08-05 22:18:28 UTC (rev 265307)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AudioNodeOptions.h"
+
+namespace WebCore {
+
+struct DynamicsCompressorOptions : AudioNodeOptions {
+    float attack { 0.003 };
+    float knee { 30 };
+    float ratio { 12 };
+    float release { 0.25 };
+    float threshold { -24 };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)

Copied: trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorOptions.idl (from rev 265306, trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.idl) (0 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorOptions.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorOptions.idl	2020-08-05 22:18:28 UTC (rev 265307)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=WEB_AUDIO
+] dictionary DynamicsCompressorOptions : AudioNodeOptions {
+    float attack = 0.003;
+    float knee = 30;
+    float ratio = 12;
+    float release = 0.25;
+    float threshold = -24;
+};

Modified: trunk/Source/WebCore/Modules/webaudio/GainNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/GainNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/GainNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -46,18 +46,10 @@
 
     auto gainNode = adoptRef(*new GainNode(context));
 
-    auto result = gainNode->setChannelCount(options.channelCount.valueOr(2));
+    auto result = gainNode->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
 
-    result = gainNode->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = gainNode->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-
     gainNode->gain().setValue(options.gain);
 
     return gainNode;

Modified: trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -57,18 +57,10 @@
     
     auto oscillator = adoptRef(*new OscillatorNode(context, options));
     
-    auto result = oscillator->setChannelCount(options.channelCount.valueOr(2));
+    auto result = oscillator->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
     
-    result = oscillator->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
-    if (result.hasException())
-        return result.releaseException();
-    
-    result = oscillator->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-    
     if (options.periodicWave)
         oscillator->setPeriodicWave(*options.periodicWave);
     else {

Modified: trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -69,10 +69,14 @@
 
     auto panner = adoptRef(*new PannerNode(context, options));
 
-    auto result = panner->setMaxDistance(options.maxDistance);
+    auto result = panner->handleAudioNodeOptions(options, { 2, ChannelCountMode::ClampedMax, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
 
+    result = panner->setMaxDistance(options.maxDistance);
+    if (result.hasException())
+        return result.releaseException();
+
     result = panner->setRefDistance(options.refDistance);
     if (result.hasException())
         return result.releaseException();
@@ -85,18 +89,6 @@
     if (result.hasException())
         return result.releaseException();
 
-    result = panner->setChannelCount(options.channelCount.valueOr(2));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = panner->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::ClampedMax));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = panner->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-
     return panner;
 }
 
@@ -114,10 +106,11 @@
     // Load the HRTF database asynchronously so we don't block the _javascript_ thread while creating the HRTF database.
     , m_hrtfDatabaseLoader(HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(context.sampleRate()))
 {
+    setNodeType(NodeTypePanner);
+
     setDistanceModel(options.distanceModel);
     setConeInnerAngle(options.coneInnerAngle);
     setConeOuterAngle(options.coneOuterAngle);
-    setNodeType(NodeTypePanner);
 
     addInput(makeUnique<AudioNodeInput>(this));
     addOutput(makeUnique<AudioNodeOutput>(this, 2));

Modified: trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -54,18 +54,10 @@
 
     auto node = adoptRef(*new WaveShaperNode(context));
 
-    auto result = node->setChannelCount(options.channelCount.valueOr(2));
+    auto result = node->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });
     if (result.hasException())
         return result.releaseException();
 
-    result = node->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
-    if (result.hasException())
-        return result.releaseException();
-
-    result = node->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
-    if (result.hasException())
-        return result.releaseException();
-
     if (curve) {
         result = node->setCurve(WTFMove(curve));
         if (result.hasException())

Modified: trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp (265306 => 265307)


--- trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp	2020-08-05 22:18:28 UTC (rev 265307)
@@ -55,6 +55,7 @@
     , m_connectionCount(0)
 {
     setNodeType(NodeTypePanner);
+    initializeDefaultNodeOptions(2, ChannelCountMode::ClampedMax, ChannelInterpretation::Speakers);
 
     // Load the HRTF database asynchronously so we don't block the _javascript_ thread while creating the HRTF database.
     m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(context.sampleRate());
@@ -62,11 +63,6 @@
     addInput(makeUnique<AudioNodeInput>(this));
     addOutput(makeUnique<AudioNodeOutput>(this, 2));
 
-    // Node-specific default mixing rules.
-    m_channelCount = 2;
-    m_channelCountMode = ChannelCountMode::ClampedMax;
-    m_channelInterpretation = ChannelInterpretation::Speakers;
-
     m_distanceGain = AudioParam::create(context, "distanceGain", 1.0, 0.0, 1.0);
     m_coneGain = AudioParam::create(context, "coneGain", 1.0, 0.0, 1.0);
 

Modified: trunk/Source/WebCore/Sources.txt (265306 => 265307)


--- trunk/Source/WebCore/Sources.txt	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/Sources.txt	2020-08-05 22:18:28 UTC (rev 265307)
@@ -2825,6 +2825,7 @@
 JSDoubleRange.cpp
 JSDragEvent.cpp
 JSDynamicsCompressorNode.cpp
+JSDynamicsCompressorOptions.cpp
 JSEXTBlendMinMax.cpp
 JSEXTColorBufferFloat.cpp
 JSEXTColorBufferHalfFloat.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (265306 => 265307)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-08-05 21:30:22 UTC (rev 265306)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-08-05 22:18:28 UTC (rev 265307)
@@ -2486,6 +2486,7 @@
 		8379363F1FBBB0B400C8023C /* ServiceWorkerClientData.h in Headers */ = {isa = PBXBuildFile; fileRef = 8379363E1FBBB0A500C8023C /* ServiceWorkerClientData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		837964CF1F8DB69D00218EA0 /* GeolocationPositionDataIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 837964CE1F8DB69A00218EA0 /* GeolocationPositionDataIOS.mm */; };
 		837A80131E1E127300026B9F /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 837A80111E1E127300026B9F /* Localizable.stringsdict */; };
+		837C0B7624DB3850005D5959 /* DynamicsCompressorOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 837C0B7324DB3842005D5959 /* DynamicsCompressorOptions.h */; };
 		837D46271FA2A8CE0054E1FA /* ServiceWorkerClientIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 837D46251FA2A8C50054E1FA /* ServiceWorkerClientIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		837FB3451F9EA06D00D0FC31 /* ExtendableMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */; };
 		838867351D13BA5F003697D0 /* RenderObjectEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 838867341D13BA59003697D0 /* RenderObjectEnums.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10551,6 +10552,8 @@
 		837964CE1F8DB69A00218EA0 /* GeolocationPositionDataIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GeolocationPositionDataIOS.mm; path = Modules/geolocation/ios/GeolocationPositionDataIOS.mm; sourceTree = SOURCE_ROOT; };
 		837A80121E1E127300026B9F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = SOURCE_ROOT; };
 		837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ValidationBubbleIOS.mm; sourceTree = "<group>"; };
+		837C0B7324DB3842005D5959 /* DynamicsCompressorOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DynamicsCompressorOptions.h; sourceTree = "<group>"; };
+		837C0B7524DB3843005D5959 /* DynamicsCompressorOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DynamicsCompressorOptions.idl; sourceTree = "<group>"; };
 		837D46251FA2A8C50054E1FA /* ServiceWorkerClientIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerClientIdentifier.h; sourceTree = "<group>"; };
 		837DFB341EBFEA7000601385 /* ElementCSSInlineStyle.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ElementCSSInlineStyle.idl; sourceTree = "<group>"; };
 		837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtendableMessageEvent.h; sourceTree = "<group>"; };
@@ -29607,6 +29610,8 @@
 				FD6ED2C1136B8E42003CF072 /* DynamicsCompressorNode.cpp */,
 				FD6ED2C2136B8E42003CF072 /* DynamicsCompressorNode.h */,
 				FD6ED2C9136B8E9D003CF072 /* DynamicsCompressorNode.idl */,
+				837C0B7324DB3842005D5959 /* DynamicsCompressorOptions.h */,
+				837C0B7524DB3843005D5959 /* DynamicsCompressorOptions.idl */,
 				FD315FC212B0267500C1A359 /* GainNode.cpp */,
 				FD315FC312B0267500C1A359 /* GainNode.h */,
 				FD315FC412B0267500C1A359 /* GainNode.idl */,
@@ -30851,6 +30856,7 @@
 				FD6ED2C8136B8E66003CF072 /* DynamicsCompressor.h in Headers */,
 				FD537357137B653B00008DCE /* DynamicsCompressorKernel.h in Headers */,
 				FD6ED2C4136B8E42003CF072 /* DynamicsCompressorNode.h in Headers */,
+				837C0B7624DB3850005D5959 /* DynamicsCompressorOptions.h in Headers */,
 				2D2E34AC21A4E192004598B5 /* EditableImageReference.h in Headers */,
 				93309DE2099E64920056E581 /* EditAction.h in Headers */,
 				93309DE4099E64920056E581 /* EditCommand.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to