mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add disconnect methods; cleanup DOM stuff (#2)
* Add disconnect methods * Use Dom, not DomRoot DomRoot will keep it permanently rooted, it should only be used in values not on the JS heap
This commit is contained in:
parent
23f7a73622
commit
f3bc183dba
4 changed files with 34 additions and 29 deletions
|
@ -17,7 +17,7 @@ use dom::bindings::error::{Error, Fallible};
|
|||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_media::audio::buffer_source_node::AudioBufferSourceNodeMessage;
|
||||
|
@ -37,8 +37,8 @@ audio_param_impl!(Detune, AudioBufferSourceNode, AudioBufferSourceNodeMessage, S
|
|||
pub struct AudioBufferSourceNode {
|
||||
source_node: AudioScheduledSourceNode,
|
||||
buffer: MutNullableDom<AudioBuffer>,
|
||||
playback_rate: DomRoot<AudioParam>,
|
||||
detune: DomRoot<AudioParam>,
|
||||
playback_rate: Dom<AudioParam>,
|
||||
detune: Dom<AudioParam>,
|
||||
loop_enabled: Cell<bool>,
|
||||
loop_start: Cell<f64>,
|
||||
loop_end: Cell<f64>,
|
||||
|
@ -79,8 +79,8 @@ impl AudioBufferSourceNode {
|
|||
AudioBufferSourceNode {
|
||||
source_node,
|
||||
buffer: Default::default(),
|
||||
playback_rate,
|
||||
detune,
|
||||
playback_rate: Dom::from_ref(&playback_rate),
|
||||
detune: Dom::from_ref(&detune),
|
||||
loop_enabled: Cell::new(options.loop_),
|
||||
loop_start: Cell::new(*options.loopStart),
|
||||
loop_end: Cell::new(*options.loopEnd),
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::baseaudiocontext::BaseAudioContext;
|
|||
use dom::bindings::codegen::Bindings::AudioNodeBinding::{AudioNodeMethods, AudioNodeOptions};
|
||||
use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
use dom::audioparam::AudioParam;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -24,7 +24,7 @@ pub struct AudioNode {
|
|||
eventtarget: EventTarget,
|
||||
#[ignore_malloc_size_of = "servo_media"]
|
||||
node_id: NodeId,
|
||||
context: DomRoot<BaseAudioContext>,
|
||||
context: Dom<BaseAudioContext>,
|
||||
number_of_inputs: u32,
|
||||
number_of_outputs: u32,
|
||||
channel_count: Cell<u32>,
|
||||
|
@ -45,7 +45,7 @@ impl AudioNode {
|
|||
AudioNode {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
node_id,
|
||||
context: DomRoot::from_ref(context),
|
||||
context: Dom::from_ref(context),
|
||||
number_of_inputs,
|
||||
number_of_outputs,
|
||||
channel_count: Cell::new(options.channelCount.unwrap_or(2)),
|
||||
|
@ -96,31 +96,36 @@ impl AudioNodeMethods for AudioNode {
|
|||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
fn Disconnect(&self) -> ErrorResult {
|
||||
// TODO
|
||||
self.context.audio_context_impl()
|
||||
.disconnect_all_from(self.node_id());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
fn Disconnect_(&self, _: u32) -> ErrorResult {
|
||||
// TODO
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-output
|
||||
fn Disconnect_(&self, out: u32) -> ErrorResult {
|
||||
self.context.audio_context_impl()
|
||||
.disconnect_output(self.node_id().output(out));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
fn Disconnect__(&self, _: &AudioNode) -> ErrorResult {
|
||||
// TODO
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode
|
||||
fn Disconnect__(&self, to: &AudioNode) -> ErrorResult {
|
||||
self.context.audio_context_impl()
|
||||
.disconnect_between(self.node_id(), to.node_id());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
fn Disconnect___(&self, _: &AudioNode, _: u32) -> ErrorResult{
|
||||
// TODO
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode-output
|
||||
fn Disconnect___(&self, to: &AudioNode, out: u32) -> ErrorResult{
|
||||
self.context.audio_context_impl()
|
||||
.disconnect_output_between(self.node_id().output(out), to.node_id());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect
|
||||
fn Disconnect____(&self, _: &AudioNode, _: u32, _: u32) -> ErrorResult {
|
||||
// TODO
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode-output-input
|
||||
fn Disconnect____(&self, to: &AudioNode, out: u32, inp: u32) -> ErrorResult {
|
||||
self.context.audio_context_impl()
|
||||
.disconnect_output_between_to(self.node_id().output(out), to.node_id().input(inp));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, Chann
|
|||
use dom::bindings::codegen::Bindings::GainNodeBinding::{self, GainNodeMethods, GainOptions};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_media::audio::context::AudioContext;
|
||||
|
@ -27,7 +27,7 @@ audio_param_impl!(Gain, GainNode, GainNodeMessage, SetGain);
|
|||
#[dom_struct]
|
||||
pub struct GainNode {
|
||||
node: AudioNode,
|
||||
gain: DomRoot<AudioParam>,
|
||||
gain: Dom<AudioParam>,
|
||||
}
|
||||
|
||||
impl GainNode {
|
||||
|
@ -60,7 +60,7 @@ impl GainNode {
|
|||
);
|
||||
GainNode {
|
||||
node,
|
||||
gain
|
||||
gain: Dom::from_ref(&gain),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::OscillatorNodeBinding::{self, OscillatorOp
|
|||
use dom::bindings::codegen::Bindings::OscillatorNodeBinding::OscillatorNodeMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_media::audio::context::AudioContext;
|
||||
|
@ -32,8 +32,8 @@ audio_param_impl!(Detune, OscillatorNode, OscillatorNodeMessage, SetDetune);
|
|||
pub struct OscillatorNode {
|
||||
source_node: AudioScheduledSourceNode,
|
||||
oscillator_type: OscillatorType,
|
||||
frequency: DomRoot<AudioParam>,
|
||||
detune: DomRoot<AudioParam>,
|
||||
frequency: Dom<AudioParam>,
|
||||
detune: Dom<AudioParam>,
|
||||
}
|
||||
|
||||
impl OscillatorNode {
|
||||
|
@ -70,8 +70,8 @@ impl OscillatorNode {
|
|||
OscillatorNode {
|
||||
source_node,
|
||||
oscillator_type: oscillator_options.type_,
|
||||
frequency,
|
||||
detune,
|
||||
frequency: Dom::from_ref(&frequency),
|
||||
detune: Dom::from_ref(&detune),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue