Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index 23ba1efbfe7eab84dee7b489679d6b4c1a681d4e..560fcf5df8eda14087d8df1d13125698f036ef76 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -828,7 +828,7 @@ void HTMLMediaElement::prepareForLoad() |
// algorithm, but do it now because we won't start that until after the timer fires and the |
// event may have already fired by then. |
setShouldDelayLoadEvent(true); |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->reset(); |
} |
@@ -1144,7 +1144,7 @@ void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track) |
// The track readiness state might have changed as a result of the user |
// clicking the captions button. In this case, a check whether all the |
// resources have failed loading should be done in order to hide the CC button. |
- if (hasMediaControls() && track->readinessState() == TextTrack::FailedToLoad) |
+ if (mediaControls() && track->readinessState() == TextTrack::FailedToLoad) |
mediaControls()->refreshClosedCaptionsButtonVisibility(); |
} |
} |
@@ -1374,7 +1374,7 @@ void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
noneSupported(); |
updateDisplayState(); |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->reset(); |
} |
@@ -1527,7 +1527,7 @@ void HTMLMediaElement::setReadyState(ReadyState state) |
seek(m_mediaController->currentTime()); |
} |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->reset(); |
if (renderer()) |
renderer()->updateFromElement(); |
@@ -1574,7 +1574,7 @@ void HTMLMediaElement::setReadyState(ReadyState state) |
if (shouldUpdateDisplayState) { |
updateDisplayState(); |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->refreshClosedCaptionsButtonVisibility(); |
} |
@@ -2117,7 +2117,7 @@ void HTMLMediaElement::updateVolume() |
if (webMediaPlayer()) |
webMediaPlayer()->setVolume(effectiveMediaVolume()); |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->updateVolume(); |
} |
@@ -2169,7 +2169,7 @@ void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
if (!effectivePlaybackRate()) |
return; |
- if (!m_paused && hasMediaControls()) |
+ if (!m_paused && mediaControls()) |
mediaControls()->playbackProgressed(); |
cueTimeline().updateActiveCues(currentTime()); |
@@ -2369,7 +2369,7 @@ void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac |
void HTMLMediaElement::textTracksChanged() |
{ |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->refreshClosedCaptionsButtonVisibility(); |
} |
@@ -2770,7 +2770,7 @@ void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
m_duration = duration; |
scheduleEvent(EventTypeNames::durationchange); |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->reset(); |
if (renderer()) |
renderer()->updateFromElement(); |
@@ -2816,21 +2816,21 @@ void HTMLMediaElement::mediaPlayerRequestSeek(double time) |
void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) |
{ |
m_remoteRoutesAvailable = routesAvailable; |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->refreshCastButtonVisibility(); |
} |
void HTMLMediaElement::connectedToRemoteDevice() |
{ |
m_playingRemotely = true; |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->startedCasting(); |
} |
void HTMLMediaElement::disconnectedFromRemoteDevice() |
{ |
m_playingRemotely = false; |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->stoppedCasting(); |
} |
@@ -2967,7 +2967,7 @@ void HTMLMediaElement::updatePlayState() |
webMediaPlayer()->play(); |
} |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->playbackStarted(); |
startPlaybackProgressTimer(); |
m_playing = true; |
@@ -2986,7 +2986,7 @@ void HTMLMediaElement::updatePlayState() |
if (couldPlayIfEnoughData()) |
prepareToPlay(); |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->playbackStopped(); |
} |
@@ -3077,9 +3077,8 @@ void HTMLMediaElement::clearMediaPlayer(int flags) |
// We can't cast if we don't have a media player. |
m_remoteRoutesAvailable = false; |
m_playingRemotely = false; |
- if (hasMediaControls()) { |
+ if (mediaControls()) |
mediaControls()->refreshCastButtonVisibility(); |
- } |
if (m_textTracks) |
configureTextTrackDisplay(AssumeNoVisibleChange); |
@@ -3175,7 +3174,7 @@ void HTMLMediaElement::exitFullscreen() |
void HTMLMediaElement::didBecomeFullscreenElement() |
{ |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->enteredFullscreen(); |
if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoElement()) |
document().renderView()->compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
@@ -3183,7 +3182,7 @@ void HTMLMediaElement::didBecomeFullscreenElement() |
void HTMLMediaElement::willStopBeingFullscreenElement() |
{ |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->exitedFullscreen(); |
if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoElement()) |
document().renderView()->compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
@@ -3295,23 +3294,17 @@ void HTMLMediaElement::setShouldDelayLoadEvent(bool shouldDelay) |
MediaControls* HTMLMediaElement::mediaControls() const |
{ |
- return toMediaControls(closedShadowRoot()->firstChild()); |
-} |
- |
-bool HTMLMediaElement::hasMediaControls() const |
-{ |
- if (ShadowRoot* userAgent = closedShadowRoot()) { |
- Node* node = userAgent->firstChild(); |
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isMediaControls()); |
- return node; |
+ if (ShadowRoot* shadowRoot = closedShadowRoot()) { |
+ // Note that |shadowRoot->firstChild()| may be null. |
+ return toMediaControls(shadowRoot->firstChild()); |
} |
- return false; |
+ return nullptr; |
} |
void HTMLMediaElement::ensureMediaControls() |
{ |
- if (hasMediaControls()) |
+ if (mediaControls()) |
return; |
RefPtrWillBeRawPtr<MediaControls> mediaControls = MediaControls::create(*this); |
@@ -3329,7 +3322,7 @@ void HTMLMediaElement::ensureMediaControls() |
void HTMLMediaElement::configureMediaControls() |
{ |
if (!inDocument()) { |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->hide(); |
return; |
} |
@@ -3373,7 +3366,7 @@ void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu |
m_haveVisibleTextTrack = haveVisibleTextTrack; |
m_closedCaptionsVisible = m_haveVisibleTextTrack; |
- if (!m_haveVisibleTextTrack && !hasMediaControls()) |
+ if (!m_haveVisibleTextTrack && !mediaControls()) |
return; |
ensureMediaControls(); |
@@ -3572,7 +3565,7 @@ bool HTMLMediaElement::isInteractiveContent() const |
void HTMLMediaElement::defaultEventHandler(Event* event) |
{ |
if (event->type() == EventTypeNames::focusin) { |
- if (hasMediaControls()) |
+ if (mediaControls()) |
mediaControls()->mediaElementFocused(); |
} |
HTMLElement::defaultEventHandler(event); |