<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:jer.noble&#64;apple.com" title="Jer Noble &lt;jer.noble&#64;apple.com&gt;"> <span class="fn">Jer Noble</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Record whether a media element was prevented from playing without user interaction"
   href="https://bugs.webkit.org/show_bug.cgi?id=167214">bug 167214</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #299269 Flags</td>
           <td>review?, commit-queue?
           </td>
           <td>review-
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Record whether a media element was prevented from playing without user interaction"
   href="https://bugs.webkit.org/show_bug.cgi?id=167214#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Record whether a media element was prevented from playing without user interaction"
   href="https://bugs.webkit.org/show_bug.cgi?id=167214">bug 167214</a>
              from <span class="vcard"><a class="email" href="mailto:jer.noble&#64;apple.com" title="Jer Noble &lt;jer.noble&#64;apple.com&gt;"> <span class="fn">Jer Noble</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=299269&amp;action=diff" name="attach_299269" title="Patch">attachment 299269</a> <a href="attachment.cgi?id=299269&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=299269&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=299269&amp;action=review</a>

<span class="quote">&gt; Source/WebCore/html/HTMLMediaElement.cpp:3106
&gt; +    bool preventedPlaybackWithoutUserGesture = false;
&gt; +    if (!m_mediaSession-&gt;playbackPermitted(*this, &amp;preventedPlaybackWithoutUserGesture)) {
&gt; +        if (preventedPlaybackWithoutUserGesture)
&gt; +            m_preventedFromPlayingWithoutUserGesture = true;
&gt;          return;
&gt; +    }</span >

When is m_preventedFromPlayingWithoutUserGesture ever reset to false?

<span class="quote">&gt; Source/WebCore/html/HTMLMediaElement.h:719
&gt; -    bool canTransitionFromAutoplayToPlay() const;
&gt; +    bool canTransitionFromAutoplayToPlay(bool* preventedPlaybackWithoutUserGesture) const;</span >

This and ...

<span class="quote">&gt; Source/WebCore/html/MediaElementSession.h:55
&gt; -    bool playbackPermitted(const HTMLMediaElement&amp;) const;
&gt; +    bool playbackPermitted(const HTMLMediaElement&amp;, bool* preventedPlaybackWithoutUserGesture) const;</span >

This.

I don't like this &quot;out boolean pointer parameter&quot; change.  We should some other way of representing failure, on the order of &quot;ExceptionOr&lt;&gt;&quot;.  For example, something like:

enum class PlaybackDenialReason {
    UserGestureRequired,
    PageConsentRequired,
    FullscreenRequired,
};
template &lt;typename T&gt;
class SuccessOr : public optional&lt;T&gt; {
public:
    explicit constexpr operator bool() const { return !optional::operator bool(); }
};

And have these methods return SuccessOr&lt;PlaybackDenialReason&gt;.  I.e.:

    SuccessOr&lt;PlaybackDenialReason&gt; playbackPermitted(const HTMLMediaElement&amp;) const;

So the call sites can remain exactly the same:

    if (!playbackPermitted(m_element)) { ... }

And in the places we care about why playback was denied, we can look at the return value:

    auto success = canTransitionFromAutoplayToPlay(&amp;preventedPlaybackWithoutUserGesture));
    if (success) { ... } else {
        m_preventedFromPlayingWithoutUserGesture = success.value() == PlaybackDenialReason:: UserGestureRequired;
    }</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>