Title: [252755] trunk/Source
Revision
252755
Author
[email protected]
Date
2019-11-21 16:32:45 -0800 (Thu, 21 Nov 2019)

Log Message

Ignore the requests to enter/exit video fullscreen/picture-in-picture if the requesting mode is the same as the current mode
https://bugs.webkit.org/show_bug.cgi?id=204461

Patch by Peng Liu <[email protected]> on 2019-11-21
Reviewed by Jer Noble.

Source/WebCore:

Change the order of enum VideoPresentationMode and add some log messages regarding presentation mode change.
Those changes make the debugging easier.

Covered by existing test cases.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):
(WebCore::HTMLMediaElement::didBecomeFullscreenElement):
(WebCore::HTMLMediaElement::waitForPreparedForInlineThen):
(WebCore::HTMLMediaElement::setVideoFullscreenLayer):
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::webkitSetPresentationMode):
(WebCore::HTMLVideoElement::setFullscreenMode):
(WebCore::HTMLVideoElement::fullscreenModeChanged):
* html/HTMLVideoElement.h:
* html/HTMLVideoElement.idl:

Source/WebKit:

In enterVideoFullscreenForVideoElement() and exitVideoFullscreenForVideoElement(),
we can ignore the request if the targeting mode is the same as the current one.

* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
(WebKit::VideoFullscreenManager::exitVideoFullscreenForVideoElement):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252754 => 252755)


