RESOLVED FIXED171227
Indicate presence of audio when handling autoplay events
https://bugs.webkit.org/show_bug.cgi?id=171227
Summary Indicate presence of audio when handling autoplay events
Matt Rajca
Reported 2017-04-24 09:47:02 PDT
When notifying clients of autoplay events, indicate whether there is audio.
Attachments
Patch (20.92 KB, patch)
2017-04-24 13:03 PDT, Matt Rajca
no flags
Patch (22.13 KB, patch)
2017-04-24 14:00 PDT, Matt Rajca
no flags
Patch (25.10 KB, patch)
2017-04-25 09:51 PDT, Matt Rajca
achristensen: review+
Matt Rajca
Comment 1 2017-04-24 13:03:32 PDT
Sam Weinig
Comment 2 2017-04-24 13:12:53 PDT
Comment on attachment 307998 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307998&action=review > Source/WebCore/page/AutoplayEvent.h:41 > +enum AutoplayEventFlags { > + AutoplayEventFlagsNone = 0, > + AutoplayEventFlagsHasAudio = 1 << 0, > +}; Generally we are using enum class for things like this theses days. > Source/WebKit2/UIProcess/API/C/WKPage.cpp:2249 > + m_client.handleAutoplayEvent(toAPI(&page), static_cast<WKAutoplayEvent>(event), static_cast<WKAutoplayEventFlags>(flags), m_client.base.clientInfo); This should use an explicit conversion function that enumerates the enums, rather than assuming the WebCore type and the API type will have the same bit values. This is also true for WKAutoplayEvent.
Matt Rajca
Comment 3 2017-04-24 13:35:50 PDT
(In reply to Sam Weinig from comment #2) > Comment on attachment 307998 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=307998&action=review > > > Source/WebCore/page/AutoplayEvent.h:41 > > +enum AutoplayEventFlags { > > + AutoplayEventFlagsNone = 0, > > + AutoplayEventFlagsHasAudio = 1 << 0, > > +}; > > Generally we are using enum class for things like this theses days. I didn't use an enum class because this is used as a set of options (bitmask) and we can't use the usual operators like | and & with enum classes. > > > Source/WebKit2/UIProcess/API/C/WKPage.cpp:2249 > > + m_client.handleAutoplayEvent(toAPI(&page), static_cast<WKAutoplayEvent>(event), static_cast<WKAutoplayEventFlags>(flags), m_client.base.clientInfo); > > This should use an explicit conversion function that enumerates the enums, > rather than assuming the WebCore type and the API type will have the same > bit values. This is also true for WKAutoplayEvent. I'll add one.
Matt Rajca
Comment 4 2017-04-24 14:00:59 PDT
Sam Weinig
Comment 5 2017-04-24 15:55:17 PDT
(In reply to Matt Rajca from comment #3) > (In reply to Sam Weinig from comment #2) > > Comment on attachment 307998 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=307998&action=review > > > > > Source/WebCore/page/AutoplayEvent.h:41 > > > +enum AutoplayEventFlags { > > > + AutoplayEventFlagsNone = 0, > > > + AutoplayEventFlagsHasAudio = 1 << 0, > > > +}; > > > > Generally we are using enum class for things like this theses days. > > I didn't use an enum class because this is used as a set of options > (bitmask) and we can't use the usual operators like | and & with enum > classes. If you want to use it as a bit set, then we have the OptionSet<> wrapper for that, which can use an enum class.
Matt Rajca
Comment 6 2017-04-24 16:41:48 PDT
(In reply to Sam Weinig from comment #5) > (In reply to Matt Rajca from comment #3) > > (In reply to Sam Weinig from comment #2) > > > Comment on attachment 307998 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=307998&action=review > > > > > > > Source/WebCore/page/AutoplayEvent.h:41 > > > > +enum AutoplayEventFlags { > > > > + AutoplayEventFlagsNone = 0, > > > > + AutoplayEventFlagsHasAudio = 1 << 0, > > > > +}; > > > > > > Generally we are using enum class for things like this theses days. > > > > I didn't use an enum class because this is used as a set of options > > (bitmask) and we can't use the usual operators like | and & with enum > > classes. > > If you want to use it as a bit set, then we have the OptionSet<> wrapper for > that, which can use an enum class. Thanks, didn't know about that.
Matt Rajca
Comment 7 2017-04-25 09:51:51 PDT
Matt Rajca
Comment 8 2017-04-25 17:03:03 PDT
Note You need to log in before you can comment on or make changes to this bug.