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