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

Unified Diff: Source/core/animation/Player.cpp

Issue 23874019: Web Animations CSS: Start running animations on the compositor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/Player.cpp
diff --git a/Source/core/animation/Player.cpp b/Source/core/animation/Player.cpp
index 92c7cf4ca491e513fae3cdfbcca78171125c9071..946e1bc542a968a0846973ee1a3302b4a52e94e1 100644
--- a/Source/core/animation/Player.cpp
+++ b/Source/core/animation/Player.cpp
@@ -32,17 +32,12 @@
#include "config.h"
#include "core/animation/Player.h"
+#include "core/animation/Animation.h"
#include "core/animation/DocumentTimeline.h"
#include "core/animation/TimedItem.h"
namespace WebCore {
-namespace {
-
-double effectiveTime(double time) { return isNull(time) ? 0 : time; }
-
-} // namespace
-
PassRefPtr<Player> Player::create(DocumentTimeline& timeline, TimedItem* content)
{
return adoptRef(new Player(timeline, content));
@@ -82,6 +77,45 @@ double Player::currentTimeBeforeDrift() const
return (effectiveTime(m_timeline.currentTime()) - startTime()) * m_playbackRate;
}
+bool Player::isCandidateForCompositorAnimation() const
+{
+ if (!m_content || !m_content->isAnimation())
+ return false;
+
+ const Animation* animation = toAnimation(m_content.get());
+ if (hasStartTime()) {
+ // FIXME: Support starting compositor animations that have a fixed
+ // start time.
+ return animation->isRunningCompositorAnimation();
shans 2013/11/18 01:02:06 This is confusing. Why doesn't this method map cle
dstockwell 2013/11/18 05:30:34 This method no longer exists.
+ }
+
+ return animation->isCandidateForCompositorAnimation();
+}
+
+bool Player::startCompositorAnimations()
+{
+ // FIXME: Support starting compositor animations that have a fixed
+ // start time.
+ ASSERT(!hasStartTime());
+ if (!m_content || !m_content->isAnimation())
+ return false;
+
+ return toAnimation(m_content.get())->startCompositorAnimations();
+}
+
+bool Player::isRunningCompositorAnimation(const Element* element, CSSPropertyID property)
+{
+ if (!m_content || !m_content->isAnimation())
+ return false;
+ return toAnimation(m_content.get())->isRunningCompositorAnimation(element, property);
+}
+
+void Player::cancelCompositorAnimations()
+{
+ if (isRunningCompositorAnimation())
+ toAnimation(m_content.get())->cancelCompositorAnimations();
+}
+
double Player::pausedTimeDrift() const
{
ASSERT(pausedInternal());
@@ -139,7 +173,8 @@ void Player::setCurrentTime(double seekTime)
void Player::pauseForTesting()
{
- ASSERT(!paused());
+ RELEASE_ASSERT(!isRunningCompositorAnimation());
+ RELEASE_ASSERT(!paused());
m_isPausedForTesting = true;
setPausedImpl(true);
}
@@ -155,9 +190,10 @@ void Player::setPausedImpl(bool newValue)
if (pausedInternal() == newValue)
return;
- if (newValue)
+ if (newValue) {
+ cancelCompositorAnimations();
m_pauseStartTime = currentTime();
- else {
+ } else {
m_timeDrift = pausedTimeDrift();
m_pauseStartTime = nullValue();
}

Powered by Google App Engine
This is Rietveld 408576698