<!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>[175330] 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/175330">175330</a></dd>
<dt>Author</dt> <dd>adachan@apple.com</dd>
<dt>Date</dt> <dd>2014-10-29 10:41:10 -0700 (Wed, 29 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove MediaSessionClient::hasMediaCharacteristics() and MediaSessionClient::mediaStateDidChange().
https://bugs.webkit.org/show_bug.cgi?id=138153

Reviewed by Jer Noble.

After http://trac.webkit.org/changeset/175273, Document no longer keeps a set of MediaSessions
and it doesn't need to query each MediaSession for its characteristics and play state.
MediaSessionClient::hasMediaCharacteristics() is no longer needed and MediaSessionClient::mediaStateDidChange()
can be removed if HTMLMediaElement calls Document::updateIsPlayingAudio() after m_playing has changed.

No new tests, no behavior change.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updatePlayState):
Call setPlaying() rather than setting m_playing directly.
(WebCore::HTMLMediaElement::setPlaying):
Update m_playing. If it has changed, call Document::updateIsPlayingAudio().
(WebCore::HTMLMediaElement::setPausedInternal):
Call setPlaying() rather than setting m_playing directly.
(WebCore::HTMLMediaElement::isPlayingAudio):
Call isPlaying() directly rather than checking the MediaSession's state.
* html/HTMLMediaElement.h:
* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::setState):
MediaSessionClient::mediaStateDidChange() has been removed.
(WebCore::MediaSession::hasMediaCharacteristics): Deleted.
* platform/audio/MediaSession.h:
(WebCore::MediaSessionClient::mediaStateDidChange): Deleted.
* platform/audio/ios/AudioDestinationIOS.h:
* platform/audio/mac/AudioDestinationMac.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#trunkSourceWebCoreplatformaudioMediaSessioncpp">trunk/Source/WebCore/platform/audio/MediaSession.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionh">trunk/Source/WebCore/platform/audio/MediaSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioiosAudioDestinationIOSh">trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacAudioDestinationMach">trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/ChangeLog        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2014-10-28  Ada Chan  &lt;adachan@apple.com&gt;
+
+        Remove MediaSessionClient::hasMediaCharacteristics() and MediaSessionClient::mediaStateDidChange().
+        https://bugs.webkit.org/show_bug.cgi?id=138153
+
+        Reviewed by Jer Noble.
+
+        After http://trac.webkit.org/changeset/175273, Document no longer keeps a set of MediaSessions
+        and it doesn't need to query each MediaSession for its characteristics and play state.
+        MediaSessionClient::hasMediaCharacteristics() is no longer needed and MediaSessionClient::mediaStateDidChange()
+        can be removed if HTMLMediaElement calls Document::updateIsPlayingAudio() after m_playing has changed.
+
+        No new tests, no behavior change.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updatePlayState):
+        Call setPlaying() rather than setting m_playing directly.
+        (WebCore::HTMLMediaElement::setPlaying):
+        Update m_playing. If it has changed, call Document::updateIsPlayingAudio().
+        (WebCore::HTMLMediaElement::setPausedInternal):
+        Call setPlaying() rather than setting m_playing directly.
+        (WebCore::HTMLMediaElement::isPlayingAudio):
+        Call isPlaying() directly rather than checking the MediaSession's state.
+        * html/HTMLMediaElement.h:
+        * platform/audio/MediaSession.cpp:
+        (WebCore::MediaSession::setState):
+        MediaSessionClient::mediaStateDidChange() has been removed.
+        (WebCore::MediaSession::hasMediaCharacteristics): Deleted.
+        * platform/audio/MediaSession.h:
+        (WebCore::MediaSessionClient::mediaStateDidChange): Deleted.
+        * platform/audio/ios/AudioDestinationIOS.h:
+        * platform/audio/mac/AudioDestinationMac.h:
+
</ins><span class="cx"> 2014-10-29  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Clean up virtual functions in html/
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -4531,15 +4531,14 @@
</span><span class="cx">             m_activityToken = document().page()-&gt;pageThrottler().mediaActivityToken();
</span><span class="cx"> 
</span><span class="cx">         startPlaybackProgressTimer();
</span><del>-        m_playing = true;
-
</del><ins>+        setPlaying(true);
</ins><span class="cx">     } else {
</span><span class="cx">         if (!playerPaused)
</span><span class="cx">             m_player-&gt;pause();
</span><span class="cx">         refreshCachedTime();
</span><span class="cx"> 
</span><span class="cx">         m_playbackProgressTimer.stop();
</span><del>-        m_playing = false;
</del><ins>+        setPlaying(false);
</ins><span class="cx">         MediaTime time = currentMediaTime();
</span><span class="cx">         if (time &gt; m_lastSeekTime)
</span><span class="cx">             addPlayedRange(m_lastSeekTime, time);
</span><span class="lines">@@ -4558,6 +4557,15 @@
</span><span class="cx">         renderer()-&gt;updateFromElement();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLMediaElement::setPlaying(bool playing)
+{
+    if (m_playing == playing)
+        return;
+    
+    m_playing = playing;
+    document().updateIsPlayingAudio();
+}
+
</ins><span class="cx"> void HTMLMediaElement::setPausedInternal(bool b)
</span><span class="cx"> {
</span><span class="cx">     m_pausedInternal = b;
</span><span class="lines">@@ -4676,7 +4684,7 @@
</span><span class="cx">     m_inActiveDocument = false;
</span><span class="cx"> 
</span><span class="cx">     // Stop the playback without generating events
</span><del>-    m_playing = false;
</del><ins>+    setPlaying(false);
</ins><span class="cx">     setPausedInternal(true);
</span><span class="cx">     m_mediaSession-&gt;clientWillPausePlayback();
</span><span class="cx"> 
</span><span class="lines">@@ -6019,26 +6027,9 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLMediaElement::hasMediaCharacteristics(MediaSession::MediaCharacteristics characteristics) const
-{
-    if ((characteristics &amp; MediaSession::MediaCharacteristicAudible) &amp;&amp; !hasAudio())
-        return false;
-    if ((characteristics &amp; MediaSession::MediaCharacteristicVisual) &amp;&amp; !hasVideo())
-        return false;
-    if ((characteristics &amp; MediaSession::MediaCharacteristicLegible) &amp;&amp; !hasClosedCaptions())
-        return false;
-
-    return true;
-}
-
-void HTMLMediaElement::mediaStateDidChange()
-{
-    document().updateIsPlayingAudio();
-}
-
</del><span class="cx"> bool HTMLMediaElement::isPlayingAudio()
</span><span class="cx"> {
</span><del>-    return m_mediaSession-&gt;state() == MediaSession::Playing &amp;&amp; hasAudio();
</del><ins>+    return isPlaying() &amp;&amp; hasAudio();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLMediaElement::doesHaveAttribute(const AtomicString&amp; attribute, AtomicString* value) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -650,6 +650,7 @@
</span><span class="cx"> 
</span><span class="cx">     void updateVolume();
</span><span class="cx">     void updatePlayState();
</span><ins>+    void setPlaying(bool);
</ins><span class="cx">     bool potentiallyPlaying() const;
</span><span class="cx">     bool endedPlayback() const;
</span><span class="cx">     bool stoppedDueToErrors() const;
</span><span class="lines">@@ -708,8 +709,6 @@
</span><span class="cx">     virtual bool canReceiveRemoteControlCommands() const override { return true; }
</span><span class="cx">     virtual void didReceiveRemoteControlCommand(MediaSession::RemoteControlCommandType) override;
</span><span class="cx">     virtual bool overrideBackgroundPlaybackRestriction() const override;
</span><del>-    virtual bool hasMediaCharacteristics(MediaSession::MediaCharacteristics) const override;
-    virtual void mediaStateDidChange() override;
</del><span class="cx"> 
</span><span class="cx">     // AudioProducer overrides
</span><span class="cx">     virtual bool isPlayingAudio() override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSession.cpp (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSession.cpp        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/platform/audio/MediaSession.cpp        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -76,13 +76,7 @@
</span><span class="cx"> void MediaSession::setState(State state)
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;MediaSession::setState(%p) - %s&quot;, this, stateName(state));
</span><del>-
-    if (m_state == state)
-        return;
-
</del><span class="cx">     m_state = state;
</span><del>-
-    client().mediaStateDidChange();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaSession::beginInterruption(InterruptionType type)
</span><span class="lines">@@ -113,11 +107,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaSession::hasMediaCharacteristics(MediaSession::MediaCharacteristics mediaCharacteristics) const
-{
-    return client().hasMediaCharacteristics(mediaCharacteristics);
-}
-
</del><span class="cx"> bool MediaSession::clientWillBeginPlayback()
</span><span class="cx"> {
</span><span class="cx">     setState(Playing);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSession.h (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSession.h        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/platform/audio/MediaSession.h        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -71,14 +71,6 @@
</span><span class="cx">     void beginInterruption(InterruptionType);
</span><span class="cx">     void endInterruption(EndInterruptionFlags);
</span><span class="cx"> 
</span><del>-    enum MediaCharacteristicFlags {
-        MediaCharacteristicAudible = 1,
-        MediaCharacteristicVisual = 1 &lt;&lt; 1,
-        MediaCharacteristicLegible = 1 &lt;&lt; 2,
-    };
-    typedef unsigned MediaCharacteristics;
-    bool hasMediaCharacteristics(MediaCharacteristics) const;
-
</del><span class="cx">     void applicationWillEnterForeground() const;
</span><span class="cx">     void applicationWillEnterBackground() const;
</span><span class="cx"> 
</span><span class="lines">@@ -147,9 +139,6 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool overrideBackgroundPlaybackRestriction() const = 0;
</span><span class="cx"> 
</span><del>-    virtual bool hasMediaCharacteristics(MediaSession::MediaCharacteristics) const = 0;
-    virtual void mediaStateDidChange() { }
-
</del><span class="cx">     virtual void wirelessRoutesAvailableDidChange() { }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioiosAudioDestinationIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx">     virtual bool overrideBackgroundPlaybackRestriction() const { return false; }
</span><span class="cx">     virtual void pausePlayback() override { stop(); }
</span><span class="cx">     virtual void resumePlayback() override { start(); }
</span><del>-    virtual bool hasMediaCharacteristics(MediaSession::MediaCharacteristics characteristics) const override { return characteristics == MediaSession::MediaCharacteristicAudible; }
</del><span class="cx"> 
</span><span class="cx">     // DefaultOutputUnit callback
</span><span class="cx">     static OSStatus inputProc(void* userData, AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32 busNumber, UInt32 numberOfFrames, AudioBufferList* ioData);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacAudioDestinationMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h (175329 => 175330)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h        2014-10-29 17:16:00 UTC (rev 175329)
+++ trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h        2014-10-29 17:41:10 UTC (rev 175330)
</span><span class="lines">@@ -57,7 +57,6 @@
</span><span class="cx">     virtual bool canReceiveRemoteControlCommands() const override { return false; }
</span><span class="cx">     virtual void didReceiveRemoteControlCommand(MediaSession::RemoteControlCommandType) override { }
</span><span class="cx">     virtual bool overrideBackgroundPlaybackRestriction() const override { return false; }
</span><del>-    virtual bool hasMediaCharacteristics(MediaSession::MediaCharacteristics characteristics) const override { return characteristics == MediaSession::MediaCharacteristicAudible; }
</del><span class="cx"> 
</span><span class="cx">     virtual void start() override;
</span><span class="cx">     virtual void stop() override;
</span></span></pre>
</div>
</div>

</body>
</html>