Skip to content

Commit

Permalink
Add support for default dict values being boolean, use in MediaStream…
Browse files Browse the repository at this point in the history
…Constraints
  • Loading branch information
Manishearth committed Mar 4, 2019
1 parent caa0594 commit ce635b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 9 additions & 1 deletion components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -747,7 +747,15 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
for memberType in type.unroll().flatMemberTypes
if memberType.isDictionary()
]
if dictionaries:
if defaultValue and not isinstance(defaultValue, IDLNullValue):
tag = defaultValue.type.tag()
if tag is IDLType.Tags.bool:
default = "%s::Boolean(%s)" % (
union_native_type(type),
"true" if defaultValue.value else "false")
else:
raise("We don't currently support default values that aren't null or boolean")
elif dictionaries:
if defaultValue:
assert isinstance(defaultValue, IDLNullValue)
dictionary, = dictionaries
Expand Down
6 changes: 2 additions & 4 deletions components/script/dom/webidls/MediaDevices.webidl
Expand Up @@ -23,10 +23,8 @@ partial interface MediaDevices {


dictionary MediaStreamConstraints {
(boolean or MediaTrackConstraints) video;
// (boolean or MediaTrackConstraints) video = false;
(boolean or MediaTrackConstraints) audio;
// (boolean or MediaTrackConstraints) audio = false;
(boolean or MediaTrackConstraints) video = false;
(boolean or MediaTrackConstraints) audio = false;
};

dictionary DoubleRange {
Expand Down

0 comments on commit ce635b7

Please sign in to comment.