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

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

Issue 2118313002: Do not create more than one ElementVisibilityObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 // Check for autoplay, and record metrics about it if needed. 1627 // Check for autoplay, and record metrics about it if needed.
1628 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { 1628 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) {
1629 recordAutoplaySourceMetric(AutoplaySourceAttribute); 1629 recordAutoplaySourceMetric(AutoplaySourceAttribute);
1630 1630
1631 // If the autoplay experiment says that it's okay to play now, 1631 // If the autoplay experiment says that it's okay to play now,
1632 // then don't require a user gesture. 1632 // then don't require a user gesture.
1633 m_autoplayHelper->becameReadyToPlay(); 1633 m_autoplayHelper->becameReadyToPlay();
1634 1634
1635 if (!isGestureNeededForPlayback()) { 1635 if (!isGestureNeededForPlayback()) {
1636 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) { 1636 if (isHTMLVideoElement() && muted() && RuntimeEnabledFeatures::a utoplayMutedVideosEnabled()) {
1637 m_autoplayVisibilityObserver = new ElementVisibilityObserver (this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapPersiste nt(this))); 1637 // We might end up in a situation where the previous
1638 m_autoplayVisibilityObserver->start(); 1638 // observer didn't had time to fire yet. We can avoid
1639 // creating a new one in this case.
1640 if (!m_autoplayVisibilityObserver) {
1641 m_autoplayVisibilityObserver = new ElementVisibilityObse rver(this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapPers istent(this)));
1642 m_autoplayVisibilityObserver->start();
1643 }
1639 } else { 1644 } else {
1640 m_paused = false; 1645 m_paused = false;
1641 invalidateCachedTime(); 1646 invalidateCachedTime();
1642 scheduleEvent(EventTypeNames::play); 1647 scheduleEvent(EventTypeNames::play);
1643 scheduleNotifyPlaying(); 1648 scheduleNotifyPlaying();
1644 m_autoplaying = false; 1649 m_autoplaying = false;
1645 } 1650 }
1646 } 1651 }
1647 } 1652 }
1648 1653
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 4033
4029 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4034 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4030 { 4035 {
4031 IntRect result; 4036 IntRect result;
4032 if (LayoutObject* object = m_element->layoutObject()) 4037 if (LayoutObject* object = m_element->layoutObject())
4033 result = object->absoluteBoundingBoxRect(); 4038 result = object->absoluteBoundingBoxRect();
4034 return result; 4039 return result;
4035 } 4040 }
4036 4041
4037 } // namespace blink 4042 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698