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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Return the internal elements, which is used by registering clicking | 81 // Return the internal elements, which is used by registering clicking |
82 // EventHandlers from MediaControlsWindowEventListener. | 82 // EventHandlers from MediaControlsWindowEventListener. |
83 MediaControlPanelElement* panelElement() { return m_panel; } | 83 MediaControlPanelElement* panelElement() { return m_panel; } |
84 MediaControlTimelineElement* timelineElement() { return m_timeline; } | 84 MediaControlTimelineElement* timelineElement() { return m_timeline; } |
85 MediaControlCastButtonElement* castButtonElement() { return m_castButton; } | 85 MediaControlCastButtonElement* castButtonElement() { return m_castButton; } |
86 MediaControlVolumeSliderElement* volumeSliderElement() { | 86 MediaControlVolumeSliderElement* volumeSliderElement() { |
87 return m_volumeSlider; | 87 return m_volumeSlider; |
88 } | 88 } |
89 | 89 |
90 // Notify us that our controls enclosure has changed width. | |
91 void notifyPanelWidthChanged(const LayoutUnit& newWidth); | |
92 | |
93 // Notify us that the media element's network state has changed. | 90 // Notify us that the media element's network state has changed. |
94 void networkStateChanged(); | 91 void networkStateChanged(); |
95 | 92 |
96 void toggleOverflowMenu(); | 93 void toggleOverflowMenu(); |
97 | 94 |
98 bool overflowMenuVisible(); | 95 bool overflowMenuVisible(); |
99 | 96 |
100 // TODO(mlamouri): this is temporary to notify the controls that an | 97 // TODO(mlamouri): this is temporary to notify the controls that an |
101 // HTMLTrackElement failed to load because there is no web exposed way to | 98 // HTMLTrackElement failed to load because there is no web exposed way to |
102 // be notified on the TextTrack object. See https://crbug.com/669977 | 99 // be notified on the TextTrack object. See https://crbug.com/669977 |
(...skipping 20 matching lines...) Expand all Loading... |
123 | 120 |
124 DECLARE_VIRTUAL_TRACE(); | 121 DECLARE_VIRTUAL_TRACE(); |
125 | 122 |
126 private: | 123 private: |
127 friend class MediaControlsMediaEventListener; | 124 friend class MediaControlsMediaEventListener; |
128 friend class MediaControlsOrientationLockDelegateTest; | 125 friend class MediaControlsOrientationLockDelegateTest; |
129 friend class MediaControlsTest; | 126 friend class MediaControlsTest; |
130 | 127 |
131 void invalidate(Element*); | 128 void invalidate(Element*); |
132 | 129 |
| 130 // Need to be members of MediaControls for private member access. |
133 class BatchedControlUpdate; | 131 class BatchedControlUpdate; |
| 132 class MediaControlsResizeObserverCallback; |
| 133 |
| 134 // Notify us that our controls enclosure has changed size. |
| 135 void notifyElementSizeChanged(ClientRect* newSize); |
134 | 136 |
135 explicit MediaControls(HTMLMediaElement&); | 137 explicit MediaControls(HTMLMediaElement&); |
136 | 138 |
137 void initializeControls(); | 139 void initializeControls(); |
138 | 140 |
139 void makeOpaque(); | 141 void makeOpaque(); |
140 void makeTransparent(); | 142 void makeTransparent(); |
141 | 143 |
142 void updatePlayState(); | 144 void updatePlayState(); |
143 | 145 |
144 enum HideBehaviorFlags { | 146 enum HideBehaviorFlags { |
145 IgnoreNone = 0, | 147 IgnoreNone = 0, |
146 IgnoreVideoHover = 1 << 0, | 148 IgnoreVideoHover = 1 << 0, |
147 IgnoreFocus = 1 << 1, | 149 IgnoreFocus = 1 << 1, |
148 IgnoreControlsHover = 1 << 2, | 150 IgnoreControlsHover = 1 << 2, |
149 IgnoreWaitForTimer = 1 << 3, | 151 IgnoreWaitForTimer = 1 << 3, |
150 }; | 152 }; |
151 | 153 |
152 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const; | 154 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const; |
153 void hideMediaControlsTimerFired(TimerBase*); | 155 void hideMediaControlsTimerFired(TimerBase*); |
154 void startHideMediaControlsTimer(); | 156 void startHideMediaControlsTimer(); |
155 void stopHideMediaControlsTimer(); | 157 void stopHideMediaControlsTimer(); |
156 void resetHideMediaControlsTimer(); | 158 void resetHideMediaControlsTimer(); |
157 | 159 |
158 void panelWidthChangedTimerFired(TimerBase*); | 160 void elementSizeChangedTimerFired(TimerBase*); |
159 | 161 |
160 void hideAllMenus(); | 162 void hideAllMenus(); |
161 | 163 |
162 // Hide elements that don't fit, and show those things that we want which | 164 // Hide elements that don't fit, and show those things that we want which |
163 // do fit. This requires that m_panelWidth is current. | 165 // do fit. This requires that m_effectiveWidth and m_effectiveHeight are |
| 166 // current. |
164 void computeWhichControlsFit(); | 167 void computeWhichControlsFit(); |
165 | 168 |
166 // Node | 169 // Node |
167 bool isMediaControls() const override { return true; } | 170 bool isMediaControls() const override { return true; } |
168 bool willRespondToMouseMoveEvents() override { return true; } | 171 bool willRespondToMouseMoveEvents() override { return true; } |
169 void defaultEventHandler(Event*) override; | 172 void defaultEventHandler(Event*) override; |
170 bool containsRelatedTarget(Event*); | 173 bool containsRelatedTarget(Event*); |
171 | 174 |
172 // Methods called by MediaControlsMediaEventListener. | 175 // Methods called by MediaControlsMediaEventListener. |
173 void onVolumeChange(); | 176 void onVolumeChange(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 217 |
215 Member<MediaControlsMediaEventListener> m_mediaEventListener; | 218 Member<MediaControlsMediaEventListener> m_mediaEventListener; |
216 Member<MediaControlsWindowEventListener> m_windowEventListener; | 219 Member<MediaControlsWindowEventListener> m_windowEventListener; |
217 Member<MediaControlsOrientationLockDelegate> m_orientationLockDelegate; | 220 Member<MediaControlsOrientationLockDelegate> m_orientationLockDelegate; |
218 | 221 |
219 TaskRunnerTimer<MediaControls> m_hideMediaControlsTimer; | 222 TaskRunnerTimer<MediaControls> m_hideMediaControlsTimer; |
220 unsigned m_hideTimerBehaviorFlags; | 223 unsigned m_hideTimerBehaviorFlags; |
221 bool m_isMouseOverControls : 1; | 224 bool m_isMouseOverControls : 1; |
222 bool m_isPausedForScrubbing : 1; | 225 bool m_isPausedForScrubbing : 1; |
223 | 226 |
224 TaskRunnerTimer<MediaControls> m_panelWidthChangedTimer; | 227 // Watches the video element for resize and updates media controls as |
225 int m_panelWidth; | 228 // necessary. |
| 229 Member<ResizeObserver> m_resizeObserver; |
| 230 |
| 231 TaskRunnerTimer<MediaControls> m_elementSizeChangedTimer; |
| 232 IntSize m_size; |
226 | 233 |
227 bool m_keepShowingUntilTimerFires : 1; | 234 bool m_keepShowingUntilTimerFires : 1; |
228 }; | 235 }; |
229 | 236 |
230 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); | 237 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls()); |
231 | 238 |
232 } // namespace blink | 239 } // namespace blink |
233 | 240 |
234 #endif | 241 #endif |
OLD | NEW |