Skip to content

Inconsistent use of null #561

@sandersdan

Description

@sandersdan

The VideoColorSpaceInit definition does not allow fields to be null, but since the fields are optional they can be set to undefined:

dictionary VideoColorSpaceInit {
  VideoColorPrimaries primaries;
  VideoTransferCharacteristics transfer;
  VideoMatrixCoefficients matrix;
  boolean fullRange;
};

VideoColorSpace, however, has nullable fields:

interface VideoColorSpace {
  readonly attribute VideoColorPrimaries? primaries;
  readonly attribute VideoTransferCharacteristics? transfer;
  readonly attribute VideoMatrixCoefficients? matrix;
  readonly attribute boolean? fullRange;
  ...
};

As a result, missing values can become null, and a VideoColorSpace cannot be reliably used in place of a VideoColorSpaceInit. This same pattern appears in several different places in WebCodecs.

The two fixes I can see are:

  1. Change the interfaces to allow undefined but not null.
  2. Change the dictionaries to allow null.

I'm leaning towards (2) as the least surprising option. Any objections?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions