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