Bug 226213

Summary: Make MediaSession readystate enums all lowercase
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: New BugsAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, eric.carlson, esprehn+autocc, ews-watchlist, glenn, jer.noble, kondapallykalyan, peng.liu6, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://heycam.github.io/webidl/#idl-enums
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Jean-Yves Avenard [:jya] 2021-05-24 22:15:37 PDT
Make MediaSession readystate enums all lowercase
Comment 1 Radar WebKit Bug Importer 2021-05-24 22:16:22 PDT
<rdar://problem/78437011>
Comment 2 Jean-Yves Avenard [:jya] 2021-05-24 23:37:18 PDT
Created attachment 429632 [details]
Patch
Comment 3 Jean-Yves Avenard [:jya] 2021-05-25 05:18:41 PDT
Created attachment 429646 [details]
Patch
Comment 4 Peng Liu 2021-05-25 10:10:26 PDT
Comment on attachment 429646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429646&action=review

> Source/WebCore/Modules/mediasession/MediaSessionReadyState.h:37
> +    Haveenoughdata,

Oh? Why do we need these changes in C++ code?
Comment 5 Chris Dumez 2021-05-25 10:17:12 PDT
Comment on attachment 429646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429646&action=review

>> Source/WebCore/Modules/mediasession/MediaSessionReadyState.h:37
>> +    Haveenoughdata,
> 
> Oh? Why do we need these changes in C++ code?

That's what the C++ code generated by the IDL bindings generator expects based on the IDL enum values. I don't think there is a way around that at the moment sadly.
Comment 6 Chris Dumez 2021-05-25 10:19:47 PDT
Comment on attachment 429646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429646&action=review

> Source/WebCore/Modules/mediasession/MediaSessionReadyState.idl:29
> +    "havenothing",

