Bug 171227 - Indicate presence of audio when handling autoplay events
Summary: Indicate presence of audio when handling autoplay events
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Matt Rajca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-24 09:47 PDT by Matt Rajca
Modified: 2017-04-25 17:03 PDT (History)
2 users (show)

See Also:


Attachments
Patch (20.92 KB, patch)
2017-04-24 13:03 PDT, Matt Rajca
no flags Details | Formatted Diff | Diff
Patch (22.13 KB, patch)
2017-04-24 14:00 PDT, Matt Rajca
no flags Details | Formatted Diff | Diff
Patch (25.10 KB, patch)
2017-04-25 09:51 PDT, Matt Rajca
achristensen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Rajca 2017-04-24 09:47:02 PDT
When notifying clients of autoplay events, indicate whether there is audio.
Comment 1 Matt Rajca 2017-04-24 13:03:32 PDT
Created attachment 307998 [details]
Patch
Comment 2 Sam Weinig 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.
Comment 3 Matt Rajca 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.
Comment 4 Matt Rajca 2017-04-24 14:00:59 PDT
Created attachment 308007 [details]
Patch
Comment 5 Sam Weinig 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.
Comment 6 Matt Rajca 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.
Comment 7 Matt Rajca 2017-04-25 09:51:51 PDT
Created attachment 308109 [details]
Patch
Comment 8 Matt Rajca 2017-04-25 17:03:03 PDT
Committed r215771: <http://trac.webkit.org/changeset/215771>