Skip to content

Make VideoColorSpace constructor argument optional - #337

Merged
sandersdan merged 1 commit into
w3c:mainfrom
tidoust:fix-VideoColorSpace-idl
Aug 13, 2021
Merged

sandersdan merged 1 commit into
w3c:mainfrom
tidoust:fix-VideoColorSpace-idl

Conversation

@tidoust

@tidoust tidoust commented Aug 12, 2021 •

Copy link
Copy Markdown
Member

The constructor takes a VideoColorSpaceInit dictionary as input that does not have any required parameter. Quoting from the Web IDL spec, the input "must be specified as optional and have a default value provided. This is to encourage API designs that do not require authors to pass an empty dictionary value when they wish only to use the dictionary’s default values."
https://heycam.github.io/webidl/#idl-operations


Preview | Diff

The constructor takes a `VideoColorSpaceInit` dictionary as input that does not
have any required parameter. Quoting from the Web IDL spec, the input "must be
specified as optional and have a default value provided. This is to encourage
API designs that do not require authors to pass an empty dictionary value when
they wish only to use the dictionary’s default values."
https://heycam.github.io/webidl/#idl-operations
@sandersdan

Copy link
Copy Markdown
Contributor

Hmm, not so sure about this one. The current shape comes from a previous iteration where fullRange was not optional, and I don't expect to add new required fields in the future, but it doesn't really make sense to construct a default VideoColorSpace.

We could do something like make primaries required, the concern is that this needlessly complicates cases where apps are translating existing incomplete metadata.

There is some tension here where colorSpace is always nullable/optional in our IDL which is treated the same as a default VideoColorSpace. There was at least some question about making it required (with a default); if we had done that then it would be useful to construct a default VideoColorSpace.

@tidoust

tidoust commented Aug 13, 2021

Copy link
Copy Markdown
Member Author

I see that there is an open discussion to "consider a pattern for dictionary arguments which must have at least one member" in Web IDL, see whatwg/webidl#903

Without that pattern, the constraint needs to be specified in prose, e.g. by throwing a TypeError in the constructor if none of the members were set as done in getUserMedia().

@sandersdan

Copy link
Copy Markdown
Contributor

I don't think that quite fits our case. After pondering for a while, I think we should just merge this (and also reconsider the question of nullability vs defaults).

@sandersdan
sandersdan merged commit 7dc4e87 into w3c:main Aug 13, 2021
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Aug 13, 2021
SHA: 7dc4e87
Reason: push, by @sandersdan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
pull Bot pushed a commit to FreddyZeng/chromium that referenced this pull request Aug 14, 2021
w3c/webcodecs#337

Change-Id: I9bfa01253d159e28f3c0f262badf3ecea63a4105
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3094929
Auto-Submit: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#911935}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants