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 setAllowHiddenAudioElements(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(int panelWidth); |
| 84 |
77 DECLARE_VIRTUAL_TRACE(); | 85 DECLARE_VIRTUAL_TRACE(); |
78 | 86 |
79 private: | 87 private: |
80 explicit MediaControls(HTMLMediaElement&); | 88 explicit MediaControls(HTMLMediaElement&); |
81 | 89 |
82 void initializeControls(); | 90 void initializeControls(); |
83 | 91 |
84 void makeOpaque(); | 92 void makeOpaque(); |
85 void makeTransparent(); | 93 void makeTransparent(); |
86 | 94 |
87 void updatePlayState(); | 95 void updatePlayState(); |
88 | 96 |
89 enum HideBehaviorFlags { | 97 enum HideBehaviorFlags { |
90 IgnoreNone = 0, | 98 IgnoreNone = 0, |
91 IgnoreVideoHover = 1 << 0, | 99 IgnoreVideoHover = 1 << 0, |
92 IgnoreFocus = 1 << 1, | 100 IgnoreFocus = 1 << 1, |
93 IgnoreControlsHover = 1 << 2 | 101 IgnoreControlsHover = 1 << 2 |
94 }; | 102 }; |
95 | 103 |
96 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const; | 104 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const; |
97 void hideMediaControlsTimerFired(Timer<MediaControls>*); | 105 void hideMediaControlsTimerFired(Timer<MediaControls>*); |
98 void startHideMediaControlsTimer(); | 106 void startHideMediaControlsTimer(); |
99 void stopHideMediaControlsTimer(); | 107 void stopHideMediaControlsTimer(); |
100 void resetHideMediaControlsTimer(); | 108 void resetHideMediaControlsTimer(); |
101 | 109 |
102 // Attempts to show the overlay cast button. If it is covered by another | 110 // Attempts to show the overlay cast button. If it is covered by another |
103 // element in the page, it will be hidden. | 111 // element in the page, it will be hidden. |
104 void tryShowOverlayCastButton(); | 112 void tryShowOverlayCastButton(); |
105 | 113 |
| 114 // After changing the want / don't want state of one or more controls, |
| 115 // call this to recompute what's visible. |
| 116 void changedControlSelections(); |
| 117 |
| 118 void panelWidthChangedTimerFired(Timer<MediaControls>*); |
| 119 |
| 120 // Hide elements that don't fit, and show those things that we want which |
| 121 // do fit. This requires that m_panelWidth is current. |
| 122 void computeWhichControlsFit(); |
| 123 |
106 // Node | 124 // Node |
107 bool isMediaControls() const override { return true; } | 125 bool isMediaControls() const override { return true; } |
108 bool willRespondToMouseMoveEvents() override { return true; } | 126 bool willRespondToMouseMoveEvents() override { return true; } |
109 void defaultEventHandler(Event*) override; | 127 void defaultEventHandler(Event*) override; |
110 bool containsRelatedTarget(Event*); | 128 bool containsRelatedTarget(Event*); |
111 | 129 |
112 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; | 130 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; |
113 | 131 |
114 // Media control elements. | 132 // Media control elements. |
115 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure; | 133 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure; |
116 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton
; | 134 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton
; |
117 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton; | 135 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton; |
118 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure; | 136 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure; |
119 RawPtrWillBeMember<MediaControlPanelElement> m_panel; | 137 RawPtrWillBeMember<MediaControlPanelElement> m_panel; |
120 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton; | 138 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton; |
121 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline; | 139 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline; |
122 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDispl
ay; | 140 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDispl
ay; |
123 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDispla
y; | 141 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDispla
y; |
124 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton; | 142 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton; |
125 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider; | 143 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider; |
126 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleCl
osedCaptionsButton; | 144 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleCl
osedCaptionsButton; |
127 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton; | 145 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton; |
128 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton; | 146 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton; |
129 | 147 |
130 Timer<MediaControls> m_hideMediaControlsTimer; | 148 Timer<MediaControls> m_hideMediaControlsTimer; |
131 unsigned m_hideTimerBehaviorFlags; | 149 unsigned m_hideTimerBehaviorFlags; |
132 bool m_isMouseOverControls : 1; | 150 bool m_isMouseOverControls : 1; |
133 bool m_isPausedForScrubbing : 1; | 151 bool m_isPausedForScrubbing : 1; |
| 152 |
| 153 Timer<MediaControls> m_panelWidthChangedTimer; |
| 154 int m_panelWidth; |
| 155 |
| 156 bool m_allowHiddenAudioElements : 1; |
| 157 bool m_keepMuteButton : 1; |
134 }; | 158 }; |
135 | 159 |
136 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); | 160 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); |
137 | 161 |
138 } | 162 } |
139 | 163 |
140 #endif | 164 #endif |
OLD | NEW |