Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / animation / DocumentAnimations.cpp
index ac67bc8..16815bb 100644 (file)
 #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"
@@ -46,10 +46,10 @@ namespace WebCore {
 
 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
@@ -57,14 +57,13 @@ void updateAnimationTiming(Document& document)
 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)
@@ -72,20 +71,24 @@ void DocumentAnimations::updateAnimationTimingForGetComputedStyle(Node& node, CS
     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();
     }