Title: [268816] trunk/Source/WebCore
Revision
268816
Author
[email protected]
Date
2020-10-21 12:21:55 -0700 (Wed, 21 Oct 2020)

Log Message

A video element may fail to enter picture-in-picture from fullscreen
https://bugs.webkit.org/show_bug.cgi?id=217999

Reviewed by Eric Carlson.

When a video element is entering picture-in-picture from fullscreen,
WebKit should only fire the `webkitendfullscreenEvent` event, but should not
request the player in the UI process to exit fullscreen(picture-in-picture).
So the condition to decide sending the exit fullscreen request is wrong because
HTMLMediaElement::didBecomeFullscreenElement(), which sets `m_waitingToEnterFullscreen`
to false, might be called before dispatching the `webkitendfullscreenEvent` event.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Fix the condition.
(WebCore::HTMLMediaElement::exitFullscreen): Set fullscreen mode to VideoFullscreenModeNone.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268815 => 268816)


--- trunk/Source/WebCore/ChangeLog	2020-10-21 19:19:36 UTC (rev 268815)
+++ trunk/Source/WebCore/ChangeLog	2020-10-21 19:21:55 UTC (rev 268816)
@@ -1,3 +1,21 @@
+2020-10-21  Peng Liu  <[email protected]>
+
+        A video element may fail to enter picture-in-picture from fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=217999
+
+        Reviewed by Eric Carlson.
+
+        When a video element is entering picture-in-picture from fullscreen,
+        WebKit should only fire the `webkitendfullscreenEvent` event, but should not
+        request the player in the UI process to exit fullscreen(picture-in-picture).
+        So the condition to decide sending the exit fullscreen request is wrong because
+        HTMLMediaElement::didBecomeFullscreenElement(), which sets `m_waitingToEnterFullscreen`
+        to false, might be called before dispatching the `webkitendfullscreenEvent` event.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::dispatchEvent): Fix the condition.
+        (WebCore::HTMLMediaElement::exitFullscreen): Set fullscreen mode to VideoFullscreenModeNone.
+
 2020-10-21  Zalan Bujtas  <[email protected]>
 
         [LFC][Integration] Ascent and descent are rounded to integral position

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (268815 => 268816)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2020-10-21 19:19:36 UTC (rev 268815)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2020-10-21 19:21:55 UTC (rev 268816)
@@ -5740,10 +5740,8 @@
     // We need to fire the end fullscreen event to notify the page
     // to change the position/size back *before* exiting fullscreen.
     // Otherwise, the exit fullscreen animation will be incorrect.
-    if (!m_videoFullscreenStandby && !m_waitingToEnterFullscreen && event.type() == eventNames().webkitendfullscreenEvent) {
-        setFullscreenMode(VideoFullscreenModeNone);
+    if (!m_videoFullscreenStandby && m_videoFullscreenMode == VideoFullscreenModeNone && event.type() == eventNames().webkitendfullscreenEvent)
         document().page()->chrome().client().exitVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this));
-    }
 }
 
 bool HTMLMediaElement::addEventListener(const AtomString& eventType, Ref<EventListener>&& listener, const AddEventListenerOptions& options)
@@ -6002,6 +6000,7 @@
         }
 
         if (oldVideoFullscreenMode == VideoFullscreenModeStandard) {
+            setFullscreenMode(VideoFullscreenModeNone);
             // The exit fullscreen request will be sent in dispatchEvent().
             scheduleEvent(eventNames().webkitendfullscreenEvent);
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to