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

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

Issue 2477203002: Media Controls: delegate 'volumechange' and 'focusin' handling to an EventListener. (Closed)
Patch Set: add comment Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..c607fce4e0be6578d1af1dad39884f906e9f7617
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.cpp
@@ -0,0 +1,48 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/shadow/MediaControlsMediaEventListener.h"
+
+#include "core/events/Event.h"
+#include "core/html/HTMLMediaElement.h"
+#include "core/html/shadow/MediaControls.h"
+
+namespace blink {
+
+MediaControlsMediaEventListener::MediaControlsMediaEventListener(
+ MediaControls* mediaControls)
+ : EventListener(CPPEventListenerType), m_mediaControls(mediaControls) {
+ m_mediaControls->m_mediaElement->addEventListener(
+ EventTypeNames::volumechange, this, false);
+ m_mediaControls->m_mediaElement->addEventListener(EventTypeNames::focusin,
+ this, false);
+}
+
+bool MediaControlsMediaEventListener::operator==(
+ const EventListener& other) const {
+ return this == &other;
+}
+
+void MediaControlsMediaEventListener::handleEvent(
+ ExecutionContext* executionContext,
+ Event* event) {
+ if (event->type() == EventTypeNames::volumechange) {
+ m_mediaControls->onVolumeChange();
+ return;
+ }
+
+ if (event->type() == EventTypeNames::focusin) {
+ m_mediaControls->onFocusIn();
+ return;
+ }
+
+ NOTREACHED();
+}
+
+DEFINE_TRACE(MediaControlsMediaEventListener) {
+ EventListener::trace(visitor);
+ visitor->trace(m_mediaControls);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControlsMediaEventListener.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698