Chromium Code Reviews| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 using namespace HTMLNames; | 104 using namespace HTMLNames; |
| 105 | 105 |
| 106 using WeakMediaElementSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaEl ement>>; | 106 using WeakMediaElementSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaEl ement>>; |
| 107 using DocumentElementSetMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<Document> , WeakMediaElementSet>; | 107 using DocumentElementSetMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<Document> , WeakMediaElementSet>; |
| 108 | 108 |
| 109 namespace { | 109 namespace { |
| 110 | 110 |
| 111 // URL protocol used to signal that the media source API is being used. | 111 // URL protocol used to signal that the media source API is being used. |
| 112 const char mediaSourceBlobProtocol[] = "blob"; | 112 const char mediaSourceBlobProtocol[] = "blob"; |
| 113 | 113 |
| 114 enum MediaControlsShow { | |
| 115 MediaControlsShowAttribute = 0, | |
| 116 MediaControlsShowFullscreen, | |
| 117 MediaControlsShowNoScript, | |
| 118 MediaControlsShowNone, | |
|
philipj_slow
2016/02/19 04:05:43
Maybe MediaControlsNotShown?
mlamouri (slow - plz ping)
2016/02/23 18:42:13
Done.
| |
| 119 MediaControlsShowMax | |
|
philipj_slow
2016/02/19 04:05:43
AutoplayExperimentHelper.h has NumberOfAutoplayMet
mlamouri (slow - plz ping)
2016/02/23 18:42:13
Yes, it is a weird exception, see: https://code.go
philipj_slow
2016/02/24 09:54:33
OK, there's a bit of both, and some *Count as well
| |
| 120 }; | |
| 121 | |
| 114 #if !LOG_DISABLED | 122 #if !LOG_DISABLED |
| 115 String urlForLoggingMedia(const KURL& url) | 123 String urlForLoggingMedia(const KURL& url) |
| 116 { | 124 { |
| 117 static const unsigned maximumURLLengthForLogging = 128; | 125 static const unsigned maximumURLLengthForLogging = 128; |
| 118 | 126 |
| 119 if (url.string().length() < maximumURLLengthForLogging) | 127 if (url.string().length() < maximumURLLengthForLogging) |
| 120 return url.string(); | 128 return url.string(); |
| 121 return url.string().substring(0, maximumURLLengthForLogging) + "..."; | 129 return url.string().substring(0, maximumURLLengthForLogging) + "..."; |
| 122 } | 130 } |
| 123 | 131 |
| (...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2076 } | 2084 } |
| 2077 | 2085 |
| 2078 void HTMLMediaElement::setLoop(bool b) | 2086 void HTMLMediaElement::setLoop(bool b) |
| 2079 { | 2087 { |
| 2080 WTF_LOG(Media, "HTMLMediaElement::setLoop(%p, %s)", this, boolString(b)); | 2088 WTF_LOG(Media, "HTMLMediaElement::setLoop(%p, %s)", this, boolString(b)); |
| 2081 setBooleanAttribute(loopAttr, b); | 2089 setBooleanAttribute(loopAttr, b); |
| 2082 } | 2090 } |
| 2083 | 2091 |
| 2084 bool HTMLMediaElement::shouldShowControls() const | 2092 bool HTMLMediaElement::shouldShowControls() const |
| 2085 { | 2093 { |
| 2086 LocalFrame* frame = document().frame(); | 2094 return shouldShowControlsInternal(false); |
| 2087 | |
| 2088 // always show controls when scripting is disabled | |
| 2089 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) | |
| 2090 return true; | |
| 2091 | |
| 2092 // Always show controls when in full screen mode. | |
| 2093 if (isFullscreen()) | |
| 2094 return true; | |
| 2095 | |
| 2096 return fastHasAttribute(controlsAttr); | |
| 2097 } | 2095 } |
| 2098 | 2096 |
| 2099 double HTMLMediaElement::volume() const | 2097 double HTMLMediaElement::volume() const |
| 2100 { | 2098 { |
| 2101 return m_volume; | 2099 return m_volume; |
| 2102 } | 2100 } |
| 2103 | 2101 |
| 2104 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) | 2102 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) |
| 2105 { | 2103 { |
| 2106 WTF_LOG(Media, "HTMLMediaElement::setVolume(%p, %f)", this, vol); | 2104 WTF_LOG(Media, "HTMLMediaElement::setVolume(%p, %f)", this, vol); |
| (...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3346 void HTMLMediaElement::configureMediaControls() | 3344 void HTMLMediaElement::configureMediaControls() |
| 3347 { | 3345 { |
| 3348 if (!inDocument()) { | 3346 if (!inDocument()) { |
| 3349 if (mediaControls()) | 3347 if (mediaControls()) |
| 3350 mediaControls()->hide(); | 3348 mediaControls()->hide(); |
| 3351 return; | 3349 return; |
| 3352 } | 3350 } |
| 3353 | 3351 |
| 3354 ensureMediaControls(); | 3352 ensureMediaControls(); |
| 3355 mediaControls()->reset(); | 3353 mediaControls()->reset(); |
| 3356 if (shouldShowControls()) | 3354 |
| 3355 if (shouldShowControlsInternal(true)) | |
| 3357 mediaControls()->show(); | 3356 mediaControls()->show(); |
| 3358 else | 3357 else |
| 3359 mediaControls()->hide(); | 3358 mediaControls()->hide(); |
| 3360 } | 3359 } |
| 3361 | 3360 |
| 3362 CueTimeline& HTMLMediaElement::cueTimeline() | 3361 CueTimeline& HTMLMediaElement::cueTimeline() |
| 3363 { | 3362 { |
| 3364 if (!m_cueTimeline) | 3363 if (!m_cueTimeline) |
| 3365 m_cueTimeline = adoptPtrWillBeNoop(new CueTimeline(*this)); | 3364 m_cueTimeline = adoptPtrWillBeNoop(new CueTimeline(*this)); |
| 3366 return *m_cueTimeline; | 3365 return *m_cueTimeline; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3568 { | 3567 { |
| 3569 m_autoplayHelper.updatePositionNotificationRegistration(); | 3568 m_autoplayHelper.updatePositionNotificationRegistration(); |
| 3570 } | 3569 } |
| 3571 | 3570 |
| 3572 // TODO(liberato): remove once autoplay gesture override experiment concludes. | 3571 // TODO(liberato): remove once autoplay gesture override experiment concludes. |
| 3573 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() | 3572 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() |
| 3574 { | 3573 { |
| 3575 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); | 3574 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); |
| 3576 } | 3575 } |
| 3577 | 3576 |
| 3577 bool HTMLMediaElement::shouldShowControlsInternal(bool record) const | |
| 3578 { | |
| 3579 DEFINE_STATIC_LOCAL(EnumerationHistogram, showControlsHistogram, ("Media.Con trols.Show", MediaControlsShowMax)); | |
| 3580 | |
| 3581 // These checks are in order of conditions superseeding each other, which | |
|
philipj_slow
2016/02/19 04:05:43
Well, this would be true of any order where all "r
mlamouri (slow - plz ping)
2016/02/23 18:42:13
I understand what you mean. I guess my comment is
| |
| 3582 // also matches speed. In other words, a media element with a controls | |
| 3583 // attribute, will always have controls, regardless of the other conditions. | |
| 3584 // Same for an element in fullscreen. That means that recorded metrics will | |
| 3585 // only show the superseeding reason of the controls showing. | |
| 3586 | |
| 3587 if (fastHasAttribute(controlsAttr)) { | |
| 3588 if (record) | |
| 3589 showControlsHistogram.count(MediaControlsShowAttribute); | |
| 3590 return true; | |
| 3591 } | |
| 3592 | |
| 3593 if (isFullscreen()) { | |
| 3594 if (record) | |
| 3595 showControlsHistogram.count(MediaControlsShowFullscreen); | |
| 3596 return true; | |
| 3597 } | |
| 3598 | |
| 3599 LocalFrame* frame = document().frame(); | |
| 3600 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) { | |
| 3601 if (record) | |
| 3602 showControlsHistogram.count(MediaControlsShowNoScript); | |
| 3603 return true; | |
| 3604 } | |
| 3605 | |
| 3606 showControlsHistogram.count(MediaControlsShowNone); | |
| 3607 return false; | |
| 3608 } | |
| 3609 | |
| 3578 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3610 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3579 { | 3611 { |
| 3580 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) | 3612 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) |
| 3581 audioSourceProvider().setClient(nullptr); | 3613 audioSourceProvider().setClient(nullptr); |
| 3582 } | 3614 } |
| 3583 | 3615 |
| 3584 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) | 3616 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) |
| 3585 { | 3617 { |
| 3586 MutexLocker locker(provideInputLock); | 3618 MutexLocker locker(provideInputLock); |
| 3587 | 3619 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3635 { | 3667 { |
| 3636 visitor->trace(m_client); | 3668 visitor->trace(m_client); |
| 3637 } | 3669 } |
| 3638 | 3670 |
| 3639 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3671 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
| 3640 { | 3672 { |
| 3641 visitor->trace(m_client); | 3673 visitor->trace(m_client); |
| 3642 } | 3674 } |
| 3643 | 3675 |
| 3644 } // namespace blink | 3676 } // namespace blink |
| OLD | NEW |