diff --git a/components/script/dom/audiobuffersourcenode.rs b/components/script/dom/audiobuffersourcenode.rs index 3a1bcf6e914..64ca58b5bc9 100644 --- a/components/script/dom/audiobuffersourcenode.rs +++ b/components/script/dom/audiobuffersourcenode.rs @@ -7,12 +7,13 @@ use dom::audioparam::{AudioParam, AudioParamImpl}; use dom::audioscheduledsourcenode::AudioScheduledSourceNode; use dom::baseaudiocontext::BaseAudioContext; use dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding; -use dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceOptions; use dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceNodeMethods; +use dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceOptions; use dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation}; -use dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding::AudioScheduledSourceNodeBinding::AudioScheduledSourceNodeMethods; +use dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding:: + AudioScheduledSourceNodeBinding::AudioScheduledSourceNodeMethods; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; use dom::bindings::num::Finite; @@ -46,13 +47,12 @@ pub struct AudioBufferSourceNode { impl AudioBufferSourceNode { #[allow(unrooted_must_root)] - #[allow(unsafe_code)] fn new_inherited( window: &Window, context: &BaseAudioContext, options: &AudioBufferSourceOptions, ) -> AudioBufferSourceNode { - let mut node_options = unsafe { AudioNodeOptions::empty(window.get_cx()) }; + let mut node_options = AudioNodeOptions::empty(); node_options.channelCount = Some(2); node_options.channelCountMode = Some(ChannelCountMode::Max); node_options.channelInterpretation = Some(ChannelInterpretation::Speakers); diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 7f65eb04cbd..9a5310f70e8 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -86,7 +86,6 @@ pub struct BaseAudioContext { impl BaseAudioContext { #[allow(unrooted_must_root)] - #[allow(unsafe_code)] pub fn new_inherited( global: &GlobalScope, options: BaseAudioContextOptions, @@ -109,7 +108,7 @@ impl BaseAudioContext { state: Cell::new(AudioContextState::Suspended), }; - let mut options = unsafe { AudioNodeOptions::empty(global.get_cx()) }; + let mut options = AudioNodeOptions::empty(); options.channelCount = Some(2); options.channelCountMode = Some(ChannelCountMode::Explicit); options.channelInterpretation = Some(ChannelInterpretation::Speakers); @@ -287,21 +286,13 @@ impl BaseAudioContextMethods for BaseAudioContext { event_handler!(statechange, GetOnstatechange, SetOnstatechange); /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator - #[allow(unsafe_code)] fn CreateOscillator(&self) -> DomRoot { - let global = self.global(); - let window = global.as_window(); - let options = unsafe { OscillatorOptions::empty(window.get_cx()) }; - OscillatorNode::new(&window, &self, &options) + OscillatorNode::new(&self.global().as_window(), &self, &OscillatorOptions::empty()) } /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain - #[allow(unsafe_code)] fn CreateGain(&self) -> DomRoot { - let global = self.global(); - let window = global.as_window(); - let options = unsafe { GainOptions::empty(window.get_cx()) }; - GainNode::new(&window, &self, &options) + GainNode::new(&self.global().as_window(), &self, &GainOptions::empty()) } /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer @@ -315,16 +306,11 @@ impl BaseAudioContextMethods for BaseAudioContext { *sample_rate <= 0. { return Err(Error::NotSupported); } - let global = self.global(); - Ok(AudioBuffer::new(&global.as_window(), number_of_channels, length, *sample_rate, None)) + Ok(AudioBuffer::new(&self.global().as_window(), number_of_channels, length, *sample_rate, None)) } - #[allow(unsafe_code)] fn CreateBufferSource(&self) -> DomRoot { - let global = self.global(); - // XXX Can we do this implementing Default? - let options = unsafe { AudioBufferSourceOptions::empty(global.get_cx()) }; - AudioBufferSourceNode::new(&global.as_window(), &self, &options) + AudioBufferSourceNode::new(&self.global().as_window(), &self, &AudioBufferSourceOptions::empty()) } #[allow(unrooted_must_root)] diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index 6b43651231d..3bb2c573233 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -31,14 +31,13 @@ pub struct GainNode { } impl GainNode { - #[allow(unsafe_code)] #[allow(unrooted_must_root)] pub fn new_inherited( window: &Window, context: &BaseAudioContext, gain_options: &GainOptions, ) -> GainNode { - let mut node_options = unsafe { AudioNodeOptions::empty(window.get_cx()) }; + let mut node_options = AudioNodeOptions::empty(); node_options.channelCount = Some(2); node_options.channelCountMode = Some(ChannelCountMode::Max); node_options.channelInterpretation = Some(ChannelInterpretation::Speakers); diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs index 0440111410a..adb9cc778bc 100644 --- a/components/script/dom/oscillatornode.rs +++ b/components/script/dom/oscillatornode.rs @@ -38,13 +38,12 @@ pub struct OscillatorNode { impl OscillatorNode { #[allow(unrooted_must_root)] - #[allow(unsafe_code)] pub fn new_inherited( window: &Window, context: &BaseAudioContext, oscillator_options: &OscillatorOptions, ) -> OscillatorNode { - let mut node_options = unsafe { AudioNodeOptions::empty(window.get_cx()) }; + let mut node_options = AudioNodeOptions::empty(); node_options.channelCount = Some(2); node_options.channelCountMode = Some(ChannelCountMode::Max); node_options.channelInterpretation = Some(ChannelInterpretation::Speakers);