Title: [227373] trunk/Source/WebCore
Revision
227373
Author
ryanhad...@apple.com
Date
2018-01-22 17:29:39 -0800 (Mon, 22 Jan 2018)

Log Message

Resign NowPlaying status when no media element is eligible
https://bugs.webkit.org/show_bug.cgi?id=181914
<rdar://problem/35294116>

Patch by Eric Carlson <eric.carl...@apple.com> on 2018-01-22
Reviewed by Jer Noble.

No new tests, these changes prevent existing tests from crashing.

* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::playbackPermitted const): Return early when the media
element has been suspended.
(WebCore::MediaElementSession::canShowControlsManager const): Return false when the
media element has been suspended.
(WebCore::isMainContentForPurposesOfAutoplay): Return early if it isn't safe to update
style because HitTest can force a layout.
(WebCore::MediaElementSession::updateIsMainContent const): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (227372 => 227373)


--- trunk/Source/WebCore/ChangeLog	2018-01-23 01:25:36 UTC (rev 227372)
+++ trunk/Source/WebCore/ChangeLog	2018-01-23 01:29:39 UTC (rev 227373)
@@ -1,3 +1,23 @@
+2018-01-22  Eric Carlson  <eric.carl...@apple.com>
+
+        Resign NowPlaying status when no media element is eligible
+        https://bugs.webkit.org/show_bug.cgi?id=181914
+        <rdar://problem/35294116>
+
+        Reviewed by Jer Noble.
+
+        No new tests, these changes prevent existing tests from crashing.
+
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::playbackPermitted const): Return early when the media 
+        element has been suspended.
+        (WebCore::MediaElementSession::canShowControlsManager const): Return false when the
+        media element has been suspended.
+        (WebCore::isMainContentForPurposesOfAutoplay): Return early if it isn't safe to update
+        style because HitTest can force a layout.
+        (WebCore::MediaElementSession::updateIsMainContent const): Ditto.
+
 2018-01-22  Alex Christensen  <achristen...@webkit.org>
 
         Begin removing QTKit code

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (227372 => 227373)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2018-01-23 01:25:36 UTC (rev 227372)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2018-01-23 01:29:39 UTC (rev 227373)
@@ -551,6 +551,8 @@
 
     bool willLog(WTFLogLevel) const;
 
+    bool isSuspended() const final;
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
     virtual void finishInitialization();
@@ -864,7 +866,6 @@
     bool shouldOverrideBackgroundLoadingRestriction() const override;
     bool canProduceAudio() const final;
     bool processingUserGestureForMedia() const final;
-    bool isSuspended() const final;
 
     void pageMutedStateDidChange() override;
 

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (227372 => 227373)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2018-01-23 01:25:36 UTC (rev 227372)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2018-01-23 01:29:39 UTC (rev 227373)
@@ -162,6 +162,9 @@
 
 SuccessOr<MediaPlaybackDenialReason> MediaElementSession::playbackPermitted(const HTMLMediaElement& element) const
 {
+    if (m_element.isSuspended())
+        return { };
+
     if (element.document().isMediaDocument() && !element.document().ownerElement())
         return { };
 
@@ -295,6 +298,11 @@
 
 bool MediaElementSession::canShowControlsManager(PlaybackControlsPurpose purpose) const
 {
+    if (m_element.isSuspended()) {
+        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: isSuspended()");
+        return false;
+    }
+
     if (m_element.isFullscreen()) {
         LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is fullscreen");
         return true;
@@ -335,11 +343,6 @@
         return false;
     }
 
-    if (m_element.document().activeDOMObjectsAreSuspended()) {
-        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: activeDOMObjectsAreSuspended()");
-        return false;
-    }
-
     if (!playbackPermitted(m_element)) {
         LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Playback not permitted");
         return false;
@@ -379,11 +382,6 @@
     }
 
     if (purpose == PlaybackControlsPurpose::NowPlaying) {
-        if (!m_element.inActiveDocument()) {
-            LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Not in active document");
-            return false;
-        }
-
         LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Potentially plays audio");
         return true;
     }
@@ -696,7 +694,8 @@
 
 static bool isMainContentForPurposesOfAutoplay(const HTMLMediaElement& element)
 {
-    if (!element.hasAudio() || !element.hasVideo())
+    Document& document = element.document();
+    if (!document.isSafeToUpdateStyleOrLayout() || !element.hasAudio() || !element.hasVideo())
         return false;
 
     // Elements which have not yet been laid out, or which are not yet in the DOM, cannot be main content.
@@ -716,7 +715,6 @@
         return false;
 
     // Main content elements must be in the main frame.
-    Document& document = element.document();
     if (!document.frame() || !document.frame()->isMainFrame())
         return false;
 
@@ -823,6 +821,9 @@
 
 bool MediaElementSession::updateIsMainContent() const
 {
+    if (m_element.isSuspended())
+        return false;
+
     bool wasMainContent = m_isMainContent;
     m_isMainContent = isMainContentForPurposesOfAutoplay(m_element);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to