Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp

Issue 2724983006: Media Controls: do not use events but C++ callbacks for insertion/removal from document. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
index 087b1013c313014963936a4221c8eedf8a6e6212..21e0cc0e175e852aab831c3fe2fec1a4fa3981ee 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
@@ -338,6 +338,35 @@ void MediaControls::initializeControls() {
*this, MediaControlToggleClosedCaptionsButtonElement::create(*this)));
}
+Node::InsertionNotificationRequest MediaControls::insertedInto(
+ ContainerNode* root) {
+ if (!mediaElement().isConnected())
+ return HTMLDivElement::insertedInto(root);
+
+ // TODO(mlamouri): we should show the controls instead of having
+ // HTMLMediaElement do it.
+
+ // m_windowEventListener doesn't need to be re-attached as it's only needed
+ // when a menu is visible.
+ m_mediaEventListener->attach();
+ if (m_orientationLockDelegate)
+ m_orientationLockDelegate->attach();
+
+ return HTMLDivElement::insertedInto(root);
+}
+
+void MediaControls::removedFrom(ContainerNode*) {
+ DCHECK(!mediaElement().isConnected());
+
+ // TODO(mlamouri): we hide show the controls instead of having
+ // HTMLMediaElement do it.
+
+ m_windowEventListener->stop();
+ m_mediaEventListener->detach();
+ if (m_orientationLockDelegate)
+ m_orientationLockDelegate->detach();
+}
+
void MediaControls::reset() {
EventDispatchForbiddenScope::AllowUserAgentEvents allowEventsInShadow;
BatchedControlUpdate batch(this);
@@ -688,27 +717,6 @@ bool MediaControls::containsRelatedTarget(Event* event) {
return contains(relatedTarget->toNode());
}
-void MediaControls::onInsertedIntoDocument() {
- // TODO(mlamouri): we should show the controls instead of having
- // HTMLMediaElement do it.
-
- // m_windowEventListener doesn't need to be re-attached as it's only needed
- // when a menu is visible.
- m_mediaEventListener->attach();
- if (m_orientationLockDelegate)
- m_orientationLockDelegate->attach();
-}
-
-void MediaControls::onRemovedFromDocument() {
- // TODO(mlamouri): we hide show the controls instead of having
- // HTMLMediaElement do it.
-
- m_windowEventListener->stop();
- m_mediaEventListener->detach();
- if (m_orientationLockDelegate)
- m_orientationLockDelegate->detach();
-}
-
void MediaControls::onVolumeChange() {
m_muteButton->updateDisplayType();
m_volumeSlider->setVolume(mediaElement().muted() ? 0

Powered by Google App Engine
This is Rietveld 408576698