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

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

Issue 2173353002: Simplify ElementVisibilityObserver implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust visibility 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 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1632
1633 // If the autoplay experiment says that it's okay to play now, 1633 // If the autoplay experiment says that it's okay to play now,
1634 // then don't require a user gesture. 1634 // then don't require a user gesture.
1635 m_autoplayHelper->becameReadyToPlay(); 1635 m_autoplayHelper->becameReadyToPlay();
1636 1636
1637 if (!isGestureNeededForPlayback()) { 1637 if (!isGestureNeededForPlayback()) {
1638 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) { 1638 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) {
1639 // We might end up in a situation where the previous 1639 // We might end up in a situation where the previous
1640 // observer didn't had time to fire yet. We can avoid 1640 // observer didn't had time to fire yet. We can avoid
1641 // creating a new one in this case. 1641 // creating a new one in this case.
1642 if (!m_autoplayVisibilityObserver) { 1642 if (!m_autoplayVisibilityObserver)
1643 m_autoplayVisibilityObserver = new ElementVisibilityObse rver(this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapWeak Persistent(this))); 1643 m_autoplayVisibilityObserver = ElementVisibilityObserver ::create(this, this);
1644 m_autoplayVisibilityObserver->start();
1645 }
1646 } else { 1644 } else {
1647 m_paused = false; 1645 m_paused = false;
1648 invalidateCachedTime(); 1646 invalidateCachedTime();
1649 scheduleEvent(EventTypeNames::play); 1647 scheduleEvent(EventTypeNames::play);
1650 scheduleNotifyPlaying(); 1648 scheduleNotifyPlaying();
1651 m_autoplaying = false; 1649 m_autoplaying = false;
1652 } 1650 }
1653 } 1651 }
1654 } 1652 }
1655 1653
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3664 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3662 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3665 visitor->trace(m_playPromiseResolvers); 3663 visitor->trace(m_playPromiseResolvers);
3666 visitor->trace(m_playPromiseResolveList); 3664 visitor->trace(m_playPromiseResolveList);
3667 visitor->trace(m_playPromiseRejectList); 3665 visitor->trace(m_playPromiseRejectList);
3668 visitor->trace(m_audioSourceProvider); 3666 visitor->trace(m_audioSourceProvider);
3669 visitor->trace(m_autoplayHelperClient); 3667 visitor->trace(m_autoplayHelperClient);
3670 visitor->trace(m_autoplayHelper); 3668 visitor->trace(m_autoplayHelper);
3671 visitor->trace(m_srcObject); 3669 visitor->trace(m_srcObject);
3672 visitor->trace(m_autoplayVisibilityObserver); 3670 visitor->trace(m_autoplayVisibilityObserver);
3673 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); 3671 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this);
3672 HTMLElement::trace(visitor);
3674 Supplementable<HTMLMediaElement>::trace(visitor); 3673 Supplementable<HTMLMediaElement>::trace(visitor);
3675 HTMLElement::trace(visitor);
3676 ActiveDOMObject::trace(visitor); 3674 ActiveDOMObject::trace(visitor);
3677 } 3675 }
3678 3676
3679 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) 3677 DEFINE_TRACE_WRAPPERS(HTMLMediaElement)
3680 { 3678 {
3681 visitor->traceWrappers(m_videoTracks); 3679 visitor->traceWrappers(m_videoTracks);
3682 visitor->traceWrappers(m_audioTracks); 3680 visitor->traceWrappers(m_audioTracks);
3683 visitor->traceWrappers(m_textTracks); 3681 visitor->traceWrappers(m_textTracks);
3684 HTMLElement::traceWrappers(visitor); 3682 HTMLElement::traceWrappers(visitor);
3685 } 3683 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 } 3901 }
3904 } 3902 }
3905 3903
3906 void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus sta tus) 3904 void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus sta tus)
3907 { 3905 {
3908 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax)); 3906 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax));
3909 3907
3910 autoplayUnmuteHistogram.count(status); 3908 autoplayUnmuteHistogram.count(status);
3911 } 3909 }
3912 3910
3913 void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible) 3911 void HTMLMediaElement::onVisibilityChanged(bool isVisible)
3914 { 3912 {
3915 if (!isVisible) 3913 if (!isVisible)
3916 return; 3914 return;
3917 3915
3918 if (shouldAutoplay()) { 3916 if (shouldAutoplay()) {
3919 m_paused = false; 3917 m_paused = false;
3920 invalidateCachedTime(); 3918 invalidateCachedTime();
3921 scheduleEvent(EventTypeNames::play); 3919 scheduleEvent(EventTypeNames::play);
3922 scheduleNotifyPlaying(); 3920 scheduleNotifyPlaying();
3923 m_autoplaying = false; 3921 m_autoplaying = false;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4038 4036
4039 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4037 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4040 { 4038 {
4041 IntRect result; 4039 IntRect result;
4042 if (LayoutObject* object = m_element->layoutObject()) 4040 if (LayoutObject* object = m_element->layoutObject())
4043 result = object->absoluteBoundingBoxRect(); 4041 result = object->absoluteBoundingBoxRect();
4044 return result; 4042 return result;
4045 } 4043 }
4046 4044
4047 } // namespace blink 4045 } // 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