Are we trying to match a spec? If so, you could use '-' as separator to end up with nicer names on c++ side, e.g. 'havenothing' -> 'have-nothing'
Comment 7 Chris Dumez 2021-05-25 10:20:03 PDT
(In reply to Chris Dumez from comment #6)
> Comment on attachment 429646 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429646&action=review
> 
> > Source/WebCore/Modules/mediasession/MediaSessionReadyState.idl:29
> > +    "havenothing",
> 
> Are we trying to match a spec? If so, you could use '-' as separator to end
> up with nicer names on c++ side, e.g. 'havenothing' -> 'have-nothing'

If so -> If NOT
Comment 8 Chris Dumez 2021-05-25 10:22:19 PDT
Comment on attachment 429646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429646&action=review

>>> Source/WebCore/Modules/mediasession/MediaSessionReadyState.h:37
>>> +    Haveenoughdata,
>> 
>> Oh? Why do we need these changes in C++ code?
> 
> That's what the C++ code generated by the IDL bindings generator expects based on the IDL enum values. I don't think there is a way around that at the moment sadly.

I think we wouldn't need any C++ changes if we used '-' in the names in the IDL (e.g. 'have-nothing').
Comment 9 Eric Carlson 2021-05-25 10:26:28 PDT
Comment on attachment 429646 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429646&action=review

> LayoutTests/media/media-session/mock-coordinator-expected.txt:156
> -EXPECTED (latestChange == 'coordinatorStateChanged') OK
> +EXPECTED (latestChange == 'playbackStateChanged') OK
> +EXPECTED (latestChange == 'playbackStateChanged') OK
> +EXPECTED (latestChange == 'playbackStateChanged') OK
> +EXPECTED (latestChange == 'coordinatorStateChanged'), OBSERVED 'undefined', AFTER TIMEOUT FAIL

Is this supposed to part of this change?
Comment 10 Jean-Yves Avenard [:jya] 2021-05-25 17:14:15 PDT
(In reply to Chris Dumez from comment #6)
> Comment on attachment 429646 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429646&action=review
> 
> > Source/WebCore/Modules/mediasession/MediaSessionReadyState.idl:29
> > +    "havenothing",
> 
> Are we trying to match a spec? If so, you could use '-' as separator to end
> up with nicer names on c++ side, e.g. 'havenothing' -> 'have-nothing'

yes, currently Media Session states and actions use that format: "seekbackward" "previoustrack", "togglemicrophone" 

HTML Media events are also all in lowercase "loadedmetata"
Comment 11 Jean-Yves Avenard [:jya] 2021-05-25 17:15:51 PDT
(In reply to Peng Liu from comment #4)
> Comment on attachment 429646 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429646&action=review
> 
> > Source/WebCore/Modules/mediasession/MediaSessionReadyState.h:37
> > +    Haveenoughdata,
> 
> Oh? Why do we need these changes in C++ code?

The IDL binding code makes assumptions on how the actual C++ enum is named. It creates a 1:1 association between the IDL name and the C++ enum.

Maybe there's an IDL settings to force which C++ enum watches.
Comment 12 Chris Dumez 2021-05-25 17:15:56 PDT
(In reply to Jean-Yves Avenard [:jya] from comment #10)
> (In reply to Chris Dumez from comment #6)
> > Comment on attachment 429646 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=429646&action=review
> > 
> > > Source/WebCore/Modules/mediasession/MediaSessionReadyState.idl:29
> > > +    "havenothing",
> > 
> > Are we trying to match a spec? If so, you could use '-' as separator to end
> > up with nicer names on c++ side, e.g. 'havenothing' -> 'have-nothing'
> 
> yes, currently Media Session states and actions use that format:
> "seekbackward" "previoustrack", "togglemicrophone" 
> 
> HTML Media events are also all in lowercase "loadedmetata"

how about picture-in-picture?
Source/WebCore/html/HTMLVideoElement.idl:[Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "inline", "fullscreen", "picture-in-picture" };
Comment 13 Chris Dumez 2021-05-25 17:18:57 PDT
(In reply to Chris Dumez from comment #12)
> (In reply to Jean-Yves Avenard [:jya] from comment #10)
> > (In reply to Chris Dumez from comment #6)
> > > Comment on attachment 429646 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=429646&action=review
> > > 
> > > > Source/WebCore/Modules/mediasession/MediaSessionReadyState.idl:29
> > > > +    "havenothing",
> > > 
> > > Are we trying to match a spec? If so, you could use '-' as separator to end
> > > up with nicer names on c++ side, e.g. 'havenothing' -> 'have-nothing'
> > 
> > yes, currently Media Session states and actions use that format:
> > "seekbackward" "previoustrack", "togglemicrophone" 
> > 
> > HTML Media events are also all in lowercase "loadedmetata"
> 
> how about picture-in-picture?
> Source/WebCore/html/HTMLVideoElement.idl:
> [Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "inline",
> "fullscreen", "picture-in-picture" };

MediaDecodingType also has "media-source". MediaKeysRequirement has "not-allowed". I am sure there are other examples.
Comment 14 Chris Dumez 2021-05-25 17:21:12 PDT
(In reply to Chris Dumez from comment #13)
> (In reply to Chris Dumez from comment #12)
> > (In reply to Jean-Yves Avenard [:jya] from comment #10)
> > > (In reply to Chris Dumez from comment #6)
> > > > Comment on attachment 429646 [details]
> > > > Patch
> > > > 
> > > > View in context:
> > > > https://bugs.webkit.org/attachment.cgi?id=429646&action=review
> > > > 
> > > > > Source/WebCore/Modules/mediasession/MediaSessionReadyState.idl:29
> > > > > +    "havenothing",
> > > > 
> > > > Are we trying to match a spec? If so, you could use '-' as separator to end
> > > > up with nicer names on c++ side, e.g. 'havenothing' -> 'have-nothing'
> > > 
> > > yes, currently Media Session states and actions use that format:
> > > "seekbackward" "previoustrack", "togglemicrophone" 
> > > 
> > > HTML Media events are also all in lowercase "loadedmetata"
> > 
> > how about picture-in-picture?
> > Source/WebCore/html/HTMLVideoElement.idl:
> > [Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "inline",
> > "fullscreen", "picture-in-picture" };
> 
> MediaDecodingType also has "media-source". MediaKeysRequirement has
> "not-allowed". I am sure there are other examples.

The fact is that there is plenty of precedent for using - as word separator in enum strings. I think it looks much nicer and our bindings generator deals with nicely with them. If we have control over the naming, seems unfortunate to end up with the ugly way :P
Comment 15 Jean-Yves Avenard [:jya] 2021-05-25 17:24:50 PDT
(In reply to Chris Dumez from comment #14)
> The fact is that there is plenty of precedent for using - as word separator
> in enum strings. I think it looks much nicer and our bindings generator
> deals with nicely with them. If we have control over the naming, seems
> unfortunate to end up with the ugly way :P

From searching at the time in the spec (we had a discussion in #webkit), the use of "firstword" is much more prevalent than "first-word" and "firstWord".

Sadly, it's all over the place.
Comment 16 Jean-Yves Avenard [:jya] 2021-05-25 18:41:33 PDT
Created attachment 429724 [details]
Patch
Comment 17 EWS 2021-05-26 18:33:09 PDT
Committed r278143 (238187@main): <https://commits.webkit.org/238187@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 429724 [details].