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 |
112 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; | 128 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; |
113 | 129 |
114 // Media control elements. | 130 // Media control elements. |
115 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure; | 131 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure; |
116 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton
; | 132 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton
; |
117 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton; | 133 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton; |
118 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure; | 134 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure; |
119 RawPtrWillBeMember<MediaControlPanelElement> m_panel; | 135 RawPtrWillBeMember<MediaControlPanelElement> m_panel; |
120 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton; | 136 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton; |
121 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline; | 137 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline; |
122 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDispl
ay; | 138 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDispl
ay; |
123 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDispla
y; | 139 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDispla
y; |
124 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton; | 140 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton; |
125 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider; | 141 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider; |
126 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleCl
osedCaptionsButton; | 142 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleCl
osedCaptionsButton; |
127 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton; | 143 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton; |
128 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton; | 144 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton; |
129 | 145 |
130 Timer<MediaControls> m_hideMediaControlsTimer; | 146 Timer<MediaControls> m_hideMediaControlsTimer; |
131 unsigned m_hideTimerBehaviorFlags; | 147 unsigned m_hideTimerBehaviorFlags; |
132 bool m_isMouseOverControls : 1; | 148 bool m_isMouseOverControls : 1; |
133 bool m_isPausedForScrubbing : 1; | 149 bool m_isPausedForScrubbing : 1; |
| 150 |
| 151 Timer<MediaControls> m_panelWidthChangedTimer; |
| 152 int m_panelWidth; |
| 153 |
| 154 bool m_allowHiddenVolumeControls : 1; |
| 155 bool m_keepMuteButton : 1; |
134 }; | 156 }; |
135 | 157 |
136 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); | 158 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); |
137 | 159 |
138 } | 160 } |
139 | 161 |
140 #endif | 162 #endif |
OLD | NEW |