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 11 matching lines...) Expand all Loading... | |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/html/shadow/MediaControls.h" | 27 #include "core/html/shadow/MediaControls.h" |
28 | 28 |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
30 #include "core/dom/ClientRect.h" | 30 #include "core/dom/ClientRect.h" |
31 #include "core/dom/Fullscreen.h" | 31 #include "core/dom/Fullscreen.h" |
32 #include "core/dom/ResizeObserver.h" | |
33 #include "core/dom/ResizeObserverCallback.h" | |
34 #include "core/dom/ResizeObserverEntry.h" | |
32 #include "core/dom/TaskRunnerHelper.h" | 35 #include "core/dom/TaskRunnerHelper.h" |
33 #include "core/events/MouseEvent.h" | 36 #include "core/events/MouseEvent.h" |
34 #include "core/frame/Settings.h" | 37 #include "core/frame/Settings.h" |
35 #include "core/html/HTMLMediaElement.h" | 38 #include "core/html/HTMLMediaElement.h" |
36 #include "core/html/HTMLVideoElement.h" | 39 #include "core/html/HTMLVideoElement.h" |
37 #include "core/html/shadow/MediaControlsMediaEventListener.h" | 40 #include "core/html/shadow/MediaControlsMediaEventListener.h" |
38 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h" | 41 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h" |
39 #include "core/html/shadow/MediaControlsWindowEventListener.h" | 42 #include "core/html/shadow/MediaControlsWindowEventListener.h" |
40 #include "core/html/track/TextTrackContainer.h" | 43 #include "core/html/track/TextTrackContainer.h" |
41 #include "core/html/track/TextTrackList.h" | 44 #include "core/html/track/TextTrackList.h" |
42 #include "core/layout/LayoutObject.h" | 45 #include "core/layout/LayoutObject.h" |
43 #include "core/layout/LayoutTheme.h" | 46 #include "core/layout/LayoutTheme.h" |
44 #include "platform/EventDispatchForbiddenScope.h" | 47 #include "platform/EventDispatchForbiddenScope.h" |
45 | 48 |
46 namespace blink { | 49 namespace blink { |
47 | 50 |
51 namespace { | |
52 | |
53 constexpr int kOverlayPlayButtonWidth = 48; | |
54 constexpr int kOverlayPlayButtonHeight = 48; | |
55 constexpr int kOverlayBottomMargin = 10; | |
56 | |
57 #if OS(ANDROID) | |
58 constexpr int kMediaPanelHeight = 48; | |
59 #else | |
60 constexpr int kMediaPanelHeight = 32; | |
61 #endif | |
mlamouri (slow - plz ping)
2017/03/07 19:07:30
Can you drop the `#if`? I don't think we even need
mlamouri (slow - plz ping)
2017/03/08 19:13:04
On 2017/03/07 at 19:07:30, mlamouri wrote:
> Can y
steimel
2017/03/09 16:42:24
Done.
| |
62 | |
63 // If these change, they must also be changed in | |
64 // LayoutTests/virtual/android/media/controls/overlay-play-button.js. | |
mlamouri (slow - plz ping)
2017/03/07 19:07:30
Not sure how useful is this comment as the tests w
steimel
2017/03/09 16:42:24
Done.
| |
65 constexpr int kMinWidthForOverlayPlayButton = kOverlayPlayButtonWidth; | |
66 constexpr int kMinHeightForOverlayPlayButton = | |
67 kOverlayPlayButtonHeight + kMediaPanelHeight + (2 * kOverlayBottomMargin); | |
68 | |
69 } // anonymous namespace | |
70 | |
48 // If you change this value, then also update the corresponding value in | 71 // If you change this value, then also update the corresponding value in |
49 // LayoutTests/media/media-controls.js. | 72 // LayoutTests/media/media-controls.js. |
50 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; | 73 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; |
51 | 74 |
52 static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) { | 75 static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) { |
53 // Unconditionally allow the user to exit fullscreen if we are in it | 76 // Unconditionally allow the user to exit fullscreen if we are in it |
54 // now. Especially on android, when we might not yet know if | 77 // now. Especially on android, when we might not yet know if |
55 // fullscreen is supported, we sometimes guess incorrectly and show | 78 // fullscreen is supported, we sometimes guess incorrectly and show |
56 // the button earlier, and we don't want to remove it here if the | 79 // the button earlier, and we don't want to remove it here if the |
57 // user chose to enter fullscreen. crbug.com/500732 . | 80 // user chose to enter fullscreen. crbug.com/500732 . |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 } | 130 } |
108 | 131 |
109 private: | 132 private: |
110 Member<MediaControls> m_controls; | 133 Member<MediaControls> m_controls; |
111 static int s_batchDepth; | 134 static int s_batchDepth; |
112 }; | 135 }; |
113 | 136 |
114 // Count of number open batches for controls visibility. | 137 // Count of number open batches for controls visibility. |
115 int MediaControls::BatchedControlUpdate::s_batchDepth = 0; | 138 int MediaControls::BatchedControlUpdate::s_batchDepth = 0; |
116 | 139 |
140 class MediaControls::MediaControlsResizeObserverCallback final | |
141 : public ResizeObserverCallback { | |
142 public: | |
143 explicit MediaControlsResizeObserverCallback(MediaControls* controls) | |
144 : m_controls(controls) { | |
145 DCHECK(controls); | |
146 } | |
147 ~MediaControlsResizeObserverCallback() override = default; | |
148 | |
149 void handleEvent(const HeapVector<Member<ResizeObserverEntry>>& entries, | |
150 ResizeObserver* observer) override { | |
151 DCHECK_EQ(1u, entries.size()); | |
152 DCHECK_EQ(entries[0]->target(), m_controls->m_mediaElement); | |
153 m_controls->notifyElementSizeChanged(entries[0]->contentRect()); | |
154 } | |
155 | |
156 DEFINE_INLINE_TRACE() { | |
157 visitor->trace(m_controls); | |
158 ResizeObserverCallback::trace(visitor); | |
159 } | |
160 | |
161 private: | |
162 Member<MediaControls> m_controls; | |
163 }; | |
164 | |
117 MediaControls::MediaControls(HTMLMediaElement& mediaElement) | 165 MediaControls::MediaControls(HTMLMediaElement& mediaElement) |
118 : HTMLDivElement(mediaElement.document()), | 166 : HTMLDivElement(mediaElement.document()), |
119 m_mediaElement(&mediaElement), | 167 m_mediaElement(&mediaElement), |
120 m_overlayEnclosure(nullptr), | 168 m_overlayEnclosure(nullptr), |
121 m_overlayPlayButton(nullptr), | 169 m_overlayPlayButton(nullptr), |
122 m_overlayCastButton(nullptr), | 170 m_overlayCastButton(nullptr), |
123 m_enclosure(nullptr), | 171 m_enclosure(nullptr), |
124 m_panel(nullptr), | 172 m_panel(nullptr), |
125 m_playButton(nullptr), | 173 m_playButton(nullptr), |
126 m_timeline(nullptr), | 174 m_timeline(nullptr), |
(...skipping 12 matching lines...) Expand all Loading... | |
139 this, | 187 this, |
140 WTF::bind(&MediaControls::hideAllMenus, wrapWeakPersistent(this)))), | 188 WTF::bind(&MediaControls::hideAllMenus, wrapWeakPersistent(this)))), |
141 m_orientationLockDelegate(nullptr), | 189 m_orientationLockDelegate(nullptr), |
142 m_hideMediaControlsTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, | 190 m_hideMediaControlsTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, |
143 &mediaElement.document()), | 191 &mediaElement.document()), |
144 this, | 192 this, |
145 &MediaControls::hideMediaControlsTimerFired), | 193 &MediaControls::hideMediaControlsTimerFired), |
146 m_hideTimerBehaviorFlags(IgnoreNone), | 194 m_hideTimerBehaviorFlags(IgnoreNone), |
147 m_isMouseOverControls(false), | 195 m_isMouseOverControls(false), |
148 m_isPausedForScrubbing(false), | 196 m_isPausedForScrubbing(false), |
149 m_panelWidthChangedTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, | 197 m_resizeObserver(ResizeObserver::create( |
150 &mediaElement.document()), | 198 mediaElement.document(), |
151 this, | 199 new MediaControlsResizeObserverCallback(this))), |
152 &MediaControls::panelWidthChangedTimerFired), | 200 m_elementSizeChangedTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, |
153 m_panelWidth(0), | 201 &mediaElement.document()), |
154 m_keepShowingUntilTimerFires(false) {} | 202 this, |
203 &MediaControls::elementSizeChangedTimerFired), | |
204 m_keepShowingUntilTimerFires(false) { | |
205 m_resizeObserver->observe(m_mediaElement); | |
206 } | |
155 | 207 |
156 MediaControls* MediaControls::create(HTMLMediaElement& mediaElement, | 208 MediaControls* MediaControls::create(HTMLMediaElement& mediaElement, |
157 ShadowRoot& shadowRoot) { | 209 ShadowRoot& shadowRoot) { |
158 MediaControls* controls = new MediaControls(mediaElement); | 210 MediaControls* controls = new MediaControls(mediaElement); |
159 controls->setShadowPseudoId(AtomicString("-webkit-media-controls")); | 211 controls->setShadowPseudoId(AtomicString("-webkit-media-controls")); |
160 controls->initializeControls(); | 212 controls->initializeControls(); |
161 controls->reset(); | 213 controls->reset(); |
162 | 214 |
163 // Initialize the orientation lock when going fullscreen feature. | 215 // Initialize the orientation lock when going fullscreen feature. |
164 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() && | 216 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() && |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 396 |
345 // TODO(mlamouri): we should show the controls instead of having | 397 // TODO(mlamouri): we should show the controls instead of having |
346 // HTMLMediaElement do it. | 398 // HTMLMediaElement do it. |
347 | 399 |
348 // m_windowEventListener doesn't need to be re-attached as it's only needed | 400 // m_windowEventListener doesn't need to be re-attached as it's only needed |
349 // when a menu is visible. | 401 // when a menu is visible. |
350 m_mediaEventListener->attach(); | 402 m_mediaEventListener->attach(); |
351 if (m_orientationLockDelegate) | 403 if (m_orientationLockDelegate) |
352 m_orientationLockDelegate->attach(); | 404 m_orientationLockDelegate->attach(); |
353 | 405 |
406 if (!m_resizeObserver) { | |
407 m_resizeObserver = | |
408 ResizeObserver::create(m_mediaElement->document(), | |
409 new MediaControlsResizeObserverCallback(this)); | |
410 m_resizeObserver->observe(m_mediaElement); | |
411 } | |
412 | |
354 return HTMLDivElement::insertedInto(root); | 413 return HTMLDivElement::insertedInto(root); |
355 } | 414 } |
356 | 415 |
357 void MediaControls::removedFrom(ContainerNode*) { | 416 void MediaControls::removedFrom(ContainerNode*) { |
358 DCHECK(!mediaElement().isConnected()); | 417 DCHECK(!mediaElement().isConnected()); |
359 | 418 |
360 // TODO(mlamouri): we hide show the controls instead of having | 419 // TODO(mlamouri): we hide show the controls instead of having |
361 // HTMLMediaElement do it. | 420 // HTMLMediaElement do it. |
362 | 421 |
363 m_windowEventListener->stop(); | 422 m_windowEventListener->stop(); |
364 m_mediaEventListener->detach(); | 423 m_mediaEventListener->detach(); |
365 if (m_orientationLockDelegate) | 424 if (m_orientationLockDelegate) |
366 m_orientationLockDelegate->detach(); | 425 m_orientationLockDelegate->detach(); |
426 | |
427 m_resizeObserver.clear(); | |
367 } | 428 } |
368 | 429 |
369 void MediaControls::reset() { | 430 void MediaControls::reset() { |
370 EventDispatchForbiddenScope::AllowUserAgentEvents allowEventsInShadow; | 431 EventDispatchForbiddenScope::AllowUserAgentEvents allowEventsInShadow; |
371 BatchedControlUpdate batch(this); | 432 BatchedControlUpdate batch(this); |
372 | 433 |
373 const double duration = mediaElement().duration(); | 434 const double duration = mediaElement().duration(); |
374 m_durationDisplay->setTextContent( | 435 m_durationDisplay->setTextContent( |
375 LayoutTheme::theme().formatMediaControlsTime(duration)); | 436 LayoutTheme::theme().formatMediaControlsTime(duration)); |
376 m_durationDisplay->setCurrentValue(duration); | 437 m_durationDisplay->setCurrentValue(duration); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 stopHideMediaControlsTimer(); | 870 stopHideMediaControlsTimer(); |
810 startHideMediaControlsTimer(); | 871 startHideMediaControlsTimer(); |
811 } | 872 } |
812 | 873 |
813 void MediaControls::onExitedFullscreen() { | 874 void MediaControls::onExitedFullscreen() { |
814 m_fullscreenButton->setIsFullscreen(false); | 875 m_fullscreenButton->setIsFullscreen(false); |
815 stopHideMediaControlsTimer(); | 876 stopHideMediaControlsTimer(); |
816 startHideMediaControlsTimer(); | 877 startHideMediaControlsTimer(); |
817 } | 878 } |
818 | 879 |
819 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) { | 880 void MediaControls::notifyElementSizeChanged(ClientRect* newSize) { |
820 // Don't bother to do any work if this matches the most recent panel | |
821 // width, since we're called after layout. | |
822 // Note that this code permits a bad frame on resize, since it is | 881 // Note that this code permits a bad frame on resize, since it is |
823 // run after the relayout / paint happens. It would be great to improve | 882 // run after the relayout / paint happens. It would be great to improve |
824 // this, but it would be even greater to move this code entirely to | 883 // this, but it would be even greater to move this code entirely to |
825 // JS and fix it there. | 884 // JS and fix it there. |
826 m_panelWidth = newWidth.toInt(); | 885 |
886 IntSize oldSize = m_size; | |
887 m_size.setWidth(newSize->width()); | |
888 m_size.setHeight(newSize->height()); | |
827 | 889 |
828 // Adjust for effective zoom. | 890 // Adjust for effective zoom. |
829 if (!m_panel->layoutObject() || !m_panel->layoutObject()->style()) | 891 if (m_panel->layoutObject() && m_panel->layoutObject()->style()) { |
830 return; | 892 m_size.setWidth(ceil(m_size.width() / |
831 m_panelWidth = | 893 m_panel->layoutObject()->style()->effectiveZoom())); |
832 ceil(m_panelWidth / m_panel->layoutObject()->style()->effectiveZoom()); | 894 m_size.setHeight(ceil(m_size.height() / |
895 m_panel->layoutObject()->style()->effectiveZoom())); | |
896 } | |
833 | 897 |
834 m_panelWidthChangedTimer.startOneShot(0, BLINK_FROM_HERE); | 898 // Don't bother to do any work if this matches the most recent size. |
899 if (oldSize != m_size) | |
900 m_elementSizeChangedTimer.startOneShot(0, BLINK_FROM_HERE); | |
835 } | 901 } |
836 | 902 |
837 void MediaControls::panelWidthChangedTimerFired(TimerBase*) { | 903 void MediaControls::elementSizeChangedTimerFired(TimerBase*) { |
838 computeWhichControlsFit(); | 904 computeWhichControlsFit(); |
839 } | 905 } |
840 | 906 |
841 void MediaControls::computeWhichControlsFit() { | 907 void MediaControls::computeWhichControlsFit() { |
842 // Hide all controls that don't fit, and show the ones that do. | 908 // Hide all controls that don't fit, and show the ones that do. |
843 // This might be better suited for a layout, but since JS media controls | 909 // This might be better suited for a layout, but since JS media controls |
844 // won't benefit from that anwyay, we just do it here like JS will. | 910 // won't benefit from that anwyay, we just do it here like JS will. |
845 | 911 |
846 // Controls that we'll hide / show, in order of decreasing priority. | 912 // Controls that we'll hide / show, in order of decreasing priority. |
847 MediaControlElement* elements[] = { | 913 MediaControlElement* elements[] = { |
848 // Exclude m_overflowMenu; we handle it specially. | 914 // Exclude m_overflowMenu; we handle it specially. |
849 m_playButton.get(), | 915 m_playButton.get(), |
850 m_fullscreenButton.get(), | 916 m_fullscreenButton.get(), |
851 m_downloadButton.get(), | 917 m_downloadButton.get(), |
852 m_timeline.get(), | 918 m_timeline.get(), |
853 m_muteButton.get(), | 919 m_muteButton.get(), |
854 m_volumeSlider.get(), | 920 m_volumeSlider.get(), |
855 m_toggleClosedCaptionsButton.get(), | 921 m_toggleClosedCaptionsButton.get(), |
856 m_castButton.get(), | 922 m_castButton.get(), |
857 m_currentTimeDisplay.get(), | 923 m_currentTimeDisplay.get(), |
858 m_durationDisplay.get(), | 924 m_durationDisplay.get(), |
859 }; | 925 }; |
860 | 926 |
861 // TODO(mlamouri): we need a more dynamic way to find out the width of an | 927 // TODO(mlamouri): we need a more dynamic way to find out the width of an |
862 // element. | 928 // element. |
863 const int sliderMargin = 36; // Sliders have 18px margin on each side. | 929 const int sliderMargin = 36; // Sliders have 18px margin on each side. |
864 | 930 |
865 if (!m_panelWidth) { | 931 if (!m_size.width()) { |
866 // No layout yet -- hide everything, then make them show up later. | 932 // No layout yet -- hide everything, then make them show up later. |
867 // This prevents the wrong controls from being shown briefly | 933 // This prevents the wrong controls from being shown briefly |
868 // immediately after the first layout and paint, but before we have | 934 // immediately after the first layout and paint, but before we have |
869 // a chance to revise them. | 935 // a chance to revise them. |
870 for (MediaControlElement* element : elements) { | 936 for (MediaControlElement* element : elements) { |
871 if (element) | 937 if (element) |
872 element->setDoesFit(false); | 938 element->setDoesFit(false); |
873 } | 939 } |
874 return; | 940 return; |
875 } | 941 } |
(...skipping 24 matching lines...) Expand all Loading... | |
900 MediaControlElement* firstDisplacedElement = nullptr; | 966 MediaControlElement* firstDisplacedElement = nullptr; |
901 // For each control that fits, enable it in order of decreasing priority. | 967 // For each control that fits, enable it in order of decreasing priority. |
902 for (MediaControlElement* element : elements) { | 968 for (MediaControlElement* element : elements) { |
903 if (!element) | 969 if (!element) |
904 continue; | 970 continue; |
905 int width = minimumWidth; | 971 int width = minimumWidth; |
906 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) | 972 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) |
907 width += sliderMargin; | 973 width += sliderMargin; |
908 element->shouldShowButtonInOverflowMenu(false); | 974 element->shouldShowButtonInOverflowMenu(false); |
909 if (element->isWanted()) { | 975 if (element->isWanted()) { |
910 if (usedWidth + width <= m_panelWidth) { | 976 if (usedWidth + width <= m_size.width()) { |
911 element->setDoesFit(true); | 977 element->setDoesFit(true); |
912 usedWidth += width; | 978 usedWidth += width; |
913 } else { | 979 } else { |
914 element->setDoesFit(false); | 980 element->setDoesFit(false); |
915 element->shouldShowButtonInOverflowMenu(true); | 981 element->shouldShowButtonInOverflowMenu(true); |
916 if (element->hasOverflowButton()) | 982 if (element->hasOverflowButton()) |
917 overflowElements.push_front(element); | 983 overflowElements.push_front(element); |
918 // We want a way to access the first media element that was | 984 // We want a way to access the first media element that was |
919 // removed. If we don't end up needing an overflow menu, we can | 985 // removed. If we don't end up needing an overflow menu, we can |
920 // use the space the overflow menu would have taken up to | 986 // use the space the overflow menu would have taken up to |
921 // instead display that media element. | 987 // instead display that media element. |
922 if (!element->hasOverflowButton() && !firstDisplacedElement) | 988 if (!element->hasOverflowButton() && !firstDisplacedElement) |
923 firstDisplacedElement = element; | 989 firstDisplacedElement = element; |
924 } | 990 } |
925 } | 991 } |
926 } | 992 } |
927 | 993 |
928 // If we don't have at least two overflow elements, we will not show the | 994 // If we don't have at least two overflow elements, we will not show the |
929 // overflow menu. | 995 // overflow menu. |
930 if (overflowElements.empty()) { | 996 if (overflowElements.empty()) { |
931 m_overflowMenu->setIsWanted(false); | 997 m_overflowMenu->setIsWanted(false); |
932 usedWidth -= minimumWidth; | 998 usedWidth -= minimumWidth; |
933 if (firstDisplacedElement) { | 999 if (firstDisplacedElement) { |
934 int width = minimumWidth; | 1000 int width = minimumWidth; |
935 if ((firstDisplacedElement == m_timeline.get()) || | 1001 if ((firstDisplacedElement == m_timeline.get()) || |
936 (firstDisplacedElement == m_volumeSlider.get())) | 1002 (firstDisplacedElement == m_volumeSlider.get())) |
937 width += sliderMargin; | 1003 width += sliderMargin; |
938 if (usedWidth + width <= m_panelWidth) | 1004 if (usedWidth + width <= m_size.width()) |
939 firstDisplacedElement->setDoesFit(true); | 1005 firstDisplacedElement->setDoesFit(true); |
940 } | 1006 } |
941 } else if (overflowElements.size() == 1) { | 1007 } else if (overflowElements.size() == 1) { |
942 m_overflowMenu->setIsWanted(false); | 1008 m_overflowMenu->setIsWanted(false); |
943 overflowElements.front()->setDoesFit(true); | 1009 overflowElements.front()->setDoesFit(true); |
944 } | 1010 } |
1011 | |
1012 // Decide if the overlay play button fits. | |
1013 if (m_overlayPlayButton) { | |
1014 bool doesFit = m_size.width() >= kMinWidthForOverlayPlayButton && | |
1015 m_size.height() >= kMinHeightForOverlayPlayButton; | |
1016 m_overlayPlayButton->setDoesFit(doesFit); | |
1017 } | |
945 } | 1018 } |
946 | 1019 |
947 void MediaControls::invalidate(Element* element) { | 1020 void MediaControls::invalidate(Element* element) { |
948 if (!element) | 1021 if (!element) |
949 return; | 1022 return; |
950 | 1023 |
951 if (LayoutObject* layoutObject = element->layoutObject()) | 1024 if (LayoutObject* layoutObject = element->layoutObject()) |
952 layoutObject | 1025 layoutObject |
953 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 1026 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
954 } | 1027 } |
(...skipping 23 matching lines...) Expand all Loading... | |
978 void MediaControls::hideAllMenus() { | 1051 void MediaControls::hideAllMenus() { |
979 m_windowEventListener->stop(); | 1052 m_windowEventListener->stop(); |
980 | 1053 |
981 if (m_overflowList->isWanted()) | 1054 if (m_overflowList->isWanted()) |
982 m_overflowList->setIsWanted(false); | 1055 m_overflowList->setIsWanted(false); |
983 if (m_textTrackList->isWanted()) | 1056 if (m_textTrackList->isWanted()) |
984 m_textTrackList->setVisible(false); | 1057 m_textTrackList->setVisible(false); |
985 } | 1058 } |
986 | 1059 |
987 DEFINE_TRACE(MediaControls) { | 1060 DEFINE_TRACE(MediaControls) { |
1061 visitor->trace(m_resizeObserver); | |
988 visitor->trace(m_mediaElement); | 1062 visitor->trace(m_mediaElement); |
989 visitor->trace(m_panel); | 1063 visitor->trace(m_panel); |
990 visitor->trace(m_overlayPlayButton); | 1064 visitor->trace(m_overlayPlayButton); |
991 visitor->trace(m_overlayEnclosure); | 1065 visitor->trace(m_overlayEnclosure); |
992 visitor->trace(m_playButton); | 1066 visitor->trace(m_playButton); |
993 visitor->trace(m_currentTimeDisplay); | 1067 visitor->trace(m_currentTimeDisplay); |
994 visitor->trace(m_timeline); | 1068 visitor->trace(m_timeline); |
995 visitor->trace(m_muteButton); | 1069 visitor->trace(m_muteButton); |
996 visitor->trace(m_volumeSlider); | 1070 visitor->trace(m_volumeSlider); |
997 visitor->trace(m_toggleClosedCaptionsButton); | 1071 visitor->trace(m_toggleClosedCaptionsButton); |
998 visitor->trace(m_fullscreenButton); | 1072 visitor->trace(m_fullscreenButton); |
999 visitor->trace(m_downloadButton); | 1073 visitor->trace(m_downloadButton); |
1000 visitor->trace(m_durationDisplay); | 1074 visitor->trace(m_durationDisplay); |
1001 visitor->trace(m_enclosure); | 1075 visitor->trace(m_enclosure); |
1002 visitor->trace(m_textTrackList); | 1076 visitor->trace(m_textTrackList); |
1003 visitor->trace(m_overflowMenu); | 1077 visitor->trace(m_overflowMenu); |
1004 visitor->trace(m_overflowList); | 1078 visitor->trace(m_overflowList); |
1005 visitor->trace(m_castButton); | 1079 visitor->trace(m_castButton); |
1006 visitor->trace(m_overlayCastButton); | 1080 visitor->trace(m_overlayCastButton); |
1007 visitor->trace(m_mediaEventListener); | 1081 visitor->trace(m_mediaEventListener); |
1008 visitor->trace(m_windowEventListener); | 1082 visitor->trace(m_windowEventListener); |
1009 visitor->trace(m_orientationLockDelegate); | 1083 visitor->trace(m_orientationLockDelegate); |
1010 HTMLDivElement::trace(visitor); | 1084 HTMLDivElement::trace(visitor); |
1011 } | 1085 } |
1012 | 1086 |
1013 } // namespace blink | 1087 } // namespace blink |
OLD | NEW |