Title: [165862] trunk/Source/WebCore
- Revision
- 165862
- Author
- [email protected]
- Date
- 2014-03-18 18:48:54 -0700 (Tue, 18 Mar 2014)
Log Message
Unify <media> element callback registration and unregistration
https://bugs.webkit.org/show_bug.cgi?id=130417
Reviewed by Eric Carlson.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::registerWithDocument):
(WebCore::HTMLMediaElement::unregisterWithDocument):
(WebCore::HTMLMediaElement::didMoveToNewDocument):
* html/HTMLMediaElement.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (165861 => 165862)
--- trunk/Source/WebCore/ChangeLog 2014-03-19 01:38:16 UTC (rev 165861)
+++ trunk/Source/WebCore/ChangeLog 2014-03-19 01:48:54 UTC (rev 165862)
@@ -1,3 +1,18 @@
+2014-03-18 Jeffrey Pfau <[email protected]>
+
+ Unify <media> element callback registration and unregistration
+ https://bugs.webkit.org/show_bug.cgi?id=130417
+
+ Reviewed by Eric Carlson.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement):
+ (WebCore::HTMLMediaElement::~HTMLMediaElement):
+ (WebCore::HTMLMediaElement::registerWithDocument):
+ (WebCore::HTMLMediaElement::unregisterWithDocument):
+ (WebCore::HTMLMediaElement::didMoveToNewDocument):
+ * html/HTMLMediaElement.h:
+
2014-03-18 Jer Noble <[email protected]>
MediaDocument should set a max-width on its <video> element.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (165861 => 165862)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2014-03-19 01:38:16 UTC (rev 165861)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2014-03-19 01:48:54 UTC (rev 165862)
@@ -361,13 +361,6 @@
// FIXME: We should clean up and look to better merge the iOS and non-iOS code below.
Settings* settings = document.settings();
#if !PLATFORM(IOS)
- document.registerForMediaVolumeCallbacks(this);
- document.registerForPrivateBrowsingStateChangedCallbacks(this);
-
-#if ENABLE(PAGE_VISIBILITY_API)
- document.registerForVisibilityStateChangedCallbacks(this);
-#endif
-
if (settings && settings->mediaPlaybackRequiresUserGesture()) {
m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);
@@ -382,13 +375,12 @@
}
#endif // !PLATFORM(IOS)
- addElementToDocumentMap(*this, document);
-
#if ENABLE(VIDEO_TRACK)
- document.registerForCaptionPreferencesChangedCallbacks(this);
if (document.page())
m_captionDisplayMode = document.page()->group().captionPreferences()->captionDisplayMode();
#endif
+
+ registerWithDocument(document);
}
HTMLMediaElement::~HTMLMediaElement()
@@ -397,18 +389,10 @@
m_asyncEventQueue.close();
- if (m_isWaitingUntilMediaCanStart)
- document().removeMediaCanStartListener(this);
setShouldDelayLoadEvent(false);
- document().unregisterForMediaVolumeCallbacks(this);
- document().unregisterForPrivateBrowsingStateChangedCallbacks(this);
+ unregisterWithDocument(document());
-#if ENABLE(PAGE_VISIBILITY_API)
- document().unregisterForVisibilityStateChangedCallbacks(this);
-#endif
-
#if ENABLE(VIDEO_TRACK)
- document().unregisterForCaptionPreferencesChangedCallbacks(this);
if (m_audioTracks) {
m_audioTracks->clearElement();
for (unsigned i = 0; i < m_audioTracks->length(); ++i)
@@ -445,21 +429,53 @@
setMediaKeys(0);
#endif
- removeElementFromDocumentMap(*this, document());
-
m_completelyLoaded = true;
if (m_player)
m_player->clearMediaPlayerClient();
}
+void HTMLMediaElement::registerWithDocument(Document& document)
+{
+ if (m_isWaitingUntilMediaCanStart)
+ document.addMediaCanStartListener(this);
+
+#if !PLATFORM(IOS)
+ document.registerForMediaVolumeCallbacks(this);
+ document.registerForPrivateBrowsingStateChangedCallbacks(this);
+#if ENABLE(PAGE_VISIBILITY_API)
+ document.registerForVisibilityStateChangedCallbacks(this);
+#endif
+#endif
+
+#if ENABLE(VIDEO_TRACK)
+ document.registerForCaptionPreferencesChangedCallbacks(this);
+#endif
+
+ addElementToDocumentMap(*this, document);
+}
+
+void HTMLMediaElement::unregisterWithDocument(Document& document)
+{
+ if (m_isWaitingUntilMediaCanStart)
+ document.removeMediaCanStartListener(this);
+
+#if !PLATFORM(IOS)
+ document.unregisterForMediaVolumeCallbacks(this);
+ document.unregisterForPrivateBrowsingStateChangedCallbacks(this);
+#if ENABLE(PAGE_VISIBILITY_API)
+ document.unregisterForVisibilityStateChangedCallbacks(this);
+#endif
+#endif
+
+#if ENABLE(VIDEO_TRACK)
+ document.unregisterForCaptionPreferencesChangedCallbacks(this);
+#endif
+
+ removeElementFromDocumentMap(*this, document);
+}
+
void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
{
- if (m_isWaitingUntilMediaCanStart) {
- if (oldDocument)
- oldDocument->removeMediaCanStartListener(this);
- document().addMediaCanStartListener(this);
- }
-
if (m_shouldDelayLoadEvent) {
if (oldDocument)
oldDocument->decrementLoadEventDelayCount();
@@ -467,20 +483,11 @@
}
if (oldDocument) {
-#if ENABLE(PAGE_VISIBILITY_API)
- oldDocument->unregisterForVisibilityStateChangedCallbacks(this);
-#endif
- oldDocument->unregisterForMediaVolumeCallbacks(this);
- removeElementFromDocumentMap(*this, *oldDocument);
+ unregisterWithDocument(*oldDocument);
}
-#if ENABLE(PAGE_VISIBILITY_API)
- document().registerForVisibilityStateChangedCallbacks(this);
-#endif
+ registerWithDocument(document());
- document().registerForMediaVolumeCallbacks(this);
- addElementToDocumentMap(*this, document());
-
HTMLElement::didMoveToNewDocument(oldDocument);
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (165861 => 165862)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2014-03-19 01:38:16 UTC (rev 165861)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2014-03-19 01:48:54 UTC (rev 165862)
@@ -707,6 +707,9 @@
virtual bool canReceiveRemoteControlCommands() const override { return true; }
virtual void didReceiveRemoteControlCommand(MediaSession::RemoteControlCommandType) override;
+ void registerWithDocument(Document&);
+ void unregisterWithDocument(Document&);
+
Timer<HTMLMediaElement> m_loadTimer;
Timer<HTMLMediaElement> m_progressEventTimer;
Timer<HTMLMediaElement> m_playbackProgressTimer;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes