Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2028 // 4.8.10.8 Playing the media resource | 2028 // 4.8.10.8 Playing the media resource |
| 2029 // The ended attribute must return true if the media element has ended | 2029 // The ended attribute must return true if the media element has ended |
| 2030 // playback and the direction of playback is forwards, and false otherwise. | 2030 // playback and the direction of playback is forwards, and false otherwise. |
| 2031 return endedPlayback() && getDirectionOfPlayback() == Forward; | 2031 return endedPlayback() && getDirectionOfPlayback() == Forward; |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 bool HTMLMediaElement::autoplay() const { | 2034 bool HTMLMediaElement::autoplay() const { |
| 2035 return fastHasAttribute(autoplayAttr); | 2035 return fastHasAttribute(autoplayAttr); |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 bool HTMLMediaElement::shouldAutoplay() { | 2038 bool HTMLMediaElement::shouldAutoplay() const { |
| 2039 if (document().isSandboxed(SandboxAutomaticFeatures)) | 2039 if (document().isSandboxed(SandboxAutomaticFeatures)) |
| 2040 return false; | 2040 return false; |
| 2041 return m_autoplaying && m_paused && autoplay(); | 2041 return m_autoplaying && m_paused && autoplay(); |
| 2042 } | 2042 } |
| 2043 | 2043 |
| 2044 String HTMLMediaElement::preload() const { | 2044 String HTMLMediaElement::preload() const { |
| 2045 return preloadTypeToString(preloadType()); | 2045 return preloadTypeToString(preloadType()); |
| 2046 } | 2046 } |
| 2047 | 2047 |
| 2048 void HTMLMediaElement::setPreload(const AtomicString& preload) { | 2048 void HTMLMediaElement::setPreload(const AtomicString& preload) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2140 resolver->reject(DOMException::create(code.get(), message)); | 2140 resolver->reject(DOMException::create(code.get(), message)); |
| 2141 return promise; | 2141 return promise; |
| 2142 } | 2142 } |
| 2143 | 2143 |
| 2144 return promise; | 2144 return promise; |
| 2145 } | 2145 } |
| 2146 | 2146 |
| 2147 Nullable<ExceptionCode> HTMLMediaElement::play() { | 2147 Nullable<ExceptionCode> HTMLMediaElement::play() { |
| 2148 BLINK_MEDIA_LOG << "play(" << (void*)this << ")"; | 2148 BLINK_MEDIA_LOG << "play(" << (void*)this << ")"; |
| 2149 | 2149 |
| 2150 if (!UserGestureIndicator::processingUserGesture()) { | 2150 if (UserGestureIndicator::utilizeUserGesture()) { |
|
Rick Byers
2016/11/25 15:51:59
This is just a semantics-preserving cleanup, right
foolip
2016/11/28 15:13:05
This preserved behavior, yes.
If utilizeUserGestu
mlamouri (slow - plz ping)
2016/12/01 10:24:50
I'm not Rick, but reading the header file, I would
| |
| 2151 unlockUserGesture(); | |
| 2152 } else { | |
| 2151 m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Method); | 2153 m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Method); |
| 2152 if (isGestureNeededForPlayback()) { | 2154 if (isGestureNeededForPlayback()) { |
| 2153 // If we're already playing, then this play would do nothing anyway. | 2155 // If we're already playing, then this play would do nothing anyway. |
| 2154 // Call playInternal to handle scheduling the promise resolution. | 2156 // Call playInternal to handle scheduling the promise resolution. |
| 2155 if (!m_paused) { | 2157 if (!m_paused) { |
| 2156 playInternal(); | 2158 playInternal(); |
| 2157 return nullptr; | 2159 return nullptr; |
| 2158 } | 2160 } |
| 2159 | 2161 |
| 2160 String message = ExceptionMessages::failedToExecute( | 2162 String message = ExceptionMessages::failedToExecute( |
| 2161 "play", "HTMLMediaElement", | 2163 "play", "HTMLMediaElement", |
| 2162 "API can only be initiated by a user gesture."); | 2164 "API can only be initiated by a user gesture."); |
| 2163 document().addConsoleMessage(ConsoleMessage::create( | 2165 document().addConsoleMessage(ConsoleMessage::create( |
| 2164 JSMessageSource, WarningMessageLevel, message)); | 2166 JSMessageSource, WarningMessageLevel, message)); |
| 2165 return NotAllowedError; | 2167 return NotAllowedError; |
| 2166 } | 2168 } |
| 2167 } else { | |
| 2168 UserGestureIndicator::utilizeUserGesture(); | |
| 2169 unlockUserGesture(); | |
| 2170 } | 2169 } |
| 2171 | 2170 |
| 2172 if (m_error && m_error->code() == MediaError::kMediaErrSrcNotSupported) | 2171 if (m_error && m_error->code() == MediaError::kMediaErrSrcNotSupported) |
| 2173 return NotSupportedError; | 2172 return NotSupportedError; |
| 2174 | 2173 |
| 2175 playInternal(); | 2174 playInternal(); |
| 2176 | 2175 |
| 2177 return nullptr; | 2176 return nullptr; |
| 2178 } | 2177 } |
| 2179 | 2178 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2344 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) | 2343 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) |
| 2345 << ")"; | 2344 << ")"; |
| 2346 | 2345 |
| 2347 if (m_muted == muted) | 2346 if (m_muted == muted) |
| 2348 return; | 2347 return; |
| 2349 | 2348 |
| 2350 bool wasAutoplayingMuted = isAutoplayingMuted(); | 2349 bool wasAutoplayingMuted = isAutoplayingMuted(); |
| 2351 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && | 2350 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && |
| 2352 m_muted && isLockedPendingUserGesture(); | 2351 m_muted && isLockedPendingUserGesture(); |
| 2353 | 2352 |
| 2354 if (UserGestureIndicator::processingUserGesture()) | 2353 if (UserGestureIndicator::utilizeUserGesture()) |
|
Rick Byers
2016/11/25 15:51:59
It's not clear to me that utilizeUserGesture is ap
foolip
2016/11/28 15:13:05
The documentation says "consider calling utilizeUs
mlamouri (slow - plz ping)
2016/12/01 10:24:50
That one is harder because we eagerly unlock but d
| |
| 2355 unlockUserGesture(); | 2354 unlockUserGesture(); |
| 2356 | 2355 |
| 2357 m_muted = muted; | 2356 m_muted = muted; |
| 2358 | 2357 |
| 2359 scheduleEvent(EventTypeNames::volumechange); | 2358 scheduleEvent(EventTypeNames::volumechange); |
| 2360 | 2359 |
| 2361 // If an element autoplayed while muted, it needs to be unlocked to unmute, | 2360 // If an element autoplayed while muted, it needs to be unlocked to unmute, |
| 2362 // otherwise, it will be paused. | 2361 // otherwise, it will be paused. |
| 2363 if (wasAutoplayingMuted) { | 2362 if (wasAutoplayingMuted) { |
| 2364 if (isGestureNeededForPlayback()) { | 2363 if (isGestureNeededForPlayback()) { |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4030 | 4029 |
| 4031 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) { | 4030 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) { |
| 4032 visitor->trace(m_client); | 4031 visitor->trace(m_client); |
| 4033 } | 4032 } |
| 4034 | 4033 |
| 4035 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { | 4034 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) { |
| 4036 visitor->trace(m_client); | 4035 visitor->trace(m_client); |
| 4037 } | 4036 } |
| 4038 | 4037 |
| 4039 } // namespace blink | 4038 } // namespace blink |
| OLD | NEW |