#include "config.h"
#include "core/animation/DocumentAnimations.h"
-#include "core/animation/ActiveAnimations.h"
#include "core/animation/AnimationClock.h"
#include "core/animation/DocumentTimeline.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/dom/Node.h"
+#include "core/dom/NodeRenderStyle.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/rendering/RenderView.h"
namespace {
-void updateAnimationTiming(Document& document)
+void updateAnimationTiming(Document& document, TimingUpdateReason reason)
{
- document.timeline().serviceAnimations();
- document.transitionTimeline().serviceAnimations();
+ document.timeline().serviceAnimations(reason);
+ document.transitionTimeline().serviceAnimations(reason);
}
} // namespace
void DocumentAnimations::updateAnimationTimingForAnimationFrame(Document& document, double monotonicAnimationStartTime)
{
document.animationClock().updateTime(monotonicAnimationStartTime);
- updateAnimationTiming(document);
+ updateAnimationTiming(document, TimingUpdateForAnimationFrame);
}
-void DocumentAnimations::updateOutdatedAnimationPlayersAfterFrameCallbacks(Document& document)
+void DocumentAnimations::updateOutdatedAnimationPlayersIfNeeded(Document& document)
{
- if (document.timeline().hasOutdatedAnimationPlayer()) {
- updateAnimationTiming(document);
- }
+ if (needsOutdatedAnimationPlayerUpdate(document))
+ updateAnimationTiming(document, TimingUpdateOnDemand);
}
void DocumentAnimations::updateAnimationTimingForGetComputedStyle(Node& node, CSSPropertyID property)
if (!node.isElementNode())
return;
const Element& element = toElement(node);
- if (element.document().timeline().hasOutdatedAnimationPlayer()) {
- updateAnimationTiming(element.document());
- return;
- }
- if (const ActiveAnimations* activeAnimations = element.activeAnimations()) {
- if (activeAnimations->hasActiveAnimationsOnCompositor(property))
- updateAnimationTiming(element.document());
+ if (RenderStyle* style = element.renderStyle()) {
+ if ((property == CSSPropertyOpacity && style->isRunningOpacityAnimationOnCompositor())
+ || ((property == CSSPropertyTransform || property == CSSPropertyWebkitTransform) && style->isRunningTransformAnimationOnCompositor())
+ || (property == CSSPropertyWebkitFilter && style->isRunningFilterAnimationOnCompositor())) {
+ updateAnimationTiming(element.document(), TimingUpdateOnDemand);
+ }
}
}
+bool DocumentAnimations::needsOutdatedAnimationPlayerUpdate(const Document& document)
+{
+ return document.timeline().hasOutdatedAnimationPlayer() || document.transitionTimeline().hasOutdatedAnimationPlayer();
+}
+
void DocumentAnimations::startPendingAnimations(Document& document)
{
ASSERT(document.lifecycle().state() == DocumentLifecycle::CompositingClean);
- if (document.cssPendingAnimations().startPendingAnimations()) {
+ if (document.compositorPendingAnimations().startPendingAnimations()) {
ASSERT(document.view());
document.view()->scheduleAnimation();
}