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

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.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/MediaControlsMediaEventListener.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.cpp
index 76d680d18cee696b52edf93407031d4a34e33727..070f17b32971c62841984ede8a0b15d1d8086e8d 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.cpp
@@ -14,18 +14,13 @@ namespace blink {
MediaControlsMediaEventListener::MediaControlsMediaEventListener(
MediaControls* mediaControls)
: EventListener(CPPEventListenerType), m_mediaControls(mediaControls) {
- // These events are always active because they are needed in order to attach
- // or detach the whole controls.
- mediaElement().addEventListener(EventTypeNames::DOMNodeInsertedIntoDocument,
- this, false);
- mediaElement().addEventListener(EventTypeNames::DOMNodeRemovedFromDocument,
- this, false);
-
if (mediaElement().isConnected())
attach();
}
void MediaControlsMediaEventListener::attach() {
+ DCHECK(mediaElement().isConnected());
+
mediaElement().addEventListener(EventTypeNames::volumechange, this, false);
mediaElement().addEventListener(EventTypeNames::focusin, this, false);
mediaElement().addEventListener(EventTypeNames::timeupdate, this, false);
@@ -50,6 +45,8 @@ void MediaControlsMediaEventListener::attach() {
}
void MediaControlsMediaEventListener::detach() {
+ DCHECK(!mediaElement().isConnected());
+
m_mediaControls->document().removeEventListener(
EventTypeNames::fullscreenchange, this, false);
@@ -71,14 +68,6 @@ HTMLMediaElement& MediaControlsMediaEventListener::mediaElement() {
void MediaControlsMediaEventListener::handleEvent(
ExecutionContext* executionContext,
Event* event) {
- if (event->type() == EventTypeNames::DOMNodeInsertedIntoDocument) {
- m_mediaControls->onInsertedIntoDocument();
- return;
- }
- if (event->type() == EventTypeNames::DOMNodeRemovedFromDocument) {
- m_mediaControls->onRemovedFromDocument();
- return;
- }
if (event->type() == EventTypeNames::volumechange) {
m_mediaControls->onVolumeChange();
return;

Powered by Google App Engine
This is Rietveld 408576698