OLD | NEW |
---|---|
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 void changedClosedCaptionsVisibility(); | 60 void changedClosedCaptionsVisibility(); |
61 void refreshClosedCaptionsButtonVisibility(); | 61 void refreshClosedCaptionsButtonVisibility(); |
62 | 62 |
63 void enteredFullscreen(); | 63 void enteredFullscreen(); |
64 void exitedFullscreen(); | 64 void exitedFullscreen(); |
65 | 65 |
66 void startedCasting(); | 66 void startedCasting(); |
67 void stoppedCasting(); | 67 void stoppedCasting(); |
68 void refreshCastButtonVisibility(); | 68 void refreshCastButtonVisibility(); |
69 void showOverlayCastButton(); | 69 void showOverlayCastButton(); |
70 // Update cast button visibility, but don't try to update our panel | |
71 // button visibility for space. | |
72 void refreshCastButtonVisibilityWithoutUpdate(); | |
73 | |
74 void setAllowHiddenVolumeControls(bool); | |
70 | 75 |
71 void mediaElementFocused(); | 76 void mediaElementFocused(); |
72 | 77 |
73 // Returns the layout object for the part of the controls that should be | 78 // Returns the layout object for the part of the controls that should be |
74 // used for overlap checking during text track layout. May be null. | 79 // used for overlap checking during text track layout. May be null. |
75 LayoutObject* layoutObjectForTextTrackLayout(); | 80 LayoutObject* layoutObjectForTextTrackLayout(); |
76 | 81 |
82 // Notify us that our controls enclosure has changed width. | |
83 void notifyPanelWidthChanged(const LayoutUnit& newWidth); | |
84 | |
77 DECLARE_VIRTUAL_TRACE(); | 85 DECLARE_VIRTUAL_TRACE(); |
78 | 86 |
79 private: | 87 private: |
88 class BatchedControlUpdate; | |
89 | |
80 explicit MediaControls(HTMLMediaElement&); | 90 explicit MediaControls(HTMLMediaElement&); |
81 | 91 |
82 void initializeControls(); | 92 void initializeControls(); |
83 | 93 |
84 void makeOpaque(); | 94 void makeOpaque(); |
85 void makeTransparent(); | 95 void makeTransparent(); |
86 | 96 |
87 void updatePlayState(); | 97 void updatePlayState(); |
88 | 98 |
89 enum HideBehaviorFlags { | 99 enum HideBehaviorFlags { |
90 IgnoreNone = 0, | 100 IgnoreNone = 0, |
91 IgnoreVideoHover = 1 << 0, | 101 IgnoreVideoHover = 1 << 0, |
92 IgnoreFocus = 1 << 1, | 102 IgnoreFocus = 1 << 1, |
93 IgnoreControlsHover = 1 << 2 | 103 IgnoreControlsHover = 1 << 2 |
94 }; | 104 }; |
95 | 105 |
96 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const; | 106 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const; |
97 void hideMediaControlsTimerFired(Timer<MediaControls>*); | 107 void hideMediaControlsTimerFired(Timer<MediaControls>*); |
98 void startHideMediaControlsTimer(); | 108 void startHideMediaControlsTimer(); |
99 void stopHideMediaControlsTimer(); | 109 void stopHideMediaControlsTimer(); |
100 void resetHideMediaControlsTimer(); | 110 void resetHideMediaControlsTimer(); |
101 | 111 |
102 // Attempts to show the overlay cast button. If it is covered by another | 112 // Attempts to show the overlay cast button. If it is covered by another |
103 // element in the page, it will be hidden. | 113 // element in the page, it will be hidden. |
104 void tryShowOverlayCastButton(); | 114 void tryShowOverlayCastButton(); |
105 | 115 |
116 void panelWidthChangedTimerFired(Timer<MediaControls>*); | |
117 | |
118 // Hide elements that don't fit, and show those things that we want which | |
119 // do fit. This requires that m_panelWidth is current. | |
120 void computeWhichControlsFit(); | |
121 | |
106 // Node | 122 // Node |
107 bool isMediaControls() const override { return true; } | 123 bool isMediaControls() const override { return true; } |
108 bool willRespondToMouseMoveEvents() override { return true; } | 124 bool willRespondToMouseMoveEvents() override { return true; } |
109 void defaultEventHandler(Event*) override; | 125 void defaultEventHandler(Event*) override; |
110 bool containsRelatedTarget(Event*); | 126 bool containsRelatedTarget(Event*); |
111 | 127 |
128 // Open a new batch of controls updates. | |
129 void beginBatchUpdate(); | |
130 | |
131 // Close the innermost batch of controls updates. If this is the only | |
132 // open batch, then also update the control layout. | |
133 void endBatchUpdate(); | |
134 | |
112 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; | 135 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; |
113 | 136 |
114 // Media control elements. | 137 // Media control elements. |
115 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure; | 138 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure; |
116 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton ; | 139 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton ; |
117 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton; | 140 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton; |
118 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure; | 141 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure; |
119 RawPtrWillBeMember<MediaControlPanelElement> m_panel; | 142 RawPtrWillBeMember<MediaControlPanelElement> m_panel; |
120 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton; | 143 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton; |
121 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline; | 144 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline; |
122 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDispl ay; | 145 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDispl ay; |
123 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDispla y; | 146 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDispla y; |
124 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton; | 147 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton; |
125 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider; | 148 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider; |
126 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleCl osedCaptionsButton; | 149 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleCl osedCaptionsButton; |
127 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton; | 150 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton; |
128 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton; | 151 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton; |
129 | 152 |
130 Timer<MediaControls> m_hideMediaControlsTimer; | 153 Timer<MediaControls> m_hideMediaControlsTimer; |
131 unsigned m_hideTimerBehaviorFlags; | 154 unsigned m_hideTimerBehaviorFlags; |
132 bool m_isMouseOverControls : 1; | 155 bool m_isMouseOverControls : 1; |
133 bool m_isPausedForScrubbing : 1; | 156 bool m_isPausedForScrubbing : 1; |
157 | |
158 Timer<MediaControls> m_panelWidthChangedTimer; | |
159 int m_panelWidth; | |
160 | |
161 bool m_allowHiddenVolumeControls : 1; | |
162 bool m_keepMuteButton : 1; | |
163 | |
164 int m_batchDepth; | |
philipj_slow
2015/08/03 13:52:34
Rather than keeping the state on the MediaControls
philipj_slow
2015/08/04 11:54:53
Ping.
liberato (no reviews please)
2015/08/04 15:07:00
if two tabs have media controls, might they not ge
philipj_slow
2015/08/04 15:15:59
A grep for 'static unsigned s_' will find the patt
liberato (no reviews please)
2015/08/05 06:11:35
Done.
| |
134 }; | 165 }; |
135 | 166 |
136 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); | 167 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); |
137 | 168 |
138 } | 169 } |
139 | 170 |
140 #endif | 171 #endif |
OLD | NEW |