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

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

Issue 2382233002: Hide overflow menu/closed caption list when clicking outside the list (Closed)
Patch Set: applied Mounir's comments Created 4 years, 2 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 de2ce349106fa3307492ef92fc62cff6d58085d6..51c0e572f25e1bdf880a655a495e5ef0a7ef698b 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
@@ -32,6 +32,7 @@
#include "core/events/MouseEvent.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLMediaElement.h"
+#include "core/html/shadow/MediaControlsWindowEventListener.h"
#include "core/html/track/TextTrackContainer.h"
#include "core/layout/LayoutObject.h"
#include "core/layout/LayoutTheme.h"
@@ -120,6 +121,9 @@ MediaControls::MediaControls(HTMLMediaElement& mediaElement)
m_castButton(nullptr),
m_fullscreenButton(nullptr),
m_downloadButton(nullptr),
+ m_windowEventListener(MediaControlsWindowEventListener::create(
+ this,
+ WTF::bind(&MediaControls::hideAllMenus, wrapWeakPersistent(this)))),
m_hideMediaControlsTimer(this,
&MediaControls::hideMediaControlsTimerFired),
m_hideTimerBehaviorFlags(IgnoreNone),
@@ -519,6 +523,9 @@ void MediaControls::toggleTextTrackList() {
return;
}
+ if (!m_textTrackList->isWanted())
+ m_windowEventListener->start();
+
m_textTrackList->setVisible(!m_textTrackList->isWanted());
}
@@ -864,9 +871,21 @@ bool MediaControls::overflowMenuVisible() {
void MediaControls::toggleOverflowMenu() {
DCHECK(m_overflowList);
+
+ if (!m_overflowList->isWanted())
+ m_windowEventListener->start();
m_overflowList->setIsWanted(!m_overflowList->isWanted());
}
+void MediaControls::hideAllMenus() {
+ m_windowEventListener->stop();
+
+ if (m_overflowList->isWanted())
+ m_overflowList->setIsWanted(false);
+ if (m_textTrackList->isWanted())
+ m_textTrackList->setVisible(false);
+}
+
DEFINE_TRACE(MediaControls) {
visitor->trace(m_mediaElement);
visitor->trace(m_panel);
@@ -887,6 +906,7 @@ DEFINE_TRACE(MediaControls) {
visitor->trace(m_overflowList);
visitor->trace(m_castButton);
visitor->trace(m_overlayCastButton);
+ visitor->trace(m_windowEventListener);
HTMLDivElement::trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698