diff options
author | Josh Matthews <josh@joshmatthews.net> | 2024-10-07 21:51:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 01:51:58 +0000 |
commit | 7d931e673af2780f3f62d52cb17324ec2cc68c71 (patch) | |
tree | 450d534196e9eb8d0e04db37203b414f5d92420d /components/script/dom/audiobuffer.rs | |
parent | 946fa9cdee68bb834a3b75821e8e7f94cf86d31c (diff) | |
download | servo-7d931e673af2780f3f62d52cb17324ec2cc68c71.tar.gz servo-7d931e673af2780f3f62d52cb17324ec2cc68c71.zip |
script: Include constructors and static methods in generated DOM traits (#33665)
* Add all constructors, special operations, and static methods to generated DOM interface traits.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move all constructors and static methods defined in bare impl blocks inside FooMethods trait impls.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Add missing doc links.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/audiobuffer.rs')
-rw-r--r-- | components/script/dom/audiobuffer.rs | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs index 954f36f43d3..59cca8d8ec7 100644 --- a/components/script/dom/audiobuffer.rs +++ b/components/script/dom/audiobuffer.rs @@ -109,33 +109,6 @@ impl AudioBuffer { buffer } - // https://webaudio.github.io/web-audio-api/#dom-audiobuffer-audiobuffer - #[allow(non_snake_case)] - pub fn Constructor( - window: &Window, - proto: Option<HandleObject>, - can_gc: CanGc, - options: &AudioBufferOptions, - ) -> Fallible<DomRoot<AudioBuffer>> { - if options.length == 0 || - options.numberOfChannels == 0 || - options.numberOfChannels > MAX_CHANNEL_COUNT || - *options.sampleRate < MIN_SAMPLE_RATE || - *options.sampleRate > MAX_SAMPLE_RATE - { - return Err(Error::NotSupported); - } - Ok(AudioBuffer::new_with_proto( - window, - proto, - options.numberOfChannels, - options.length, - *options.sampleRate, - None, - can_gc, - )) - } - // Initialize the underlying channels data with initial data provided by // the user or silence otherwise. fn set_initial_data(&self, initial_data: Option<&[Vec<f32>]>) { @@ -210,6 +183,32 @@ impl AudioBuffer { } impl AudioBufferMethods for AudioBuffer { + // https://webaudio.github.io/web-audio-api/#dom-audiobuffer-audiobuffer + fn Constructor( + window: &Window, + proto: Option<HandleObject>, + can_gc: CanGc, + options: &AudioBufferOptions, + ) -> Fallible<DomRoot<AudioBuffer>> { + if options.length == 0 || + options.numberOfChannels == 0 || + options.numberOfChannels > MAX_CHANNEL_COUNT || + *options.sampleRate < MIN_SAMPLE_RATE || + *options.sampleRate > MAX_SAMPLE_RATE + { + return Err(Error::NotSupported); + } + Ok(AudioBuffer::new_with_proto( + window, + proto, + options.numberOfChannels, + options.length, + *options.sampleRate, + None, + can_gc, + )) + } + // https://webaudio.github.io/web-audio-api/#dom-audiobuffer-samplerate fn SampleRate(&self) -> Finite<f32> { Finite::wrap(self.sample_rate) |