Bug 1262358 - Part 1: Split autoplay condition into statements. r?cpearce
MozReview-Commit-ID: 19f4XOa4Kzw
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3986,24 +3986,42 @@ void HTMLMediaElement::ChangeNetworkStat
bool HTMLMediaElement::CanActivateAutoplay()
{
// For stream inputs, we activate autoplay on HAVE_NOTHING because
// this element itself might be blocking the stream from making progress by
// being paused. We also activate autopaly when playing a media source since
// the data download is controlled by the script and there is no way to
// evaluate MediaDecoder::CanPlayThrough().
- return !mPausedForInactiveDocumentOrChannel &&
- mAutoplaying &&
- mPaused &&
- ((mDecoder && mReadyState >= nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA) ||
- mSrcStream || mMediaSource) &&
- HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) &&
- mAutoplayEnabled &&
- !IsEditable();
+
+ if (!HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) || !mAutoplayEnabled) {
+ return false;
+ }
+
+ if (!mAutoplaying) {
+ return false;
+ }
+
+ if (IsEditable()) {
+ return false;
+ }
+
+ if (!mPaused) {
+ return false;
+ }
+
+ if (mPausedForInactiveDocumentOrChannel) {
+ return false;
+ }
+
+ bool hasData =
+ (mDecoder && mReadyState >= nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA) ||
+ mSrcStream || mMediaSource;
+
+ return hasData;
}
void HTMLMediaElement::CheckAutoplayDataReady()
{
if (!CanActivateAutoplay()) {
return;
}