Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 943333003: Remove HTMLMediaElement::hasMediaControls() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 821
822 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above 822 // FIXME: Investigate whether these can be moved into m_networkState != NETW ORK_EMPTY block above
823 // so they are closer to the relevant spec steps. 823 // so they are closer to the relevant spec steps.
824 m_lastSeekTime = 0; 824 m_lastSeekTime = 0;
825 m_duration = std::numeric_limits<double>::quiet_NaN(); 825 m_duration = std::numeric_limits<double>::quiet_NaN();
826 826
827 // The spec doesn't say to block the load event until we actually run the as ynchronous section 827 // The spec doesn't say to block the load event until we actually run the as ynchronous section
828 // algorithm, but do it now because we won't start that until after the time r fires and the 828 // algorithm, but do it now because we won't start that until after the time r fires and the
829 // event may have already fired by then. 829 // event may have already fired by then.
830 setShouldDelayLoadEvent(true); 830 setShouldDelayLoadEvent(true);
831 if (hasMediaControls()) 831 if (mediaControls())
832 mediaControls()->reset(); 832 mediaControls()->reset();
833 } 833 }
834 834
835 void HTMLMediaElement::loadInternal() 835 void HTMLMediaElement::loadInternal()
836 { 836 {
837 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the 837 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the
838 // disabled state when the element's resource selection algorithm last start ed". 838 // disabled state when the element's resource selection algorithm last start ed".
839 m_textTracksWhenResourceSelectionBegan.clear(); 839 m_textTracksWhenResourceSelectionBegan.clear();
840 if (m_textTracks) { 840 if (m_textTracks) {
841 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 841 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1137
1138 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track) 1138 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track)
1139 { 1139 {
1140 if (webMediaPlayer()&& m_textTracksWhenResourceSelectionBegan.contains(track )) { 1140 if (webMediaPlayer()&& m_textTracksWhenResourceSelectionBegan.contains(track )) {
1141 if (track->readinessState() != TextTrack::Loading) 1141 if (track->readinessState() != TextTrack::Loading)
1142 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState() )); 1142 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState() ));
1143 } else { 1143 } else {
1144 // The track readiness state might have changed as a result of the user 1144 // The track readiness state might have changed as a result of the user
1145 // clicking the captions button. In this case, a check whether all the 1145 // clicking the captions button. In this case, a check whether all the
1146 // resources have failed loading should be done in order to hide the CC button. 1146 // resources have failed loading should be done in order to hide the CC button.
1147 if (hasMediaControls() && track->readinessState() == TextTrack::FailedTo Load) 1147 if (mediaControls() && track->readinessState() == TextTrack::FailedToLoa d)
1148 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1148 mediaControls()->refreshClosedCaptionsButtonVisibility();
1149 } 1149 }
1150 } 1150 }
1151 1151
1152 void HTMLMediaElement::textTrackModeChanged(TextTrack* track) 1152 void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
1153 { 1153 {
1154 if (track->trackType() == TextTrack::TrackElement) { 1154 if (track->trackType() == TextTrack::TrackElement) {
1155 // 4.8.10.12.3 Sourcing out-of-band text tracks 1155 // 4.8.10.12.3 Sourcing out-of-band text tracks
1156 // ... when a text track corresponding to a track element is created wit h text track 1156 // ... when a text track corresponding to a track element is created wit h text track
1157 // mode set to disabled and subsequently changes its text track mode to hidden, showing, 1157 // mode set to disabled and subsequently changes its text track mode to hidden, showing,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) 1367 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA)
1368 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); 1368 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK));
1369 else if (error == WebMediaPlayer::NetworkStateDecodeError) 1369 else if (error == WebMediaPlayer::NetworkStateDecodeError)
1370 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); 1370 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE));
1371 else if ((error == WebMediaPlayer::NetworkStateFormatError 1371 else if ((error == WebMediaPlayer::NetworkStateFormatError
1372 || error == WebMediaPlayer::NetworkStateNetworkError) 1372 || error == WebMediaPlayer::NetworkStateNetworkError)
1373 && m_loadState == LoadingFromSrcAttr) 1373 && m_loadState == LoadingFromSrcAttr)
1374 noneSupported(); 1374 noneSupported();
1375 1375
1376 updateDisplayState(); 1376 updateDisplayState();
1377 if (hasMediaControls()) 1377 if (mediaControls())
1378 mediaControls()->reset(); 1378 mediaControls()->reset();
1379 } 1379 }
1380 1380
1381 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) 1381 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state)
1382 { 1382 {
1383 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is %d", this, static_cast<int>(state), static_cast<int>(m_networkState)); 1383 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is %d", this, static_cast<int>(state), static_cast<int>(m_networkState));
1384 1384
1385 if (state == WebMediaPlayer::NetworkStateEmpty) { 1385 if (state == WebMediaPlayer::NetworkStateEmpty) {
1386 // Just update the cached state and leave, we can't do anything. 1386 // Just update the cached state and leave, we can't do anything.
1387 m_networkState = NETWORK_EMPTY; 1387 m_networkState = NETWORK_EMPTY;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 jumped = true; 1520 jumped = true;
1521 } 1521 }
1522 1522
1523 if (m_mediaController) { 1523 if (m_mediaController) {
1524 if (jumped && initialPlaybackPosition > m_mediaController->currentTi me()) 1524 if (jumped && initialPlaybackPosition > m_mediaController->currentTi me())
1525 m_mediaController->setCurrentTime(initialPlaybackPosition); 1525 m_mediaController->setCurrentTime(initialPlaybackPosition);
1526 else 1526 else
1527 seek(m_mediaController->currentTime()); 1527 seek(m_mediaController->currentTime());
1528 } 1528 }
1529 1529
1530 if (hasMediaControls()) 1530 if (mediaControls())
1531 mediaControls()->reset(); 1531 mediaControls()->reset();
1532 if (renderer()) 1532 if (renderer())
1533 renderer()->updateFromElement(); 1533 renderer()->updateFromElement();
1534 } 1534 }
1535 1535
1536 bool shouldUpdateDisplayState = false; 1536 bool shouldUpdateDisplayState = false;
1537 1537
1538 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { 1538 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) {
1539 m_haveFiredLoadedData = true; 1539 m_haveFiredLoadedData = true;
1540 shouldUpdateDisplayState = true; 1540 shouldUpdateDisplayState = true;
(...skipping 26 matching lines...) Expand all
1567 } 1567 }
1568 } 1568 }
1569 1569
1570 scheduleEvent(EventTypeNames::canplaythrough); 1570 scheduleEvent(EventTypeNames::canplaythrough);
1571 1571
1572 shouldUpdateDisplayState = true; 1572 shouldUpdateDisplayState = true;
1573 } 1573 }
1574 1574
1575 if (shouldUpdateDisplayState) { 1575 if (shouldUpdateDisplayState) {
1576 updateDisplayState(); 1576 updateDisplayState();
1577 if (hasMediaControls()) 1577 if (mediaControls())
1578 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1578 mediaControls()->refreshClosedCaptionsButtonVisibility();
1579 } 1579 }
1580 1580
1581 updatePlayState(); 1581 updatePlayState();
1582 updateMediaController(); 1582 updateMediaController();
1583 cueTimeline().updateActiveCues(currentTime()); 1583 cueTimeline().updateActiveCues(currentTime());
1584 } 1584 }
1585 1585
1586 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1586 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1587 { 1587 {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 updateVolume(); 2110 updateVolume();
2111 2111
2112 scheduleEvent(EventTypeNames::volumechange); 2112 scheduleEvent(EventTypeNames::volumechange);
2113 } 2113 }
2114 2114
2115 void HTMLMediaElement::updateVolume() 2115 void HTMLMediaElement::updateVolume()
2116 { 2116 {
2117 if (webMediaPlayer()) 2117 if (webMediaPlayer())
2118 webMediaPlayer()->setVolume(effectiveMediaVolume()); 2118 webMediaPlayer()->setVolume(effectiveMediaVolume());
2119 2119
2120 if (hasMediaControls()) 2120 if (mediaControls())
2121 mediaControls()->updateVolume(); 2121 mediaControls()->updateVolume();
2122 } 2122 }
2123 2123
2124 double HTMLMediaElement::effectiveMediaVolume() const 2124 double HTMLMediaElement::effectiveMediaVolume() const
2125 { 2125 {
2126 if (m_muted) 2126 if (m_muted)
2127 return 0; 2127 return 0;
2128 2128
2129 if (m_mediaController && m_mediaController->muted()) 2129 if (m_mediaController && m_mediaController->muted())
2130 return 0; 2130 return 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 pause(); 2162 pause();
2163 } 2163 }
2164 } 2164 }
2165 2165
2166 if (!m_seeking) 2166 if (!m_seeking)
2167 scheduleTimeupdateEvent(true); 2167 scheduleTimeupdateEvent(true);
2168 2168
2169 if (!effectivePlaybackRate()) 2169 if (!effectivePlaybackRate())
2170 return; 2170 return;
2171 2171
2172 if (!m_paused && hasMediaControls()) 2172 if (!m_paused && mediaControls())
2173 mediaControls()->playbackProgressed(); 2173 mediaControls()->playbackProgressed();
2174 2174
2175 cueTimeline().updateActiveCues(currentTime()); 2175 cueTimeline().updateActiveCues(currentTime());
2176 } 2176 }
2177 2177
2178 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) 2178 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent)
2179 { 2179 {
2180 double now = WTF::currentTime(); 2180 double now = WTF::currentTime();
2181 double movieTime = currentTime(); 2181 double movieTime = currentTime();
2182 2182
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 // passed to mediaPlayerDidAddTextTrack. 2362 // passed to mediaPlayerDidAddTextTrack.
2363 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); 2363 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client());
2364 if (!textTrack) 2364 if (!textTrack)
2365 return; 2365 return;
2366 2366
2367 removeTextTrack(textTrack.get()); 2367 removeTextTrack(textTrack.get());
2368 } 2368 }
2369 2369
2370 void HTMLMediaElement::textTracksChanged() 2370 void HTMLMediaElement::textTracksChanged()
2371 { 2371 {
2372 if (hasMediaControls()) 2372 if (mediaControls())
2373 mediaControls()->refreshClosedCaptionsButtonVisibility(); 2373 mediaControls()->refreshClosedCaptionsButtonVisibility();
2374 } 2374 }
2375 2375
2376 void HTMLMediaElement::addTextTrack(TextTrack* track) 2376 void HTMLMediaElement::addTextTrack(TextTrack* track)
2377 { 2377 {
2378 textTracks()->append(track); 2378 textTracks()->append(track);
2379 2379
2380 textTracksChanged(); 2380 textTracksChanged();
2381 } 2381 }
2382 2382
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 2763 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek);
2764 2764
2765 // Abort if duration unchanged. 2765 // Abort if duration unchanged.
2766 if (m_duration == duration) 2766 if (m_duration == duration)
2767 return; 2767 return;
2768 2768
2769 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); 2769 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration);
2770 m_duration = duration; 2770 m_duration = duration;
2771 scheduleEvent(EventTypeNames::durationchange); 2771 scheduleEvent(EventTypeNames::durationchange);
2772 2772
2773 if (hasMediaControls()) 2773 if (mediaControls())
2774 mediaControls()->reset(); 2774 mediaControls()->reset();
2775 if (renderer()) 2775 if (renderer())
2776 renderer()->updateFromElement(); 2776 renderer()->updateFromElement();
2777 2777
2778 if (requestSeek) 2778 if (requestSeek)
2779 seek(duration); 2779 seek(duration);
2780 } 2780 }
2781 2781
2782 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2782 void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
2783 { 2783 {
(...skipping 25 matching lines...) Expand all
2809 if (m_mediaController) { 2809 if (m_mediaController) {
2810 m_mediaController->setCurrentTime(time); 2810 m_mediaController->setCurrentTime(time);
2811 return; 2811 return;
2812 } 2812 }
2813 setCurrentTime(time, ASSERT_NO_EXCEPTION); 2813 setCurrentTime(time, ASSERT_NO_EXCEPTION);
2814 } 2814 }
2815 2815
2816 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) 2816 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable)
2817 { 2817 {
2818 m_remoteRoutesAvailable = routesAvailable; 2818 m_remoteRoutesAvailable = routesAvailable;
2819 if (hasMediaControls()) 2819 if (mediaControls())
2820 mediaControls()->refreshCastButtonVisibility(); 2820 mediaControls()->refreshCastButtonVisibility();
2821 } 2821 }
2822 2822
2823 void HTMLMediaElement::connectedToRemoteDevice() 2823 void HTMLMediaElement::connectedToRemoteDevice()
2824 { 2824 {
2825 m_playingRemotely = true; 2825 m_playingRemotely = true;
2826 if (hasMediaControls()) 2826 if (mediaControls())
2827 mediaControls()->startedCasting(); 2827 mediaControls()->startedCasting();
2828 } 2828 }
2829 2829
2830 void HTMLMediaElement::disconnectedFromRemoteDevice() 2830 void HTMLMediaElement::disconnectedFromRemoteDevice()
2831 { 2831 {
2832 m_playingRemotely = false; 2832 m_playingRemotely = false;
2833 if (hasMediaControls()) 2833 if (mediaControls())
2834 mediaControls()->stoppedCasting(); 2834 mediaControls()->stoppedCasting();
2835 } 2835 }
2836 2836
2837 // MediaPlayerPresentation methods 2837 // MediaPlayerPresentation methods
2838 void HTMLMediaElement::mediaPlayerRepaint() 2838 void HTMLMediaElement::mediaPlayerRepaint()
2839 { 2839 {
2840 if (m_webLayer) 2840 if (m_webLayer)
2841 m_webLayer->invalidate(); 2841 m_webLayer->invalidate();
2842 2842
2843 updateDisplayState(); 2843 updateDisplayState();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 invalidateCachedTime(); 2960 invalidateCachedTime();
2961 2961
2962 if (!isPlaying) { 2962 if (!isPlaying) {
2963 // Set rate, muted before calling play in case they were set before the media engine was setup. 2963 // Set rate, muted before calling play in case they were set before the media engine was setup.
2964 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 2964 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
2965 webMediaPlayer()->setRate(effectivePlaybackRate()); 2965 webMediaPlayer()->setRate(effectivePlaybackRate());
2966 updateVolume(); 2966 updateVolume();
2967 webMediaPlayer()->play(); 2967 webMediaPlayer()->play();
2968 } 2968 }
2969 2969
2970 if (hasMediaControls()) 2970 if (mediaControls())
2971 mediaControls()->playbackStarted(); 2971 mediaControls()->playbackStarted();
2972 startPlaybackProgressTimer(); 2972 startPlaybackProgressTimer();
2973 m_playing = true; 2973 m_playing = true;
2974 2974
2975 } else { // Should not be playing right now 2975 } else { // Should not be playing right now
2976 if (isPlaying) 2976 if (isPlaying)
2977 webMediaPlayer()->pause(); 2977 webMediaPlayer()->pause();
2978 refreshCachedTime(); 2978 refreshCachedTime();
2979 2979
2980 m_playbackProgressTimer.stop(); 2980 m_playbackProgressTimer.stop();
2981 m_playing = false; 2981 m_playing = false;
2982 double time = currentTime(); 2982 double time = currentTime();
2983 if (time > m_lastSeekTime) 2983 if (time > m_lastSeekTime)
2984 addPlayedRange(m_lastSeekTime, time); 2984 addPlayedRange(m_lastSeekTime, time);
2985 2985
2986 if (couldPlayIfEnoughData()) 2986 if (couldPlayIfEnoughData())
2987 prepareToPlay(); 2987 prepareToPlay();
2988 2988
2989 if (hasMediaControls()) 2989 if (mediaControls())
2990 mediaControls()->playbackStopped(); 2990 mediaControls()->playbackStopped();
2991 } 2991 }
2992 2992
2993 updateMediaController(); 2993 updateMediaController();
2994 2994
2995 if (renderer()) 2995 if (renderer())
2996 renderer()->updateFromElement(); 2996 renderer()->updateFromElement();
2997 } 2997 }
2998 2998
2999 void HTMLMediaElement::stopPeriodicTimers() 2999 void HTMLMediaElement::stopPeriodicTimers()
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 3070
3071 stopPeriodicTimers(); 3071 stopPeriodicTimers();
3072 m_loadTimer.stop(); 3072 m_loadTimer.stop();
3073 3073
3074 m_pendingActionFlags &= ~flags; 3074 m_pendingActionFlags &= ~flags;
3075 m_loadState = WaitingForSource; 3075 m_loadState = WaitingForSource;
3076 3076
3077 // We can't cast if we don't have a media player. 3077 // We can't cast if we don't have a media player.
3078 m_remoteRoutesAvailable = false; 3078 m_remoteRoutesAvailable = false;
3079 m_playingRemotely = false; 3079 m_playingRemotely = false;
3080 if (hasMediaControls()) { 3080 if (mediaControls())
3081 mediaControls()->refreshCastButtonVisibility(); 3081 mediaControls()->refreshCastButtonVisibility();
3082 }
3083 3082
3084 if (m_textTracks) 3083 if (m_textTracks)
3085 configureTextTrackDisplay(AssumeNoVisibleChange); 3084 configureTextTrackDisplay(AssumeNoVisibleChange);
3086 } 3085 }
3087 3086
3088 void HTMLMediaElement::stop() 3087 void HTMLMediaElement::stop()
3089 { 3088 {
3090 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); 3089 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this);
3091 3090
3092 if (m_playing && m_initialPlayWithoutUserGestures) 3091 if (m_playing && m_initialPlayWithoutUserGestures)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 3167
3169 void HTMLMediaElement::exitFullscreen() 3168 void HTMLMediaElement::exitFullscreen()
3170 { 3169 {
3171 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen(%p)", this); 3170 WTF_LOG(Media, "HTMLMediaElement::exitFullscreen(%p)", this);
3172 3171
3173 Fullscreen::from(document()).exitFullscreen(); 3172 Fullscreen::from(document()).exitFullscreen();
3174 } 3173 }
3175 3174
3176 void HTMLMediaElement::didBecomeFullscreenElement() 3175 void HTMLMediaElement::didBecomeFullscreenElement()
3177 { 3176 {
3178 if (hasMediaControls()) 3177 if (mediaControls())
3179 mediaControls()->enteredFullscreen(); 3178 mediaControls()->enteredFullscreen();
3180 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl ement()) 3179 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl ement())
3181 document().renderView()->compositor()->setNeedsCompositingUpdate(Composi tingUpdateRebuildTree); 3180 document().renderView()->compositor()->setNeedsCompositingUpdate(Composi tingUpdateRebuildTree);
3182 } 3181 }
3183 3182
3184 void HTMLMediaElement::willStopBeingFullscreenElement() 3183 void HTMLMediaElement::willStopBeingFullscreenElement()
3185 { 3184 {
3186 if (hasMediaControls()) 3185 if (mediaControls())
3187 mediaControls()->exitedFullscreen(); 3186 mediaControls()->exitedFullscreen();
3188 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl ement()) 3187 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl ement())
3189 document().renderView()->compositor()->setNeedsCompositingUpdate(Composi tingUpdateRebuildTree); 3188 document().renderView()->compositor()->setNeedsCompositingUpdate(Composi tingUpdateRebuildTree);
3190 } 3189 }
3191 3190
3192 blink::WebLayer* HTMLMediaElement::platformLayer() const 3191 blink::WebLayer* HTMLMediaElement::platformLayer() const
3193 { 3192 {
3194 return m_webLayer; 3193 return m_webLayer;
3195 } 3194 }
3196 3195
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 m_shouldDelayLoadEvent = shouldDelay; 3287 m_shouldDelayLoadEvent = shouldDelay;
3289 if (shouldDelay) 3288 if (shouldDelay)
3290 document().incrementLoadEventDelayCount(); 3289 document().incrementLoadEventDelayCount();
3291 else 3290 else
3292 document().decrementLoadEventDelayCount(); 3291 document().decrementLoadEventDelayCount();
3293 } 3292 }
3294 3293
3295 3294
3296 MediaControls* HTMLMediaElement::mediaControls() const 3295 MediaControls* HTMLMediaElement::mediaControls() const
3297 { 3296 {
3298 return toMediaControls(closedShadowRoot()->firstChild()); 3297 if (ShadowRoot* shadowRoot = closedShadowRoot()) {
3299 } 3298 // Note that |shadowRoot->firstChild()| may be null.
3300 3299 return toMediaControls(shadowRoot->firstChild());
3301 bool HTMLMediaElement::hasMediaControls() const
3302 {
3303 if (ShadowRoot* userAgent = closedShadowRoot()) {
3304 Node* node = userAgent->firstChild();
3305 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isMediaControls());
3306 return node;
3307 } 3300 }
3308 3301
3309 return false; 3302 return nullptr;
3310 } 3303 }
3311 3304
3312 void HTMLMediaElement::ensureMediaControls() 3305 void HTMLMediaElement::ensureMediaControls()
3313 { 3306 {
3314 if (hasMediaControls()) 3307 if (mediaControls())
3315 return; 3308 return;
3316 3309
3317 RefPtrWillBeRawPtr<MediaControls> mediaControls = MediaControls::create(*thi s); 3310 RefPtrWillBeRawPtr<MediaControls> mediaControls = MediaControls::create(*thi s);
3318 3311
3319 mediaControls->reset(); 3312 mediaControls->reset();
3320 if (isFullscreen()) 3313 if (isFullscreen())
3321 mediaControls->enteredFullscreen(); 3314 mediaControls->enteredFullscreen();
3322 3315
3323 ensureClosedShadowRoot().appendChild(mediaControls); 3316 ensureClosedShadowRoot().appendChild(mediaControls);
3324 3317
3325 if (!shouldShowControls() || !inDocument()) 3318 if (!shouldShowControls() || !inDocument())
3326 mediaControls->hide(); 3319 mediaControls->hide();
3327 } 3320 }
3328 3321
3329 void HTMLMediaElement::configureMediaControls() 3322 void HTMLMediaElement::configureMediaControls()
3330 { 3323 {
3331 if (!inDocument()) { 3324 if (!inDocument()) {
3332 if (hasMediaControls()) 3325 if (mediaControls())
3333 mediaControls()->hide(); 3326 mediaControls()->hide();
3334 return; 3327 return;
3335 } 3328 }
3336 3329
3337 ensureMediaControls(); 3330 ensureMediaControls();
3338 mediaControls()->reset(); 3331 mediaControls()->reset();
3339 if (shouldShowControls()) 3332 if (shouldShowControls())
3340 mediaControls()->show(); 3333 mediaControls()->show();
3341 else 3334 else
3342 mediaControls()->hide(); 3335 mediaControls()->hide();
(...skipping 23 matching lines...) Expand all
3366 } 3359 }
3367 3360
3368 if (assumption == AssumeNoVisibleChange 3361 if (assumption == AssumeNoVisibleChange
3369 && m_haveVisibleTextTrack == haveVisibleTextTrack) { 3362 && m_haveVisibleTextTrack == haveVisibleTextTrack) {
3370 cueTimeline().updateActiveCues(currentTime()); 3363 cueTimeline().updateActiveCues(currentTime());
3371 return; 3364 return;
3372 } 3365 }
3373 m_haveVisibleTextTrack = haveVisibleTextTrack; 3366 m_haveVisibleTextTrack = haveVisibleTextTrack;
3374 m_closedCaptionsVisible = m_haveVisibleTextTrack; 3367 m_closedCaptionsVisible = m_haveVisibleTextTrack;
3375 3368
3376 if (!m_haveVisibleTextTrack && !hasMediaControls()) 3369 if (!m_haveVisibleTextTrack && !mediaControls())
3377 return; 3370 return;
3378 3371
3379 ensureMediaControls(); 3372 ensureMediaControls();
3380 mediaControls()->changedClosedCaptionsVisibility(); 3373 mediaControls()->changedClosedCaptionsVisibility();
3381 3374
3382 cueTimeline().updateActiveCues(currentTime()); 3375 cueTimeline().updateActiveCues(currentTime());
3383 updateTextTrackDisplay(); 3376 updateTextTrackDisplay();
3384 } 3377 }
3385 3378
3386 void* HTMLMediaElement::preDispatchEventHandler(Event* event) 3379 void* HTMLMediaElement::preDispatchEventHandler(Event* event)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 } 3558 }
3566 3559
3567 bool HTMLMediaElement::isInteractiveContent() const 3560 bool HTMLMediaElement::isInteractiveContent() const
3568 { 3561 {
3569 return fastHasAttribute(controlsAttr); 3562 return fastHasAttribute(controlsAttr);
3570 } 3563 }
3571 3564
3572 void HTMLMediaElement::defaultEventHandler(Event* event) 3565 void HTMLMediaElement::defaultEventHandler(Event* event)
3573 { 3566 {
3574 if (event->type() == EventTypeNames::focusin) { 3567 if (event->type() == EventTypeNames::focusin) {
3575 if (hasMediaControls()) 3568 if (mediaControls())
3576 mediaControls()->mediaElementFocused(); 3569 mediaControls()->mediaElementFocused();
3577 } 3570 }
3578 HTMLElement::defaultEventHandler(event); 3571 HTMLElement::defaultEventHandler(event);
3579 } 3572 }
3580 3573
3581 DEFINE_TRACE(HTMLMediaElement) 3574 DEFINE_TRACE(HTMLMediaElement)
3582 { 3575 {
3583 #if ENABLE(OILPAN) 3576 #if ENABLE(OILPAN)
3584 visitor->trace(m_playedTimeRanges); 3577 visitor->trace(m_playedTimeRanges);
3585 visitor->trace(m_asyncEventQueue); 3578 visitor->trace(m_asyncEventQueue);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3632 3625
3633 #if ENABLE(WEB_AUDIO) 3626 #if ENABLE(WEB_AUDIO)
3634 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3627 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3635 { 3628 {
3636 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3629 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3637 audioSourceProvider()->setClient(nullptr); 3630 audioSourceProvider()->setClient(nullptr);
3638 } 3631 }
3639 #endif 3632 #endif
3640 3633
3641 } 3634 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698