--- trunk/Source/WebCore/ChangeLog	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebCore/ChangeLog	2019-11-22 00:32:45 UTC (rev 252755)
@@ -1,3 +1,27 @@
+2019-11-21  Peng Liu  <[email protected]>
+
+        Ignore the requests to enter/exit video fullscreen/picture-in-picture if the requesting mode is the same as the current mode
+        https://bugs.webkit.org/show_bug.cgi?id=204461
+
+        Reviewed by Jer Noble.
+
+        Change the order of enum VideoPresentationMode and add some log messages regarding presentation mode change.
+        Those changes make the debugging easier.
+
+        Covered by existing test cases.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::enterFullscreen):
+        (WebCore::HTMLMediaElement::didBecomeFullscreenElement):
+        (WebCore::HTMLMediaElement::waitForPreparedForInlineThen):
+        (WebCore::HTMLMediaElement::setVideoFullscreenLayer):
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::webkitSetPresentationMode):
+        (WebCore::HTMLVideoElement::setFullscreenMode):
+        (WebCore::HTMLVideoElement::fullscreenModeChanged):
+        * html/HTMLVideoElement.h:
+        * html/HTMLVideoElement.idl:
+
 2019-11-21  Justin Fan  <[email protected]>
 
         [WebGL] Fix framebufferTexture2D with DEPTH_STENCIL_ATTACHMENT on ANGLE

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (252754 => 252755)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2019-11-22 00:32:45 UTC (rev 252755)
@@ -6049,7 +6049,7 @@
 
 void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
 {
-    INFO_LOG(LOGIDENTIFIER);
+    INFO_LOG(LOGIDENTIFIER, ", m_videoFullscreenMode = ", m_videoFullscreenMode, ", mode = ", mode);
     ASSERT(mode != VideoFullscreenModeNone);
 
     if (m_videoFullscreenMode == mode)
@@ -6078,6 +6078,7 @@
         if (is<HTMLVideoElement>(*this)) {
             HTMLVideoElement& asVideo = downcast<HTMLVideoElement>(*this);
             if (document().page()->chrome().client().supportsVideoFullscreen(m_videoFullscreenMode)) {
+                INFO_LOG(LOGIDENTIFIER, "Entering fullscreen mode ", m_videoFullscreenMode, ", m_videoFullscreenStandby = ", m_videoFullscreenStandby);
                 document().page()->chrome().client().enterVideoFullscreenForVideoElement(asVideo, m_videoFullscreenMode, m_videoFullscreenStandby);
                 scheduleEvent(eventNames().webkitbeginfullscreenEvent);
             }
@@ -6196,6 +6197,7 @@
 
 void HTMLMediaElement::didBecomeFullscreenElement()
 {
+    INFO_LOG(LOGIDENTIFIER, ", fullscreen mode = ", fullscreenMode());
     m_waitingToEnterFullscreen = false;
     if (hasMediaControls())
         mediaControls()->enteredFullscreen();
@@ -6227,6 +6229,7 @@
 
 void HTMLMediaElement::waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler)
 {
+    INFO_LOG(LOGIDENTIFIER);
     ASSERT(!m_preparedForInlineCompletionHandler);
     if (m_preparedForInline)  {
         completionHandler();
@@ -6251,6 +6254,7 @@
 
 void HTMLMediaElement::setVideoFullscreenLayer(PlatformLayer* platformLayer, WTF::Function<void()>&& completionHandler)
 {
+    INFO_LOG(LOGIDENTIFIER);
     m_videoFullscreenLayer = platformLayer;
     if (!m_player) {
         completionHandler();

Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (252754 => 252755)


--- trunk/Source/WebCore/html/HTMLVideoElement.cpp	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp	2019-11-22 00:32:45 UTC (rev 252755)
@@ -452,12 +452,13 @@
 
 void HTMLVideoElement::webkitSetPresentationMode(VideoPresentationMode mode)
 {
-    ALWAYS_LOG(LOGIDENTIFIER, mode);
+    INFO_LOG(LOGIDENTIFIER, ", mode = ",  mode);
     setFullscreenMode(toFullscreenMode(mode));
 }
 
 void HTMLVideoElement::setFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
 {
+    INFO_LOG(LOGIDENTIFIER, ", mode = ", mode);
 #if ENABLE(PICTURE_IN_PICTURE_API)
     if (m_pictureInPictureAPITestEnabled) {
         if (mode == VideoFullscreenModePictureInPicture) {
@@ -510,7 +511,7 @@
 void HTMLVideoElement::fullscreenModeChanged(VideoFullscreenMode mode)
 {
     if (mode != fullscreenMode()) {
-        ALWAYS_LOG(LOGIDENTIFIER, "changed from ", fullscreenMode(), ", to ", mode);
+        INFO_LOG(LOGIDENTIFIER, "changed from ", fullscreenMode(), ", to ", mode);
         scheduleEvent(eventNames().webkitpresentationmodechangedEvent);
 
 #if ENABLE(PICTURE_IN_PICTURE_API)

Modified: trunk/Source/WebCore/html/HTMLVideoElement.h (252754 => 252755)


--- trunk/Source/WebCore/html/HTMLVideoElement.h	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebCore/html/HTMLVideoElement.h	2019-11-22 00:32:45 UTC (rev 252755)
@@ -82,7 +82,7 @@
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)
-    enum class VideoPresentationMode { Fullscreen, PictureInPicture, Inline };
+    enum class VideoPresentationMode { Inline, Fullscreen, PictureInPicture};
     WEBCORE_EXPORT bool webkitSupportsPresentationMode(VideoPresentationMode) const;
     void webkitSetPresentationMode(VideoPresentationMode);
     VideoPresentationMode webkitPresentationMode() const;

Modified: trunk/Source/WebCore/html/HTMLVideoElement.idl (252754 => 252755)


--- trunk/Source/WebCore/html/HTMLVideoElement.idl	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebCore/html/HTMLVideoElement.idl	2019-11-22 00:32:45 UTC (rev 252755)
@@ -59,4 +59,4 @@
     [Conditional=VIDEO_PRESENTATION_MODE] void webkitSetPresentationMode(VideoPresentationMode mode);
 };
 
-[Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "fullscreen", "picture-in-picture", "inline" };
+[Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "inline", "fullscreen", "picture-in-picture" };

Modified: trunk/Source/WebKit/ChangeLog (252754 => 252755)


--- trunk/Source/WebKit/ChangeLog	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebKit/ChangeLog	2019-11-22 00:32:45 UTC (rev 252755)
@@ -1,3 +1,17 @@
+2019-11-21  Peng Liu  <[email protected]>
+
+        Ignore the requests to enter/exit video fullscreen/picture-in-picture if the requesting mode is the same as the current mode
+        https://bugs.webkit.org/show_bug.cgi?id=204461
+
+        Reviewed by Jer Noble.
+
+        In enterVideoFullscreenForVideoElement() and exitVideoFullscreenForVideoElement(),
+        we can ignore the request if the targeting mode is the same as the current one.
+
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+        (WebKit::VideoFullscreenManager::exitVideoFullscreenForVideoElement):
+
 2019-11-20  ChangSeok Oh  <[email protected]>
 
         [GTK] Add ANGLE backend to GTK port

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (252754 => 252755)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2019-11-21 23:35:21 UTC (rev 252754)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2019-11-22 00:32:45 UTC (rev 252755)
@@ -248,6 +248,10 @@
     ASSERT(addResult.iterator->value == contextId);
 
     auto [model, interface] = ensureModelAndInterface(contextId);
+    HTMLMediaElementEnums::VideoFullscreenMode oldMode = interface->fullscreenMode();
+    if (oldMode == mode)
+        return;
+
     addClientForContext(contextId);
     if (!interface->layerHostingContext())
         interface->setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
@@ -255,7 +259,6 @@
     auto videoRect = inlineVideoFrame(videoElement);
     FloatRect videoLayerFrame = FloatRect(0, 0, videoRect.width(), videoRect.height());
 
-    HTMLMediaElementEnums::VideoFullscreenMode oldMode = interface->fullscreenMode();
     interface->setTargetIsFullscreen(true);
     interface->setFullscreenMode(mode);
     interface->setFullscreenStandby(standby);
@@ -296,6 +299,9 @@
 
     uint64_t contextId = m_videoElements.get(&videoElement);
     auto& interface = ensureInterface(contextId);
+    HTMLMediaElementEnums::VideoFullscreenMode oldMode = interface.fullscreenMode();
+    if (oldMode == HTMLMediaElementEnums::VideoFullscreenModeNone)
+        return;
 
     interface.setTargetIsFullscreen(false);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to