diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-10-21 03:27:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 03:27:18 -0400 |
commit | 5011e9c21c4c562a1e4b5380be19cef696e305ea (patch) | |
tree | 969975ce481a3d8bc2dba4cf5579ea0c3bd1a35a /components/script/dom/audiocontext.rs | |
parent | 882dcc8408159bed5633337d11e83b6839f97e34 (diff) | |
parent | 40ee701283310a505770023594f1f9d64b31e2a2 (diff) | |
download | servo-5011e9c21c4c562a1e4b5380be19cef696e305ea.tar.gz servo-5011e9c21c4c562a1e4b5380be19cef696e305ea.zip |
Auto merge of #24471 - saschanaz:enum-default, r=ferjm
Support enum value as a union default value
<!-- Please describe your changes on the following line: -->
Didn't implement the actual latency thing because the relevant things are already marked as TODO.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21342
<!-- Either: -->
- [x] There are tests for these changes
<!-- 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. -->
Diffstat (limited to 'components/script/dom/audiocontext.rs')
-rw-r--r-- | components/script/dom/audiocontext.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index 8f98586b3ea..2b6f04b421b 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -13,6 +13,7 @@ use crate::dom::bindings::codegen::Bindings::AudioContextBinding::{ }; use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState; use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextBinding::BaseAudioContextMethods; +use crate::dom::bindings::codegen::UnionTypes::AudioContextLatencyCategoryOrDouble; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; @@ -48,7 +49,12 @@ impl AudioContext { ); // Step 4.1. - let latency_hint = options.latencyHint; + let latency_hint = match options.latencyHint { + AudioContextLatencyCategoryOrDouble::AudioContextLatencyCategory(category) => category, + AudioContextLatencyCategoryOrDouble::Double(_) => { + AudioContextLatencyCategory::Interactive + }, // TODO + }; // Step 4.2. The sample rate is set during the creation of the BaseAudioContext. // servo-media takes care of setting the default sample rate of the output device @@ -250,7 +256,12 @@ impl<'a> From<&'a AudioContextOptions> for RealTimeAudioContextOptions { fn from(options: &AudioContextOptions) -> Self { Self { sample_rate: *options.sampleRate.unwrap_or(Finite::wrap(44100.)), - latency_hint: options.latencyHint.into(), + latency_hint: match options.latencyHint { + AudioContextLatencyCategoryOrDouble::AudioContextLatencyCategory(category) => { + category.into() + }, + AudioContextLatencyCategoryOrDouble::Double(_) => LatencyCategory::Interactive, // TODO + }, } } } |