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

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

Issue 2245613002: Revert "Simplify ElementVisibilityObserver implementation." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | 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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 1652
1653 // If the autoplay experiment says that it's okay to play now, 1653 // If the autoplay experiment says that it's okay to play now,
1654 // then don't require a user gesture. 1654 // then don't require a user gesture.
1655 m_autoplayHelper->becameReadyToPlay(); 1655 m_autoplayHelper->becameReadyToPlay();
1656 1656
1657 if (!isGestureNeededForPlayback()) { 1657 if (!isGestureNeededForPlayback()) {
1658 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) { 1658 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) {
1659 // We might end up in a situation where the previous 1659 // We might end up in a situation where the previous
1660 // observer didn't had time to fire yet. We can avoid 1660 // observer didn't had time to fire yet. We can avoid
1661 // creating a new one in this case. 1661 // creating a new one in this case.
1662 if (!m_autoplayVisibilityObserver) 1662 if (!m_autoplayVisibilityObserver) {
1663 m_autoplayVisibilityObserver = ElementVisibilityObserver ::create(this, this); 1663 m_autoplayVisibilityObserver = new ElementVisibilityObse rver(this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapWeak Persistent(this)));
1664 m_autoplayVisibilityObserver->start();
1665 }
1664 } else { 1666 } else {
1665 m_paused = false; 1667 m_paused = false;
1666 invalidateCachedTime(); 1668 invalidateCachedTime();
1667 scheduleEvent(EventTypeNames::play); 1669 scheduleEvent(EventTypeNames::play);
1668 scheduleNotifyPlaying(); 1670 scheduleNotifyPlaying();
1669 m_autoplaying = false; 1671 m_autoplaying = false;
1670 } 1672 }
1671 } 1673 }
1672 } 1674 }
1673 1675
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3668 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3667 visitor->trace(m_playPromiseResolvers); 3669 visitor->trace(m_playPromiseResolvers);
3668 visitor->trace(m_playPromiseResolveList); 3670 visitor->trace(m_playPromiseResolveList);
3669 visitor->trace(m_playPromiseRejectList); 3671 visitor->trace(m_playPromiseRejectList);
3670 visitor->trace(m_audioSourceProvider); 3672 visitor->trace(m_audioSourceProvider);
3671 visitor->trace(m_autoplayHelperClient); 3673 visitor->trace(m_autoplayHelperClient);
3672 visitor->trace(m_autoplayHelper); 3674 visitor->trace(m_autoplayHelper);
3673 visitor->trace(m_srcObject); 3675 visitor->trace(m_srcObject);
3674 visitor->trace(m_autoplayVisibilityObserver); 3676 visitor->trace(m_autoplayVisibilityObserver);
3675 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); 3677 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this);
3678 Supplementable<HTMLMediaElement>::trace(visitor);
3676 HTMLElement::trace(visitor); 3679 HTMLElement::trace(visitor);
3677 Supplementable<HTMLMediaElement>::trace(visitor);
3678 ActiveDOMObject::trace(visitor); 3680 ActiveDOMObject::trace(visitor);
3679 } 3681 }
3680 3682
3681 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) 3683 DEFINE_TRACE_WRAPPERS(HTMLMediaElement)
3682 { 3684 {
3683 visitor->traceWrappers(m_videoTracks); 3685 visitor->traceWrappers(m_videoTracks);
3684 visitor->traceWrappers(m_audioTracks); 3686 visitor->traceWrappers(m_audioTracks);
3685 visitor->traceWrappers(m_textTracks); 3687 visitor->traceWrappers(m_textTracks);
3686 HTMLElement::traceWrappers(visitor); 3688 HTMLElement::traceWrappers(visitor);
3687 } 3689 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3905 } 3907 }
3906 } 3908 }
3907 3909
3908 void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus sta tus) 3910 void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus sta tus)
3909 { 3911 {
3910 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax)); 3912 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax));
3911 3913
3912 autoplayUnmuteHistogram.count(status); 3914 autoplayUnmuteHistogram.count(status);
3913 } 3915 }
3914 3916
3915 void HTMLMediaElement::onVisibilityChanged(bool isVisible) 3917 void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible)
3916 { 3918 {
3917 if (!isVisible) 3919 if (!isVisible)
3918 return; 3920 return;
3919 3921
3920 if (shouldAutoplay()) { 3922 if (shouldAutoplay()) {
3921 m_paused = false; 3923 m_paused = false;
3922 invalidateCachedTime(); 3924 invalidateCachedTime();
3923 scheduleEvent(EventTypeNames::play); 3925 scheduleEvent(EventTypeNames::play);
3924 scheduleNotifyPlaying(); 3926 scheduleNotifyPlaying();
3925 m_autoplaying = false; 3927 m_autoplaying = false;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 4042
4041 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4043 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4042 { 4044 {
4043 IntRect result; 4045 IntRect result;
4044 if (LayoutObject* object = m_element->layoutObject()) 4046 if (LayoutObject* object = m_element->layoutObject())
4045 result = object->absoluteBoundingBoxRect(); 4047 result = object->absoluteBoundingBoxRect();
4046 return result; 4048 return result;
4047 } 4049 }
4048 4050
4049 } // namespace blink 4051 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698