diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-04-27 20:47:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-27 20:47:11 -0400 |
commit | ffd9441a3dfdf35eaff6e3046febdc6272eb4283 (patch) | |
tree | 6132afd066a7b2da1e9394973600dccc4b0606df /components/script | |
parent | 10bee0db5df3af32151c1f268fb2cd99f151efa9 (diff) | |
parent | feeb89149db37f3f682e0fdc5d27e877db49a093 (diff) | |
download | servo-ffd9441a3dfdf35eaff6e3046febdc6272eb4283.tar.gz servo-ffd9441a3dfdf35eaff6e3046febdc6272eb4283.zip |
Auto merge of #23279 - snarasi6:master, r=jdm
Implement deprecated setPosition and setOrientation methods for AudioListener #22898
<!-- Please describe your changes on the following line: -->
I have uncommented the two methods SetPosition and SetOrientation in AudioListener.webidl and have included the two methods in the AudioListener.rs file. I have some errors while handling the NotSupported error for the methods. Can you please review the code and help me out with the errors?
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23279)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/audiolistener.rs | 37 | ||||
-rw-r--r-- | components/script/dom/webidls/AudioListener.webidl | 4 |
2 files changed, 39 insertions, 2 deletions
diff --git a/components/script/dom/audiolistener.rs b/components/script/dom/audiolistener.rs index 730da9e17b6..31ef2c4cac9 100644 --- a/components/script/dom/audiolistener.rs +++ b/components/script/dom/audiolistener.rs @@ -6,9 +6,13 @@ use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioListenerBinding::{self, AudioListenerMethods}; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; +use crate::dom::bindings::error::Fallible; +use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::window::Window; + +use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AudioParamMethods; use dom_struct::dom_struct; use servo_media::audio::param::{ParamDir, ParamType}; use std::f32; @@ -121,6 +125,7 @@ impl AudioListener { f32::MIN, // min value f32::MAX, // max value ); + AudioListener { reflector_: Reflector::new(), position_x: Dom::from_ref(&position_x), @@ -181,4 +186,36 @@ impl AudioListenerMethods for AudioListener { fn UpZ(&self) -> DomRoot<AudioParam> { DomRoot::from_ref(&self.up_z) } + + // https://webaudio.github.io/web-audio-api/#dom-audiolistener-setorientation + fn SetOrientation( + &self, + x: Finite<f32>, + y: Finite<f32>, + z: Finite<f32>, + xUp: Finite<f32>, + yUp: Finite<f32>, + zUp: Finite<f32>, + ) -> Fallible<DomRoot<AudioListener>> { + self.forward_x.SetValue(x); + self.forward_y.SetValue(y); + self.forward_z.SetValue(z); + self.up_x.SetValue(xUp); + self.up_y.SetValue(yUp); + self.up_z.SetValue(zUp); + Ok(DomRoot::from_ref(self)) + } + + // https://webaudio.github.io/web-audio-api/#dom-audiolistener-setposition + fn SetPosition( + &self, + x: Finite<f32>, + y: Finite<f32>, + z: Finite<f32>, + ) -> Fallible<DomRoot<AudioListener>> { + self.position_x.SetValue(x); + self.position_y.SetValue(y); + self.position_z.SetValue(z); + Ok(DomRoot::from_ref(self)) + } } diff --git a/components/script/dom/webidls/AudioListener.webidl b/components/script/dom/webidls/AudioListener.webidl index 91c4d2e58c9..d625740802f 100644 --- a/components/script/dom/webidls/AudioListener.webidl +++ b/components/script/dom/webidls/AudioListener.webidl @@ -17,6 +17,6 @@ interface AudioListener { readonly attribute AudioParam upX; readonly attribute AudioParam upY; readonly attribute AudioParam upZ; - // void setPosition (float x, float y, float z); - // void setOrientation (float x, float y, float z, float xUp, float yUp, float zUp); + [Throws] AudioListener setPosition (float x, float y, float z); + [Throws] AudioListener setOrientation (float x, float y, float z, float xUp, float yUp, float zUp); }; |