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 constexpr int kOverlayPlayButtonWidth = 48; | |
| 53 constexpr int kOverlayPlayButtonHeight = 48; | |
| 54 constexpr int kOverlayBottomMargin = 10; | |
| 55 constexpr int kAndroidMediaPanelHeight = 48; | |
| 56 | |
| 57 constexpr int kMinWidthForOverlayPlayButton = kOverlayPlayButtonWidth; | |
| 58 constexpr int kMinHeightForOverlayPlayButton = kOverlayPlayButtonHeight + | |
| 59 (2 * kAndroidMediaPanelHeight) + | |
| 60 (2 * kOverlayBottomMargin); | |
| 61 } // namespace | |
| 62 | |
| 48 // If you change this value, then also update the corresponding value in | 63 // If you change this value, then also update the corresponding value in |
| 49 // LayoutTests/media/media-controls.js. | 64 // LayoutTests/media/media-controls.js. |
| 50 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; | 65 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; |
| 51 | 66 |
| 52 static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) { | 67 static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) { |
| 53 // Unconditionally allow the user to exit fullscreen if we are in it | 68 // Unconditionally allow the user to exit fullscreen if we are in it |
| 54 // now. Especially on android, when we might not yet know if | 69 // now. Especially on android, when we might not yet know if |
| 55 // fullscreen is supported, we sometimes guess incorrectly and show | 70 // fullscreen is supported, we sometimes guess incorrectly and show |
| 56 // the button earlier, and we don't want to remove it here if the | 71 // the button earlier, and we don't want to remove it here if the |
| 57 // user chose to enter fullscreen. crbug.com/500732 . | 72 // user chose to enter fullscreen. crbug.com/500732 . |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 } | 122 } |
| 108 | 123 |
| 109 private: | 124 private: |
| 110 Member<MediaControls> m_controls; | 125 Member<MediaControls> m_controls; |
| 111 static int s_batchDepth; | 126 static int s_batchDepth; |
| 112 }; | 127 }; |
| 113 | 128 |
| 114 // Count of number open batches for controls visibility. | 129 // Count of number open batches for controls visibility. |
| 115 int MediaControls::BatchedControlUpdate::s_batchDepth = 0; | 130 int MediaControls::BatchedControlUpdate::s_batchDepth = 0; |
| 116 | 131 |
| 132 class MediaControls::MediaControlsResizeObserverCallback | |
|
whywhat
2017/02/23 21:37:31
nit: could you add a comment to the forward declar
steimel
2017/02/24 00:42:43
Done.
| |
| 133 : public ResizeObserverCallback { | |
| 134 public: | |
| 135 explicit MediaControlsResizeObserverCallback(MediaControls* controls) | |
| 136 : m_controls(controls) { | |
| 137 DCHECK(controls); | |
| 138 } | |
| 139 ~MediaControlsResizeObserverCallback() override = default; | |
| 140 | |
| 141 void handleEvent(const HeapVector<Member<ResizeObserverEntry>>& entries, | |
| 142 ResizeObserver* observer) override { | |
| 143 DCHECK_EQ(1u, entries.size()); | |
|
whywhat
2017/02/23 21:37:31
nit: DCHECK entries[0]->target() is m_mediaElement
steimel
2017/02/24 00:42:43
Done.
| |
| 144 ClientRect* contentRect = entries[0]->contentRect(); | |
| 145 m_controls->notifyElementSizeChanged(contentRect->width(), | |
| 146 contentRect->height()); | |
| 147 } | |
| 148 | |
| 149 DEFINE_INLINE_TRACE() { | |
| 150 visitor->trace(m_controls); | |
| 151 ResizeObserverCallback::trace(visitor); | |
| 152 } | |
| 153 | |
| 154 private: | |
| 155 Member<MediaControls> m_controls; | |
| 156 }; | |
| 157 | |
| 117 MediaControls::MediaControls(HTMLMediaElement& mediaElement) | 158 MediaControls::MediaControls(HTMLMediaElement& mediaElement) |
| 118 : HTMLDivElement(mediaElement.document()), | 159 : HTMLDivElement(mediaElement.document()), |
| 160 m_resizeObserver(ResizeObserver::create( | |
| 161 mediaElement.document(), | |
| 162 new MediaControlsResizeObserverCallback(this))), | |
| 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), |
| 127 m_currentTimeDisplay(nullptr), | 171 m_currentTimeDisplay(nullptr), |
| 128 m_durationDisplay(nullptr), | 172 m_durationDisplay(nullptr), |
| (...skipping 10 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_elementSizeChangedTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, |
|
whywhat
2017/02/23 21:37:32
rant: I'm sad unspeced is used as a word (however
steimel
2017/02/24 00:42:43
Acknowledged :)
| |
| 150 &mediaElement.document()), | 194 &mediaElement.document()), |
| 151 this, | 195 this, |
| 152 &MediaControls::panelWidthChangedTimerFired), | 196 &MediaControls::elementSizeChangedTimerFired), |
| 153 m_panelWidth(0), | 197 m_elementWidth(0), |
| 154 m_keepShowingUntilTimerFires(false) {} | 198 m_elementHeight(0), |
| 199 m_keepShowingUntilTimerFires(false) { | |
| 200 m_resizeObserver->observe(m_mediaElement); | |
| 201 } | |
| 155 | 202 |
| 156 MediaControls* MediaControls::create(HTMLMediaElement& mediaElement, | 203 MediaControls* MediaControls::create(HTMLMediaElement& mediaElement, |
| 157 ShadowRoot& shadowRoot) { | 204 ShadowRoot& shadowRoot) { |
| 158 MediaControls* controls = new MediaControls(mediaElement); | 205 MediaControls* controls = new MediaControls(mediaElement); |
| 159 controls->setShadowPseudoId(AtomicString("-webkit-media-controls")); | 206 controls->setShadowPseudoId(AtomicString("-webkit-media-controls")); |
| 160 controls->initializeControls(); | 207 controls->initializeControls(); |
| 161 controls->reset(); | 208 controls->reset(); |
| 162 | 209 |
| 163 // Initialize the orientation lock when going fullscreen feature. | 210 // Initialize the orientation lock when going fullscreen feature. |
| 164 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() && | 211 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() && |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 stopHideMediaControlsTimer(); | 828 stopHideMediaControlsTimer(); |
| 782 startHideMediaControlsTimer(); | 829 startHideMediaControlsTimer(); |
| 783 } | 830 } |
| 784 | 831 |
| 785 void MediaControls::onExitedFullscreen() { | 832 void MediaControls::onExitedFullscreen() { |
| 786 m_fullscreenButton->setIsFullscreen(false); | 833 m_fullscreenButton->setIsFullscreen(false); |
| 787 stopHideMediaControlsTimer(); | 834 stopHideMediaControlsTimer(); |
| 788 startHideMediaControlsTimer(); | 835 startHideMediaControlsTimer(); |
| 789 } | 836 } |
| 790 | 837 |
| 791 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) { | 838 void MediaControls::notifyElementSizeChanged(int newWidth, int newHeight) { |
| 792 // Don't bother to do any work if this matches the most recent panel | 839 // Don't bother to do any work if this matches the most recent panel |
| 793 // width, since we're called after layout. | 840 // size, since we're called after layout. |
|
whywhat
2017/02/23 21:37:31
nit: I'm not sure this comment is up-to-date, I do
steimel
2017/02/24 00:42:43
You're right. At some point, I guess that logic wa
| |
| 794 // Note that this code permits a bad frame on resize, since it is | 841 // Note that this code permits a bad frame on resize, since it is |
| 795 // run after the relayout / paint happens. It would be great to improve | 842 // run after the relayout / paint happens. It would be great to improve |
| 796 // this, but it would be even greater to move this code entirely to | 843 // this, but it would be even greater to move this code entirely to |
| 797 // JS and fix it there. | 844 // JS and fix it there. |
| 798 m_panelWidth = newWidth.toInt(); | 845 m_elementWidth = newWidth; |
| 846 m_elementHeight = newHeight; | |
| 847 m_sizingInitialized = true; | |
| 799 | 848 |
| 800 // Adjust for effective zoom. | 849 // Adjust for effective zoom. |
| 801 if (!m_panel->layoutObject() || !m_panel->layoutObject()->style()) | 850 if (!m_panel->layoutObject() || !m_panel->layoutObject()->style()) |
| 802 return; | 851 return; |
| 803 m_panelWidth = | |
| 804 ceil(m_panelWidth / m_panel->layoutObject()->style()->effectiveZoom()); | |
| 805 | 852 |
| 806 m_panelWidthChangedTimer.startOneShot(0, BLINK_FROM_HERE); | 853 m_elementWidth = |
|
whywhat
2017/02/23 21:37:31
is it still the element's width or panel's width a
steimel
2017/02/24 00:42:43
Those are both good points. For the first, I've ch
| |
| 854 ceil(m_elementWidth / m_panel->layoutObject()->style()->effectiveZoom()); | |
| 855 | |
| 856 m_elementSizeChangedTimer.startOneShot(0, BLINK_FROM_HERE); | |
| 807 } | 857 } |
| 808 | 858 |
| 809 void MediaControls::panelWidthChangedTimerFired(TimerBase*) { | 859 void MediaControls::elementSizeChangedTimerFired(TimerBase*) { |
| 810 computeWhichControlsFit(); | 860 computeWhichControlsFit(); |
| 811 } | 861 } |
| 812 | 862 |
| 813 void MediaControls::computeWhichControlsFit() { | 863 void MediaControls::computeWhichControlsFit() { |
| 814 // Hide all controls that don't fit, and show the ones that do. | 864 // Hide all controls that don't fit, and show the ones that do. |
| 815 // This might be better suited for a layout, but since JS media controls | 865 // This might be better suited for a layout, but since JS media controls |
| 816 // won't benefit from that anwyay, we just do it here like JS will. | 866 // won't benefit from that anwyay, we just do it here like JS will. |
| 817 | 867 |
| 818 // Controls that we'll hide / show, in order of decreasing priority. | 868 // Controls that we'll hide / show, in order of decreasing priority. |
| 819 MediaControlElement* elements[] = { | 869 MediaControlElement* elements[] = { |
| 820 // Exclude m_overflowMenu; we handle it specially. | 870 // Exclude m_overflowMenu; we handle it specially. |
| 821 m_playButton.get(), | 871 m_playButton.get(), |
| 822 m_fullscreenButton.get(), | 872 m_fullscreenButton.get(), |
| 823 m_downloadButton.get(), | 873 m_downloadButton.get(), |
| 824 m_timeline.get(), | 874 m_timeline.get(), |
| 825 m_muteButton.get(), | 875 m_muteButton.get(), |
| 826 m_volumeSlider.get(), | 876 m_volumeSlider.get(), |
| 827 m_toggleClosedCaptionsButton.get(), | 877 m_toggleClosedCaptionsButton.get(), |
| 828 m_castButton.get(), | 878 m_castButton.get(), |
| 829 m_currentTimeDisplay.get(), | 879 m_currentTimeDisplay.get(), |
| 830 m_durationDisplay.get(), | 880 m_durationDisplay.get(), |
| 831 }; | 881 }; |
| 832 | 882 |
| 833 // TODO(mlamouri): we need a more dynamic way to find out the width of an | 883 // TODO(mlamouri): we need a more dynamic way to find out the width of an |
| 834 // element. | 884 // element. |
| 835 const int sliderMargin = 36; // Sliders have 18px margin on each side. | 885 const int sliderMargin = 36; // Sliders have 18px margin on each side. |
| 836 | 886 |
| 837 if (!m_panelWidth) { | 887 if (!m_elementWidth) { |
| 838 // No layout yet -- hide everything, then make them show up later. | 888 // No layout yet -- hide everything, then make them show up later. |
| 839 // This prevents the wrong controls from being shown briefly | 889 // This prevents the wrong controls from being shown briefly |
| 840 // immediately after the first layout and paint, but before we have | 890 // immediately after the first layout and paint, but before we have |
| 841 // a chance to revise them. | 891 // a chance to revise them. |
| 842 for (MediaControlElement* element : elements) { | 892 for (MediaControlElement* element : elements) { |
| 843 if (element) | 893 if (element) |
| 844 element->setDoesFit(false); | 894 element->setDoesFit(false); |
| 845 } | 895 } |
| 846 return; | 896 return; |
| 847 } | 897 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 872 MediaControlElement* firstDisplacedElement = nullptr; | 922 MediaControlElement* firstDisplacedElement = nullptr; |
| 873 // For each control that fits, enable it in order of decreasing priority. | 923 // For each control that fits, enable it in order of decreasing priority. |
| 874 for (MediaControlElement* element : elements) { | 924 for (MediaControlElement* element : elements) { |
| 875 if (!element) | 925 if (!element) |
| 876 continue; | 926 continue; |
| 877 int width = minimumWidth; | 927 int width = minimumWidth; |
| 878 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) | 928 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) |
| 879 width += sliderMargin; | 929 width += sliderMargin; |
| 880 element->shouldShowButtonInOverflowMenu(false); | 930 element->shouldShowButtonInOverflowMenu(false); |
| 881 if (element->isWanted()) { | 931 if (element->isWanted()) { |
| 882 if (usedWidth + width <= m_panelWidth) { | 932 if (usedWidth + width <= m_elementWidth) { |
| 883 element->setDoesFit(true); | 933 element->setDoesFit(true); |
| 884 usedWidth += width; | 934 usedWidth += width; |
| 885 } else { | 935 } else { |
| 886 element->setDoesFit(false); | 936 element->setDoesFit(false); |
| 887 element->shouldShowButtonInOverflowMenu(true); | 937 element->shouldShowButtonInOverflowMenu(true); |
| 888 if (element->hasOverflowButton()) | 938 if (element->hasOverflowButton()) |
| 889 overflowElements.push_front(element); | 939 overflowElements.push_front(element); |
| 890 // We want a way to access the first media element that was | 940 // We want a way to access the first media element that was |
| 891 // removed. If we don't end up needing an overflow menu, we can | 941 // removed. If we don't end up needing an overflow menu, we can |
| 892 // use the space the overflow menu would have taken up to | 942 // use the space the overflow menu would have taken up to |
| 893 // instead display that media element. | 943 // instead display that media element. |
| 894 if (!element->hasOverflowButton() && !firstDisplacedElement) | 944 if (!element->hasOverflowButton() && !firstDisplacedElement) |
| 895 firstDisplacedElement = element; | 945 firstDisplacedElement = element; |
| 896 } | 946 } |
| 897 } | 947 } |
| 898 } | 948 } |
| 899 | 949 |
| 900 // If we don't have at least two overflow elements, we will not show the | 950 // If we don't have at least two overflow elements, we will not show the |
| 901 // overflow menu. | 951 // overflow menu. |
| 902 if (overflowElements.empty()) { | 952 if (overflowElements.empty()) { |
| 903 m_overflowMenu->setIsWanted(false); | 953 m_overflowMenu->setIsWanted(false); |
| 904 usedWidth -= minimumWidth; | 954 usedWidth -= minimumWidth; |
| 905 if (firstDisplacedElement) { | 955 if (firstDisplacedElement) { |
| 906 int width = minimumWidth; | 956 int width = minimumWidth; |
| 907 if ((firstDisplacedElement == m_timeline.get()) || | 957 if ((firstDisplacedElement == m_timeline.get()) || |
| 908 (firstDisplacedElement == m_volumeSlider.get())) | 958 (firstDisplacedElement == m_volumeSlider.get())) |
| 909 width += sliderMargin; | 959 width += sliderMargin; |
| 910 if (usedWidth + width <= m_panelWidth) | 960 if (usedWidth + width <= m_elementWidth) |
| 911 firstDisplacedElement->setDoesFit(true); | 961 firstDisplacedElement->setDoesFit(true); |
| 912 } | 962 } |
| 913 } else if (overflowElements.size() == 1) { | 963 } else if (overflowElements.size() == 1) { |
| 914 m_overflowMenu->setIsWanted(false); | 964 m_overflowMenu->setIsWanted(false); |
| 915 overflowElements.front()->setDoesFit(true); | 965 overflowElements.front()->setDoesFit(true); |
| 916 } | 966 } |
| 967 | |
| 968 // Decide if the overlay play button fits. | |
| 969 if (m_elementWidth && m_elementHeight && m_overlayPlayButton) { | |
| 970 bool doesFit = m_elementWidth >= kMinWidthForOverlayPlayButton && | |
| 971 m_elementHeight >= kMinHeightForOverlayPlayButton; | |
| 972 m_overlayPlayButton->setDoesFit(doesFit); | |
| 973 } | |
| 917 } | 974 } |
| 918 | 975 |
| 919 void MediaControls::invalidate(Element* element) { | 976 void MediaControls::invalidate(Element* element) { |
| 920 if (!element) | 977 if (!element) |
| 921 return; | 978 return; |
| 922 | 979 |
| 923 if (LayoutObject* layoutObject = element->layoutObject()) | 980 if (LayoutObject* layoutObject = element->layoutObject()) |
| 924 layoutObject | 981 layoutObject |
| 925 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 982 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| 926 } | 983 } |
| 927 | 984 |
| 928 void MediaControls::networkStateChanged() { | 985 void MediaControls::networkStateChanged() { |
| 929 invalidate(m_playButton); | 986 invalidate(m_playButton); |
| 930 invalidate(m_overlayPlayButton); | 987 invalidate(m_overlayPlayButton); |
| 931 invalidate(m_muteButton); | 988 invalidate(m_muteButton); |
| 932 invalidate(m_fullscreenButton); | 989 invalidate(m_fullscreenButton); |
| 933 invalidate(m_downloadButton); | 990 invalidate(m_downloadButton); |
| 934 invalidate(m_timeline); | 991 invalidate(m_timeline); |
| 935 invalidate(m_volumeSlider); | 992 invalidate(m_volumeSlider); |
| 936 } | 993 } |
| 937 | 994 |
| 995 void MediaControls::onLayout(int width, int height) { | |
| 996 if (!m_sizingInitialized) { | |
|
whywhat
2017/02/23 21:37:31
nit: no need for {}
I wish we could somehow reque
steimel
2017/02/24 00:42:43
Right. I had tried to initialize in the ctor (and
| |
| 997 notifyElementSizeChanged(width, height); | |
| 998 } | |
| 999 } | |
| 1000 | |
| 938 bool MediaControls::overflowMenuVisible() { | 1001 bool MediaControls::overflowMenuVisible() { |
| 939 return m_overflowList ? m_overflowList->isWanted() : false; | 1002 return m_overflowList ? m_overflowList->isWanted() : false; |
| 940 } | 1003 } |
| 941 | 1004 |
| 942 void MediaControls::toggleOverflowMenu() { | 1005 void MediaControls::toggleOverflowMenu() { |
| 943 DCHECK(m_overflowList); | 1006 DCHECK(m_overflowList); |
| 944 | 1007 |
| 945 if (!m_overflowList->isWanted()) | 1008 if (!m_overflowList->isWanted()) |
| 946 m_windowEventListener->start(); | 1009 m_windowEventListener->start(); |
| 947 m_overflowList->setIsWanted(!m_overflowList->isWanted()); | 1010 m_overflowList->setIsWanted(!m_overflowList->isWanted()); |
| 948 } | 1011 } |
| 949 | 1012 |
| 950 void MediaControls::hideAllMenus() { | 1013 void MediaControls::hideAllMenus() { |
| 951 m_windowEventListener->stop(); | 1014 m_windowEventListener->stop(); |
| 952 | 1015 |
| 953 if (m_overflowList->isWanted()) | 1016 if (m_overflowList->isWanted()) |
| 954 m_overflowList->setIsWanted(false); | 1017 m_overflowList->setIsWanted(false); |
| 955 if (m_textTrackList->isWanted()) | 1018 if (m_textTrackList->isWanted()) |
| 956 m_textTrackList->setVisible(false); | 1019 m_textTrackList->setVisible(false); |
| 957 } | 1020 } |
| 958 | 1021 |
| 959 DEFINE_TRACE(MediaControls) { | 1022 DEFINE_TRACE(MediaControls) { |
| 1023 visitor->trace(m_resizeObserver); | |
| 960 visitor->trace(m_mediaElement); | 1024 visitor->trace(m_mediaElement); |
| 961 visitor->trace(m_panel); | 1025 visitor->trace(m_panel); |
| 962 visitor->trace(m_overlayPlayButton); | 1026 visitor->trace(m_overlayPlayButton); |
| 963 visitor->trace(m_overlayEnclosure); | 1027 visitor->trace(m_overlayEnclosure); |
| 964 visitor->trace(m_playButton); | 1028 visitor->trace(m_playButton); |
| 965 visitor->trace(m_currentTimeDisplay); | 1029 visitor->trace(m_currentTimeDisplay); |
| 966 visitor->trace(m_timeline); | 1030 visitor->trace(m_timeline); |
| 967 visitor->trace(m_muteButton); | 1031 visitor->trace(m_muteButton); |
| 968 visitor->trace(m_volumeSlider); | 1032 visitor->trace(m_volumeSlider); |
| 969 visitor->trace(m_toggleClosedCaptionsButton); | 1033 visitor->trace(m_toggleClosedCaptionsButton); |
| 970 visitor->trace(m_fullscreenButton); | 1034 visitor->trace(m_fullscreenButton); |
| 971 visitor->trace(m_downloadButton); | 1035 visitor->trace(m_downloadButton); |
| 972 visitor->trace(m_durationDisplay); | 1036 visitor->trace(m_durationDisplay); |
| 973 visitor->trace(m_enclosure); | 1037 visitor->trace(m_enclosure); |
| 974 visitor->trace(m_textTrackList); | 1038 visitor->trace(m_textTrackList); |
| 975 visitor->trace(m_overflowMenu); | 1039 visitor->trace(m_overflowMenu); |
| 976 visitor->trace(m_overflowList); | 1040 visitor->trace(m_overflowList); |
| 977 visitor->trace(m_castButton); | 1041 visitor->trace(m_castButton); |
| 978 visitor->trace(m_overlayCastButton); | 1042 visitor->trace(m_overlayCastButton); |
| 979 visitor->trace(m_mediaEventListener); | 1043 visitor->trace(m_mediaEventListener); |
| 980 visitor->trace(m_windowEventListener); | 1044 visitor->trace(m_windowEventListener); |
| 981 visitor->trace(m_orientationLockDelegate); | 1045 visitor->trace(m_orientationLockDelegate); |
| 982 HTMLDivElement::trace(visitor); | 1046 HTMLDivElement::trace(visitor); |
| 983 } | 1047 } |
| 984 | 1048 |
| 985 } // namespace blink | 1049 } // namespace blink |
| OLD | NEW |