Title: [262599] trunk/Source/WebCore
Revision
262599
Author
peng.l...@apple.com
Date
2020-06-04 22:52:22 -0700 (Thu, 04 Jun 2020)

Log Message

A YouTube video gets stuck after rapidly tapping on touchbar’s PIP button
https://bugs.webkit.org/show_bug.cgi?id=212729

Reviewed by Darin Adler.

Call HTMLVideoElement::setFullscreenMode() instead of HTMLMediaElement::enterFullscreen()
and HTMLMediaElement::exitFullscreen() to toggle picture-in-picture mode.
HTMLVideoElement::setFullscreenMode() is robust under stress test after r262456.

Manually tested.

* platform/cocoa/PlaybackSessionModelMediaElement.mm:
(WebCore::PlaybackSessionModelMediaElement::togglePictureInPicture):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (262598 => 262599)


--- trunk/Source/WebCore/ChangeLog	2020-06-05 05:36:33 UTC (rev 262598)
+++ trunk/Source/WebCore/ChangeLog	2020-06-05 05:52:22 UTC (rev 262599)
@@ -1,3 +1,19 @@
+2020-06-04  Peng Liu  <peng.l...@apple.com>
+
+        A YouTube video gets stuck after rapidly tapping on touchbar’s PIP button
+        https://bugs.webkit.org/show_bug.cgi?id=212729
+
+        Reviewed by Darin Adler.
+
+        Call HTMLVideoElement::setFullscreenMode() instead of HTMLMediaElement::enterFullscreen()
+        and HTMLMediaElement::exitFullscreen() to toggle picture-in-picture mode.
+        HTMLVideoElement::setFullscreenMode() is robust under stress test after r262456.
+
+        Manually tested.
+
+        * platform/cocoa/PlaybackSessionModelMediaElement.mm:
+        (WebCore::PlaybackSessionModelMediaElement::togglePictureInPicture):
+
 2020-06-04  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r262583.

Modified: trunk/Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.mm (262598 => 262599)


--- trunk/Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.mm	2020-06-05 05:36:33 UTC (rev 262598)
+++ trunk/Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.mm	2020-06-05 05:52:22 UTC (rev 262599)
@@ -32,8 +32,7 @@
 #import "Event.h"
 #import "EventListener.h"
 #import "EventNames.h"
-#import "HTMLElement.h"
-#import "HTMLMediaElement.h"
+#import "HTMLVideoElement.h"
 #import "Logging.h"
 #import "MediaControlsHost.h"
 #import "MediaSelectionOption.h"
@@ -314,10 +313,15 @@
 
 void PlaybackSessionModelMediaElement::togglePictureInPicture()
 {
-    if (m_mediaElement->fullscreenMode() == MediaPlayerEnums::VideoFullscreenModePictureInPicture)
-        m_mediaElement->exitFullscreen();
+    ASSERT(is<HTMLVideoElement>(*m_mediaElement));
+    if (!is<HTMLVideoElement>(*m_mediaElement))
+        return;
+
+    auto& element = downcast<HTMLVideoElement>(*m_mediaElement);
+    if (element.fullscreenMode() == MediaPlayerEnums::VideoFullscreenModePictureInPicture)
+        element.setFullscreenMode(MediaPlayerEnums::VideoFullscreenModeNone);
     else
-        m_mediaElement->enterFullscreen(MediaPlayerEnums::VideoFullscreenModePictureInPicture);
+        element.setFullscreenMode(MediaPlayerEnums::VideoFullscreenModePictureInPicture);
 }
 
 void PlaybackSessionModelMediaElement::toggleMuted()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to