Re: [mediacapture-image] The (bool or ConstrainDouble) case for pan/tilt/zoom is unclear (#225)

> I seem to remember that we had a long discussion with webidl folks, ending up in them saying that the spec (and the code!) makes it impossible for C++ to tell the difference between {foo: {}} and {} - ie you can't tell that something is present but empty :-(

It would be interesting to know the details and to which code you are referring to.

At least in Chrome WebIDL implementation it is possible for C++ to tell the difference between {pan: {}} and {}. I have made POC which does exactly that (and also {pan: true} for that matter).

Based on my reading of an ECMAScript value an IDL dictionary type value conversion algorithm (https://heycam.github.io/webidl/#es-dictionary), if the dictionary members do not have defaults values (like in the case of MediaTrackConstraintSet), if the ECMAScript value is null or undefined or if the ECMAScript value is Object without property _key_ or if the value of the property is undefined, the _key_ member of the resulting IDL dictionary value will not be set and it will thus not exists and it should be possible for C++, for instance, to detect that the _key_ does not exist.

If however, the IDL dictionary definition has default values for members (like in the case of MediaTrackSupportedConstraints), the ECMAScript value an IDL dictionary type value conversion algorithm sets the corresponding resulting IDL dictionary value members using the default values if the ECMAScript value is null or undefined or if the ECMAScript value is Object without property _key_ or if the value of the property is undefined.

Could it be that it is the latter case (with default values) which you are remembering?

-- 
GitHub Notification of comment by eehakkin
Please view or discuss this issue at https://github.com/w3c/mediacapture-image/issues/225#issuecomment-624774574 using your GitHub account

Received on Wednesday, 6 May 2020 17:10:35 UTC