Title: [199603] trunk/Source/WebCore
Revision
199603
Author
jer.no...@apple.com
Date
2016-04-15 12:06:30 -0700 (Fri, 15 Apr 2016)

Log Message

Audio elements should be able to have a controls manager.
https://bugs.webkit.org/show_bug.cgi?id=156630

Reviewed by Beth Dakin.

Now that there is no longer a architectural restriction about what kind of media elements
can be used with WebPlaybackSessionManager, allow audio elements to create a controls
manager.

Drive-by fix: clear the controls manager when destroying the media player due to entering
the page cache, and when destroying the media element.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::updatePlayState):
(WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canControlControlsManager):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (199602 => 199603)


--- trunk/Source/WebCore/ChangeLog	2016-04-15 19:01:39 UTC (rev 199602)
+++ trunk/Source/WebCore/ChangeLog	2016-04-15 19:06:30 UTC (rev 199603)
@@ -1,3 +1,24 @@
+2016-04-15  Jer Noble  <jer.no...@apple.com>
+
+        Audio elements should be able to have a controls manager.
+        https://bugs.webkit.org/show_bug.cgi?id=156630
+
+        Reviewed by Beth Dakin.
+
+        Now that there is no longer a architectural restriction about what kind of media elements
+        can be used with WebPlaybackSessionManager, allow audio elements to create a controls
+        manager.
+
+        Drive-by fix: clear the controls manager when destroying the media player due to entering
+        the page cache, and when destroying the media element.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::~HTMLMediaElement):
+        (WebCore::HTMLMediaElement::updatePlayState):
+        (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::canControlControlsManager):
+
 2016-04-15  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Calling SVGAnimatedPropertyTearOff::animationEnded() will crash if the SVG property is not animating

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (199602 => 199603)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-04-15 19:01:39 UTC (rev 199602)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-04-15 19:06:30 UTC (rev 199603)
@@ -499,6 +499,9 @@
     setShouldDelayLoadEvent(false);
     unregisterWithDocument(document());
 
+    if (document().page())
+        document().page()->chrome().client().clearPlaybackControlsManager(*this);
+
 #if ENABLE(VIDEO_TRACK)
     if (m_audioTracks) {
         m_audioTracks->clearElement();
@@ -4824,10 +4827,8 @@
     LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s, playerPaused = %s", this, boolString(shouldBePlaying), boolString(playerPaused));
 
     if (shouldBePlaying) {
-        if (document().page() && m_mediaSession->canControlControlsManager(*this)) {
-            HTMLVideoElement& asVideo = downcast<HTMLVideoElement>(*this);
-            document().page()->chrome().client().setUpPlaybackControlsManager(asVideo);
-        }
+        if (document().page() && m_mediaSession->canControlControlsManager(*this))
+            document().page()->chrome().client().setUpPlaybackControlsManager(*this);
 
         setDisplayMode(Video);
         invalidateCachedTime();
@@ -4861,7 +4862,7 @@
         startPlaybackProgressTimer();
         setPlaying(true);
     } else {
-        if (endedPlayback() && document().page() && is<HTMLVideoElement>(*this))
+        if (endedPlayback() && document().page())
             document().page()->chrome().client().clearPlaybackControlsManager(*this);
 
         if (!playerPaused)
@@ -5030,7 +5031,10 @@
 
     if (m_videoFullscreenMode != VideoFullscreenModeNone)
         exitFullscreen();
-    
+
+    if (document().page())
+        document().page()->chrome().client().clearPlaybackControlsManager(*this);
+
     m_inActiveDocument = false;
 
     // Stop the playback without generating events

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (199602 => 199603)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2016-04-15 19:01:39 UTC (rev 199602)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2016-04-15 19:06:30 UTC (rev 199603)
@@ -214,9 +214,7 @@
 
 bool MediaElementSession::canControlControlsManager(const HTMLMediaElement& element) const
 {
-    // FIXME: rdar://problem/25537071 Audio elements should be able to have a controls manager as well.
-    // Audio elements should probably only have a controls manager if they started playing via a user gesture.
-    if (!element.isVideo())
+    if (!element.hasAudio())
         return false;
 
     if (!playbackPermitted(element))
@@ -226,10 +224,8 @@
     if (!renderer)
         return false;
 
-    if (renderer->clientWidth() >= elementMainContentMinimumWidth && renderer->clientHeight() >= elementMainContentMinimumHeight) {
-        if (element.hasAudio() && element.hasVideo())
+    if (element.hasVideo() && renderer->clientWidth() >= elementMainContentMinimumWidth && renderer->clientHeight() >= elementMainContentMinimumHeight)
             return true;
-    }
 
     if (ScriptController::processingUserGestureForMedia())
         return true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to