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

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.h

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 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 15 matching lines...) Expand all
26 26
27 #ifndef MediaControls_h 27 #ifndef MediaControls_h
28 #define MediaControls_h 28 #define MediaControls_h
29 29
30 #include "core/html/HTMLDivElement.h" 30 #include "core/html/HTMLDivElement.h"
31 #include "core/html/shadow/MediaControlElements.h" 31 #include "core/html/shadow/MediaControlElements.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 class Event; 35 class Event;
36 class MediaControlsMediaEventListener;
36 class MediaControlsWindowEventListener; 37 class MediaControlsWindowEventListener;
37 38
38 class CORE_EXPORT MediaControls final : public HTMLDivElement { 39 class CORE_EXPORT MediaControls final : public HTMLDivElement {
39 public: 40 public:
40 static MediaControls* create(HTMLMediaElement&); 41 static MediaControls* create(HTMLMediaElement&);
41 42
42 HTMLMediaElement& mediaElement() const { return *m_mediaElement; } 43 HTMLMediaElement& mediaElement() const { return *m_mediaElement; }
43 44
44 void reset(); 45 void reset();
45 46
46 void show(); 47 void show();
47 void hide(); 48 void hide();
48 bool isVisible() const; 49 bool isVisible() const;
49 50
50 void playbackStarted(); 51 void playbackStarted();
51 void playbackProgressed(); 52 void playbackProgressed();
52 void playbackStopped(); 53 void playbackStopped();
53 54
54 void beginScrubbing(); 55 void beginScrubbing();
55 void endScrubbing(); 56 void endScrubbing();
56 57
57 void updateCurrentTimeDisplay(); 58 void updateCurrentTimeDisplay();
58 59
59 void updateVolume();
60
61 void changedClosedCaptionsVisibility(); 60 void changedClosedCaptionsVisibility();
62 void refreshClosedCaptionsButtonVisibility(); 61 void refreshClosedCaptionsButtonVisibility();
63 void toggleTextTrackList(); 62 void toggleTextTrackList();
64 void showTextTrackAtIndex(unsigned indexToEnable); 63 void showTextTrackAtIndex(unsigned indexToEnable);
65 void disableShowingTextTracks(); 64 void disableShowingTextTracks();
66 65
67 void enteredFullscreen(); 66 void enteredFullscreen();
68 void exitedFullscreen(); 67 void exitedFullscreen();
69 68
70 void startedCasting(); 69 void startedCasting();
71 void stoppedCasting(); 70 void stoppedCasting();
72 void refreshCastButtonVisibility(); 71 void refreshCastButtonVisibility();
73 void showOverlayCastButtonIfNeeded(); 72 void showOverlayCastButtonIfNeeded();
74 // Update cast button visibility, but don't try to update our panel 73 // Update cast button visibility, but don't try to update our panel
75 // button visibility for space. 74 // button visibility for space.
76 void refreshCastButtonVisibilityWithoutUpdate(); 75 void refreshCastButtonVisibilityWithoutUpdate();
77 76
78 void setAllowHiddenVolumeControls(bool); 77 void setAllowHiddenVolumeControls(bool);
79 78
80 void mediaElementFocused();
81
82 // Returns the layout object for the part of the controls that should be 79 // Returns the layout object for the part of the controls that should be
83 // used for overlap checking during text track layout. May be null. 80 // used for overlap checking during text track layout. May be null.
84 LayoutObject* layoutObjectForTextTrackLayout(); 81 LayoutObject* layoutObjectForTextTrackLayout();
85 82
86 // Return the internal elements, which is used by registering clicking 83 // Return the internal elements, which is used by registering clicking
87 // EventHandlers from MediaControlsWindowEventListener. 84 // EventHandlers from MediaControlsWindowEventListener.
88 MediaControlPanelElement* panelElement() { return m_panel; } 85 MediaControlPanelElement* panelElement() { return m_panel; }
89 MediaControlTimelineElement* timelineElement() { return m_timeline; } 86 MediaControlTimelineElement* timelineElement() { return m_timeline; }
90 MediaControlCastButtonElement* castButtonElement() { return m_castButton; } 87 MediaControlCastButtonElement* castButtonElement() { return m_castButton; }
91 MediaControlVolumeSliderElement* volumeSliderElement() { 88 MediaControlVolumeSliderElement* volumeSliderElement() {
92 return m_volumeSlider; 89 return m_volumeSlider;
93 } 90 }
94 91
95 // Notify us that our controls enclosure has changed width. 92 // Notify us that our controls enclosure has changed width.
96 void notifyPanelWidthChanged(const LayoutUnit& newWidth); 93 void notifyPanelWidthChanged(const LayoutUnit& newWidth);
97 94
98 // Notify us that the media element's network state has changed. 95 // Notify us that the media element's network state has changed.
99 void networkStateChanged(); 96 void networkStateChanged();
100 97
101 void toggleOverflowMenu(); 98 void toggleOverflowMenu();
102 99
103 bool overflowMenuVisible(); 100 bool overflowMenuVisible();
104 101
105 DECLARE_VIRTUAL_TRACE(); 102 DECLARE_VIRTUAL_TRACE();
106 103
107 private: 104 private:
105 friend class MediaControlsMediaEventListener;
108 friend class MediaControlsTest; 106 friend class MediaControlsTest;
109 107
110 void invalidate(Element*); 108 void invalidate(Element*);
111 109
112 class BatchedControlUpdate; 110 class BatchedControlUpdate;
113 111
114 explicit MediaControls(HTMLMediaElement&); 112 explicit MediaControls(HTMLMediaElement&);
115 113
116 void initializeControls(); 114 void initializeControls();
117 115
(...skipping 23 matching lines...) Expand all
141 // Hide elements that don't fit, and show those things that we want which 139 // Hide elements that don't fit, and show those things that we want which
142 // do fit. This requires that m_panelWidth is current. 140 // do fit. This requires that m_panelWidth is current.
143 void computeWhichControlsFit(); 141 void computeWhichControlsFit();
144 142
145 // Node 143 // Node
146 bool isMediaControls() const override { return true; } 144 bool isMediaControls() const override { return true; }
147 bool willRespondToMouseMoveEvents() override { return true; } 145 bool willRespondToMouseMoveEvents() override { return true; }
148 void defaultEventHandler(Event*) override; 146 void defaultEventHandler(Event*) override;
149 bool containsRelatedTarget(Event*); 147 bool containsRelatedTarget(Event*);
150 148
149 // Methods called by MediaControlsMediaEventListener.
150 void onVolumeChange();
151 void onFocusIn();
152
151 Member<HTMLMediaElement> m_mediaElement; 153 Member<HTMLMediaElement> m_mediaElement;
152 154
153 // Media control elements. 155 // Media control elements.
154 Member<MediaControlOverlayEnclosureElement> m_overlayEnclosure; 156 Member<MediaControlOverlayEnclosureElement> m_overlayEnclosure;
155 Member<MediaControlOverlayPlayButtonElement> m_overlayPlayButton; 157 Member<MediaControlOverlayPlayButtonElement> m_overlayPlayButton;
156 Member<MediaControlCastButtonElement> m_overlayCastButton; 158 Member<MediaControlCastButtonElement> m_overlayCastButton;
157 Member<MediaControlPanelEnclosureElement> m_enclosure; 159 Member<MediaControlPanelEnclosureElement> m_enclosure;
158 Member<MediaControlPanelElement> m_panel; 160 Member<MediaControlPanelElement> m_panel;
159 Member<MediaControlPlayButtonElement> m_playButton; 161 Member<MediaControlPlayButtonElement> m_playButton;
160 Member<MediaControlTimelineElement> m_timeline; 162 Member<MediaControlTimelineElement> m_timeline;
161 Member<MediaControlCurrentTimeDisplayElement> m_currentTimeDisplay; 163 Member<MediaControlCurrentTimeDisplayElement> m_currentTimeDisplay;
162 Member<MediaControlTimeRemainingDisplayElement> m_durationDisplay; 164 Member<MediaControlTimeRemainingDisplayElement> m_durationDisplay;
163 Member<MediaControlMuteButtonElement> m_muteButton; 165 Member<MediaControlMuteButtonElement> m_muteButton;
164 Member<MediaControlVolumeSliderElement> m_volumeSlider; 166 Member<MediaControlVolumeSliderElement> m_volumeSlider;
165 Member<MediaControlToggleClosedCaptionsButtonElement> 167 Member<MediaControlToggleClosedCaptionsButtonElement>
166 m_toggleClosedCaptionsButton; 168 m_toggleClosedCaptionsButton;
167 Member<MediaControlTextTrackListElement> m_textTrackList; 169 Member<MediaControlTextTrackListElement> m_textTrackList;
168 Member<MediaControlOverflowMenuButtonElement> m_overflowMenu; 170 Member<MediaControlOverflowMenuButtonElement> m_overflowMenu;
169 Member<MediaControlOverflowMenuListElement> m_overflowList; 171 Member<MediaControlOverflowMenuListElement> m_overflowList;
170 172
171 Member<MediaControlCastButtonElement> m_castButton; 173 Member<MediaControlCastButtonElement> m_castButton;
172 Member<MediaControlFullscreenButtonElement> m_fullscreenButton; 174 Member<MediaControlFullscreenButtonElement> m_fullscreenButton;
173 Member<MediaControlDownloadButtonElement> m_downloadButton; 175 Member<MediaControlDownloadButtonElement> m_downloadButton;
174 176
177 Member<MediaControlsMediaEventListener> m_mediaEventListener;
175 Member<MediaControlsWindowEventListener> m_windowEventListener; 178 Member<MediaControlsWindowEventListener> m_windowEventListener;
176 179
177 Timer<MediaControls> m_hideMediaControlsTimer; 180 Timer<MediaControls> m_hideMediaControlsTimer;
178 unsigned m_hideTimerBehaviorFlags; 181 unsigned m_hideTimerBehaviorFlags;
179 bool m_isMouseOverControls : 1; 182 bool m_isMouseOverControls : 1;
180 bool m_isPausedForScrubbing : 1; 183 bool m_isPausedForScrubbing : 1;
181 184
182 Timer<MediaControls> m_panelWidthChangedTimer; 185 Timer<MediaControls> m_panelWidthChangedTimer;
183 int m_panelWidth; 186 int m_panelWidth;
184 187
185 bool m_keepShowingUntilTimerFires : 1; 188 bool m_keepShowingUntilTimerFires : 1;
186 }; 189 };
187 190
188 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); 191 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls());
189 192
190 } // namespace blink 193 } // namespace blink
191 194
192 #endif 195 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698