[Mac] Playback target clients do not unregister on page reload
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 May 2015 18:45:40 +0000 (18:45 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 May 2015 18:45:40 +0000 (18:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144761

Reviewed by Brady Eidson.

* dom/Document.cpp:
(WebCore::Document::prepareForDestruction): Unregister all target picker clients.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::registerWithDocument): Register for page cache callback.
(WebCore::HTMLMediaElement::unregisterWithDocument): Unregister for page cache callback.
(WebCore::HTMLMediaElement::documentWillSuspendForPageCache): New.
(WebCore::HTMLMediaElement::documentDidResumeFromPageCache): New.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184001 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h

index 9e68ab79c655a115e3b0d31c6e0203aa3523c369..ab2d844b249250ba657cc173399ccc25f1f913a9 100644 (file)
@@ -1,3 +1,19 @@
+2015-05-08  Eric Carlson  <eric.carlson@apple.com>
+
+        [Mac] Playback target clients do not unregister on page reload
+        https://bugs.webkit.org/show_bug.cgi?id=144761
+
+        Reviewed by Brady Eidson.
+
+        * dom/Document.cpp:
+        (WebCore::Document::prepareForDestruction): Unregister all target picker clients.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::registerWithDocument): Register for page cache callback.
+        (WebCore::HTMLMediaElement::unregisterWithDocument): Unregister for page cache callback.
+        (WebCore::HTMLMediaElement::documentWillSuspendForPageCache): New.
+        (WebCore::HTMLMediaElement::documentDidResumeFromPageCache): New.
+
 2015-05-08  Chris Dumez  <cdumez@apple.com>
 
         Throttle RequestAnimationFrame in subframes that are outside the viewport
index 6d3e1a8b60053b9c3785da0f1c5ac722be0cc4ed..26bb0cef1517a7d554fd998d18667a720eeb4185 100644 (file)
@@ -2252,6 +2252,15 @@ void Document::prepareForDestruction()
     if (m_mediaQueryMatcher)
         m_mediaQueryMatcher->documentDestroyed();
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    if (!m_clientToIDMap.isEmpty() && page()) {
+        Vector<WebCore::MediaPlaybackTargetClient*> clients;
+        copyKeysToVector(m_clientToIDMap, clients);
+        for (auto client : clients)
+            removePlaybackTargetPickerClient(*client);
+    }
+#endif
+
     disconnectFromFrame();
 
     m_hasPreparedForDestruction = true;
index 4e4e6765e9ba2e4ef4e5af52fc80d55b60c07bfe..99419a508a46a6c4448af926423426b414add734 100644 (file)
@@ -460,6 +460,10 @@ void HTMLMediaElement::registerWithDocument(Document& document)
         document.registerForPageScaleFactorChangedCallbacks(this);
 #endif
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    document.registerForPageCacheSuspensionCallbacks(this);
+#endif
+
     document.addAudioProducer(this);
     addElementToDocumentMap(*this, document);
 }
@@ -488,6 +492,10 @@ void HTMLMediaElement::unregisterWithDocument(Document& document)
         document.unregisterForPageScaleFactorChangedCallbacks(this);
 #endif
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    document.unregisterForPageCacheSuspensionCallbacks(this);
+#endif
+
     document.removeAudioProducer(this);
     removeElementFromDocumentMap(*this, document);
 }
@@ -509,6 +517,18 @@ void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
     HTMLElement::didMoveToNewDocument(oldDocument);
 }
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+void HTMLMediaElement::documentWillSuspendForPageCache()
+{
+    m_mediaSession->unregisterWithDocument(*this);
+}
+
+void HTMLMediaElement::documentDidResumeFromPageCache()
+{
+    m_mediaSession->registerWithDocument(*this);
+}
+#endif
+
 bool HTMLMediaElement::hasCustomFocusLogic() const
 {
     return true;
index eed426424796be555c4bf0efeb5ceaf7bb1c4e74..ff9944ced01ac2d32d63634aa150740919ac2fe6 100644 (file)
@@ -737,6 +737,11 @@ private:
 
     void updateCaptionContainer();
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    virtual void documentWillSuspendForPageCache() override final;
+    virtual void documentDidResumeFromPageCache() override final;
+#endif
+
     Timer m_pendingActionTimer;
     Timer m_progressEventTimer;
     Timer m_playbackProgressTimer;