Chromium Code Reviews| 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( |
|
foolip
2016/11/08 10:28:29
Can you test what happens with this code?
<video>
mlamouri (slow - plz ping)
2016/11/11 05:29:17
Added. Looks okay.
foolip
2016/11/11 09:50:20
Surprising. Do you know why it works, are internal
mlamouri (slow - plz ping)
2016/11/11 19:13:27
Hmm, I think it's because we eagerly create the co
|
| + 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 |