Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 setPlayerPreload(); | 1024 setPlayerPreload(); |
| 1025 | 1025 |
| 1026 if (fastHasAttribute(mutedAttr)) | 1026 if (fastHasAttribute(mutedAttr)) |
| 1027 m_muted = true; | 1027 m_muted = true; |
| 1028 updateVolume(); | 1028 updateVolume(); |
| 1029 | 1029 |
| 1030 DCHECK(!m_mediaSource); | 1030 DCHECK(!m_mediaSource); |
| 1031 | 1031 |
| 1032 bool attemptLoad = true; | 1032 bool attemptLoad = true; |
| 1033 | 1033 |
| 1034 // MediaSource is a blob URL that is not a media stream. | |
|
foolip
2016/06/28 15:28:51
This comment doesn't seem quite accurate, if it's
whywhat
2016/06/28 16:13:50
Done. I inlined |isObject| since it made the expre
whywhat
2016/06/28 18:06:34
So loadType() doesn't catch corrupt or revoked med
foolip
2016/06/29 09:30:27
Actually I think that it's the test that should ch
| |
| 1034 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc eBlobProtocol); | 1035 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc eBlobProtocol); |
|
foolip
2016/06/28 15:28:51
While you're here, may I suggest replacing mediaSo
whywhat
2016/06/28 16:13:50
Done.
| |
| 1035 if (isStreamOrBlobUrl) { | 1036 if (isStreamOrBlobUrl && !source.isMediaStream() && (!source.isURL() || !isM ediaStreamURL(url.getString()))) { |
|
sof
2016/06/27 19:28:48
Can (at least) be reduced to
if (url.protocolIs(m
whywhat
2016/06/28 16:13:50
I believe now it's even simpler.
| |
| 1036 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi aStreamURL(url.getString())); | 1037 m_mediaSource = HTMLMediaSource::lookup(url.getString()); |
| 1037 if (isMediaStream) { | |
| 1038 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByStre am); | |
| 1039 } else { | |
| 1040 m_mediaSource = HTMLMediaSource::lookup(url.getString()); | |
| 1041 | 1038 |
| 1042 if (m_mediaSource) { | 1039 if (m_mediaSource) { |
| 1043 if (!m_mediaSource->attachToElement(this)) { | 1040 if (!m_mediaSource->attachToElement(this)) { |
|
sof
2016/06/27 19:28:48
nit: the two ifs could be fused.
whywhat
2016/06/28 16:13:50
Ditto.
whywhat
2016/06/28 18:06:34
Actually fused these diffs :)
| |
| 1044 // Forget our reference to the MediaSource, so we leave it a lone | 1041 // Forget our reference to the MediaSource, so we leave it alone |
| 1045 // while processing remainder of load failure. | 1042 // while processing remainder of load failure. |
| 1046 m_mediaSource = nullptr; | 1043 m_mediaSource = nullptr; |
| 1047 attemptLoad = false; | 1044 attemptLoad = false; |
| 1048 } | |
| 1049 } | 1045 } |
| 1050 } | 1046 } |
| 1051 } | 1047 } |
| 1052 | 1048 |
| 1053 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType ); | 1049 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType ); |
| 1054 if (attemptLoad && canLoadResource) { | 1050 if (attemptLoad && canLoadResource) { |
| 1055 DCHECK(!webMediaPlayer()); | 1051 DCHECK(!webMediaPlayer()); |
| 1056 | 1052 |
| 1057 // Conditionally defer the load if effective preload is 'none'. | 1053 // Conditionally defer the load if effective preload is 'none'. |
| 1058 // Skip this optional deferral for MediaStream sources or any blob URL, | 1054 // Skip this optional deferral for MediaStream sources or any blob URL, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1216 } | 1212 } |
| 1217 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); | 1213 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); |
| 1218 m_deferredLoadState = WaitingForTrigger; | 1214 m_deferredLoadState = WaitingForTrigger; |
| 1219 } | 1215 } |
| 1220 | 1216 |
| 1221 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const | 1217 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const |
| 1222 { | 1218 { |
| 1223 if (m_mediaSource) | 1219 if (m_mediaSource) |
| 1224 return WebMediaPlayer::LoadTypeMediaSource; | 1220 return WebMediaPlayer::LoadTypeMediaSource; |
| 1225 | 1221 |
| 1226 if (m_srcObject || isMediaStreamURL(m_currentSrc.getString())) | 1222 if (m_srcObject || (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc. getString()))) |
|
foolip
2016/06/28 15:28:51
Did this assert somewhere before?
whywhat
2016/06/28 16:13:50
isMediaStreamURL is using a hash map that eventual
| |
| 1227 return WebMediaPlayer::LoadTypeMediaStream; | 1223 return WebMediaPlayer::LoadTypeMediaStream; |
| 1228 | 1224 |
| 1229 return WebMediaPlayer::LoadTypeURL; | 1225 return WebMediaPlayer::LoadTypeURL; |
| 1230 } | 1226 } |
| 1231 | 1227 |
| 1232 bool HTMLMediaElement::textTracksAreReady() const | 1228 bool HTMLMediaElement::textTracksAreReady() const |
| 1233 { | 1229 { |
| 1234 // 4.8.10.12.1 Text track model | 1230 // 4.8.10.12.1 Text track model |
| 1235 // ... | 1231 // ... |
| 1236 // The text tracks of a media element are ready if all the text tracks whose mode was not | 1232 // The text tracks of a media element are ready if all the text tracks whose mode was not |
| (...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3718 void HTMLMediaElement::unlockUserGesture() | 3714 void HTMLMediaElement::unlockUserGesture() |
| 3719 { | 3715 { |
| 3720 m_lockedPendingUserGesture = false; | 3716 m_lockedPendingUserGesture = false; |
| 3721 } | 3717 } |
| 3722 | 3718 |
| 3723 bool HTMLMediaElement::isGestureNeededForPlayback() const | 3719 bool HTMLMediaElement::isGestureNeededForPlayback() const |
| 3724 { | 3720 { |
| 3725 if (!m_lockedPendingUserGesture) | 3721 if (!m_lockedPendingUserGesture) |
| 3726 return false; | 3722 return false; |
| 3727 | 3723 |
| 3724 if (loadType() == WebMediaPlayer::LoadTypeMediaStream) | |
| 3725 return false; | |
| 3726 | |
| 3728 // We want to allow muted video to autoplay if: | 3727 // We want to allow muted video to autoplay if: |
| 3729 // - the flag is enabled; | 3728 // - the flag is enabled; |
| 3730 // - Data Saver is not enabled; | 3729 // - Data Saver is not enabled; |
| 3731 // - Autoplay is enabled in settings; | 3730 // - Autoplay is enabled in settings; |
| 3732 if (isHTMLVideoElement() | 3731 if (isHTMLVideoElement() |
| 3733 && muted() | 3732 && muted() |
| 3734 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled() | 3733 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled() |
| 3735 && !(document().settings() && document().settings()->dataSaverEnabled()) | 3734 && !(document().settings() && document().settings()->dataSaverEnabled()) |
| 3736 && isAutoplayAllowedPerSettings()) { | 3735 && isAutoplayAllowedPerSettings()) { |
| 3737 return false; | 3736 return false; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4023 | 4022 |
| 4024 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 4023 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 4025 { | 4024 { |
| 4026 IntRect result; | 4025 IntRect result; |
| 4027 if (LayoutObject* object = m_element->layoutObject()) | 4026 if (LayoutObject* object = m_element->layoutObject()) |
| 4028 result = object->absoluteBoundingBoxRect(); | 4027 result = object->absoluteBoundingBoxRect(); |
| 4029 return result; | 4028 return result; |
| 4030 } | 4029 } |
| 4031 | 4030 |
| 4032 } // namespace blink | 4031 } // namespace blink |
| OLD | NEW |