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 constexpr int kOverlayPlayButtonWidth = 48; | |
| 54 constexpr int kOverlayPlayButtonHeight = 48; | |
| 55 constexpr int kOverlayBottomMargin = 10; | |
| 56 constexpr int kAndroidMediaPanelHeight = 48; | |
| 57 | |
| 58 // If these change, they must also be changed in | |
| 59 // LayoutTests/virtual/android/media/controls/overlay-play-button.js. | |
| 60 constexpr int kMinWidthForOverlayPlayButton = kOverlayPlayButtonWidth; | |
| 61 constexpr int kMinHeightForOverlayPlayButton = kOverlayPlayButtonHeight + | |
| 62 (2 * 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 return false; | 735 return false; |
| 688 return contains(relatedTarget->toNode()); | 736 return contains(relatedTarget->toNode()); |
| 689 } | 737 } |
| 690 | 738 |
| 691 void MediaControls::onInsertedIntoDocument() { | 739 void MediaControls::onInsertedIntoDocument() { |
| 692 // TODO(mlamouri): we should show the controls instead of having | 740 // TODO(mlamouri): we should show the controls instead of having |
| 693 // HTMLMediaElement do it. | 741 // HTMLMediaElement do it. |
| 694 | 742 |
| 695 // m_windowEventListener doesn't need to be re-attached as it's only needed | 743 // m_windowEventListener doesn't need to be re-attached as it's only needed |
| 696 // when a menu is visible. | 744 // when a menu is visible. |
| 745 if (!m_resizeObserver) { | |
| 746 m_resizeObserver = | |
| 747 ResizeObserver::create(m_mediaElement->document(), | |
| 748 new MediaControlsResizeObserverCallback(this)); | |
| 749 m_resizeObserver->observe(m_mediaElement); | |
| 750 } | |
|
mlamouri (slow - plz ping)
2017/03/03 14:33:56
nit: add at the end
steimel
2017/03/03 19:38:54
Done.
| |
| 697 m_mediaEventListener->attach(); | 751 m_mediaEventListener->attach(); |
| 698 if (m_orientationLockDelegate) | 752 if (m_orientationLockDelegate) |
| 699 m_orientationLockDelegate->attach(); | 753 m_orientationLockDelegate->attach(); |
| 700 } | 754 } |
| 701 | 755 |
| 702 void MediaControls::onRemovedFromDocument() { | 756 void MediaControls::onRemovedFromDocument() { |
| 703 // TODO(mlamouri): we hide show the controls instead of having | 757 // TODO(mlamouri): we hide show the controls instead of having |
| 704 // HTMLMediaElement do it. | 758 // HTMLMediaElement do it. |
| 705 | 759 |
| 760 m_resizeObserver.clear(); | |
|
mlamouri (slow - plz ping)
2017/03/03 14:33:56
ditto
steimel
2017/03/03 19:38:54
Done.
| |
| 706 m_windowEventListener->stop(); | 761 m_windowEventListener->stop(); |
| 707 m_mediaEventListener->detach(); | 762 m_mediaEventListener->detach(); |
| 708 if (m_orientationLockDelegate) | 763 if (m_orientationLockDelegate) |
| 709 m_orientationLockDelegate->detach(); | 764 m_orientationLockDelegate->detach(); |
| 710 } | 765 } |
| 711 | 766 |
| 712 void MediaControls::onVolumeChange() { | 767 void MediaControls::onVolumeChange() { |
| 713 m_muteButton->updateDisplayType(); | 768 m_muteButton->updateDisplayType(); |
| 714 m_volumeSlider->setVolume(mediaElement().muted() ? 0 | 769 m_volumeSlider->setVolume(mediaElement().muted() ? 0 |
| 715 : mediaElement().volume()); | 770 : mediaElement().volume()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 stopHideMediaControlsTimer(); | 857 stopHideMediaControlsTimer(); |
| 803 startHideMediaControlsTimer(); | 858 startHideMediaControlsTimer(); |
| 804 } | 859 } |
| 805 | 860 |
| 806 void MediaControls::onExitedFullscreen() { | 861 void MediaControls::onExitedFullscreen() { |
| 807 m_fullscreenButton->setIsFullscreen(false); | 862 m_fullscreenButton->setIsFullscreen(false); |
| 808 stopHideMediaControlsTimer(); | 863 stopHideMediaControlsTimer(); |
| 809 startHideMediaControlsTimer(); | 864 startHideMediaControlsTimer(); |
| 810 } | 865 } |
| 811 | 866 |
| 812 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) { | 867 void MediaControls::notifyElementSizeChanged(ClientRect* newSize) { |
| 813 // Don't bother to do any work if this matches the most recent panel | |
| 814 // width, since we're called after layout. | |
| 815 // Note that this code permits a bad frame on resize, since it is | 868 // Note that this code permits a bad frame on resize, since it is |
| 816 // run after the relayout / paint happens. It would be great to improve | 869 // run after the relayout / paint happens. It would be great to improve |
| 817 // this, but it would be even greater to move this code entirely to | 870 // this, but it would be even greater to move this code entirely to |
| 818 // JS and fix it there. | 871 // JS and fix it there. |
| 819 m_panelWidth = newWidth.toInt(); | 872 |
| 873 IntSize oldSize = m_size; | |
| 874 m_size.setWidth(newSize->width()); | |
| 875 m_size.setHeight(newSize->height()); | |
| 820 | 876 |
| 821 // Adjust for effective zoom. | 877 // Adjust for effective zoom. |
| 822 if (!m_panel->layoutObject() || !m_panel->layoutObject()->style()) | 878 if (m_panel->layoutObject() && m_panel->layoutObject()->style()) { |
| 823 return; | 879 m_size.setWidth(ceil(m_size.width() / |
| 824 m_panelWidth = | 880 m_panel->layoutObject()->style()->effectiveZoom())); |
| 825 ceil(m_panelWidth / m_panel->layoutObject()->style()->effectiveZoom()); | 881 m_size.setHeight(ceil(m_size.height() / |
| 882 m_panel->layoutObject()->style()->effectiveZoom())); | |
| 883 } | |
| 826 | 884 |
| 827 m_panelWidthChangedTimer.startOneShot(0, BLINK_FROM_HERE); | 885 // Don't bother to do any work if this matches the most recent size. |
| 886 if (oldSize != m_size) | |
| 887 m_elementSizeChangedTimer.startOneShot(0, BLINK_FROM_HERE); | |
| 828 } | 888 } |
| 829 | 889 |
| 830 void MediaControls::panelWidthChangedTimerFired(TimerBase*) { | 890 void MediaControls::elementSizeChangedTimerFired(TimerBase*) { |
| 831 computeWhichControlsFit(); | 891 computeWhichControlsFit(); |
| 832 } | 892 } |
| 833 | 893 |
| 834 void MediaControls::computeWhichControlsFit() { | 894 void MediaControls::computeWhichControlsFit() { |
| 835 // Hide all controls that don't fit, and show the ones that do. | 895 // Hide all controls that don't fit, and show the ones that do. |
| 836 // This might be better suited for a layout, but since JS media controls | 896 // This might be better suited for a layout, but since JS media controls |
| 837 // won't benefit from that anwyay, we just do it here like JS will. | 897 // won't benefit from that anwyay, we just do it here like JS will. |
| 838 | 898 |
| 839 // Controls that we'll hide / show, in order of decreasing priority. | 899 // Controls that we'll hide / show, in order of decreasing priority. |
| 840 MediaControlElement* elements[] = { | 900 MediaControlElement* elements[] = { |
| 841 // Exclude m_overflowMenu; we handle it specially. | 901 // Exclude m_overflowMenu; we handle it specially. |
| 842 m_playButton.get(), | 902 m_playButton.get(), |
| 843 m_fullscreenButton.get(), | 903 m_fullscreenButton.get(), |
| 844 m_downloadButton.get(), | 904 m_downloadButton.get(), |
| 845 m_timeline.get(), | 905 m_timeline.get(), |
| 846 m_muteButton.get(), | 906 m_muteButton.get(), |
| 847 m_volumeSlider.get(), | 907 m_volumeSlider.get(), |
| 848 m_toggleClosedCaptionsButton.get(), | 908 m_toggleClosedCaptionsButton.get(), |
| 849 m_castButton.get(), | 909 m_castButton.get(), |
| 850 m_currentTimeDisplay.get(), | 910 m_currentTimeDisplay.get(), |
| 851 m_durationDisplay.get(), | 911 m_durationDisplay.get(), |
| 852 }; | 912 }; |
| 853 | 913 |
| 854 // TODO(mlamouri): we need a more dynamic way to find out the width of an | 914 // TODO(mlamouri): we need a more dynamic way to find out the width of an |
| 855 // element. | 915 // element. |
| 856 const int sliderMargin = 36; // Sliders have 18px margin on each side. | 916 const int sliderMargin = 36; // Sliders have 18px margin on each side. |
| 857 | 917 |
| 858 if (!m_panelWidth) { | 918 if (!m_size.width()) { |
| 859 // No layout yet -- hide everything, then make them show up later. | 919 // No layout yet -- hide everything, then make them show up later. |
| 860 // This prevents the wrong controls from being shown briefly | 920 // This prevents the wrong controls from being shown briefly |
| 861 // immediately after the first layout and paint, but before we have | 921 // immediately after the first layout and paint, but before we have |
| 862 // a chance to revise them. | 922 // a chance to revise them. |
| 863 for (MediaControlElement* element : elements) { | 923 for (MediaControlElement* element : elements) { |
| 864 if (element) | 924 if (element) |
| 865 element->setDoesFit(false); | 925 element->setDoesFit(false); |
| 866 } | 926 } |
| 867 return; | 927 return; |
| 868 } | 928 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 893 MediaControlElement* firstDisplacedElement = nullptr; | 953 MediaControlElement* firstDisplacedElement = nullptr; |
| 894 // For each control that fits, enable it in order of decreasing priority. | 954 // For each control that fits, enable it in order of decreasing priority. |
| 895 for (MediaControlElement* element : elements) { | 955 for (MediaControlElement* element : elements) { |
| 896 if (!element) | 956 if (!element) |
| 897 continue; | 957 continue; |
| 898 int width = minimumWidth; | 958 int width = minimumWidth; |
| 899 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) | 959 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) |
| 900 width += sliderMargin; | 960 width += sliderMargin; |
| 901 element->shouldShowButtonInOverflowMenu(false); | 961 element->shouldShowButtonInOverflowMenu(false); |
| 902 if (element->isWanted()) { | 962 if (element->isWanted()) { |
| 903 if (usedWidth + width <= m_panelWidth) { | 963 if (usedWidth + width <= m_size.width()) { |
| 904 element->setDoesFit(true); | 964 element->setDoesFit(true); |
| 905 usedWidth += width; | 965 usedWidth += width; |
| 906 } else { | 966 } else { |
| 907 element->setDoesFit(false); | 967 element->setDoesFit(false); |
| 908 element->shouldShowButtonInOverflowMenu(true); | 968 element->shouldShowButtonInOverflowMenu(true); |
| 909 if (element->hasOverflowButton()) | 969 if (element->hasOverflowButton()) |
| 910 overflowElements.push_front(element); | 970 overflowElements.push_front(element); |
| 911 // We want a way to access the first media element that was | 971 // We want a way to access the first media element that was |
| 912 // removed. If we don't end up needing an overflow menu, we can | 972 // removed. If we don't end up needing an overflow menu, we can |
| 913 // use the space the overflow menu would have taken up to | 973 // use the space the overflow menu would have taken up to |
| 914 // instead display that media element. | 974 // instead display that media element. |
| 915 if (!element->hasOverflowButton() && !firstDisplacedElement) | 975 if (!element->hasOverflowButton() && !firstDisplacedElement) |
| 916 firstDisplacedElement = element; | 976 firstDisplacedElement = element; |
| 917 } | 977 } |
| 918 } | 978 } |
| 919 } | 979 } |
| 920 | 980 |
| 921 // If we don't have at least two overflow elements, we will not show the | 981 // If we don't have at least two overflow elements, we will not show the |
| 922 // overflow menu. | 982 // overflow menu. |
| 923 if (overflowElements.empty()) { | 983 if (overflowElements.empty()) { |
| 924 m_overflowMenu->setIsWanted(false); | 984 m_overflowMenu->setIsWanted(false); |
| 925 usedWidth -= minimumWidth; | 985 usedWidth -= minimumWidth; |
| 926 if (firstDisplacedElement) { | 986 if (firstDisplacedElement) { |
| 927 int width = minimumWidth; | 987 int width = minimumWidth; |
| 928 if ((firstDisplacedElement == m_timeline.get()) || | 988 if ((firstDisplacedElement == m_timeline.get()) || |
| 929 (firstDisplacedElement == m_volumeSlider.get())) | 989 (firstDisplacedElement == m_volumeSlider.get())) |
| 930 width += sliderMargin; | 990 width += sliderMargin; |
| 931 if (usedWidth + width <= m_panelWidth) | 991 if (usedWidth + width <= m_size.width()) |
| 932 firstDisplacedElement->setDoesFit(true); | 992 firstDisplacedElement->setDoesFit(true); |
| 933 } | 993 } |
| 934 } else if (overflowElements.size() == 1) { | 994 } else if (overflowElements.size() == 1) { |
| 935 m_overflowMenu->setIsWanted(false); | 995 m_overflowMenu->setIsWanted(false); |
| 936 overflowElements.front()->setDoesFit(true); | 996 overflowElements.front()->setDoesFit(true); |
| 937 } | 997 } |
| 998 | |
| 999 // Decide if the overlay play button fits. | |
| 1000 if (m_overlayPlayButton) { | |
| 1001 bool doesFit = m_size.width() >= kMinWidthForOverlayPlayButton && | |
| 1002 m_size.height() >= kMinHeightForOverlayPlayButton; | |
| 1003 m_overlayPlayButton->setDoesFit(doesFit); | |
| 1004 } | |
| 938 } | 1005 } |
| 939 | 1006 |
| 940 void MediaControls::invalidate(Element* element) { | 1007 void MediaControls::invalidate(Element* element) { |
| 941 if (!element) | 1008 if (!element) |
| 942 return; | 1009 return; |
| 943 | 1010 |
| 944 if (LayoutObject* layoutObject = element->layoutObject()) | 1011 if (LayoutObject* layoutObject = element->layoutObject()) |
| 945 layoutObject | 1012 layoutObject |
| 946 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 1013 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| 947 } | 1014 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 971 void MediaControls::hideAllMenus() { | 1038 void MediaControls::hideAllMenus() { |
| 972 m_windowEventListener->stop(); | 1039 m_windowEventListener->stop(); |
| 973 | 1040 |
| 974 if (m_overflowList->isWanted()) | 1041 if (m_overflowList->isWanted()) |
| 975 m_overflowList->setIsWanted(false); | 1042 m_overflowList->setIsWanted(false); |
| 976 if (m_textTrackList->isWanted()) | 1043 if (m_textTrackList->isWanted()) |
| 977 m_textTrackList->setVisible(false); | 1044 m_textTrackList->setVisible(false); |
| 978 } | 1045 } |
| 979 | 1046 |
| 980 DEFINE_TRACE(MediaControls) { | 1047 DEFINE_TRACE(MediaControls) { |
| 1048 visitor->trace(m_resizeObserver); | |
| 981 visitor->trace(m_mediaElement); | 1049 visitor->trace(m_mediaElement); |
| 982 visitor->trace(m_panel); | 1050 visitor->trace(m_panel); |
| 983 visitor->trace(m_overlayPlayButton); | 1051 visitor->trace(m_overlayPlayButton); |
| 984 visitor->trace(m_overlayEnclosure); | 1052 visitor->trace(m_overlayEnclosure); |
| 985 visitor->trace(m_playButton); | 1053 visitor->trace(m_playButton); |
| 986 visitor->trace(m_currentTimeDisplay); | 1054 visitor->trace(m_currentTimeDisplay); |
| 987 visitor->trace(m_timeline); | 1055 visitor->trace(m_timeline); |
| 988 visitor->trace(m_muteButton); | 1056 visitor->trace(m_muteButton); |
| 989 visitor->trace(m_volumeSlider); | 1057 visitor->trace(m_volumeSlider); |
| 990 visitor->trace(m_toggleClosedCaptionsButton); | 1058 visitor->trace(m_toggleClosedCaptionsButton); |
| 991 visitor->trace(m_fullscreenButton); | 1059 visitor->trace(m_fullscreenButton); |
| 992 visitor->trace(m_downloadButton); | 1060 visitor->trace(m_downloadButton); |
| 993 visitor->trace(m_durationDisplay); | 1061 visitor->trace(m_durationDisplay); |
| 994 visitor->trace(m_enclosure); | 1062 visitor->trace(m_enclosure); |
| 995 visitor->trace(m_textTrackList); | 1063 visitor->trace(m_textTrackList); |
| 996 visitor->trace(m_overflowMenu); | 1064 visitor->trace(m_overflowMenu); |
| 997 visitor->trace(m_overflowList); | 1065 visitor->trace(m_overflowList); |
| 998 visitor->trace(m_castButton); | 1066 visitor->trace(m_castButton); |
| 999 visitor->trace(m_overlayCastButton); | 1067 visitor->trace(m_overlayCastButton); |
| 1000 visitor->trace(m_mediaEventListener); | 1068 visitor->trace(m_mediaEventListener); |
| 1001 visitor->trace(m_windowEventListener); | 1069 visitor->trace(m_windowEventListener); |
| 1002 visitor->trace(m_orientationLockDelegate); | 1070 visitor->trace(m_orientationLockDelegate); |
| 1003 HTMLDivElement::trace(visitor); | 1071 HTMLDivElement::trace(visitor); |
| 1004 } | 1072 } |
| 1005 | 1073 |
| 1006 } // namespace blink | 1074 } // namespace blink |
| OLD | NEW |