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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #include "core/html/shadow/MediaControls.h" 27 #include "core/html/shadow/MediaControls.h"
28 28
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
30 #include "core/dom/ClientRect.h" 30 #include "core/dom/ClientRect.h"
31 #include "core/dom/Fullscreen.h" 31 #include "core/dom/Fullscreen.h"
32 #include "core/events/MouseEvent.h" 32 #include "core/events/MouseEvent.h"
33 #include "core/frame/Settings.h" 33 #include "core/frame/Settings.h"
34 #include "core/html/HTMLMediaElement.h" 34 #include "core/html/HTMLMediaElement.h"
35 #include "core/html/shadow/MediaControlsWindowEventListener.h"
35 #include "core/html/track/TextTrackContainer.h" 36 #include "core/html/track/TextTrackContainer.h"
36 #include "core/layout/LayoutObject.h" 37 #include "core/layout/LayoutObject.h"
37 #include "core/layout/LayoutTheme.h" 38 #include "core/layout/LayoutTheme.h"
38 #include "platform/EventDispatchForbiddenScope.h" 39 #include "platform/EventDispatchForbiddenScope.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 // If you change this value, then also update the corresponding value in 43 // If you change this value, then also update the corresponding value in
43 // LayoutTests/media/media-controls.js. 44 // LayoutTests/media/media-controls.js.
44 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; 45 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 m_currentTimeDisplay(nullptr), 114 m_currentTimeDisplay(nullptr),
114 m_durationDisplay(nullptr), 115 m_durationDisplay(nullptr),
115 m_muteButton(nullptr), 116 m_muteButton(nullptr),
116 m_volumeSlider(nullptr), 117 m_volumeSlider(nullptr),
117 m_toggleClosedCaptionsButton(nullptr), 118 m_toggleClosedCaptionsButton(nullptr),
118 m_textTrackList(nullptr), 119 m_textTrackList(nullptr),
119 m_overflowList(nullptr), 120 m_overflowList(nullptr),
120 m_castButton(nullptr), 121 m_castButton(nullptr),
121 m_fullscreenButton(nullptr), 122 m_fullscreenButton(nullptr),
122 m_downloadButton(nullptr), 123 m_downloadButton(nullptr),
124 m_windowEventListener(MediaControlsWindowEventListener::create(
125 this,
126 WTF::bind(&MediaControls::hideAllMenus, wrapWeakPersistent(this)))),
123 m_hideMediaControlsTimer(this, 127 m_hideMediaControlsTimer(this,
124 &MediaControls::hideMediaControlsTimerFired), 128 &MediaControls::hideMediaControlsTimerFired),
125 m_hideTimerBehaviorFlags(IgnoreNone), 129 m_hideTimerBehaviorFlags(IgnoreNone),
126 m_isMouseOverControls(false), 130 m_isMouseOverControls(false),
127 m_isPausedForScrubbing(false), 131 m_isPausedForScrubbing(false),
128 m_panelWidthChangedTimer(this, 132 m_panelWidthChangedTimer(this,
129 &MediaControls::panelWidthChangedTimerFired), 133 &MediaControls::panelWidthChangedTimerFired),
130 m_panelWidth(0), 134 m_panelWidth(0),
131 m_allowHiddenVolumeControls( 135 m_allowHiddenVolumeControls(
132 RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) {} 136 RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) {}
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 m_toggleClosedCaptionsButton->setIsWanted(mediaElement().hasClosedCaptions()); 516 m_toggleClosedCaptionsButton->setIsWanted(mediaElement().hasClosedCaptions());
513 BatchedControlUpdate batch(this); 517 BatchedControlUpdate batch(this);
514 } 518 }
515 519
516 void MediaControls::toggleTextTrackList() { 520 void MediaControls::toggleTextTrackList() {
517 if (!mediaElement().hasClosedCaptions()) { 521 if (!mediaElement().hasClosedCaptions()) {
518 m_textTrackList->setVisible(false); 522 m_textTrackList->setVisible(false);
519 return; 523 return;
520 } 524 }
521 525
526 if (!m_textTrackList->isWanted())
527 m_windowEventListener->start();
528
522 m_textTrackList->setVisible(!m_textTrackList->isWanted()); 529 m_textTrackList->setVisible(!m_textTrackList->isWanted());
523 } 530 }
524 531
525 void MediaControls::refreshCastButtonVisibility() { 532 void MediaControls::refreshCastButtonVisibility() {
526 refreshCastButtonVisibilityWithoutUpdate(); 533 refreshCastButtonVisibilityWithoutUpdate();
527 BatchedControlUpdate batch(this); 534 BatchedControlUpdate batch(this);
528 } 535 }
529 536
530 void MediaControls::refreshCastButtonVisibilityWithoutUpdate() { 537 void MediaControls::refreshCastButtonVisibilityWithoutUpdate() {
531 if (!shouldShowCastButton(mediaElement())) { 538 if (!shouldShowCastButton(mediaElement())) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 invalidate(m_timeline); 864 invalidate(m_timeline);
858 invalidate(m_volumeSlider); 865 invalidate(m_volumeSlider);
859 } 866 }
860 867
861 bool MediaControls::overflowMenuVisible() { 868 bool MediaControls::overflowMenuVisible() {
862 return m_overflowList ? m_overflowList->isWanted() : false; 869 return m_overflowList ? m_overflowList->isWanted() : false;
863 } 870 }
864 871
865 void MediaControls::toggleOverflowMenu() { 872 void MediaControls::toggleOverflowMenu() {
866 DCHECK(m_overflowList); 873 DCHECK(m_overflowList);
874
875 if (!m_overflowList->isWanted())
876 m_windowEventListener->start();
867 m_overflowList->setIsWanted(!m_overflowList->isWanted()); 877 m_overflowList->setIsWanted(!m_overflowList->isWanted());
868 } 878 }
869 879
880 void MediaControls::hideAllMenus() {
881 m_windowEventListener->stop();
882
883 if (m_overflowList->isWanted())
884 m_overflowList->setIsWanted(false);
885 if (m_textTrackList->isWanted())
886 m_textTrackList->setVisible(false);
887 }
888
870 DEFINE_TRACE(MediaControls) { 889 DEFINE_TRACE(MediaControls) {
871 visitor->trace(m_mediaElement); 890 visitor->trace(m_mediaElement);
872 visitor->trace(m_panel); 891 visitor->trace(m_panel);
873 visitor->trace(m_overlayPlayButton); 892 visitor->trace(m_overlayPlayButton);
874 visitor->trace(m_overlayEnclosure); 893 visitor->trace(m_overlayEnclosure);
875 visitor->trace(m_playButton); 894 visitor->trace(m_playButton);
876 visitor->trace(m_currentTimeDisplay); 895 visitor->trace(m_currentTimeDisplay);
877 visitor->trace(m_timeline); 896 visitor->trace(m_timeline);
878 visitor->trace(m_muteButton); 897 visitor->trace(m_muteButton);
879 visitor->trace(m_volumeSlider); 898 visitor->trace(m_volumeSlider);
880 visitor->trace(m_toggleClosedCaptionsButton); 899 visitor->trace(m_toggleClosedCaptionsButton);
881 visitor->trace(m_fullscreenButton); 900 visitor->trace(m_fullscreenButton);
882 visitor->trace(m_downloadButton); 901 visitor->trace(m_downloadButton);
883 visitor->trace(m_durationDisplay); 902 visitor->trace(m_durationDisplay);
884 visitor->trace(m_enclosure); 903 visitor->trace(m_enclosure);
885 visitor->trace(m_textTrackList); 904 visitor->trace(m_textTrackList);
886 visitor->trace(m_overflowMenu); 905 visitor->trace(m_overflowMenu);
887 visitor->trace(m_overflowList); 906 visitor->trace(m_overflowList);
888 visitor->trace(m_castButton); 907 visitor->trace(m_castButton);
889 visitor->trace(m_overlayCastButton); 908 visitor->trace(m_overlayCastButton);
909 visitor->trace(m_windowEventListener);
890 HTMLDivElement::trace(visitor); 910 HTMLDivElement::trace(visitor);
891 } 911 }
892 912
893 } // namespace blink 913 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698