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

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

Issue 2713613002: Convert HTMLMediaElement timers to MediaElementEvent per-frame. (Closed)
Patch Set: Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 contentMIMEType == "application/octet-stream" || 255 contentMIMEType == "application/octet-stream" ||
256 contentMIMEType == "text/plain") { 256 contentMIMEType == "text/plain") {
257 if (url.protocolIsData()) 257 if (url.protocolIsData())
258 contentMIMEType = mimeTypeFromDataURL(url.getString()); 258 contentMIMEType = mimeTypeFromDataURL(url.getString());
259 } 259 }
260 260
261 // If no MIME type is specified, always attempt to load. 261 // If no MIME type is specified, always attempt to load.
262 if (contentMIMEType.isEmpty()) 262 if (contentMIMEType.isEmpty())
263 return true; 263 return true;
264 264
265 // 4.8.10.3 MIME types - In the absence of a specification to the contrary, 265 // 4.8.12.3 MIME types - In the absence of a specification to the contrary,
266 // the MIME type "application/octet-stream" when used with parameters, e.g. 266 // the MIME type "application/octet-stream" when used with parameters, e.g.
267 // "application/octet-stream;codecs=theora", is a type that the user agent 267 // "application/octet-stream;codecs=theora", is a type that the user agent
268 // knows it cannot render. 268 // knows it cannot render.
269 if (contentMIMEType != "application/octet-stream" || 269 if (contentMIMEType != "application/octet-stream" ||
270 contentTypeCodecs.isEmpty()) { 270 contentTypeCodecs.isEmpty()) {
271 return MIMETypeRegistry::supportsMediaMIMEType(contentMIMEType, 271 return MIMETypeRegistry::supportsMediaMIMEType(contentMIMEType,
272 contentTypeCodecs); 272 contentTypeCodecs);
273 } 273 }
274 274
275 return false; 275 return false;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); 330 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs"));
331 331
332 String type = contentType.type().lower(); 332 String type = contentType.type().lower();
333 // The codecs string is not lower-cased because MP4 values are case sensitive 333 // The codecs string is not lower-cased because MP4 values are case sensitive
334 // per http://tools.ietf.org/html/rfc4281#page-7. 334 // per http://tools.ietf.org/html/rfc4281#page-7.
335 String typeCodecs = contentType.parameter(codecs); 335 String typeCodecs = contentType.parameter(codecs);
336 336
337 if (type.isEmpty()) 337 if (type.isEmpty())
338 return MIMETypeRegistry::IsNotSupported; 338 return MIMETypeRegistry::IsNotSupported;
339 339
340 // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty 340 // 4.8.12.3 MIME types - The canPlayType(type) method must return the empty
341 // string if type is a type that the user agent knows it cannot render or is 341 // string if type is a type that the user agent knows it cannot render or is
342 // the type "application/octet-stream" 342 // the type "application/octet-stream"
343 if (type == "application/octet-stream") 343 if (type == "application/octet-stream")
344 return MIMETypeRegistry::IsNotSupported; 344 return MIMETypeRegistry::IsNotSupported;
345 345
346 return MIMETypeRegistry::supportsMediaMIMEType(type, typeCodecs); 346 return MIMETypeRegistry::supportsMediaMIMEType(type, typeCodecs);
347 } 347 }
348 348
349 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; 349 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0;
350 350
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 for (const auto& element : elements) { 382 for (const auto& element : elements) {
383 element->updateControlsVisibility(); 383 element->updateControlsVisibility();
384 element->mediaControls()->onMediaControlsEnabledChange(); 384 element->mediaControls()->onMediaControlsEnabledChange();
385 } 385 }
386 } 386 }
387 387
388 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, 388 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName,
389 Document& document) 389 Document& document)
390 : HTMLElement(tagName, document), 390 : HTMLElement(tagName, document),
391 SuspendableObject(&document), 391 SuspendableObject(&document),
392 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), 392 m_loadTimer(TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
393 this, 393 this,
394 &HTMLMediaElement::loadTimerFired), 394 &HTMLMediaElement::loadTimerFired),
395 m_progressEventTimer( 395 m_progressEventTimer(
396 TaskRunnerHelper::get(TaskType::Unthrottled, &document), 396 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
397 this, 397 this,
398 &HTMLMediaElement::progressEventTimerFired), 398 &HTMLMediaElement::progressEventTimerFired),
399 m_playbackProgressTimer( 399 m_playbackProgressTimer(
400 TaskRunnerHelper::get(TaskType::Unthrottled, &document), 400 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
401 this, 401 this,
402 &HTMLMediaElement::playbackProgressTimerFired), 402 &HTMLMediaElement::playbackProgressTimerFired),
403 m_audioTracksTimer( 403 m_audioTracksTimer(
404 TaskRunnerHelper::get(TaskType::Unthrottled, &document), 404 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
405 this, 405 this,
406 &HTMLMediaElement::audioTracksTimerFired), 406 &HTMLMediaElement::audioTracksTimerFired),
407 m_viewportFillDebouncerTimer( 407 m_viewportFillDebouncerTimer(
408 TaskRunnerHelper::get(TaskType::Unthrottled, &document), 408 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
409 this, 409 this,
410 &HTMLMediaElement::viewportFillDebouncerTimerFired), 410 &HTMLMediaElement::viewportFillDebouncerTimerFired),
411 m_checkViewportIntersectionTimer( 411 m_checkViewportIntersectionTimer(
412 TaskRunnerHelper::get(TaskType::Unthrottled, &document), 412 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
413 this, 413 this,
414 &HTMLMediaElement::checkViewportIntersectionTimerFired), 414 &HTMLMediaElement::checkViewportIntersectionTimerFired),
415 m_playedTimeRanges(), 415 m_playedTimeRanges(),
416 m_asyncEventQueue(GenericEventQueue::create(this)), 416 m_asyncEventQueue(GenericEventQueue::create(this)),
417 m_playbackRate(1.0f), 417 m_playbackRate(1.0f),
418 m_defaultPlaybackRate(1.0f), 418 m_defaultPlaybackRate(1.0f),
419 m_networkState(kNetworkEmpty), 419 m_networkState(kNetworkEmpty),
420 m_readyState(kHaveNothing), 420 m_readyState(kHaveNothing),
421 m_readyStateMaximum(kHaveNothing), 421 m_readyStateMaximum(kHaveNothing),
422 m_volume(1.0f), 422 m_volume(1.0f),
423 m_lastSeekTime(0), 423 m_lastSeekTime(0),
424 m_previousProgressTime(std::numeric_limits<double>::max()), 424 m_previousProgressTime(std::numeric_limits<double>::max()),
425 m_duration(std::numeric_limits<double>::quiet_NaN()), 425 m_duration(std::numeric_limits<double>::quiet_NaN()),
426 m_lastTimeUpdateEventWallTime(0), 426 m_lastTimeUpdateEventWallTime(0),
427 m_lastTimeUpdateEventMediaTime(std::numeric_limits<double>::quiet_NaN()), 427 m_lastTimeUpdateEventMediaTime(std::numeric_limits<double>::quiet_NaN()),
428 m_defaultPlaybackStartPosition(0), 428 m_defaultPlaybackStartPosition(0),
429 m_loadState(WaitingForSource), 429 m_loadState(WaitingForSource),
430 m_deferredLoadState(NotDeferred), 430 m_deferredLoadState(NotDeferred),
431 m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired), 431 m_deferredLoadTimer(
432 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document),
433 this,
434 &HTMLMediaElement::deferredLoadTimerFired),
432 m_webLayer(nullptr), 435 m_webLayer(nullptr),
433 m_displayMode(Unknown), 436 m_displayMode(Unknown),
434 m_officialPlaybackPosition(0), 437 m_officialPlaybackPosition(0),
435 m_officialPlaybackPositionNeedsUpdate(true), 438 m_officialPlaybackPositionNeedsUpdate(true),
436 m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()), 439 m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()),
437 m_pendingActionFlags(0), 440 m_pendingActionFlags(0),
438 m_lockedPendingUserGesture(false), 441 m_lockedPendingUserGesture(false),
439 m_lockedPendingUserGestureIfCrossOriginExperimentEnabled(true), 442 m_lockedPendingUserGestureIfCrossOriginExperimentEnabled(true),
440 m_playing(false), 443 m_playing(false),
441 m_shouldDelayLoadEvent(false), 444 m_shouldDelayLoadEvent(false),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // doesn't get dispatched during the object destruction. 502 // doesn't get dispatched during the object destruction.
500 // See Document::isDelayingLoadEvent(). 503 // See Document::isDelayingLoadEvent().
501 // Also see http://crbug.com/275223 for more details. 504 // Also see http://crbug.com/275223 for more details.
502 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); 505 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking();
503 } 506 }
504 507
505 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) { 508 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) {
506 BLINK_MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")"; 509 BLINK_MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")";
507 510
508 m_loadTimer.moveToNewTaskRunner( 511 m_loadTimer.moveToNewTaskRunner(
509 TaskRunnerHelper::get(TaskType::Unthrottled, &document())); 512 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
510 m_progressEventTimer.moveToNewTaskRunner( 513 m_progressEventTimer.moveToNewTaskRunner(
511 TaskRunnerHelper::get(TaskType::Unthrottled, &document())); 514 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
512 m_playbackProgressTimer.moveToNewTaskRunner( 515 m_playbackProgressTimer.moveToNewTaskRunner(
513 TaskRunnerHelper::get(TaskType::Unthrottled, &document())); 516 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
514 m_audioTracksTimer.moveToNewTaskRunner( 517 m_audioTracksTimer.moveToNewTaskRunner(
515 TaskRunnerHelper::get(TaskType::Unthrottled, &document())); 518 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
516 m_viewportFillDebouncerTimer.moveToNewTaskRunner( 519 m_viewportFillDebouncerTimer.moveToNewTaskRunner(
517 TaskRunnerHelper::get(TaskType::Unthrottled, &document())); 520 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
518 m_checkViewportIntersectionTimer.moveToNewTaskRunner( 521 m_checkViewportIntersectionTimer.moveToNewTaskRunner(
519 TaskRunnerHelper::get(TaskType::Unthrottled, &document())); 522 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
523 m_deferredLoadTimer.moveToNewTaskRunner(
524 TaskRunnerHelper::get(TaskType::MediaElementEvent, &document()));
mlamouri (slow - plz ping) 2017/02/22 12:10:03 This is a change in behaviour, right?
520 525
521 m_autoplayUmaHelper->didMoveToNewDocument(oldDocument); 526 m_autoplayUmaHelper->didMoveToNewDocument(oldDocument);
522 // If any experiment is enabled, then we want to enable a user gesture by 527 // If any experiment is enabled, then we want to enable a user gesture by
523 // default, otherwise the experiment does nothing. 528 // default, otherwise the experiment does nothing.
524 bool oldDocumentRequiresUserGesture = 529 bool oldDocumentRequiresUserGesture =
525 computeLockedPendingUserGesture(oldDocument); 530 computeLockedPendingUserGesture(oldDocument);
526 bool newDocumentRequiresUserGesture = 531 bool newDocumentRequiresUserGesture =
527 computeLockedPendingUserGesture(document()); 532 computeLockedPendingUserGesture(document());
528 if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture) 533 if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture)
529 m_lockedPendingUserGesture = true; 534 m_lockedPendingUserGesture = true;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 737 }
733 738
734 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const { 739 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const {
735 return m_networkState; 740 return m_networkState;
736 } 741 }
737 742
738 String HTMLMediaElement::canPlayType(const String& mimeType) const { 743 String HTMLMediaElement::canPlayType(const String& mimeType) const {
739 MIMETypeRegistry::SupportsType support = supportsType(ContentType(mimeType)); 744 MIMETypeRegistry::SupportsType support = supportsType(ContentType(mimeType));
740 String canPlay; 745 String canPlay;
741 746
742 // 4.8.10.3 747 // 4.8.12.3
743 switch (support) { 748 switch (support) {
744 case MIMETypeRegistry::IsNotSupported: 749 case MIMETypeRegistry::IsNotSupported:
745 canPlay = emptyString; 750 canPlay = emptyString;
746 break; 751 break;
747 case MIMETypeRegistry::MayBeSupported: 752 case MIMETypeRegistry::MayBeSupported:
748 canPlay = "maybe"; 753 canPlay = "maybe";
749 break; 754 break;
750 case MIMETypeRegistry::IsSupported: 755 case MIMETypeRegistry::IsSupported:
751 canPlay = "probably"; 756 canPlay = "probably";
752 break; 757 break;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 1225
1221 if (loadIsDeferred() && effectivePreloadType() != WebMediaPlayer::PreloadNone) 1226 if (loadIsDeferred() && effectivePreloadType() != WebMediaPlayer::PreloadNone)
1222 startDeferredLoad(); 1227 startDeferredLoad();
1223 } 1228 }
1224 1229
1225 bool HTMLMediaElement::loadIsDeferred() const { 1230 bool HTMLMediaElement::loadIsDeferred() const {
1226 return m_deferredLoadState != NotDeferred; 1231 return m_deferredLoadState != NotDeferred;
1227 } 1232 }
1228 1233
1229 void HTMLMediaElement::deferLoad() { 1234 void HTMLMediaElement::deferLoad() {
1230 // This implements the "optional" step 3 from the resource fetch algorithm. 1235 // This implements the "optional" step 4 from the resource fetch algorithm
1236 // "If mode is remote".
1231 DCHECK(!m_deferredLoadTimer.isActive()); 1237 DCHECK(!m_deferredLoadTimer.isActive());
1232 DCHECK_EQ(m_deferredLoadState, NotDeferred); 1238 DCHECK_EQ(m_deferredLoadState, NotDeferred);
1233 // 1. Set the networkState to NETWORK_IDLE. 1239 // 1. Set the networkState to NETWORK_IDLE.
1234 // 2. Queue a task to fire a simple event named suspend at the element. 1240 // 2. Queue a task to fire a simple event named suspend at the element.
1235 changeNetworkStateFromLoadingToIdle(); 1241 changeNetworkStateFromLoadingToIdle();
1236 // 3. Queue a task to set the element's delaying-the-load-event 1242 // 3. Queue a task to set the element's delaying-the-load-event
1237 // flag to false. This stops delaying the load event. 1243 // flag to false. This stops delaying the load event.
1238 m_deferredLoadTimer.startOneShot(0, BLINK_FROM_HERE); 1244 m_deferredLoadTimer.startOneShot(0, BLINK_FROM_HERE);
1239 // 4. Wait for the task to be run. 1245 // 4. Wait for the task to be run.
1240 m_deferredLoadState = WaitingForStopDelayingLoadEventTask; 1246 m_deferredLoadState = WaitingForStopDelayingLoadEventTask;
1241 // Continued in executeDeferredLoad(). 1247 // Continued in executeDeferredLoad().
1242 } 1248 }
1243 1249
1244 void HTMLMediaElement::cancelDeferredLoad() { 1250 void HTMLMediaElement::cancelDeferredLoad() {
1245 m_deferredLoadTimer.stop(); 1251 m_deferredLoadTimer.stop();
1246 m_deferredLoadState = NotDeferred; 1252 m_deferredLoadState = NotDeferred;
1247 } 1253 }
1248 1254
1249 void HTMLMediaElement::executeDeferredLoad() { 1255 void HTMLMediaElement::executeDeferredLoad() {
1250 DCHECK_GE(m_deferredLoadState, WaitingForTrigger); 1256 DCHECK_GE(m_deferredLoadState, WaitingForTrigger);
1251 1257
1252 // resource fetch algorithm step 3 - continued from deferLoad(). 1258 // resource fetch algorithm step 4 - continued from deferLoad().
1253 1259
1254 // 5. Wait for an implementation-defined event (e.g. the user requesting that 1260 // 5. Wait for an implementation-defined event (e.g. the user requesting that
1255 // the media element begin playback). This is assumed to be whatever 'event' 1261 // the media element begin playback). This is assumed to be whatever 'event'
1256 // ended up calling this method. 1262 // ended up calling this method.
1257 cancelDeferredLoad(); 1263 cancelDeferredLoad();
1258 // 6. Set the element's delaying-the-load-event flag back to true (this 1264 // 6. Set the element's delaying-the-load-event flag back to true (this
1259 // delays the load event again, in case it hasn't been fired yet). 1265 // delays the load event again, in case it hasn't been fired yet).
1260 setShouldDelayLoadEvent(true); 1266 setShouldDelayLoadEvent(true);
1261 // 7. Set the networkState to NETWORK_LOADING. 1267 // 7. Set the networkState to NETWORK_LOADING.
1262 setNetworkState(kNetworkLoading); 1268 setNetworkState(kNetworkLoading);
(...skipping 30 matching lines...) Expand all
1293 return WebMediaPlayer::LoadTypeMediaSource; 1299 return WebMediaPlayer::LoadTypeMediaSource;
1294 1300
1295 if (m_srcObject || 1301 if (m_srcObject ||
1296 (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc.getString()))) 1302 (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc.getString())))
1297 return WebMediaPlayer::LoadTypeMediaStream; 1303 return WebMediaPlayer::LoadTypeMediaStream;
1298 1304
1299 return WebMediaPlayer::LoadTypeURL; 1305 return WebMediaPlayer::LoadTypeURL;
1300 } 1306 }
1301 1307
1302 bool HTMLMediaElement::textTracksAreReady() const { 1308 bool HTMLMediaElement::textTracksAreReady() const {
1303 // 4.8.10.12.1 Text track model 1309 // 4.8.12.11.1 Text track model
1304 // ... 1310 // ...
1305 // The text tracks of a media element are ready if all the text tracks whose 1311 // The text tracks of a media element are ready if all the text tracks whose
1306 // mode was not in the disabled state when the element's resource selection 1312 // mode was not in the disabled state when the element's resource selection
1307 // algorithm last started now have a text track readiness state of loaded or 1313 // algorithm last started now have a text track readiness state of loaded or
1308 // failed to load. 1314 // failed to load.
1309 for (const auto& textTrack : m_textTracksWhenResourceSelectionBegan) { 1315 for (const auto& textTrack : m_textTracksWhenResourceSelectionBegan) {
1310 if (textTrack->getReadinessState() == TextTrack::Loading || 1316 if (textTrack->getReadinessState() == TextTrack::Loading ||
1311 textTrack->getReadinessState() == TextTrack::NotLoaded) 1317 textTrack->getReadinessState() == TextTrack::NotLoaded)
1312 return false; 1318 return false;
1313 } 1319 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 layoutObject()->updateFromElement(); 1433 layoutObject()->updateFromElement();
1428 } 1434 }
1429 1435
1430 void HTMLMediaElement::noneSupported() { 1436 void HTMLMediaElement::noneSupported() {
1431 BLINK_MEDIA_LOG << "noneSupported(" << (void*)this << ")"; 1437 BLINK_MEDIA_LOG << "noneSupported(" << (void*)this << ")";
1432 1438
1433 stopPeriodicTimers(); 1439 stopPeriodicTimers();
1434 m_loadState = WaitingForSource; 1440 m_loadState = WaitingForSource;
1435 m_currentSourceNode = nullptr; 1441 m_currentSourceNode = nullptr;
1436 1442
1437 // 4.8.13.5 1443 // 4.8.12.5
1438 // The dedicated media source failure steps are the following steps: 1444 // The dedicated media source failure steps are the following steps:
1439 1445
1440 // 1 - Set the error attribute to a new MediaError object whose code attribute 1446 // 1 - Set the error attribute to a new MediaError object whose code attribute
1441 // is set to MEDIA_ERR_SRC_NOT_SUPPORTED. 1447 // is set to MEDIA_ERR_SRC_NOT_SUPPORTED.
1442 m_error = MediaError::create(MediaError::kMediaErrSrcNotSupported); 1448 m_error = MediaError::create(MediaError::kMediaErrSrcNotSupported);
1443 1449
1444 // 2 - Forget the media element's media-resource-specific text tracks. 1450 // 2 - Forget the media element's media-resource-specific text tracks.
1445 forgetResourceSpecificTracks(); 1451 forgetResourceSpecificTracks();
1446 1452
1447 // 3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE 1453 // 3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 m_readyState = kHaveCurrentData; 1650 m_readyState = kHaveCurrentData;
1645 } 1651 }
1646 1652
1647 if (oldState > m_readyStateMaximum) 1653 if (oldState > m_readyStateMaximum)
1648 m_readyStateMaximum = oldState; 1654 m_readyStateMaximum = oldState;
1649 1655
1650 if (m_networkState == kNetworkEmpty) 1656 if (m_networkState == kNetworkEmpty)
1651 return; 1657 return;
1652 1658
1653 if (m_seeking) { 1659 if (m_seeking) {
1654 // 4.8.10.9, step 9 note: If the media element was potentially playing 1660 // 4.8.12.9, step 9 note: If the media element was potentially playing
1655 // immediately before it started seeking, but seeking caused its readyState 1661 // immediately before it started seeking, but seeking caused its readyState
1656 // attribute to change to a value lower than kHaveFutureData, then a waiting 1662 // attribute to change to a value lower than kHaveFutureData, then a waiting
1657 // will be fired at the element. 1663 // will be fired at the element.
1658 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) 1664 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData)
1659 scheduleEvent(EventTypeNames::waiting); 1665 scheduleEvent(EventTypeNames::waiting);
1660 1666
1661 // 4.8.10.9 steps 12-14 1667 // 4.8.12.9 steps 12-14
1662 if (m_readyState >= kHaveCurrentData) 1668 if (m_readyState >= kHaveCurrentData)
1663 finishSeek(); 1669 finishSeek();
1664 } else { 1670 } else {
1665 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) { 1671 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) {
1666 // Force an update to official playback position. Automatic updates from 1672 // Force an update to official playback position. Automatic updates from
1667 // currentPlaybackPosition() will be blocked while m_readyState remains 1673 // currentPlaybackPosition() will be blocked while m_readyState remains
1668 // < kHaveFutureData. This blocking is desired after 'waiting' has been 1674 // < kHaveFutureData. This blocking is desired after 'waiting' has been
1669 // fired, but its good to update it one final time to accurately reflect 1675 // fired, but its good to update it one final time to accurately reflect
1670 // media time at the moment we ran out of data to play. 1676 // media time at the moment we ran out of data to play.
1671 setOfficialPlaybackPosition(currentPlaybackPosition()); 1677 setOfficialPlaybackPosition(currentPlaybackPosition());
1672 1678
1673 // 4.8.10.8 1679 // 4.8.12.8
1674 scheduleTimeupdateEvent(false); 1680 scheduleTimeupdateEvent(false);
1675 scheduleEvent(EventTypeNames::waiting); 1681 scheduleEvent(EventTypeNames::waiting);
1676 } 1682 }
1677 } 1683 }
1678 1684
1679 // Once enough of the media data has been fetched to determine the duration of 1685 // Once enough of the media data has been fetched to determine the duration of
1680 // the media resource, its dimensions, and other metadata... 1686 // the media resource, its dimensions, and other metadata...
1681 if (m_readyState >= kHaveMetadata && oldState < kHaveMetadata) { 1687 if (m_readyState >= kHaveMetadata && oldState < kHaveMetadata) {
1682 createPlaceholderTracksIfNecessary(); 1688 createPlaceholderTracksIfNecessary();
1683 1689
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 2112
2107 void HTMLMediaElement::updatePlaybackRate() { 2113 void HTMLMediaElement::updatePlaybackRate() {
2108 // FIXME: remove m_webMediaPlayer check once we figure out how 2114 // FIXME: remove m_webMediaPlayer check once we figure out how
2109 // m_webMediaPlayer is going out of sync with readystate. 2115 // m_webMediaPlayer is going out of sync with readystate.
2110 // m_webMediaPlayer is cleared but readystate is not set to kHaveNothing. 2116 // m_webMediaPlayer is cleared but readystate is not set to kHaveNothing.
2111 if (m_webMediaPlayer && potentiallyPlaying()) 2117 if (m_webMediaPlayer && potentiallyPlaying())
2112 webMediaPlayer()->setRate(playbackRate()); 2118 webMediaPlayer()->setRate(playbackRate());
2113 } 2119 }
2114 2120
2115 bool HTMLMediaElement::ended() const { 2121 bool HTMLMediaElement::ended() const {
2116 // 4.8.10.8 Playing the media resource 2122 // 4.8.12.8 Playing the media resource
2117 // The ended attribute must return true if the media element has ended 2123 // The ended attribute must return true if the media element has ended
2118 // playback and the direction of playback is forwards, and false otherwise. 2124 // playback and the direction of playback is forwards, and false otherwise.
2119 return endedPlayback() && getDirectionOfPlayback() == Forward; 2125 return endedPlayback() && getDirectionOfPlayback() == Forward;
2120 } 2126 }
2121 2127
2122 bool HTMLMediaElement::autoplay() const { 2128 bool HTMLMediaElement::autoplay() const {
2123 return fastHasAttribute(autoplayAttr); 2129 return fastHasAttribute(autoplayAttr);
2124 } 2130 }
2125 2131
2126 bool HTMLMediaElement::shouldAutoplay() { 2132 bool HTMLMediaElement::shouldAutoplay() {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 void HTMLMediaElement::playInternal() { 2294 void HTMLMediaElement::playInternal() {
2289 BLINK_MEDIA_LOG << "playInternal(" << (void*)this << ")"; 2295 BLINK_MEDIA_LOG << "playInternal(" << (void*)this << ")";
2290 2296
2291 // Always return the buffering strategy to normal when not paused, 2297 // Always return the buffering strategy to normal when not paused,
2292 // regardless of the cause. (In contrast with aggressive buffering which is 2298 // regardless of the cause. (In contrast with aggressive buffering which is
2293 // only enabled by pause(), not pauseInternal().) 2299 // only enabled by pause(), not pauseInternal().)
2294 if (webMediaPlayer()) 2300 if (webMediaPlayer())
2295 webMediaPlayer()->setBufferingStrategy( 2301 webMediaPlayer()->setBufferingStrategy(
2296 WebMediaPlayer::BufferingStrategy::Normal); 2302 WebMediaPlayer::BufferingStrategy::Normal);
2297 2303
2298 // 4.8.10.9. Playing the media resource 2304 // 4.8.12.8. Playing the media resource
2299 if (m_networkState == kNetworkEmpty) 2305 if (m_networkState == kNetworkEmpty)
2300 invokeResourceSelectionAlgorithm(); 2306 invokeResourceSelectionAlgorithm();
2301 2307
2302 // Generally "ended" and "looping" are exclusive. Here, the loop attribute 2308 // Generally "ended" and "looping" are exclusive. Here, the loop attribute
2303 // is ignored to seek back to start in case loop was set after playback 2309 // is ignored to seek back to start in case loop was set after playback
2304 // ended. See http://crbug.com/364442 2310 // ended. See http://crbug.com/364442
2305 if (endedPlayback(LoopCondition::Ignored)) 2311 if (endedPlayback(LoopCondition::Ignored))
2306 seek(0); 2312 seek(0);
2307 2313
2308 if (m_paused) { 2314 if (m_paused) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 return videoTrack->id(); 2680 return videoTrack->id();
2675 } 2681 }
2676 2682
2677 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { 2683 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) {
2678 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; 2684 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")";
2679 2685
2680 videoTracks().remove(trackId); 2686 videoTracks().remove(trackId);
2681 } 2687 }
2682 2688
2683 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { 2689 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) {
2684 // 4.8.10.12.2 Sourcing in-band text tracks 2690 // 4.8.12.11.2 Sourcing in-band text tracks
2685 // 1. Associate the relevant data with a new text track and its corresponding 2691 // 1. Associate the relevant data with a new text track and its corresponding
2686 // new TextTrack object. 2692 // new TextTrack object.
2687 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); 2693 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack);
2688 2694
2689 // 2. Set the new text track's kind, label, and language based on the 2695 // 2. Set the new text track's kind, label, and language based on the
2690 // semantics of the relevant data, as defined by the relevant specification. 2696 // semantics of the relevant data, as defined by the relevant specification.
2691 // If there is no label in that data, then the label must be set to the empty 2697 // If there is no label in that data, then the label must be set to the empty
2692 // string. 2698 // string.
2693 // 3. Associate the text track list of cues with the rules for updating the 2699 // 3. Associate the text track list of cues with the rules for updating the
2694 // text track rendering appropriate for the format in question. 2700 // text track rendering appropriate for the format in question.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 } 2791 }
2786 2792
2787 TextTrackList* HTMLMediaElement::textTracks() { 2793 TextTrackList* HTMLMediaElement::textTracks() {
2788 if (!m_textTracks) 2794 if (!m_textTracks)
2789 m_textTracks = TextTrackList::create(this); 2795 m_textTracks = TextTrackList::create(this);
2790 2796
2791 return m_textTracks.get(); 2797 return m_textTracks.get();
2792 } 2798 }
2793 2799
2794 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) { 2800 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) {
2795 // 4.8.10.12.3 Sourcing out-of-band text tracks 2801 // 4.8.12.11.3 Sourcing out-of-band text tracks
2796 // When a track element's parent element changes and the new parent is a media 2802 // When a track element's parent element changes and the new parent is a media
2797 // element, then the user agent must add the track element's corresponding 2803 // element, then the user agent must add the track element's corresponding
2798 // text track to the media element's list of text tracks ... [continues in 2804 // text track to the media element's list of text tracks ... [continues in
2799 // TextTrackList::append] 2805 // TextTrackList::append]
2800 TextTrack* textTrack = trackElement->track(); 2806 TextTrack* textTrack = trackElement->track();
2801 if (!textTrack) 2807 if (!textTrack)
2802 return; 2808 return;
2803 2809
2804 textTracks()->append(textTrack); 2810 textTracks()->append(textTrack);
2805 2811
(...skipping 10 matching lines...) Expand all
2816 2822
2817 TextTrack* textTrack = trackElement->track(); 2823 TextTrack* textTrack = trackElement->track();
2818 if (!textTrack) 2824 if (!textTrack)
2819 return; 2825 return;
2820 2826
2821 textTrack->setHasBeenConfigured(false); 2827 textTrack->setHasBeenConfigured(false);
2822 2828
2823 if (!m_textTracks) 2829 if (!m_textTracks)
2824 return; 2830 return;
2825 2831
2826 // 4.8.10.12.3 Sourcing out-of-band text tracks 2832 // 4.8.12.11.3 Sourcing out-of-band text tracks
2827 // When a track element's parent element changes and the old parent was a 2833 // When a track element's parent element changes and the old parent was a
2828 // media element, then the user agent must remove the track element's 2834 // media element, then the user agent must remove the track element's
2829 // corresponding text track from the media element's list of text tracks. 2835 // corresponding text track from the media element's list of text tracks.
2830 m_textTracks->remove(textTrack); 2836 m_textTracks->remove(textTrack);
2831 2837
2832 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); 2838 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack);
2833 if (index != kNotFound) 2839 if (index != kNotFound)
2834 m_textTracksWhenResourceSelectionBegan.remove(index); 2840 m_textTracksWhenResourceSelectionBegan.remove(index);
2835 } 2841 }
2836 2842
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this 3059 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this
3054 << ") - m_currentSourceNode set to 0"; 3060 << ") - m_currentSourceNode set to 0";
3055 } 3061 }
3056 } 3062 }
3057 3063
3058 void HTMLMediaElement::timeChanged() { 3064 void HTMLMediaElement::timeChanged() {
3059 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")"; 3065 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")";
3060 3066
3061 cueTimeline().updateActiveCues(currentTime()); 3067 cueTimeline().updateActiveCues(currentTime());
3062 3068
3063 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with the 3069 // 4.8.12.9 steps 12-14. Needed if no ReadyState change is associated with the
3064 // seek. 3070 // seek.
3065 if (m_seeking && m_readyState >= kHaveCurrentData && 3071 if (m_seeking && m_readyState >= kHaveCurrentData &&
3066 !webMediaPlayer()->seeking()) 3072 !webMediaPlayer()->seeking())
3067 finishSeek(); 3073 finishSeek();
3068 3074
3069 // Always call scheduleTimeupdateEvent when the media engine reports a time 3075 // Always call scheduleTimeupdateEvent when the media engine reports a time
3070 // discontinuity, it will only queue a 'timeupdate' event if we haven't 3076 // discontinuity, it will only queue a 'timeupdate' event if we haven't
3071 // already posted one at the current movie time. 3077 // already posted one at the current movie time.
3072 scheduleTimeupdateEvent(false); 3078 scheduleTimeupdateEvent(false);
3073 3079
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 3310
3305 bool HTMLMediaElement::couldPlayIfEnoughData() const { 3311 bool HTMLMediaElement::couldPlayIfEnoughData() const {
3306 return !paused() && !endedPlayback() && !stoppedDueToErrors(); 3312 return !paused() && !endedPlayback() && !stoppedDueToErrors();
3307 } 3313 }
3308 3314
3309 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const { 3315 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const {
3310 double dur = duration(); 3316 double dur = duration();
3311 if (std::isnan(dur)) 3317 if (std::isnan(dur))
3312 return false; 3318 return false;
3313 3319
3314 // 4.8.10.8 Playing the media resource 3320 // 4.8.12.8 Playing the media resource
3315 3321
3316 // A media element is said to have ended playback when the element's 3322 // A media element is said to have ended playback when the element's
3317 // readyState attribute is HAVE_METADATA or greater, 3323 // readyState attribute is HAVE_METADATA or greater,
3318 if (m_readyState < kHaveMetadata) 3324 if (m_readyState < kHaveMetadata)
3319 return false; 3325 return false;
3320 3326
3321 // and the current playback position is the end of the media resource and the 3327 // and the current playback position is the end of the media resource and the
3322 // direction of playback is forwards, Either the media element does not have a 3328 // direction of playback is forwards, Either the media element does not have a
3323 // loop attribute specified, 3329 // loop attribute specified,
3324 double now = currentPlaybackPosition(); 3330 double now = currentPlaybackPosition();
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
4168 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); 4174 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE);
4169 } 4175 }
4170 4176
4171 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { 4177 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) {
4172 m_mostlyFillingViewport = true; 4178 m_mostlyFillingViewport = true;
4173 if (m_webMediaPlayer) 4179 if (m_webMediaPlayer)
4174 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); 4180 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport);
4175 } 4181 }
4176 4182
4177 } // namespace blink 4183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698