Title: [149142] trunk/Source/WebCore
- Revision
- 149142
- Author
- [email protected]
- Date
- 2013-04-25 14:02:20 -0700 (Thu, 25 Apr 2013)
Log Message
Media elements shouldn't resume playback when a page is restored from the back/forward cache if the WKView isn't in a window
https://bugs.webkit.org/show_bug.cgi?id=115191
Reviewed by Eric Carlson.
If a page is suspended, then resumed when its WebView or WKView has been removed from a window,
the page's media elements will unpause. Check whether media is allowed to start during resume()
via Page::canMediaStart() and if not, register for mediaCanStart notifications. Then, in
mediaCanStart() if the media is force-paused, unpause it.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::suspend):
(WebCore::HTMLMediaElement::resume):
(WebCore::HTMLMediaElement::mediaCanStart):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::pageConsentRequiredForResume):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (149141 => 149142)
--- trunk/Source/WebCore/ChangeLog 2013-04-25 21:01:13 UTC (rev 149141)
+++ trunk/Source/WebCore/ChangeLog 2013-04-25 21:02:20 UTC (rev 149142)
@@ -1,3 +1,22 @@
+2013-04-25 Jer Noble <[email protected]>
+
+ Media elements shouldn't resume playback when a page is restored from the back/forward cache if the WKView isn't in a window
+ https://bugs.webkit.org/show_bug.cgi?id=115191
+
+ Reviewed by Eric Carlson.
+
+ If a page is suspended, then resumed when its WebView or WKView has been removed from a window,
+ the page's media elements will unpause. Check whether media is allowed to start during resume()
+ via Page::canMediaStart() and if not, register for mediaCanStart notifications. Then, in
+ mediaCanStart() if the media is force-paused, unpause it.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::suspend):
+ (WebCore::HTMLMediaElement::resume):
+ (WebCore::HTMLMediaElement::mediaCanStart):
+ * html/HTMLMediaElement.h:
+ (WebCore::HTMLMediaElement::pageConsentRequiredForResume):
+
2013-04-25 Andreas Kling <[email protected]>
Remove ENABLE(PARSED_STYLE_SHEET_CACHING) and make it always-on.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (149141 => 149142)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-04-25 21:01:13 UTC (rev 149141)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-04-25 21:02:20 UTC (rev 149142)
@@ -4124,6 +4124,7 @@
{
case DocumentWillBecomeInactive:
stop();
+ addBehaviorRestriction(RequirePageConsentToResumeMediaRestriction);
break;
case PageWillBeSuspended:
case _javascript_DebuggerPaused:
@@ -4138,8 +4139,15 @@
LOG(Media, "HTMLMediaElement::resume");
m_inActiveDocument = true;
- setPausedInternal(false);
+ Page* page = document()->page();
+ if (pageConsentRequiredForResume() && page && !page->canStartMedia())
+ document()->addMediaCanStartListener(this);
+ else
+ setPausedInternal(false);
+
+ removeBehaviorRestriction(RequirePageConsentToResumeMediaRestriction);
+
if (m_error && m_error->code() == MediaError::MEDIA_ERR_ABORTED) {
// Restart the load if it was aborted in the middle by moving the document to the page cache.
// m_error is only left at MEDIA_ERR_ABORTED when the document becomes inactive (it is set to
@@ -4474,9 +4482,13 @@
{
LOG(Media, "HTMLMediaElement::mediaCanStart");
- ASSERT(m_isWaitingUntilMediaCanStart);
- m_isWaitingUntilMediaCanStart = false;
- loadInternal();
+ ASSERT(m_isWaitingUntilMediaCanStart || m_pausedInternal);
+ if (m_isWaitingUntilMediaCanStart) {
+ m_isWaitingUntilMediaCanStart = false;
+ loadInternal();
+ }
+ if (m_pausedInternal)
+ setPausedInternal(false);
}
bool HTMLMediaElement::isURLAttribute(const Attribute& attribute) const
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (149141 => 149142)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2013-04-25 21:01:13 UTC (rev 149141)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2013-04-25 21:02:20 UTC (rev 149142)
@@ -401,6 +401,7 @@
RequireUserGestureForRateChangeRestriction = 1 << 1,
RequireUserGestureForFullscreenRestriction = 1 << 2,
RequirePageConsentToLoadMediaRestriction = 1 << 3,
+ RequirePageConsentToResumeMediaRestriction = 1 << 4,
};
typedef unsigned BehaviorRestrictions;
@@ -408,6 +409,7 @@
bool userGestureRequiredForRateChange() const { return m_restrictions & RequireUserGestureForRateChangeRestriction; }
bool userGestureRequiredForFullscreen() const { return m_restrictions & RequireUserGestureForFullscreenRestriction; }
bool pageConsentRequiredForLoad() const { return m_restrictions & RequirePageConsentToLoadMediaRestriction; }
+ bool pageConsentRequiredForResume() const { return m_restrictions & RequirePageConsentToResumeMediaRestriction; }
void addBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions |= restriction; }
void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes