aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/audiobuffersourcenode.rs16
-rw-r--r--components/script/dom/audionode.rs9
-rw-r--r--components/script/dom/audioscheduledsourcenode.rs9
-rw-r--r--components/script/dom/baseaudiocontext.rs6
-rw-r--r--components/script/dom/channelmergernode.rs2
-rw-r--r--components/script/dom/gainnode.rs16
-rw-r--r--components/script/dom/oscillatornode.rs16
-rw-r--r--components/script/dom/pannernode.rs2
-rw-r--r--components/script/dom/webidls/BaseAudioContext.webidl6
9 files changed, 44 insertions, 38 deletions
diff --git a/components/script/dom/audiobuffersourcenode.rs b/components/script/dom/audiobuffersourcenode.rs
index 79841e38e22..a3ddf4121a9 100644
--- a/components/script/dom/audiobuffersourcenode.rs
+++ b/components/script/dom/audiobuffersourcenode.rs
@@ -44,7 +44,7 @@ impl AudioBufferSourceNode {
window: &Window,
context: &BaseAudioContext,
options: &AudioBufferSourceOptions,
- ) -> AudioBufferSourceNode {
+ ) -> Fallible<AudioBufferSourceNode> {
let mut node_options = AudioNodeOptions::empty();
node_options.channelCount = Some(2);
node_options.channelCountMode = Some(ChannelCountMode::Max);
@@ -55,7 +55,7 @@ impl AudioBufferSourceNode {
&node_options,
0, /* inputs */
1, /* outputs */
- );
+ )?;
let node_id = source_node.node().node_id();
let playback_rate = AudioParam::new(
&window,
@@ -77,7 +77,7 @@ impl AudioBufferSourceNode {
f32::MIN,
f32::MAX,
);
- AudioBufferSourceNode {
+ Ok(AudioBufferSourceNode {
source_node,
buffer: Default::default(),
playback_rate: Dom::from_ref(&playback_rate),
@@ -85,7 +85,7 @@ impl AudioBufferSourceNode {
loop_enabled: Cell::new(options.loop_),
loop_start: Cell::new(*options.loopStart),
loop_end: Cell::new(*options.loopEnd),
- }
+ })
}
#[allow(unrooted_must_root)]
@@ -93,9 +93,9 @@ impl AudioBufferSourceNode {
window: &Window,
context: &BaseAudioContext,
options: &AudioBufferSourceOptions,
- ) -> DomRoot<AudioBufferSourceNode> {
- let node = AudioBufferSourceNode::new_inherited(window, context, options);
- reflect_dom_object(Box::new(node), window, AudioBufferSourceNodeBinding::Wrap)
+ ) -> Fallible<DomRoot<AudioBufferSourceNode>> {
+ let node = AudioBufferSourceNode::new_inherited(window, context, options)?;
+ Ok(reflect_dom_object(Box::new(node), window, AudioBufferSourceNodeBinding::Wrap))
}
pub fn Constructor(
@@ -103,7 +103,7 @@ impl AudioBufferSourceNode {
context: &BaseAudioContext,
options: &AudioBufferSourceOptions,
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
- Ok(AudioBufferSourceNode::new(window, context, options))
+ AudioBufferSourceNode::new(window, context, options)
}
}
diff --git a/components/script/dom/audionode.rs b/components/script/dom/audionode.rs
index b48a902a8b4..5a149dd814f 100644
--- a/components/script/dom/audionode.rs
+++ b/components/script/dom/audionode.rs
@@ -44,9 +44,14 @@ impl AudioNode {
options: &AudioNodeOptions,
number_of_inputs: u32,
number_of_outputs: u32,
- ) -> AudioNode {
+ ) -> Fallible<AudioNode> {
+ if let Some(c) = options.channelCount {
+ if c == 0 || c > MAX_CHANNEL_COUNT {
+ return Err(Error::NotSupported);
+ }
+ }
let node_id = context.audio_context_impl().create_node(node_type);
- AudioNode::new_inherited_for_id(node_id, context, options, number_of_inputs, number_of_outputs)
+ Ok(AudioNode::new_inherited_for_id(node_id, context, options, number_of_inputs, number_of_outputs))
}
pub fn new_inherited_for_id(
diff --git a/components/script/dom/audioscheduledsourcenode.rs b/components/script/dom/audioscheduledsourcenode.rs
index 03f1f952102..871a793f6ec 100644
--- a/components/script/dom/audioscheduledsourcenode.rs
+++ b/components/script/dom/audioscheduledsourcenode.rs
@@ -24,24 +24,25 @@ pub struct AudioScheduledSourceNode {
}
impl AudioScheduledSourceNode {
+ #[allow(unrooted_must_root)]
pub fn new_inherited(
node_type: AudioNodeInit,
context: &BaseAudioContext,
options: &AudioNodeOptions,
number_of_inputs: u32,
number_of_outputs: u32,
- ) -> AudioScheduledSourceNode {
- AudioScheduledSourceNode {
+ ) -> Fallible<AudioScheduledSourceNode> {
+ Ok(AudioScheduledSourceNode {
node: AudioNode::new_inherited(
node_type,
context,
options,
number_of_inputs,
number_of_outputs,
- ),
+ )?,
started: Cell::new(false),
stopped: Cell::new(false),
- }
+ })
}
pub fn node(&self) -> &AudioNode {
diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs
index 9513a0b22d1..15316e1b89d 100644
--- a/components/script/dom/baseaudiocontext.rs
+++ b/components/script/dom/baseaudiocontext.rs
@@ -317,7 +317,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
event_handler!(statechange, GetOnstatechange, SetOnstatechange);
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator
- fn CreateOscillator(&self) -> DomRoot<OscillatorNode> {
+ fn CreateOscillator(&self) -> Fallible<DomRoot<OscillatorNode>> {
OscillatorNode::new(
&self.global().as_window(),
&self,
@@ -326,7 +326,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
}
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain
- fn CreateGain(&self) -> DomRoot<GainNode> {
+ fn CreateGain(&self) -> Fallible<DomRoot<GainNode>> {
GainNode::new(&self.global().as_window(), &self, &GainOptions::empty())
}
@@ -360,7 +360,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
}
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffersource
- fn CreateBufferSource(&self) -> DomRoot<AudioBufferSourceNode> {
+ fn CreateBufferSource(&self) -> Fallible<DomRoot<AudioBufferSourceNode>> {
AudioBufferSourceNode::new(
&self.global().as_window(),
&self,
diff --git a/components/script/dom/channelmergernode.rs b/components/script/dom/channelmergernode.rs
index 93fcf51b27a..d36c481a158 100644
--- a/components/script/dom/channelmergernode.rs
+++ b/components/script/dom/channelmergernode.rs
@@ -49,7 +49,7 @@ impl ChannelMergerNode {
&node_options,
options.numberOfInputs, // inputs
1, // outputs
- );
+ )?;
Ok(ChannelMergerNode {
node,
})
diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs
index 17c32b00352..a48cdc7c86b 100644
--- a/components/script/dom/gainnode.rs
+++ b/components/script/dom/gainnode.rs
@@ -31,7 +31,7 @@ impl GainNode {
window: &Window,
context: &BaseAudioContext,
options: &GainOptions,
- ) -> GainNode {
+ ) -> Fallible<GainNode> {
let mut node_options = AudioNodeOptions::empty();
let count = options.parent.channelCount.unwrap_or(2);
let mode = options.parent.channelCountMode.unwrap_or(ChannelCountMode::Max);
@@ -45,7 +45,7 @@ impl GainNode {
&node_options,
1, // inputs
1, // outputs
- );
+ )?;
let gain = AudioParam::new(
window,
context,
@@ -56,10 +56,10 @@ impl GainNode {
f32::MIN, // min value
f32::MAX, // max value
);
- GainNode {
+ Ok(GainNode {
node,
gain: Dom::from_ref(&gain),
- }
+ })
}
#[allow(unrooted_must_root)]
@@ -67,9 +67,9 @@ impl GainNode {
window: &Window,
context: &BaseAudioContext,
options: &GainOptions,
- ) -> DomRoot<GainNode> {
- let node = GainNode::new_inherited(window, context, options);
- reflect_dom_object(Box::new(node), window, GainNodeBinding::Wrap)
+ ) -> Fallible<DomRoot<GainNode>> {
+ let node = GainNode::new_inherited(window, context, options)?;
+ Ok(reflect_dom_object(Box::new(node), window, GainNodeBinding::Wrap))
}
pub fn Constructor(
@@ -77,7 +77,7 @@ impl GainNode {
context: &BaseAudioContext,
options: &GainOptions,
) -> Fallible<DomRoot<GainNode>> {
- Ok(GainNode::new(window, context, options))
+ GainNode::new(window, context, options)
}
}
diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs
index f44fa747f7d..662724c4438 100644
--- a/components/script/dom/oscillatornode.rs
+++ b/components/script/dom/oscillatornode.rs
@@ -35,7 +35,7 @@ impl OscillatorNode {
window: &Window,
context: &BaseAudioContext,
oscillator_options: &OscillatorOptions,
- ) -> OscillatorNode {
+ ) -> Fallible<OscillatorNode> {
let mut node_options = AudioNodeOptions::empty();
node_options.channelCount = Some(2);
node_options.channelCountMode = Some(ChannelCountMode::Max);
@@ -46,7 +46,7 @@ impl OscillatorNode {
&node_options,
0, /* inputs */
1, /* outputs */
- );
+ )?;
let node_id = source_node.node().node_id();
let frequency = AudioParam::new(
window,
@@ -69,12 +69,12 @@ impl OscillatorNode {
440. / 2.,
);
- OscillatorNode {
+ Ok(OscillatorNode {
source_node,
oscillator_type: oscillator_options.type_,
frequency: Dom::from_ref(&frequency),
detune: Dom::from_ref(&detune),
- }
+ })
}
#[allow(unrooted_must_root)]
@@ -82,9 +82,9 @@ impl OscillatorNode {
window: &Window,
context: &BaseAudioContext,
options: &OscillatorOptions,
- ) -> DomRoot<OscillatorNode> {
- let node = OscillatorNode::new_inherited(window, context, options);
- reflect_dom_object(Box::new(node), window, OscillatorNodeBinding::Wrap)
+ ) -> Fallible<DomRoot<OscillatorNode>> {
+ let node = OscillatorNode::new_inherited(window, context, options)?;
+ Ok(reflect_dom_object(Box::new(node), window, OscillatorNodeBinding::Wrap))
}
pub fn Constructor(
@@ -92,7 +92,7 @@ impl OscillatorNode {
context: &BaseAudioContext,
options: &OscillatorOptions,
) -> Fallible<DomRoot<OscillatorNode>> {
- Ok(OscillatorNode::new(window, context, options))
+ OscillatorNode::new(window, context, options)
}
}
diff --git a/components/script/dom/pannernode.rs b/components/script/dom/pannernode.rs
index ab1fea05db9..a27388f2cab 100644
--- a/components/script/dom/pannernode.rs
+++ b/components/script/dom/pannernode.rs
@@ -84,7 +84,7 @@ impl PannerNode {
&node_options,
1, // inputs
1, // outputs
- );
+ )?;
let id = node.node_id();
let position_x = AudioParam::new(
window,
diff --git a/components/script/dom/webidls/BaseAudioContext.webidl b/components/script/dom/webidls/BaseAudioContext.webidl
index f00ec373667..14dd4bb6d5e 100644
--- a/components/script/dom/webidls/BaseAudioContext.webidl
+++ b/components/script/dom/webidls/BaseAudioContext.webidl
@@ -30,13 +30,13 @@ interface BaseAudioContext : EventTarget {
Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
optional DecodeSuccessCallback successCallback,
optional DecodeErrorCallback errorCallback);
- AudioBufferSourceNode createBufferSource();
+ [Throws] AudioBufferSourceNode createBufferSource();
// ConstantSourceNode createConstantSource();
// ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0,
// optional unsigned long numberOfInputChannels = 2,
// optional unsigned long numberOfOutputChannels = 2);
// AnalyserNode createAnalyser();
- GainNode createGain();
+ [Throws] GainNode createGain();
// DelayNode createDelay(optional double maxDelayTime = 1);
// BiquadFilterNode createBiquadFilter();
// IIRFilterNode createIIRFilter(sequence<double> feedforward,
@@ -48,7 +48,7 @@ interface BaseAudioContext : EventTarget {
// ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
// ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);
// DynamicsCompressorNode createDynamicsCompressor();
- OscillatorNode createOscillator();
+ [Throws] OscillatorNode createOscillator();
// PeriodicWave createPeriodicWave(sequence<float> real,
// sequence<float> imag,
// optional PeriodicWaveConstraints constraints);