Title: [272320] branches/safari-611-branch/Source/WebCore

Diff

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (272319 => 272320)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-03 17:18:39 UTC (rev 272319)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-03 17:33:36 UTC (rev 272320)
@@ -1,5 +1,28 @@
 2021-02-03  Russell Epstein  <[email protected]>
 
+        Apply patch. rdar://problem/73904694
+
+    2021-02-03  Jer Noble  <[email protected]>
+
+            Facebook pauses video in PiP during scroll
+            https://bugs.webkit.org/show_bug.cgi?id=220581
+            <rdar://67273166>
+
+            Reviewed by Eric Carlson.
+
+            Add a Quirk which blocks Facebook from pausing videos in Picture-in-Picture mode without that
+            pause() occurring during a User Gesture. This blocks Facebook from pausing a PiP'd video when
+            the <video> element hosting that video scrolls out of the viewport, without blocking Facebook's
+            own custom pause control from working correctly.
+
+            * html/MediaElementSession.cpp:
+            (WebCore::MediaElementSession::playbackPermitted const):
+            * page/Quirks.cpp:
+            (WebCore::Quirks::requiresUserGestureToPauseInPictureInPicture const):
+            * page/Quirks.h:
+
+2021-02-03  Russell Epstein  <[email protected]>
+
         Cherry-pick r271898. rdar://problem/73935028
 
     ScopedHighPerformanceGPURequest.h not marked framework private

Modified: branches/safari-611-branch/Source/WebCore/html/MediaElementSession.cpp (272319 => 272320)


--- branches/safari-611-branch/Source/WebCore/html/MediaElementSession.cpp	2021-02-03 17:18:39 UTC (rev 272319)
+++ branches/safari-611-branch/Source/WebCore/html/MediaElementSession.cpp	2021-02-03 17:33:36 UTC (rev 272320)
@@ -315,6 +315,14 @@
 
     // FIXME: Why are we checking top-level document only for PerDocumentAutoplayBehavior?
     const auto& topDocument = document.topDocument();
+    if (topDocument.quirks().requiresUserGestureToPauseInPictureInPicture()
+        && m_element.fullscreenMode() & HTMLMediaElementEnums::VideoFullscreenModePictureInPicture
+        && !m_element.paused()
+        && !document.processingUserGestureForMedia()) {
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a quirk requires a user gesture to pause while in Picture-in-Picture");
+        return MediaPlaybackDenialReason::UserGestureRequired;
+    }
+
     if (topDocument.mediaState() & MediaProducer::HasUserInteractedWithMediaElement && topDocument.quirks().needsPerDocumentAutoplayBehavior())
         return { };
 

Modified: branches/safari-611-branch/Source/WebCore/page/Quirks.cpp (272319 => 272320)


--- branches/safari-611-branch/Source/WebCore/page/Quirks.cpp	2021-02-03 17:18:39 UTC (rev 272319)
+++ branches/safari-611-branch/Source/WebCore/page/Quirks.cpp	2021-02-03 17:33:36 UTC (rev 272320)
@@ -45,6 +45,7 @@
 #include "NamedNodeMap.h"
 #include "NetworkStorageSession.h"
 #include "PlatformMouseEvent.h"
+#include "RegistrableDomain.h"
 #include "ResourceLoadObserver.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGPathElement.h"
@@ -1304,4 +1305,18 @@
 #endif
 }
 
+bool Quirks::requiresUserGestureToPauseInPictureInPicture() const
+{
+    // Facebook will naively pause a <video> element that has scrolled out of the viewport, regardless of whether that element is currently in PiP mode.
+    if (!needsQuirks())
+        return false;
+
+    if (!m_requiresUserGestureToPauseInPictureInPicture) {
+        auto domain = RegistrableDomain(m_document->topDocument().url());
+        m_requiresUserGestureToPauseInPictureInPicture = domain.string() == "facebook.com"_s;
+    }
+
+    return *m_requiresUserGestureToPauseInPictureInPicture;
 }
+
+}

Modified: branches/safari-611-branch/Source/WebCore/page/Quirks.h (272319 => 272320)


--- branches/safari-611-branch/Source/WebCore/page/Quirks.h	2021-02-03 17:18:39 UTC (rev 272319)
+++ branches/safari-611-branch/Source/WebCore/page/Quirks.h	2021-02-03 17:33:36 UTC (rev 272320)
@@ -127,6 +127,8 @@
 
     WEBCORE_EXPORT bool blocksReturnToFullscreenFromPictureInPictureQuirk() const;
 
+    bool requiresUserGestureToPauseInPictureInPicture() const;
+
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     static bool isMicrosoftTeamsRedirectURL(const URL&);
     static bool hasStorageAccessForAllLoginDomains(const HashSet<RegistrableDomain>&, const RegistrableDomain&);
@@ -167,6 +169,7 @@
     mutable Optional<bool> m_needsVP9FullRangeFlagQuirk;
     mutable Optional<bool> m_needsHDRPixelDepthQuirk;
     mutable Optional<bool> m_needsBlackFullscreenBackgroundQuirk;
+    mutable Optional<bool> m_requiresUserGestureToPauseInPictureInPicture;
     mutable Optional<bool> m_shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk;
     mutable Optional<bool> m_blocksReturnToFullscreenFromPictureInPictureQuirk;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to