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

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

Issue 606703002: Comply (more) with check-webkit-style in and around HTMLMediaElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLVideoElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 { 530 {
531 if (name == srcAttr) { 531 if (name == srcAttr) {
532 // Trigger a reload, as long as the 'src' attribute is present. 532 // Trigger a reload, as long as the 'src' attribute is present.
533 if (!value.isNull()) { 533 if (!value.isNull()) {
534 clearMediaPlayer(LoadMediaResource); 534 clearMediaPlayer(LoadMediaResource);
535 scheduleDelayedAction(LoadMediaResource); 535 scheduleDelayedAction(LoadMediaResource);
536 } 536 }
537 } else if (name == controlsAttr) { 537 } else if (name == controlsAttr) {
538 configureMediaControls(); 538 configureMediaControls();
539 } else if (name == preloadAttr) { 539 } else if (name == preloadAttr) {
540 if (equalIgnoringCase(value, "none")) 540 if (equalIgnoringCase(value, "none")) {
541 m_preload = MediaPlayer::None; 541 m_preload = MediaPlayer::None;
542 else if (equalIgnoringCase(value, "metadata")) 542 } else if (equalIgnoringCase(value, "metadata")) {
543 m_preload = MediaPlayer::MetaData; 543 m_preload = MediaPlayer::MetaData;
544 else { 544 } else {
545 // The spec does not define an "invalid value default" but "auto" is suggested as the 545 // The spec does not define an "invalid value default" but "auto" is suggested as the
546 // "missing value default", so use it for everything except "none" a nd "metadata" 546 // "missing value default", so use it for everything except "none" a nd "metadata"
547 m_preload = MediaPlayer::Auto; 547 m_preload = MediaPlayer::Auto;
548 } 548 }
549 549
550 // The attribute must be ignored if the autoplay attribute is present 550 // The attribute must be ignored if the autoplay attribute is present
551 if (!autoplay() && m_player) 551 if (!autoplay() && m_player)
552 setPlayerPreload(); 552 setPlayerPreload();
553 553
554 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { 554 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 String HTMLMediaElement::canPlayType(const String& mimeType, const String& keySy stem) const 693 String HTMLMediaElement::canPlayType(const String& mimeType, const String& keySy stem) const
694 { 694 {
695 if (!keySystem.isNull()) 695 if (!keySystem.isNull())
696 UseCounter::count(document(), UseCounter::CanPlayTypeKeySystem); 696 UseCounter::count(document(), UseCounter::CanPlayTypeKeySystem);
697 697
698 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType), keySystem); 698 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType), keySystem);
699 String canPlay; 699 String canPlay;
700 700
701 // 4.8.10.3 701 // 4.8.10.3
702 switch (support) 702 switch (support) {
703 { 703 case WebMimeRegistry::IsNotSupported:
704 case WebMimeRegistry::IsNotSupported: 704 canPlay = emptyString();
705 canPlay = emptyString(); 705 break;
706 break; 706 case WebMimeRegistry::MayBeSupported:
707 case WebMimeRegistry::MayBeSupported: 707 canPlay = "maybe";
708 canPlay = "maybe"; 708 break;
709 break; 709 case WebMimeRegistry::IsSupported:
710 case WebMimeRegistry::IsSupported: 710 canPlay = "probably";
711 canPlay = "probably"; 711 break;
712 break;
713 } 712 }
714 713
715 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s, %s) -> %s", this, mime Type.utf8().data(), keySystem.utf8().data(), canPlay.utf8().data()); 714 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s, %s) -> %s", this, mime Type.utf8().data(), keySystem.utf8().data(), canPlay.utf8().data());
716 715
717 return canPlay; 716 return canPlay;
718 } 717 }
719 718
720 void HTMLMediaElement::load() 719 void HTMLMediaElement::load()
721 { 720 {
722 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this); 721 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this);
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 // Explicitly cache vector sizes, as their content is constant from here. 1215 // Explicitly cache vector sizes, as their content is constant from here.
1217 size_t currentCuesSize = currentCues.size(); 1216 size_t currentCuesSize = currentCues.size();
1218 size_t missedCuesSize = missedCues.size(); 1217 size_t missedCuesSize = missedCues.size();
1219 size_t previousCuesSize = previousCues.size(); 1218 size_t previousCuesSize = previousCues.size();
1220 1219
1221 // 6 - If all of the cues in current cues have their text track cue active 1220 // 6 - If all of the cues in current cues have their text track cue active
1222 // flag set, none of the cues in other cues have their text track cue active 1221 // flag set, none of the cues in other cues have their text track cue active
1223 // flag set, and missed cues is empty, then abort these steps. 1222 // flag set, and missed cues is empty, then abort these steps.
1224 bool activeSetChanged = missedCuesSize; 1223 bool activeSetChanged = missedCuesSize;
1225 1224
1226 for (size_t i = 0; !activeSetChanged && i < previousCuesSize; ++i) 1225 for (size_t i = 0; !activeSetChanged && i < previousCuesSize; ++i) {
1227 if (!currentCues.contains(previousCues[i]) && previousCues[i].data()->is Active()) 1226 if (!currentCues.contains(previousCues[i]) && previousCues[i].data()->is Active())
1228 activeSetChanged = true; 1227 activeSetChanged = true;
1228 }
1229 1229
1230 for (size_t i = 0; i < currentCuesSize; ++i) { 1230 for (size_t i = 0; i < currentCuesSize; ++i) {
1231 currentCues[i].data()->updateDisplayTree(movieTime); 1231 currentCues[i].data()->updateDisplayTree(movieTime);
1232 1232
1233 if (!currentCues[i].data()->isActive()) 1233 if (!currentCues[i].data()->isActive())
1234 activeSetChanged = true; 1234 activeSetChanged = true;
1235 } 1235 }
1236 1236
1237 if (!activeSetChanged) 1237 if (!activeSetChanged)
1238 return; 1238 return;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 m_asyncEventQueue->enqueueEvent(event.release()); 1357 m_asyncEventQueue->enqueueEvent(event.release());
1358 } 1358 }
1359 } 1359 }
1360 1360
1361 // 16 - Set the text track cue active flag of all the cues in the current 1361 // 16 - Set the text track cue active flag of all the cues in the current
1362 // cues, and unset the text track cue active flag of all the cues in the 1362 // cues, and unset the text track cue active flag of all the cues in the
1363 // other cues. 1363 // other cues.
1364 for (size_t i = 0; i < currentCuesSize; ++i) 1364 for (size_t i = 0; i < currentCuesSize; ++i)
1365 currentCues[i].data()->setIsActive(true); 1365 currentCues[i].data()->setIsActive(true);
1366 1366
1367 for (size_t i = 0; i < previousCuesSize; ++i) 1367 for (size_t i = 0; i < previousCuesSize; ++i) {
1368 if (!currentCues.contains(previousCues[i])) 1368 if (!currentCues.contains(previousCues[i]))
1369 previousCues[i].data()->setIsActive(false); 1369 previousCues[i].data()->setIsActive(false);
1370 }
1370 1371
1371 // Update the current active cues. 1372 // Update the current active cues.
1372 m_currentlyActiveCues = currentCues; 1373 m_currentlyActiveCues = currentCues;
1373 1374
1374 if (activeSetChanged) 1375 if (activeSetChanged)
1375 updateTextTrackDisplay(); 1376 updateTextTrackDisplay();
1376 } 1377 }
1377 1378
1378 bool HTMLMediaElement::textTracksAreReady() const 1379 bool HTMLMediaElement::textTracksAreReady() const
1379 { 1380 {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 ReadyState oldState = m_readyState; 1764 ReadyState oldState = m_readyState;
1764 ReadyState newState = state; 1765 ReadyState newState = state;
1765 1766
1766 bool tracksAreReady = textTracksAreReady(); 1767 bool tracksAreReady = textTracksAreReady();
1767 1768
1768 if (newState == oldState && m_tracksAreReady == tracksAreReady) 1769 if (newState == oldState && m_tracksAreReady == tracksAreReady)
1769 return; 1770 return;
1770 1771
1771 m_tracksAreReady = tracksAreReady; 1772 m_tracksAreReady = tracksAreReady;
1772 1773
1773 if (tracksAreReady) 1774 if (tracksAreReady) {
1774 m_readyState = newState; 1775 m_readyState = newState;
1775 else { 1776 } else {
1776 // If a media file has text tracks the readyState may not progress beyon d HAVE_FUTURE_DATA until 1777 // If a media file has text tracks the readyState may not progress beyon d HAVE_FUTURE_DATA until
1777 // the text tracks are ready, regardless of the state of the media file. 1778 // the text tracks are ready, regardless of the state of the media file.
1778 if (newState <= HAVE_METADATA) 1779 if (newState <= HAVE_METADATA)
1779 m_readyState = newState; 1780 m_readyState = newState;
1780 else 1781 else
1781 m_readyState = HAVE_CURRENT_DATA; 1782 m_readyState = HAVE_CURRENT_DATA;
1782 } 1783 }
1783 1784
1784 if (oldState > m_readyStateMaximum) 1785 if (oldState > m_readyStateMaximum)
1785 m_readyStateMaximum = oldState; 1786 m_readyStateMaximum = oldState;
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 2975
2975 source = toHTMLSourceElement(node); 2976 source = toHTMLSourceElement(node);
2976 2977
2977 // If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below 2978 // If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below
2978 mediaURL = source->getNonEmptyURLAttribute(srcAttr); 2979 mediaURL = source->getNonEmptyURLAttribute(srcAttr);
2979 #if !LOG_DISABLED 2980 #if !LOG_DISABLED
2980 if (shouldLog) 2981 if (shouldLog)
2981 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'src' is %s", this, urlForLoggingMedia(mediaURL).utf8().data()); 2982 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'src' is %s", this, urlForLoggingMedia(mediaURL).utf8().data());
2982 #endif 2983 #endif
2983 if (mediaURL.isEmpty()) 2984 if (mediaURL.isEmpty())
2984 goto check_again; 2985 goto checkAgain;
2985 2986
2986 type = source->type(); 2987 type = source->type();
2987 // FIXME(82965): Add support for keySystem in <source> and set system fr om source. 2988 // FIXME(82965): Add support for keySystem in <source> and set system fr om source.
2988 if (type.isEmpty() && mediaURL.protocolIsData()) 2989 if (type.isEmpty() && mediaURL.protocolIsData())
2989 type = mimeTypeFromDataURL(mediaURL); 2990 type = mimeTypeFromDataURL(mediaURL);
2990 if (!type.isEmpty() || !system.isEmpty()) { 2991 if (!type.isEmpty() || !system.isEmpty()) {
2991 #if !LOG_DISABLED 2992 #if !LOG_DISABLED
2992 if (shouldLog) 2993 if (shouldLog)
2993 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 't ype' is '%s' - key system is '%s'", this, type.utf8().data(), system.utf8().data ()); 2994 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 't ype' is '%s' - key system is '%s'", this, type.utf8().data(), system.utf8().data ());
2994 #endif 2995 #endif
2995 if (!supportsType(ContentType(type), system)) 2996 if (!supportsType(ContentType(type), system))
2996 goto check_again; 2997 goto checkAgain;
2997 } 2998 }
2998 2999
2999 // Is it safe to load this url? 3000 // Is it safe to load this url?
3000 if (!isSafeToLoadURL(mediaURL, actionIfInvalid)) 3001 if (!isSafeToLoadURL(mediaURL, actionIfInvalid))
3001 goto check_again; 3002 goto checkAgain;
3002 3003
3003 // Making it this far means the <source> looks reasonable. 3004 // Making it this far means the <source> looks reasonable.
3004 canUseSourceElement = true; 3005 canUseSourceElement = true;
3005 3006
3006 check_again: 3007 checkAgain:
3007 if (!canUseSourceElement && actionIfInvalid == Complain && source) 3008 if (!canUseSourceElement && actionIfInvalid == Complain && source)
3008 source->scheduleErrorEvent(); 3009 source->scheduleErrorEvent();
3009 } 3010 }
3010 3011
3011 if (canUseSourceElement) { 3012 if (canUseSourceElement) {
3012 if (contentType) 3013 if (contentType)
3013 *contentType = ContentType(type); 3014 *contentType = ContentType(type);
3014 if (keySystem) 3015 if (keySystem)
3015 *keySystem = system; 3016 *keySystem = system;
3016 m_currentSourceNode = source; 3017 m_currentSourceNode = source;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 } 3141 }
3141 // Queue a task to fire a simple event named ended at the media elem ent. 3142 // Queue a task to fire a simple event named ended at the media elem ent.
3142 if (!m_sentEndEvent) { 3143 if (!m_sentEndEvent) {
3143 m_sentEndEvent = true; 3144 m_sentEndEvent = true;
3144 scheduleEvent(EventTypeNames::ended); 3145 scheduleEvent(EventTypeNames::ended);
3145 } 3146 }
3146 // If the media element has a current media controller, then report the controller state 3147 // If the media element has a current media controller, then report the controller state
3147 // for the media element's current media controller. 3148 // for the media element's current media controller.
3148 updateMediaController(); 3149 updateMediaController();
3149 } 3150 }
3151 } else {
3152 m_sentEndEvent = false;
3150 } 3153 }
3151 else
3152 m_sentEndEvent = false;
3153 3154
3154 updatePlayState(); 3155 updatePlayState();
3155 } 3156 }
3156 3157
3157 void HTMLMediaElement::mediaPlayerDurationChanged() 3158 void HTMLMediaElement::mediaPlayerDurationChanged()
3158 { 3159 {
3159 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 3160 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this);
3160 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 3161 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
3161 // the currentTime when the duration change occured. The current 3162 // the currentTime when the duration change occured. The current
3162 // WebMediaPlayer implementations always clamp currentTime() to 3163 // WebMediaPlayer implementations always clamp currentTime() to
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 3428
3428 closeMediaSource(); 3429 closeMediaSource();
3429 3430
3430 // 4 - If the media element's readyState attribute has a value equal to HAVE _NOTHING, set the 3431 // 4 - If the media element's readyState attribute has a value equal to HAVE _NOTHING, set the
3431 // element's networkState attribute to the NETWORK_EMPTY value and queue a t ask to fire a 3432 // element's networkState attribute to the NETWORK_EMPTY value and queue a t ask to fire a
3432 // simple event named emptied at the element. Otherwise, set the element's n etworkState 3433 // simple event named emptied at the element. Otherwise, set the element's n etworkState
3433 // attribute to the NETWORK_IDLE value. 3434 // attribute to the NETWORK_IDLE value.
3434 if (m_readyState == HAVE_NOTHING) { 3435 if (m_readyState == HAVE_NOTHING) {
3435 m_networkState = NETWORK_EMPTY; 3436 m_networkState = NETWORK_EMPTY;
3436 scheduleEvent(EventTypeNames::emptied); 3437 scheduleEvent(EventTypeNames::emptied);
3438 } else {
3439 m_networkState = NETWORK_IDLE;
3437 } 3440 }
3438 else
3439 m_networkState = NETWORK_IDLE;
3440 3441
3441 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 3442 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
3442 setShouldDelayLoadEvent(false); 3443 setShouldDelayLoadEvent(false);
3443 3444
3444 // 6 - Abort the overall resource selection algorithm. 3445 // 6 - Abort the overall resource selection algorithm.
3445 m_currentSourceNode = nullptr; 3446 m_currentSourceNode = nullptr;
3446 3447
3447 // Reset m_readyState since m_player is gone. 3448 // Reset m_readyState since m_player is gone.
3448 m_readyState = HAVE_NOTHING; 3449 m_readyState = HAVE_NOTHING;
3449 invalidateCachedTime(); 3450 invalidateCachedTime();
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 4032
4032 #if ENABLE(WEB_AUDIO) 4033 #if ENABLE(WEB_AUDIO)
4033 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4034 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4034 { 4035 {
4035 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4036 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4036 audioSourceProvider()->setClient(0); 4037 audioSourceProvider()->setClient(0);
4037 } 4038 }
4038 #endif 4039 #endif
4039 4040
4040 } 4041 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLVideoElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698