Closed tidoust closed 1 year ago
I don't think so; the states are true, false, and unspecified, with unspecified being rare or even aberrant. It's actually probably for the best if null and false are collated since non-full-range is the most common interpretation.
There are ways of specifying the range that include more categories; internally Chrome splits unspecified into invalid vs derived. There is always a correct value to use that is either true or false, though.
Dan's points are correct, so closing this.
The
VideoColorSpace
interface has a nullable boolean attributefullRange
. That means the attribute actually captures 3 states:null
,false
,true
. Using a boolean to capture 3 states does not seem like good practice, as developers will collate the first two cases if they write code such as:Wouldn't an enum be preferrable?
For what it's worth, there are 3 other occurrences of nullable booleans in web specs:
ProximitySensor.near
,RTCPeerConnection.canTrickleIceCandidates
,XRCompositionLayer.chromaticAberrationCorrection
. They could also benefit from using an enum.