| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } else { | 159 } else { |
| 160 set = it->value; | 160 set = it->value; |
| 161 } | 161 } |
| 162 set->add(element); | 162 set->add(element); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void removeElementFromDocumentMap(HTMLMediaElement* element, Document* document) | 165 void removeElementFromDocumentMap(HTMLMediaElement* element, Document* document) |
| 166 { | 166 { |
| 167 DocumentElementSetMap& map = documentToElementSetMap(); | 167 DocumentElementSetMap& map = documentToElementSetMap(); |
| 168 auto it = map.find(document); | 168 auto it = map.find(document); |
| 169 ASSERT(it != map.end()); | 169 DCHECK(it != map.end()); |
| 170 WeakMediaElementSet* set = it->value; | 170 WeakMediaElementSet* set = it->value; |
| 171 set->remove(element); | 171 set->remove(element); |
| 172 if (set->isEmpty()) | 172 if (set->isEmpty()) |
| 173 map.remove(it); | 173 map.remove(it); |
| 174 } | 174 } |
| 175 | 175 |
| 176 class AudioSourceProviderClientLockScope { | 176 class AudioSourceProviderClientLockScope { |
| 177 STACK_ALLOCATED(); | 177 STACK_ALLOCATED(); |
| 178 public: | 178 public: |
| 179 AudioSourceProviderClientLockScope(HTMLMediaElement& element) | 179 AudioSourceProviderClientLockScope(HTMLMediaElement& element) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 204 case WebMediaPlayerClient::AudioTrackKindMain: | 204 case WebMediaPlayerClient::AudioTrackKindMain: |
| 205 return AudioTrack::mainKeyword(); | 205 return AudioTrack::mainKeyword(); |
| 206 case WebMediaPlayerClient::AudioTrackKindMainDescriptions: | 206 case WebMediaPlayerClient::AudioTrackKindMainDescriptions: |
| 207 return AudioTrack::mainDescriptionsKeyword(); | 207 return AudioTrack::mainDescriptionsKeyword(); |
| 208 case WebMediaPlayerClient::AudioTrackKindTranslation: | 208 case WebMediaPlayerClient::AudioTrackKindTranslation: |
| 209 return AudioTrack::translationKeyword(); | 209 return AudioTrack::translationKeyword(); |
| 210 case WebMediaPlayerClient::AudioTrackKindCommentary: | 210 case WebMediaPlayerClient::AudioTrackKindCommentary: |
| 211 return AudioTrack::commentaryKeyword(); | 211 return AudioTrack::commentaryKeyword(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 ASSERT_NOT_REACHED(); | 214 NOTREACHED(); |
| 215 return emptyAtom; | 215 return emptyAtom; |
| 216 } | 216 } |
| 217 | 217 |
| 218 const AtomicString& VideoKindToString(WebMediaPlayerClient::VideoTrackKind kind) | 218 const AtomicString& VideoKindToString(WebMediaPlayerClient::VideoTrackKind kind) |
| 219 { | 219 { |
| 220 switch (kind) { | 220 switch (kind) { |
| 221 case WebMediaPlayerClient::VideoTrackKindNone: | 221 case WebMediaPlayerClient::VideoTrackKindNone: |
| 222 return emptyAtom; | 222 return emptyAtom; |
| 223 case WebMediaPlayerClient::VideoTrackKindAlternative: | 223 case WebMediaPlayerClient::VideoTrackKindAlternative: |
| 224 return VideoTrack::alternativeKeyword(); | 224 return VideoTrack::alternativeKeyword(); |
| 225 case WebMediaPlayerClient::VideoTrackKindCaptions: | 225 case WebMediaPlayerClient::VideoTrackKindCaptions: |
| 226 return VideoTrack::captionsKeyword(); | 226 return VideoTrack::captionsKeyword(); |
| 227 case WebMediaPlayerClient::VideoTrackKindMain: | 227 case WebMediaPlayerClient::VideoTrackKindMain: |
| 228 return VideoTrack::mainKeyword(); | 228 return VideoTrack::mainKeyword(); |
| 229 case WebMediaPlayerClient::VideoTrackKindSign: | 229 case WebMediaPlayerClient::VideoTrackKindSign: |
| 230 return VideoTrack::signKeyword(); | 230 return VideoTrack::signKeyword(); |
| 231 case WebMediaPlayerClient::VideoTrackKindSubtitles: | 231 case WebMediaPlayerClient::VideoTrackKindSubtitles: |
| 232 return VideoTrack::subtitlesKeyword(); | 232 return VideoTrack::subtitlesKeyword(); |
| 233 case WebMediaPlayerClient::VideoTrackKindCommentary: | 233 case WebMediaPlayerClient::VideoTrackKindCommentary: |
| 234 return VideoTrack::commentaryKeyword(); | 234 return VideoTrack::commentaryKeyword(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 ASSERT_NOT_REACHED(); | 237 NOTREACHED(); |
| 238 return emptyAtom; | 238 return emptyAtom; |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool canLoadURL(const KURL& url, const ContentType& contentType) | 241 bool canLoadURL(const KURL& url, const ContentType& contentType) |
| 242 { | 242 { |
| 243 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 243 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
| 244 | 244 |
| 245 String contentMIMEType = contentType.type().lower(); | 245 String contentMIMEType = contentType.type().lower(); |
| 246 String contentTypeCodecs = contentType.parameter(codecs); | 246 String contentTypeCodecs = contentType.parameter(codecs); |
| 247 | 247 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 270 { | 270 { |
| 271 switch (preloadType) { | 271 switch (preloadType) { |
| 272 case WebMediaPlayer::PreloadNone: | 272 case WebMediaPlayer::PreloadNone: |
| 273 return "none"; | 273 return "none"; |
| 274 case WebMediaPlayer::PreloadMetaData: | 274 case WebMediaPlayer::PreloadMetaData: |
| 275 return "metadata"; | 275 return "metadata"; |
| 276 case WebMediaPlayer::PreloadAuto: | 276 case WebMediaPlayer::PreloadAuto: |
| 277 return "auto"; | 277 return "auto"; |
| 278 } | 278 } |
| 279 | 279 |
| 280 ASSERT_NOT_REACHED(); | 280 NOTREACHED(); |
| 281 return String(); | 281 return String(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // anonymous namespace | 284 } // anonymous namespace |
| 285 | 285 |
| 286 class HTMLMediaElement::AutoplayHelperClientImpl : | 286 class HTMLMediaElement::AutoplayHelperClientImpl : |
| 287 public AutoplayExperimentHelper::Client { | 287 public AutoplayExperimentHelper::Client { |
| 288 | 288 |
| 289 public: | 289 public: |
| 290 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) | 290 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (type == "application/octet-stream") | 368 if (type == "application/octet-stream") |
| 369 return WebMimeRegistry::IsNotSupported; | 369 return WebMimeRegistry::IsNotSupported; |
| 370 | 370 |
| 371 return Platform::current()->mimeRegistry()->supportsMediaMIMEType(type, type
Codecs); | 371 return Platform::current()->mimeRegistry()->supportsMediaMIMEType(type, type
Codecs); |
| 372 } | 372 } |
| 373 | 373 |
| 374 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; | 374 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; |
| 375 | 375 |
| 376 void HTMLMediaElement::setMediaStreamRegistry(URLRegistry* registry) | 376 void HTMLMediaElement::setMediaStreamRegistry(URLRegistry* registry) |
| 377 { | 377 { |
| 378 ASSERT(!s_mediaStreamRegistry); | 378 DCHECK(!s_mediaStreamRegistry); |
| 379 s_mediaStreamRegistry = registry; | 379 s_mediaStreamRegistry = registry; |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool HTMLMediaElement::isMediaStreamURL(const String& url) | 382 bool HTMLMediaElement::isMediaStreamURL(const String& url) |
| 383 { | 383 { |
| 384 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; | 384 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; |
| 385 } | 385 } |
| 386 | 386 |
| 387 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
ent) | 387 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
ent) |
| 388 : HTMLElement(tagName, document) | 388 : HTMLElement(tagName, document) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } | 459 } |
| 460 | 460 |
| 461 HTMLMediaElement::~HTMLMediaElement() | 461 HTMLMediaElement::~HTMLMediaElement() |
| 462 { | 462 { |
| 463 DVLOG(MEDIA_LOG_LEVEL) << "~HTMLMediaElement(" << (void*)this << ")"; | 463 DVLOG(MEDIA_LOG_LEVEL) << "~HTMLMediaElement(" << (void*)this << ")"; |
| 464 | 464 |
| 465 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). | 465 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). |
| 466 // Since AudioNode::dispose() is guaranteed to be always called before | 466 // Since AudioNode::dispose() is guaranteed to be always called before |
| 467 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared | 467 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared |
| 468 // even if the AudioNode and the HTMLMediaElement die together. | 468 // even if the AudioNode and the HTMLMediaElement die together. |
| 469 ASSERT(!m_audioSourceNode); | 469 DCHECK(!m_audioSourceNode); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void HTMLMediaElement::dispose() | 472 void HTMLMediaElement::dispose() |
| 473 { | 473 { |
| 474 closeMediaSource(); | 474 closeMediaSource(); |
| 475 | 475 |
| 476 // Destroying the player may cause a resource load to be canceled, | 476 // Destroying the player may cause a resource load to be canceled, |
| 477 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being | 477 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being |
| 478 // called via ResourceFetch::didLoadResource(), then | 478 // called via ResourceFetch::didLoadResource(), then |
| 479 // FrameLoader::checkCompleted(). But it's guaranteed that the load event | 479 // FrameLoader::checkCompleted(). But it's guaranteed that the load event |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 break; | 904 break; |
| 905 case Attribute: | 905 case Attribute: |
| 906 loadSourceFromAttribute(); | 906 loadSourceFromAttribute(); |
| 907 DVLOG(MEDIA_LOG_LEVEL) << "selectMediaResource(" << (void*)this << "), u
sing 'src' attribute url"; | 907 DVLOG(MEDIA_LOG_LEVEL) << "selectMediaResource(" << (void*)this << "), u
sing 'src' attribute url"; |
| 908 break; | 908 break; |
| 909 case Children: | 909 case Children: |
| 910 loadNextSourceChild(); | 910 loadNextSourceChild(); |
| 911 DVLOG(MEDIA_LOG_LEVEL) << "selectMediaResource(" << (void*)this << "), u
sing source element"; | 911 DVLOG(MEDIA_LOG_LEVEL) << "selectMediaResource(" << (void*)this << "), u
sing source element"; |
| 912 break; | 912 break; |
| 913 default: | 913 default: |
| 914 ASSERT_NOT_REACHED(); | 914 NOTREACHED(); |
| 915 } | 915 } |
| 916 } | 916 } |
| 917 | 917 |
| 918 void HTMLMediaElement::loadSourceFromObject() | 918 void HTMLMediaElement::loadSourceFromObject() |
| 919 { | 919 { |
| 920 ASSERT(m_srcObject); | 920 DCHECK(m_srcObject); |
| 921 m_loadState = LoadingFromSrcObject; | 921 m_loadState = LoadingFromSrcObject; |
| 922 | 922 |
| 923 // No type is available when the resource comes from the 'srcObject' | 923 // No type is available when the resource comes from the 'srcObject' |
| 924 // attribute. | 924 // attribute. |
| 925 ContentType contentType((String())); | 925 ContentType contentType((String())); |
| 926 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), contentType)
; | 926 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), contentType)
; |
| 927 } | 927 } |
| 928 | 928 |
| 929 void HTMLMediaElement::loadSourceFromAttribute() | 929 void HTMLMediaElement::loadSourceFromAttribute() |
| 930 { | 930 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 961 | 961 |
| 962 // Reset the MediaPlayer and MediaSource if any | 962 // Reset the MediaPlayer and MediaSource if any |
| 963 resetMediaPlayerAndMediaSource(); | 963 resetMediaPlayerAndMediaSource(); |
| 964 | 964 |
| 965 m_loadState = LoadingFromSourceElement; | 965 m_loadState = LoadingFromSourceElement; |
| 966 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); | 966 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); |
| 967 } | 967 } |
| 968 | 968 |
| 969 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT
ype& contentType) | 969 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT
ype& contentType) |
| 970 { | 970 { |
| 971 ASSERT(isMainThread()); | 971 DCHECK(isMainThread()); |
| 972 KURL url; | 972 KURL url; |
| 973 if (source.isURL()) { | 973 if (source.isURL()) { |
| 974 url = source.getAsURL(); | 974 url = source.getAsURL(); |
| 975 ASSERT(isSafeToLoadURL(url, Complain)); | 975 DCHECK(isSafeToLoadURL(url, Complain)); |
| 976 DVLOG(MEDIA_LOG_LEVEL) << "loadResource(" << (void*)this << ", " << urlF
orLoggingMedia(url) << ", " << contentType.raw() << ")"; | 976 DVLOG(MEDIA_LOG_LEVEL) << "loadResource(" << (void*)this << ", " << urlF
orLoggingMedia(url) << ", " << contentType.raw() << ")"; |
| 977 } | 977 } |
| 978 | 978 |
| 979 LocalFrame* frame = document().frame(); | 979 LocalFrame* frame = document().frame(); |
| 980 if (!frame) { | 980 if (!frame) { |
| 981 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 981 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 982 return; | 982 return; |
| 983 } | 983 } |
| 984 | 984 |
| 985 // The resource fetch algorithm | 985 // The resource fetch algorithm |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1000 | 1000 |
| 1001 // Reset display mode to force a recalculation of what to show because we ar
e resetting the player. | 1001 // Reset display mode to force a recalculation of what to show because we ar
e resetting the player. |
| 1002 setDisplayMode(Unknown); | 1002 setDisplayMode(Unknown); |
| 1003 | 1003 |
| 1004 setPlayerPreload(); | 1004 setPlayerPreload(); |
| 1005 | 1005 |
| 1006 if (fastHasAttribute(mutedAttr)) | 1006 if (fastHasAttribute(mutedAttr)) |
| 1007 m_muted = true; | 1007 m_muted = true; |
| 1008 updateVolume(); | 1008 updateVolume(); |
| 1009 | 1009 |
| 1010 ASSERT(!m_mediaSource); | 1010 DCHECK(!m_mediaSource); |
| 1011 | 1011 |
| 1012 bool attemptLoad = true; | 1012 bool attemptLoad = true; |
| 1013 | 1013 |
| 1014 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc
eBlobProtocol); | 1014 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc
eBlobProtocol); |
| 1015 if (isStreamOrBlobUrl) { | 1015 if (isStreamOrBlobUrl) { |
| 1016 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi
aStreamURL(url.getString())); | 1016 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi
aStreamURL(url.getString())); |
| 1017 if (isMediaStream) { | 1017 if (isMediaStream) { |
| 1018 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByStre
am); | 1018 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByStre
am); |
| 1019 } else { | 1019 } else { |
| 1020 m_mediaSource = HTMLMediaSource::lookup(url.getString()); | 1020 m_mediaSource = HTMLMediaSource::lookup(url.getString()); |
| 1021 | 1021 |
| 1022 if (m_mediaSource) { | 1022 if (m_mediaSource) { |
| 1023 if (!m_mediaSource->attachToElement(this)) { | 1023 if (!m_mediaSource->attachToElement(this)) { |
| 1024 // Forget our reference to the MediaSource, so we leave it a
lone | 1024 // Forget our reference to the MediaSource, so we leave it a
lone |
| 1025 // while processing remainder of load failure. | 1025 // while processing remainder of load failure. |
| 1026 m_mediaSource = nullptr; | 1026 m_mediaSource = nullptr; |
| 1027 attemptLoad = false; | 1027 attemptLoad = false; |
| 1028 } | 1028 } |
| 1029 } | 1029 } |
| 1030 } | 1030 } |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType
); | 1033 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType
); |
| 1034 if (attemptLoad && canLoadResource) { | 1034 if (attemptLoad && canLoadResource) { |
| 1035 ASSERT(!webMediaPlayer()); | 1035 DCHECK(!webMediaPlayer()); |
| 1036 | 1036 |
| 1037 // Conditionally defer the load if effective preload is 'none'. | 1037 // Conditionally defer the load if effective preload is 'none'. |
| 1038 // Skip this optional deferral for MediaStream sources or any blob URL, | 1038 // Skip this optional deferral for MediaStream sources or any blob URL, |
| 1039 // including MediaSource blob URLs. | 1039 // including MediaSource blob URLs. |
| 1040 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel
oadNone) { | 1040 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel
oadNone) { |
| 1041 DVLOG(MEDIA_LOG_LEVEL) << "loadResource(" << (void*)this << ") : Del
aying load because preload == 'none'"; | 1041 DVLOG(MEDIA_LOG_LEVEL) << "loadResource(" << (void*)this << ") : Del
aying load because preload == 'none'"; |
| 1042 deferLoad(); | 1042 deferLoad(); |
| 1043 } else { | 1043 } else { |
| 1044 startPlayerLoad(); | 1044 startPlayerLoad(); |
| 1045 } | 1045 } |
| 1046 } else { | 1046 } else { |
| 1047 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1047 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 // If there is no poster to display, allow the media engine to render video
frames as soon as | 1050 // If there is no poster to display, allow the media engine to render video
frames as soon as |
| 1051 // they are available. | 1051 // they are available. |
| 1052 updateDisplayState(); | 1052 updateDisplayState(); |
| 1053 | 1053 |
| 1054 if (layoutObject()) | 1054 if (layoutObject()) |
| 1055 layoutObject()->updateFromElement(); | 1055 layoutObject()->updateFromElement(); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 void HTMLMediaElement::startPlayerLoad() | 1058 void HTMLMediaElement::startPlayerLoad() |
| 1059 { | 1059 { |
| 1060 ASSERT(!m_webMediaPlayer); | 1060 DCHECK(!m_webMediaPlayer); |
| 1061 | 1061 |
| 1062 WebMediaPlayerSource source; | 1062 WebMediaPlayerSource source; |
| 1063 if (m_srcObject) { | 1063 if (m_srcObject) { |
| 1064 source = WebMediaPlayerSource(WebMediaStream(m_srcObject)); | 1064 source = WebMediaPlayerSource(WebMediaStream(m_srcObject)); |
| 1065 } else { | 1065 } else { |
| 1066 // Filter out user:pass as those two URL components aren't | 1066 // Filter out user:pass as those two URL components aren't |
| 1067 // considered for media resource fetches (including for the CORS | 1067 // considered for media resource fetches (including for the CORS |
| 1068 // use-credentials mode.) That behavior aligns with Gecko, with IE | 1068 // use-credentials mode.) That behavior aligns with Gecko, with IE |
| 1069 // being more restrictive and not allowing fetches to such URLs. | 1069 // being more restrictive and not allowing fetches to such URLs. |
| 1070 // | 1070 // |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 bool HTMLMediaElement::loadIsDeferred() const | 1130 bool HTMLMediaElement::loadIsDeferred() const |
| 1131 { | 1131 { |
| 1132 return m_deferredLoadState != NotDeferred; | 1132 return m_deferredLoadState != NotDeferred; |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 void HTMLMediaElement::deferLoad() | 1135 void HTMLMediaElement::deferLoad() |
| 1136 { | 1136 { |
| 1137 // This implements the "optional" step 3 from the resource fetch algorithm. | 1137 // This implements the "optional" step 3 from the resource fetch algorithm. |
| 1138 ASSERT(!m_deferredLoadTimer.isActive()); | 1138 DCHECK(!m_deferredLoadTimer.isActive()); |
| 1139 ASSERT(m_deferredLoadState == NotDeferred); | 1139 DCHECK_EQ(m_deferredLoadState, NotDeferred); |
| 1140 // 1. Set the networkState to NETWORK_IDLE. | 1140 // 1. Set the networkState to NETWORK_IDLE. |
| 1141 // 2. Queue a task to fire a simple event named suspend at the element. | 1141 // 2. Queue a task to fire a simple event named suspend at the element. |
| 1142 changeNetworkStateFromLoadingToIdle(); | 1142 changeNetworkStateFromLoadingToIdle(); |
| 1143 // 3. Queue a task to set the element's delaying-the-load-event | 1143 // 3. Queue a task to set the element's delaying-the-load-event |
| 1144 // flag to false. This stops delaying the load event. | 1144 // flag to false. This stops delaying the load event. |
| 1145 m_deferredLoadTimer.startOneShot(0, BLINK_FROM_HERE); | 1145 m_deferredLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1146 // 4. Wait for the task to be run. | 1146 // 4. Wait for the task to be run. |
| 1147 m_deferredLoadState = WaitingForStopDelayingLoadEventTask; | 1147 m_deferredLoadState = WaitingForStopDelayingLoadEventTask; |
| 1148 // Continued in executeDeferredLoad(). | 1148 // Continued in executeDeferredLoad(). |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 void HTMLMediaElement::cancelDeferredLoad() | 1151 void HTMLMediaElement::cancelDeferredLoad() |
| 1152 { | 1152 { |
| 1153 m_deferredLoadTimer.stop(); | 1153 m_deferredLoadTimer.stop(); |
| 1154 m_deferredLoadState = NotDeferred; | 1154 m_deferredLoadState = NotDeferred; |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 void HTMLMediaElement::executeDeferredLoad() | 1157 void HTMLMediaElement::executeDeferredLoad() |
| 1158 { | 1158 { |
| 1159 ASSERT(m_deferredLoadState >= WaitingForTrigger); | 1159 DCHECK_GE(m_deferredLoadState, WaitingForTrigger); |
| 1160 | 1160 |
| 1161 // resource fetch algorithm step 3 - continued from deferLoad(). | 1161 // resource fetch algorithm step 3 - continued from deferLoad(). |
| 1162 | 1162 |
| 1163 // 5. Wait for an implementation-defined event (e.g. the user requesting tha
t the media element begin playback). | 1163 // 5. Wait for an implementation-defined event (e.g. the user requesting tha
t the media element begin playback). |
| 1164 // This is assumed to be whatever 'event' ended up calling this method. | 1164 // This is assumed to be whatever 'event' ended up calling this method. |
| 1165 cancelDeferredLoad(); | 1165 cancelDeferredLoad(); |
| 1166 // 6. Set the element's delaying-the-load-event flag back to true (this | 1166 // 6. Set the element's delaying-the-load-event flag back to true (this |
| 1167 // delays the load event again, in case it hasn't been fired yet). | 1167 // delays the load event again, in case it hasn't been fired yet). |
| 1168 setShouldDelayLoadEvent(true); | 1168 setShouldDelayLoadEvent(true); |
| 1169 // 7. Set the networkState to NETWORK_LOADING. | 1169 // 7. Set the networkState to NETWORK_LOADING. |
| 1170 setNetworkState(NETWORK_LOADING); | 1170 setNetworkState(NETWORK_LOADING); |
| 1171 | 1171 |
| 1172 startProgressEventTimer(); | 1172 startProgressEventTimer(); |
| 1173 | 1173 |
| 1174 startPlayerLoad(); | 1174 startPlayerLoad(); |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 void HTMLMediaElement::startDeferredLoad() | 1177 void HTMLMediaElement::startDeferredLoad() |
| 1178 { | 1178 { |
| 1179 if (m_deferredLoadState == WaitingForTrigger) { | 1179 if (m_deferredLoadState == WaitingForTrigger) { |
| 1180 executeDeferredLoad(); | 1180 executeDeferredLoad(); |
| 1181 return; | 1181 return; |
| 1182 } | 1182 } |
| 1183 if (m_deferredLoadState == ExecuteOnStopDelayingLoadEventTask) | 1183 if (m_deferredLoadState == ExecuteOnStopDelayingLoadEventTask) |
| 1184 return; | 1184 return; |
| 1185 ASSERT(m_deferredLoadState == WaitingForStopDelayingLoadEventTask); | 1185 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); |
| 1186 m_deferredLoadState = ExecuteOnStopDelayingLoadEventTask; | 1186 m_deferredLoadState = ExecuteOnStopDelayingLoadEventTask; |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 void HTMLMediaElement::deferredLoadTimerFired(Timer<HTMLMediaElement>*) | 1189 void HTMLMediaElement::deferredLoadTimerFired(Timer<HTMLMediaElement>*) |
| 1190 { | 1190 { |
| 1191 setShouldDelayLoadEvent(false); | 1191 setShouldDelayLoadEvent(false); |
| 1192 | 1192 |
| 1193 if (m_deferredLoadState == ExecuteOnStopDelayingLoadEventTask) { | 1193 if (m_deferredLoadState == ExecuteOnStopDelayingLoadEventTask) { |
| 1194 executeDeferredLoad(); | 1194 executeDeferredLoad(); |
| 1195 return; | 1195 return; |
| 1196 } | 1196 } |
| 1197 ASSERT(m_deferredLoadState == WaitingForStopDelayingLoadEventTask); | 1197 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); |
| 1198 m_deferredLoadState = WaitingForTrigger; | 1198 m_deferredLoadState = WaitingForTrigger; |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const | 1201 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const |
| 1202 { | 1202 { |
| 1203 if (m_mediaSource) | 1203 if (m_mediaSource) |
| 1204 return WebMediaPlayer::LoadTypeMediaSource; | 1204 return WebMediaPlayer::LoadTypeMediaSource; |
| 1205 | 1205 |
| 1206 if (m_srcObject || isMediaStreamURL(m_currentSrc.getString())) | 1206 if (m_srcObject || isMediaStreamURL(m_currentSrc.getString())) |
| 1207 return WebMediaPlayer::LoadTypeMediaStream; | 1207 return WebMediaPlayer::LoadTypeMediaStream; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 void HTMLMediaElement::textTrackModeChanged(TextTrack* track) | 1242 void HTMLMediaElement::textTrackModeChanged(TextTrack* track) |
| 1243 { | 1243 { |
| 1244 // Mark this track as "configured" so configureTextTracks won't change the m
ode again. | 1244 // Mark this track as "configured" so configureTextTracks won't change the m
ode again. |
| 1245 if (track->trackType() == TextTrack::TrackElement) | 1245 if (track->trackType() == TextTrack::TrackElement) |
| 1246 track->setHasBeenConfigured(true); | 1246 track->setHasBeenConfigured(true); |
| 1247 | 1247 |
| 1248 configureTextTrackDisplay(); | 1248 configureTextTrackDisplay(); |
| 1249 | 1249 |
| 1250 ASSERT(textTracks()->contains(track)); | 1250 DCHECK(textTracks()->contains(track)); |
| 1251 textTracks()->scheduleChangeEvent(); | 1251 textTracks()->scheduleChangeEvent(); |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 void HTMLMediaElement::disableAutomaticTextTrackSelection() | 1254 void HTMLMediaElement::disableAutomaticTextTrackSelection() |
| 1255 { | 1255 { |
| 1256 m_shouldPerformAutomaticTrackSelection = false; | 1256 m_shouldPerformAutomaticTrackSelection = false; |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI
fInvalid) | 1259 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI
fInvalid) |
| 1260 { | 1260 { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 | 1354 |
| 1355 // 7 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 1355 // 7 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
| 1356 setShouldDelayLoadEvent(false); | 1356 setShouldDelayLoadEvent(false); |
| 1357 | 1357 |
| 1358 if (layoutObject()) | 1358 if (layoutObject()) |
| 1359 layoutObject()->updateFromElement(); | 1359 layoutObject()->updateFromElement(); |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 void HTMLMediaElement::mediaEngineError(MediaError* err) | 1362 void HTMLMediaElement::mediaEngineError(MediaError* err) |
| 1363 { | 1363 { |
| 1364 ASSERT(m_readyState >= HAVE_METADATA); | 1364 DCHECK_GE(m_readyState, HAVE_METADATA); |
| 1365 DVLOG(MEDIA_LOG_LEVEL) << "mediaEngineError(" << (void*)this << ", " << stat
ic_cast<int>(err->code()) << ")"; | 1365 DVLOG(MEDIA_LOG_LEVEL) << "mediaEngineError(" << (void*)this << ", " << stat
ic_cast<int>(err->code()) << ")"; |
| 1366 | 1366 |
| 1367 // 1 - The user agent should cancel the fetching process. | 1367 // 1 - The user agent should cancel the fetching process. |
| 1368 stopPeriodicTimers(); | 1368 stopPeriodicTimers(); |
| 1369 m_loadState = WaitingForSource; | 1369 m_loadState = WaitingForSource; |
| 1370 | 1370 |
| 1371 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is | 1371 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is |
| 1372 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. | 1372 // set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE. |
| 1373 m_error = err; | 1373 m_error = err; |
| 1374 | 1374 |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 if (!code.isNull()) { | 2022 if (!code.isNull()) { |
| 2023 String message; | 2023 String message; |
| 2024 switch (code.get()) { | 2024 switch (code.get()) { |
| 2025 case NotAllowedError: | 2025 case NotAllowedError: |
| 2026 message = "play() can only be initiated by a user gesture."; | 2026 message = "play() can only be initiated by a user gesture."; |
| 2027 break; | 2027 break; |
| 2028 case NotSupportedError: | 2028 case NotSupportedError: |
| 2029 message = "The element has no supported sources."; | 2029 message = "The element has no supported sources."; |
| 2030 break; | 2030 break; |
| 2031 default: | 2031 default: |
| 2032 ASSERT_NOT_REACHED(); | 2032 NOTREACHED(); |
| 2033 } | 2033 } |
| 2034 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(code.get(), message)); | 2034 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(code.get(), message)); |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 2037 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 2038 ScriptPromise promise = resolver->promise(); | 2038 ScriptPromise promise = resolver->promise(); |
| 2039 | 2039 |
| 2040 m_playResolvers.append(resolver); | 2040 m_playResolvers.append(resolver); |
| 2041 return promise; | 2041 return promise; |
| 2042 } | 2042 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 scheduleTimeupdateEvent(false); | 2149 scheduleTimeupdateEvent(false); |
| 2150 scheduleEvent(EventTypeNames::pause); | 2150 scheduleEvent(EventTypeNames::pause); |
| 2151 scheduleRejectPlayPromises(AbortError); | 2151 scheduleRejectPlayPromises(AbortError); |
| 2152 } | 2152 } |
| 2153 | 2153 |
| 2154 updatePlayState(); | 2154 updatePlayState(); |
| 2155 } | 2155 } |
| 2156 | 2156 |
| 2157 void HTMLMediaElement::requestRemotePlayback() | 2157 void HTMLMediaElement::requestRemotePlayback() |
| 2158 { | 2158 { |
| 2159 ASSERT(m_remoteRoutesAvailable); | 2159 DCHECK(m_remoteRoutesAvailable); |
| 2160 webMediaPlayer()->requestRemotePlayback(); | 2160 webMediaPlayer()->requestRemotePlayback(); |
| 2161 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay
back")); | 2161 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay
back")); |
| 2162 } | 2162 } |
| 2163 | 2163 |
| 2164 void HTMLMediaElement::requestRemotePlaybackControl() | 2164 void HTMLMediaElement::requestRemotePlaybackControl() |
| 2165 { | 2165 { |
| 2166 ASSERT(m_remoteRoutesAvailable); | 2166 DCHECK(m_remoteRoutesAvailable); |
| 2167 webMediaPlayer()->requestRemotePlaybackControl(); | 2167 webMediaPlayer()->requestRemotePlaybackControl(); |
| 2168 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay
back_Control")); | 2168 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay
back_Control")); |
| 2169 } | 2169 } |
| 2170 | 2170 |
| 2171 void HTMLMediaElement::closeMediaSource() | 2171 void HTMLMediaElement::closeMediaSource() |
| 2172 { | 2172 { |
| 2173 if (!m_mediaSource) | 2173 if (!m_mediaSource) |
| 2174 return; | 2174 return; |
| 2175 | 2175 |
| 2176 m_mediaSource->close(); | 2176 m_mediaSource->close(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 void HTMLMediaElement::togglePlayState() | 2339 void HTMLMediaElement::togglePlayState() |
| 2340 { | 2340 { |
| 2341 if (paused()) | 2341 if (paused()) |
| 2342 play(); | 2342 play(); |
| 2343 else | 2343 else |
| 2344 pause(); | 2344 pause(); |
| 2345 } | 2345 } |
| 2346 | 2346 |
| 2347 AudioTrackList& HTMLMediaElement::audioTracks() | 2347 AudioTrackList& HTMLMediaElement::audioTracks() |
| 2348 { | 2348 { |
| 2349 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2349 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2350 return *m_audioTracks; | 2350 return *m_audioTracks; |
| 2351 } | 2351 } |
| 2352 | 2352 |
| 2353 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e
nabled) | 2353 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e
nabled) |
| 2354 { | 2354 { |
| 2355 DVLOG(MEDIA_LOG_LEVEL) << "audioTrackChanged(" << (void*)this << ") trackId=
" << trackId << " enabled=" << boolString(enabled); | 2355 DVLOG(MEDIA_LOG_LEVEL) << "audioTrackChanged(" << (void*)this << ") trackId=
" << trackId << " enabled=" << boolString(enabled); |
| 2356 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2356 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2357 | 2357 |
| 2358 audioTracks().scheduleChangeEvent(); | 2358 audioTracks().scheduleChangeEvent(); |
| 2359 | 2359 |
| 2360 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.audioTracks attribute is added. | 2360 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.audioTracks attribute is added. |
| 2361 | 2361 |
| 2362 if (!m_audioTracksTimer.isActive()) | 2362 if (!m_audioTracksTimer.isActive()) |
| 2363 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); | 2363 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); |
| 2364 } | 2364 } |
| 2365 | 2365 |
| 2366 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) | 2366 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2395 DVLOG(MEDIA_LOG_LEVEL) << "removeAudioTrack(" << (void*)this << ")"; | 2395 DVLOG(MEDIA_LOG_LEVEL) << "removeAudioTrack(" << (void*)this << ")"; |
| 2396 | 2396 |
| 2397 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2397 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2398 return; | 2398 return; |
| 2399 | 2399 |
| 2400 audioTracks().remove(trackId); | 2400 audioTracks().remove(trackId); |
| 2401 } | 2401 } |
| 2402 | 2402 |
| 2403 VideoTrackList& HTMLMediaElement::videoTracks() | 2403 VideoTrackList& HTMLMediaElement::videoTracks() |
| 2404 { | 2404 { |
| 2405 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2405 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2406 return *m_videoTracks; | 2406 return *m_videoTracks; |
| 2407 } | 2407 } |
| 2408 | 2408 |
| 2409 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select
edTrackId) | 2409 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select
edTrackId) |
| 2410 { | 2410 { |
| 2411 DVLOG(MEDIA_LOG_LEVEL) << "selectedVideoTrackChanged(" << (void*)this << ")
selectedTrackId=" << (selectedTrackId ? String::format("%u", *selectedTrackId) :
"none"); | 2411 DVLOG(MEDIA_LOG_LEVEL) << "selectedVideoTrackChanged(" << (void*)this << ")
selectedTrackId=" << (selectedTrackId ? String::format("%u", *selectedTrackId) :
"none"); |
| 2412 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2412 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2413 | 2413 |
| 2414 if (selectedTrackId) | 2414 if (selectedTrackId) |
| 2415 videoTracks().trackSelected(*selectedTrackId); | 2415 videoTracks().trackSelected(*selectedTrackId); |
| 2416 | 2416 |
| 2417 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. | 2417 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. |
| 2418 | 2418 |
| 2419 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2419 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
| 2420 } | 2420 } |
| 2421 | 2421 |
| 2422 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web
MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString&
language, bool selected) | 2422 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web
MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString&
language, bool selected) |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2957 | 2957 |
| 2958 updateDisplayState(); | 2958 updateDisplayState(); |
| 2959 if (layoutObject()) | 2959 if (layoutObject()) |
| 2960 layoutObject()->setShouldDoFullPaintInvalidation(); | 2960 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 2961 } | 2961 } |
| 2962 | 2962 |
| 2963 void HTMLMediaElement::sizeChanged() | 2963 void HTMLMediaElement::sizeChanged() |
| 2964 { | 2964 { |
| 2965 DVLOG(MEDIA_LOG_LEVEL) << "sizeChanged(" << (void*)this << ")"; | 2965 DVLOG(MEDIA_LOG_LEVEL) << "sizeChanged(" << (void*)this << ")"; |
| 2966 | 2966 |
| 2967 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2967 DCHECK(hasVideo()); // "resize" makes no sense in absence of video. |
| 2968 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2968 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
| 2969 scheduleEvent(EventTypeNames::resize); | 2969 scheduleEvent(EventTypeNames::resize); |
| 2970 | 2970 |
| 2971 if (layoutObject()) | 2971 if (layoutObject()) |
| 2972 layoutObject()->updateFromElement(); | 2972 layoutObject()->updateFromElement(); |
| 2973 } | 2973 } |
| 2974 | 2974 |
| 2975 TimeRanges* HTMLMediaElement::buffered() const | 2975 TimeRanges* HTMLMediaElement::buffered() const |
| 2976 { | 2976 { |
| 2977 if (m_mediaSource) | 2977 if (m_mediaSource) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3036 return false; | 3036 return false; |
| 3037 | 3037 |
| 3038 // and the current playback position is the end of the media resource and th
e direction | 3038 // and the current playback position is the end of the media resource and th
e direction |
| 3039 // of playback is forwards, Either the media element does not have a loop at
tribute specified, | 3039 // of playback is forwards, Either the media element does not have a loop at
tribute specified, |
| 3040 double now = currentTime(); | 3040 double now = currentTime(); |
| 3041 if (getDirectionOfPlayback() == Forward) | 3041 if (getDirectionOfPlayback() == Forward) |
| 3042 return dur > 0 && now >= dur && (loopCondition == LoopCondition::Ignored
|| !loop()); | 3042 return dur > 0 && now >= dur && (loopCondition == LoopCondition::Ignored
|| !loop()); |
| 3043 | 3043 |
| 3044 // or the current playback position is the earliest possible position and th
e direction | 3044 // or the current playback position is the earliest possible position and th
e direction |
| 3045 // of playback is backwards | 3045 // of playback is backwards |
| 3046 ASSERT(getDirectionOfPlayback() == Backward); | 3046 DCHECK_EQ(getDirectionOfPlayback(), Backward); |
| 3047 return now <= 0; | 3047 return now <= 0; |
| 3048 } | 3048 } |
| 3049 | 3049 |
| 3050 bool HTMLMediaElement::stoppedDueToErrors() const | 3050 bool HTMLMediaElement::stoppedDueToErrors() const |
| 3051 { | 3051 { |
| 3052 if (m_readyState >= HAVE_METADATA && m_error) { | 3052 if (m_readyState >= HAVE_METADATA && m_error) { |
| 3053 TimeRanges* seekableRanges = seekable(); | 3053 TimeRanges* seekableRanges = seekable(); |
| 3054 if (!seekableRanges->contain(currentTime())) | 3054 if (!seekableRanges->contain(currentTime())) |
| 3055 return true; | 3055 return true; |
| 3056 } | 3056 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3174 m_paused = true; | 3174 m_paused = true; |
| 3175 m_seeking = false; | 3175 m_seeking = false; |
| 3176 | 3176 |
| 3177 if (layoutObject()) | 3177 if (layoutObject()) |
| 3178 layoutObject()->updateFromElement(); | 3178 layoutObject()->updateFromElement(); |
| 3179 | 3179 |
| 3180 stopPeriodicTimers(); | 3180 stopPeriodicTimers(); |
| 3181 | 3181 |
| 3182 // Ensure that hasPendingActivity() is not preventing garbage collection, si
nce otherwise this | 3182 // Ensure that hasPendingActivity() is not preventing garbage collection, si
nce otherwise this |
| 3183 // media element will simply leak. | 3183 // media element will simply leak. |
| 3184 ASSERT(!hasPendingActivity()); | 3184 DCHECK(!hasPendingActivity()); |
| 3185 } | 3185 } |
| 3186 | 3186 |
| 3187 bool HTMLMediaElement::hasPendingActivity() const | 3187 bool HTMLMediaElement::hasPendingActivity() const |
| 3188 { | 3188 { |
| 3189 // The delaying-the-load-event flag is set by resource selection algorithm w
hen looking for a | 3189 // The delaying-the-load-event flag is set by resource selection algorithm w
hen looking for a |
| 3190 // resource to load, before networkState has reached to NETWORK_LOADING. | 3190 // resource to load, before networkState has reached to NETWORK_LOADING. |
| 3191 if (m_shouldDelayLoadEvent) | 3191 if (m_shouldDelayLoadEvent) |
| 3192 return true; | 3192 return true; |
| 3193 | 3193 |
| 3194 // When networkState is NETWORK_LOADING, progress and stalled events may be
fired. | 3194 // When networkState is NETWORK_LOADING, progress and stalled events may be
fired. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 return false; | 3274 return false; |
| 3275 } | 3275 } |
| 3276 | 3276 |
| 3277 bool HTMLMediaElement::textTracksVisible() const | 3277 bool HTMLMediaElement::textTracksVisible() const |
| 3278 { | 3278 { |
| 3279 return m_textTracksVisible; | 3279 return m_textTracksVisible; |
| 3280 } | 3280 } |
| 3281 | 3281 |
| 3282 static void assertShadowRootChildren(ShadowRoot& shadowRoot) | 3282 static void assertShadowRootChildren(ShadowRoot& shadowRoot) |
| 3283 { | 3283 { |
| 3284 #if ENABLE(ASSERT) | 3284 #if DCHECK_IS_ON() |
| 3285 // There can be up to two children, either or both of the text | 3285 // There can be up to two children, either or both of the text |
| 3286 // track container and media controls. If both are present, the | 3286 // track container and media controls. If both are present, the |
| 3287 // text track container must be the first child. | 3287 // text track container must be the first child. |
| 3288 unsigned numberOfChildren = shadowRoot.countChildren(); | 3288 unsigned numberOfChildren = shadowRoot.countChildren(); |
| 3289 ASSERT(numberOfChildren <= 2); | 3289 DCHECK_LE(numberOfChildren, 2u); |
| 3290 Node* firstChild = shadowRoot.firstChild(); | 3290 Node* firstChild = shadowRoot.firstChild(); |
| 3291 Node* lastChild = shadowRoot.lastChild(); | 3291 Node* lastChild = shadowRoot.lastChild(); |
| 3292 if (numberOfChildren == 1) { | 3292 if (numberOfChildren == 1) { |
| 3293 ASSERT(firstChild->isTextTrackContainer() || firstChild->isMediaControls
()); | 3293 DCHECK(firstChild->isTextTrackContainer() || firstChild->isMediaControls
()); |
| 3294 } else if (numberOfChildren == 2) { | 3294 } else if (numberOfChildren == 2) { |
| 3295 ASSERT(firstChild->isTextTrackContainer()); | 3295 DCHECK(firstChild->isTextTrackContainer()); |
| 3296 ASSERT(lastChild->isMediaControls()); | 3296 DCHECK(lastChild->isMediaControls()); |
| 3297 } | 3297 } |
| 3298 #endif | 3298 #endif |
| 3299 } | 3299 } |
| 3300 | 3300 |
| 3301 TextTrackContainer& HTMLMediaElement::ensureTextTrackContainer() | 3301 TextTrackContainer& HTMLMediaElement::ensureTextTrackContainer() |
| 3302 { | 3302 { |
| 3303 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); | 3303 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); |
| 3304 assertShadowRootChildren(shadowRoot); | 3304 assertShadowRootChildren(shadowRoot); |
| 3305 | 3305 |
| 3306 Node* firstChild = shadowRoot.firstChild(); | 3306 Node* firstChild = shadowRoot.firstChild(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3334 // of each of the text tracks in the video element's list of text tracks ... | 3334 // of each of the text tracks in the video element's list of text tracks ... |
| 3335 if (isHTMLVideoElement() && textTracksVisible()) | 3335 if (isHTMLVideoElement() && textTracksVisible()) |
| 3336 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); | 3336 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); |
| 3337 } | 3337 } |
| 3338 | 3338 |
| 3339 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen
t* document) | 3339 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen
t* document) |
| 3340 { | 3340 { |
| 3341 auto it = documentToElementSetMap().find(document); | 3341 auto it = documentToElementSetMap().find(document); |
| 3342 if (it == documentToElementSetMap().end()) | 3342 if (it == documentToElementSetMap().end()) |
| 3343 return; | 3343 return; |
| 3344 ASSERT(it->value); | 3344 DCHECK(it->value); |
| 3345 WeakMediaElementSet& elements = *it->value; | 3345 WeakMediaElementSet& elements = *it->value; |
| 3346 for (const auto& element : elements) | 3346 for (const auto& element : elements) |
| 3347 element->automaticTrackSelectionForUpdatedUserPreference(); | 3347 element->automaticTrackSelectionForUpdatedUserPreference(); |
| 3348 } | 3348 } |
| 3349 | 3349 |
| 3350 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() | 3350 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() |
| 3351 { | 3351 { |
| 3352 if (!m_textTracks || !m_textTracks->length()) | 3352 if (!m_textTracks || !m_textTracks->length()) |
| 3353 return; | 3353 return; |
| 3354 | 3354 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3469 | 3469 |
| 3470 CueTimeline& HTMLMediaElement::cueTimeline() | 3470 CueTimeline& HTMLMediaElement::cueTimeline() |
| 3471 { | 3471 { |
| 3472 if (!m_cueTimeline) | 3472 if (!m_cueTimeline) |
| 3473 m_cueTimeline = new CueTimeline(*this); | 3473 m_cueTimeline = new CueTimeline(*this); |
| 3474 return *m_cueTimeline; | 3474 return *m_cueTimeline; |
| 3475 } | 3475 } |
| 3476 | 3476 |
| 3477 void HTMLMediaElement::configureTextTrackDisplay() | 3477 void HTMLMediaElement::configureTextTrackDisplay() |
| 3478 { | 3478 { |
| 3479 ASSERT(m_textTracks); | 3479 DCHECK(m_textTracks); |
| 3480 DVLOG(MEDIA_LOG_LEVEL) << "configureTextTrackDisplay(" << (void*)this << ")"
; | 3480 DVLOG(MEDIA_LOG_LEVEL) << "configureTextTrackDisplay(" << (void*)this << ")"
; |
| 3481 | 3481 |
| 3482 if (m_processingPreferenceChange) | 3482 if (m_processingPreferenceChange) |
| 3483 return; | 3483 return; |
| 3484 | 3484 |
| 3485 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); | 3485 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); |
| 3486 m_textTracksVisible = haveVisibleTextTrack; | 3486 m_textTracksVisible = haveVisibleTextTrack; |
| 3487 | 3487 |
| 3488 if (!haveVisibleTextTrack && !mediaControls()) | 3488 if (!haveVisibleTextTrack && !mediaControls()) |
| 3489 return; | 3489 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3523 // We haven't yet found out if any remote routes are available. | 3523 // We haven't yet found out if any remote routes are available. |
| 3524 m_remoteRoutesAvailable = false; | 3524 m_remoteRoutesAvailable = false; |
| 3525 m_playingRemotely = false; | 3525 m_playingRemotely = false; |
| 3526 | 3526 |
| 3527 if (m_audioSourceNode) | 3527 if (m_audioSourceNode) |
| 3528 getAudioSourceProvider().setClient(m_audioSourceNode); | 3528 getAudioSourceProvider().setClient(m_audioSourceNode); |
| 3529 } | 3529 } |
| 3530 | 3530 |
| 3531 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) | 3531 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
| 3532 { | 3532 { |
| 3533 ASSERT(isMainThread()); | 3533 DCHECK(isMainThread()); |
| 3534 m_audioSourceNode = sourceNode; | 3534 m_audioSourceNode = sourceNode; |
| 3535 | 3535 |
| 3536 AudioSourceProviderClientLockScope scope(*this); | 3536 AudioSourceProviderClientLockScope scope(*this); |
| 3537 getAudioSourceProvider().setClient(m_audioSourceNode); | 3537 getAudioSourceProvider().setClient(m_audioSourceNode); |
| 3538 } | 3538 } |
| 3539 | 3539 |
| 3540 void HTMLMediaElement::setAllowHiddenVolumeControls(bool allow) | 3540 void HTMLMediaElement::setAllowHiddenVolumeControls(bool allow) |
| 3541 { | 3541 { |
| 3542 ensureMediaControls(); | 3542 ensureMediaControls(); |
| 3543 mediaControls()->setAllowHiddenVolumeControls(allow); | 3543 mediaControls()->setAllowHiddenVolumeControls(allow); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 resolver->resolve(); | 3735 resolver->resolve(); |
| 3736 | 3736 |
| 3737 m_playResolvers.clear(); | 3737 m_playResolvers.clear(); |
| 3738 } | 3738 } |
| 3739 | 3739 |
| 3740 void HTMLMediaElement::rejectPlayPromises() | 3740 void HTMLMediaElement::rejectPlayPromises() |
| 3741 { | 3741 { |
| 3742 // TODO(mlamouri): the message is generated based on the code because | 3742 // TODO(mlamouri): the message is generated based on the code because |
| 3743 // arguments can't be passed to a cancellable task. In order to save space | 3743 // arguments can't be passed to a cancellable task. In order to save space |
| 3744 // used by the object, the string isn't saved. | 3744 // used by the object, the string isn't saved. |
| 3745 ASSERT(m_playPromiseErrorCode == AbortError || m_playPromiseErrorCode == Not
SupportedError); | 3745 DCHECK(m_playPromiseErrorCode == AbortError || m_playPromiseErrorCode == Not
SupportedError); |
| 3746 if (m_playPromiseErrorCode == AbortError) | 3746 if (m_playPromiseErrorCode == AbortError) |
| 3747 rejectPlayPromises(AbortError, "The play() request was interrupted by a
call to pause()."); | 3747 rejectPlayPromises(AbortError, "The play() request was interrupted by a
call to pause()."); |
| 3748 else | 3748 else |
| 3749 rejectPlayPromises(NotSupportedError, "Failed to load because no support
ed source was found."); | 3749 rejectPlayPromises(NotSupportedError, "Failed to load because no support
ed source was found."); |
| 3750 } | 3750 } |
| 3751 | 3751 |
| 3752 void HTMLMediaElement::rejectPlayPromises(ExceptionCode code, const String& mess
age) | 3752 void HTMLMediaElement::rejectPlayPromises(ExceptionCode code, const String& mess
age) |
| 3753 { | 3753 { |
| 3754 ASSERT(code == AbortError || code == NotSupportedError); | 3754 DCHECK(code == AbortError || code == NotSupportedError); |
| 3755 | 3755 |
| 3756 for (auto& resolver: m_playResolvers) | 3756 for (auto& resolver: m_playResolvers) |
| 3757 resolver->reject(DOMException::create(code, message)); | 3757 resolver->reject(DOMException::create(code, message)); |
| 3758 | 3758 |
| 3759 m_playResolvers.clear(); | 3759 m_playResolvers.clear(); |
| 3760 } | 3760 } |
| 3761 | 3761 |
| 3762 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3762 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3763 { | 3763 { |
| 3764 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { | 3764 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3787 m_client = new HTMLMediaElement::AudioClientImpl(client); | 3787 m_client = new HTMLMediaElement::AudioClientImpl(client); |
| 3788 else | 3788 else |
| 3789 m_client.clear(); | 3789 m_client.clear(); |
| 3790 | 3790 |
| 3791 if (m_webAudioSourceProvider) | 3791 if (m_webAudioSourceProvider) |
| 3792 m_webAudioSourceProvider->setClient(m_client.get()); | 3792 m_webAudioSourceProvider->setClient(m_client.get()); |
| 3793 } | 3793 } |
| 3794 | 3794 |
| 3795 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(AudioBus* bus, size
_t framesToProcess) | 3795 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(AudioBus* bus, size
_t framesToProcess) |
| 3796 { | 3796 { |
| 3797 ASSERT(bus); | 3797 DCHECK(bus); |
| 3798 | 3798 |
| 3799 MutexTryLocker tryLocker(provideInputLock); | 3799 MutexTryLocker tryLocker(provideInputLock); |
| 3800 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) { | 3800 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) { |
| 3801 bus->zero(); | 3801 bus->zero(); |
| 3802 return; | 3802 return; |
| 3803 } | 3803 } |
| 3804 | 3804 |
| 3805 // Wrap the AudioBus channel data using WebVector. | 3805 // Wrap the AudioBus channel data using WebVector. |
| 3806 size_t n = bus->numberOfChannels(); | 3806 size_t n = bus->numberOfChannels(); |
| 3807 WebVector<float*> webAudioData(n); | 3807 WebVector<float*> webAudioData(n); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3869 | 3869 |
| 3870 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 3870 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
| 3871 { | 3871 { |
| 3872 IntRect result; | 3872 IntRect result; |
| 3873 if (LayoutObject* object = m_element->layoutObject()) | 3873 if (LayoutObject* object = m_element->layoutObject()) |
| 3874 result = object->absoluteBoundingBoxRect(); | 3874 result = object->absoluteBoundingBoxRect(); |
| 3875 return result; | 3875 return result; |
| 3876 } | 3876 } |
| 3877 | 3877 |
| 3878 } // namespace blink | 3878 } // namespace blink |
| OLD | NEW |