aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/audiocontext.rs15
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py31
-rw-r--r--components/script/dom/webidls/AudioContext.webidl2
3 files changed, 35 insertions, 13 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
+ },
}
}
}
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index a644e352e7a..bb02119c406 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -736,6 +736,13 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
default = '%s::USVString(USVString("%s".to_owned()))' % (
union_native_type(type),
defaultValue.value)
+ elif defaultValue.type.isEnum():
+ enum = defaultValue.type.inner.identifier.name
+ default = "%s::%s(%s::%s)" % (
+ union_native_type(type),
+ enum,
+ enum,
+ getEnumValueName(defaultValue.value))
else:
raise("We don't currently support default values that aren't null, boolean or default dictionary")
elif dictionaries:
@@ -2373,20 +2380,19 @@ def getAllTypes(descriptors, dictionaries, callbacks, typedefs):
"""
Generate all the types we're dealing with. For each type, a tuple
containing type, descriptor, dictionary is yielded. The
- descriptor and dictionary can be None if the type does not come
- from a descriptor or dictionary; they will never both be non-None.
+ descriptor can be None if the type does not come from a descriptor.
"""
for d in descriptors:
for t in getTypesFromDescriptor(d):
- yield (t, d, None)
+ yield (t, d)
for dictionary in dictionaries:
for t in getTypesFromDictionary(dictionary):
- yield (t, None, dictionary)
+ yield (t, None)
for callback in callbacks:
for t in getTypesFromCallback(callback):
- yield (t, None, None)
+ yield (t, None)
for typedef in typedefs:
- yield (typedef.innerType, None, None)
+ yield (typedef.innerType, None)
def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
@@ -2411,6 +2417,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
'crate::dom::bindings::str::DOMString',
'crate::dom::bindings::str::USVString',
'crate::dom::bindings::trace::RootedTraceableBox',
+ 'crate::dom::bindings::utils::find_enum_value',
'crate::dom::types::*',
'crate::script_runtime::JSContext as SafeJSContext',
'js::error::throw_type_error',
@@ -2426,13 +2433,17 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
# Now find all the things we'll need as arguments and return values because
# we need to wrap or unwrap them.
unionStructs = dict()
- for (t, descriptor, dictionary) in getAllTypes(descriptors, dictionaries, callbacks, typedefs):
- if dictionary:
- imports.append("%s::%s" % (CGDictionary.makeModuleName(dictionary),
- CGDictionary.makeDictionaryName(dictionary)))
+ for (t, descriptor) in getAllTypes(descriptors, dictionaries, callbacks, typedefs):
t = t.unroll()
if not t.isUnion():
continue
+ for memberType in t.flatMemberTypes:
+ if memberType.isDictionary() or memberType.isEnum():
+ memberModule = getModuleFromObject(memberType)
+ memberName = memberType.inner.identifier.name
+ imports.append("%s::%s" % (memberModule, memberName))
+ if memberType.isEnum():
+ imports.append("%s::%sValues" % (memberModule, memberName))
name = str(t)
if name not in unionStructs:
provider = descriptor or config.getDescriptorProvider()
diff --git a/components/script/dom/webidls/AudioContext.webidl b/components/script/dom/webidls/AudioContext.webidl
index 8667d8d8b8f..9e5dd6bd556 100644
--- a/components/script/dom/webidls/AudioContext.webidl
+++ b/components/script/dom/webidls/AudioContext.webidl
@@ -13,7 +13,7 @@ enum AudioContextLatencyCategory {
};
dictionary AudioContextOptions {
- AudioContextLatencyCategory latencyHint = "interactive";
+ (AudioContextLatencyCategory or double) latencyHint = "interactive";
float sampleRate;
};