<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[211008] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/211008">211008</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-20 18:31:33 -0800 (Fri, 20 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Record whether a media element was prevented from playing without user interaction
https://bugs.webkit.org/show_bug.cgi?id=167214

Patch by Matt Rajca &lt;mrajca@apple.com&gt; on 2017-01-20
Reviewed by Eric Carlson.

This state will be used to notify clients when a user explicitly starts playback
of a media element that was prevented from autoplaying.

Tests will be added after a WebKit callback API is added.

* WebCore.xcodeproj/project.pbxproj:
* dom/SuccessOr.h: Added.
(WebCore::SuccessOr::SuccessOr):
(WebCore::SuccessOr::operator bool):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay):
(WebCore::HTMLMediaElement::setReadyState):
(WebCore::HTMLMediaElement::play):
(WebCore::HTMLMediaElement::playInternal):
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::playbackPermitted):
* html/MediaElementSession.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlMediaElementSessioncpp">trunk/Source/WebCore/html/MediaElementSession.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlMediaElementSessionh">trunk/Source/WebCore/html/MediaElementSession.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomSuccessOrh">trunk/Source/WebCore/dom/SuccessOr.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211007 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-21 02:24:17 UTC (rev 211007)
+++ trunk/Source/WebCore/ChangeLog        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-01-20  Matt Rajca  &lt;mrajca@apple.com&gt;
+
+        Record whether a media element was prevented from playing without user interaction
+        https://bugs.webkit.org/show_bug.cgi?id=167214
+
+        Reviewed by Eric Carlson.
+
+        This state will be used to notify clients when a user explicitly starts playback
+        of a media element that was prevented from autoplaying.
+
+        Tests will be added after a WebKit callback API is added.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/SuccessOr.h: Added.
+        (WebCore::SuccessOr::SuccessOr):
+        (WebCore::SuccessOr::operator bool):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay):
+        (WebCore::HTMLMediaElement::setReadyState):
+        (WebCore::HTMLMediaElement::play):
+        (WebCore::HTMLMediaElement::playInternal):
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::playbackPermitted):
+        * html/MediaElementSession.h:
+
</ins><span class="cx"> 2017-01-20  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Require a button press on a gamepad for them to be exposed to the DOM.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211007 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-21 02:24:17 UTC (rev 211007)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -5695,6 +5695,7 @@
</span><span class="cx">                 C96F5EC61B5872260091EA9D /* MediaSessionInterruptionProviderMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C96F5EC21B5872260091EA9D /* MediaSessionInterruptionProviderMac.mm */; };
</span><span class="cx">                 C96F5EC71B5872260091EA9D /* MediaSessionInterruptionProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C96F5EC31B5872260091EA9D /* MediaSessionInterruptionProvider.cpp */; };
</span><span class="cx">                 C96F5EC81B5872260091EA9D /* MediaSessionInterruptionProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = C96F5EC41B5872260091EA9D /* MediaSessionInterruptionProvider.h */; };
</span><ins>+                C99058131E32C75F0073BDDA /* SuccessOr.h in Headers */ = {isa = PBXBuildFile; fileRef = C99058121E32B7340073BDDA /* SuccessOr.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 C9DADBCB1B1D3B97001F17D8 /* JSMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */; };
</span><span class="cx">                 C9F87CFE1B28F40E00979B83 /* MediaSessionEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = C9F87CFD1B28E5F600979B83 /* MediaSessionEvents.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -13628,6 +13629,7 @@
</span><span class="cx">                 C96F5EC21B5872260091EA9D /* MediaSessionInterruptionProviderMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSessionInterruptionProviderMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C96F5EC31B5872260091EA9D /* MediaSessionInterruptionProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSessionInterruptionProvider.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C96F5EC41B5872260091EA9D /* MediaSessionInterruptionProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionInterruptionProvider.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                C99058121E32B7340073BDDA /* SuccessOr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SuccessOr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionMetadata.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaSession.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C9DADBCA1B1D3B25001F17D8 /* JSMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaSession.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -24355,6 +24357,7 @@
</span><span class="cx">                                 81AC6C34131C57C20009A7E0 /* StringCallback.idl */,
</span><span class="cx">                                 A8C4A7EC09D563270003AC8D /* StyledElement.cpp */,
</span><span class="cx">                                 A8C4A7EB09D563270003AC8D /* StyledElement.h */,
</span><ins>+                                C99058121E32B7340073BDDA /* SuccessOr.h */,
</ins><span class="cx">                                 463EB6201B8789CB0096ED51 /* TagCollection.cpp */,
</span><span class="cx">                                 463EB6211B8789CB0096ED51 /* TagCollection.h */,
</span><span class="cx">                                 C65046A8167BFB5500CC2A4D /* TemplateContentDocumentFragment.h */,
</span><span class="lines">@@ -27643,6 +27646,7 @@
</span><span class="cx">                                 84A81F420FC7E02700955300 /* SourceGraphic.h in Headers */,
</span><span class="cx">                                 D01A27AE10C9BFD800026A42 /* SpaceSplitString.h in Headers */,
</span><span class="cx">                                 626CDE0F1140424C001E5A68 /* SpatialNavigation.h in Headers */,
</span><ins>+                                C99058131E32C75F0073BDDA /* SuccessOr.h in Headers */,
</ins><span class="cx">                                 AA2A5AD416A4861100975A25 /* SpeechSynthesis.h in Headers */,
</span><span class="cx">                                 AA2A5AD216A4860A00975A25 /* SpeechSynthesisEvent.h in Headers */,
</span><span class="cx">                                 AA2A5AD016A4860400975A25 /* SpeechSynthesisUtterance.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomSuccessOrh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/SuccessOr.h (0 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SuccessOr.h                                (rev 0)
+++ trunk/Source/WebCore/dom/SuccessOr.h        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &lt;wtf/Optional.h&gt;
+
+namespace WebCore {
+
+template &lt;typename T&gt;
+class SuccessOr : public std::optional&lt;T&gt; {
+public:
+    SuccessOr() : std::optional&lt;T&gt;() { }
+    SuccessOr(T&amp;&amp; error) : std::optional&lt;T&gt;(error) { }
+
+    explicit constexpr operator bool() const { return !std::optional&lt;T&gt;::operator bool(); }
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (211007 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-01-21 02:24:17 UTC (rev 211007)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -2253,15 +2253,17 @@
</span><span class="cx">     endProcessingMediaPlayerCallback();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLMediaElement::canTransitionFromAutoplayToPlay() const
</del><ins>+SuccessOr&lt;MediaPlaybackDenialReason&gt; HTMLMediaElement::canTransitionFromAutoplayToPlay() const
</ins><span class="cx"> {
</span><del>-    return isAutoplaying()
-        &amp;&amp; mediaSession().autoplayPermitted()
-        &amp;&amp; paused()
-        &amp;&amp; autoplay()
-        &amp;&amp; !pausedForUserInteraction()
-        &amp;&amp; !document().isSandboxed(SandboxAutomaticFeatures)
-        &amp;&amp; mediaSession().playbackPermitted(*this);
</del><ins>+    if (isAutoplaying()
+     &amp;&amp; mediaSession().autoplayPermitted()
+     &amp;&amp; paused()
+     &amp;&amp; autoplay()
+     &amp;&amp; !pausedForUserInteraction()
+     &amp;&amp; !document().isSandboxed(SandboxAutomaticFeatures))
+        return mediaSession().playbackPermitted(*this);
+
+    return MediaPlaybackDenialReason::PageConsentRequired;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
</span><span class="lines">@@ -2375,13 +2377,15 @@
</span><span class="cx">         if (isPotentiallyPlaying &amp;&amp; oldState &lt;= HAVE_CURRENT_DATA)
</span><span class="cx">             scheduleNotifyAboutPlaying();
</span><span class="cx"> 
</span><del>-        if (canTransitionFromAutoplayToPlay()) {
</del><ins>+        auto success = canTransitionFromAutoplayToPlay();
+        if (success) {
</ins><span class="cx">             m_paused = false;
</span><span class="cx">             invalidateCachedTime();
</span><span class="cx">             m_playbackStartedTime = currentMediaTime().toDouble();
</span><span class="cx">             scheduleEvent(eventNames().playEvent);
</span><span class="cx">             scheduleNotifyAboutPlaying();
</span><del>-        }
</del><ins>+        } else if (success.value() == MediaPlaybackDenialReason::UserGestureRequired)
+            m_preventedFromPlayingWithoutUserGesture = true;
</ins><span class="cx"> 
</span><span class="cx">         shouldUpdateDisplayState = true;
</span><span class="cx">     }
</span><span class="lines">@@ -3061,7 +3065,10 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::play(%p)&quot;, this);
</span><span class="cx"> 
</span><del>-    if (!m_mediaSession-&gt;playbackPermitted(*this)) {
</del><ins>+    auto success = m_mediaSession-&gt;playbackPermitted(*this);
+    if (!success) {
+        if (success.value() == MediaPlaybackDenialReason::UserGestureRequired)
+            m_preventedFromPlayingWithoutUserGesture = true;
</ins><span class="cx">         promise.reject(NotAllowedError);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -3086,8 +3093,12 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::play(%p)&quot;, this);
</span><span class="cx"> 
</span><del>-    if (!m_mediaSession-&gt;playbackPermitted(*this))
</del><ins>+    auto success = m_mediaSession-&gt;playbackPermitted(*this);
+    if (!success) {
+        if (success.value() == MediaPlaybackDenialReason::UserGestureRequired)
+            m_preventedFromPlayingWithoutUserGesture = true;
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx">     if (ScriptController::processingUserGestureForMedia())
</span><span class="cx">         removeBehaviorsRestrictionsAfterFirstUserGesture();
</span><span class="cx"> 
</span><span class="lines">@@ -3152,6 +3163,11 @@
</span><span class="cx">     } else if (m_readyState &gt;= HAVE_FUTURE_DATA)
</span><span class="cx">         scheduleResolvePendingPlayPromises();
</span><span class="cx"> 
</span><ins>+    if (ScriptController::processingUserGestureForMedia() &amp;&amp; m_preventedFromPlayingWithoutUserGesture) {
+        // FIXME: notify clients a user gesture was made and started playback of an element that was otherwise prevented from playing.
+        m_preventedFromPlayingWithoutUserGesture = false;
+    }
+
</ins><span class="cx">     m_autoplaying = false;
</span><span class="cx">     updatePlayState();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (211007 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2017-01-21 02:24:17 UTC (rev 211007)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -719,7 +719,7 @@
</span><span class="cx">     bool stoppedDueToErrors() const;
</span><span class="cx">     bool pausedForUserInteraction() const;
</span><span class="cx">     bool couldPlayIfEnoughData() const;
</span><del>-    bool canTransitionFromAutoplayToPlay() const;
</del><ins>+    SuccessOr&lt;MediaPlaybackDenialReason&gt; canTransitionFromAutoplayToPlay() const;
</ins><span class="cx"> 
</span><span class="cx">     MediaTime minTimeSeekable() const;
</span><span class="cx">     MediaTime maxTimeSeekable() const;
</span><span class="lines">@@ -961,6 +961,7 @@
</span><span class="cx">     bool m_creatingControls : 1;
</span><span class="cx">     bool m_receivedLayoutSizeChanged : 1;
</span><span class="cx">     bool m_hasEverNotifiedAboutPlaying : 1;
</span><ins>+    bool m_preventedFromPlayingWithoutUserGesture : 1;
</ins><span class="cx"> 
</span><span class="cx">     bool m_hasEverHadAudio : 1;
</span><span class="cx">     bool m_hasEverHadVideo : 1;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlMediaElementSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (211007 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/MediaElementSession.cpp        2017-01-21 02:24:17 UTC (rev 211007)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -148,33 +148,33 @@
</span><span class="cx">     m_restrictions &amp;= ~restriction;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaElementSession::playbackPermitted(const HTMLMediaElement&amp; element) const
</del><ins>+SuccessOr&lt;MediaPlaybackDenialReason&gt; MediaElementSession::playbackPermitted(const HTMLMediaElement&amp; element) const
</ins><span class="cx"> {
</span><span class="cx">     if (element.document().isMediaDocument() &amp;&amp; !element.document().ownerElement())
</span><del>-        return true;
</del><ins>+        return SuccessOr&lt;MediaPlaybackDenialReason&gt;();
</ins><span class="cx"> 
</span><span class="cx">     if (pageExplicitlyAllowsElementToAutoplayInline(element))
</span><del>-        return true;
</del><ins>+        return SuccessOr&lt;MediaPlaybackDenialReason&gt;();
</ins><span class="cx"> 
</span><span class="cx">     if (requiresFullscreenForVideoPlayback(element) &amp;&amp; !fullscreenPermitted(element)) {
</span><span class="cx">         LOG(Media, &quot;MediaElementSession::playbackPermitted - returning FALSE because of fullscreen restriction&quot;);
</span><del>-        return false;
</del><ins>+        return MediaPlaybackDenialReason::FullscreenRequired;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_restrictions &amp; OverrideUserGestureRequirementForMainContent &amp;&amp; updateIsMainContent())
</span><del>-        return true;
</del><ins>+        return SuccessOr&lt;MediaPlaybackDenialReason&gt;();
</ins><span class="cx"> 
</span><span class="cx">     if (m_restrictions &amp; RequireUserGestureForVideoRateChange &amp;&amp; element.isVideo() &amp;&amp; !ScriptController::processingUserGestureForMedia()) {
</span><span class="cx">         LOG(Media, &quot;MediaElementSession::playbackPermitted - returning FALSE because of video rate change restriction&quot;);
</span><del>-        return false;
</del><ins>+        return MediaPlaybackDenialReason::UserGestureRequired;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_restrictions &amp; RequireUserGestureForAudioRateChange &amp;&amp; (!element.isVideo() || element.hasAudio()) &amp;&amp; !element.muted() &amp;&amp; !ScriptController::processingUserGestureForMedia()) {
</span><span class="cx">         LOG(Media, &quot;MediaElementSession::playbackPermitted - returning FALSE because of audio rate change restriction&quot;);
</span><del>-        return false;
</del><ins>+        return MediaPlaybackDenialReason::UserGestureRequired;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return true;
</del><ins>+    return SuccessOr&lt;MediaPlaybackDenialReason&gt;();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaElementSession::autoplayPermitted() const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlMediaElementSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/MediaElementSession.h (211007 => 211008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/MediaElementSession.h        2017-01-21 02:24:17 UTC (rev 211007)
+++ trunk/Source/WebCore/html/MediaElementSession.h        2017-01-21 02:31:33 UTC (rev 211008)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;MediaPlayer.h&quot;
</span><span class="cx"> #include &quot;PlatformMediaSession.h&quot;
</span><ins>+#include &quot;SuccessOr.h&quot;
</ins><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &lt;wtf/TypeCasts.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -39,6 +40,12 @@
</span><span class="cx">     Autoplay
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum class MediaPlaybackDenialReason {
+    UserGestureRequired,
+    FullscreenRequired,
+    PageConsentRequired,
+};
+
</ins><span class="cx"> class Document;
</span><span class="cx"> class HTMLMediaElement;
</span><span class="cx"> class SourceBuffer;
</span><span class="lines">@@ -52,7 +59,7 @@
</span><span class="cx">     void registerWithDocument(Document&amp;);
</span><span class="cx">     void unregisterWithDocument(Document&amp;);
</span><span class="cx"> 
</span><del>-    bool playbackPermitted(const HTMLMediaElement&amp;) const;
</del><ins>+    SuccessOr&lt;MediaPlaybackDenialReason&gt; playbackPermitted(const HTMLMediaElement&amp;) const;
</ins><span class="cx">     bool autoplayPermitted() const;
</span><span class="cx">     bool dataLoadingPermitted(const HTMLMediaElement&amp;) const;
</span><span class="cx">     bool fullscreenPermitted(const HTMLMediaElement&amp;) const;
</span></span></pre>
</div>
</div>

</body>
</html>