Bug 763784 - Make VectorImage::GetAnimated check for CSS animations. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Mon, 22 Feb 2016 13:05:20 +0000
changeset 322801 4b13eb25130fe814d7928d69fe63de43af3dd5d4
parent 322800 083181144d0161c6c662c85d2d9d2e7b9638018e
child 322802 b910d65c6943cade98f63240233508c890d02a1c
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs763784
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 763784 - Make VectorImage::GetAnimated check for CSS animations. r=dholbert
dom/animation/AnimationTimeline.h
image/SVGDocumentWrapper.cpp
--- a/dom/animation/AnimationTimeline.h
+++ b/dom/animation/AnimationTimeline.h
@@ -86,16 +86,27 @@ public:
   /**
    * Inform this timeline that |aAnimation| which is or was observing the
    * timeline, has been updated. This serves as both the means to associate
    * AND disassociate animations with a timeline. The timeline itself will
    * determine if it needs to begin, continue or stop tracking this animation.
    */
   virtual void NotifyAnimationUpdated(Animation& aAnimation);
 
+  /**
+   * Returns true if any CSS animations, CSS transitions or Web animations are
+   * currently associated with this timeline.  As soon as an animation is
+   * applied to an element it is associated with the timeline even if it has a
+   * delayed start, so this includes animations that may not be active for some
+   * time.
+   */
+  bool HasAnimations() const {
+    return !mAnimations.IsEmpty();
+  }
+
   void RemoveAnimation(Animation* aAnimation);
 
 protected:
   nsCOMPtr<nsIGlobalObject> mWindow;
 
   // Animations observing this timeline
   //
   // We store them in (a) a hashset for quick lookup, and (b) an array
--- a/image/SVGDocumentWrapper.cpp
+++ b/image/SVGDocumentWrapper.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SVGDocumentWrapper.h"
 
+#include "mozilla/dom/DocumentTimeline.h"
 #include "mozilla/dom/Element.h"
 #include "nsICategoryManager.h"
 #include "nsIChannel.h"
 #include "nsIContentViewer.h"
 #include "nsIDocument.h"
 #include "nsIDocumentLoaderFactory.h"
 #include "nsIDOMSVGLength.h"
 #include "nsIHttpChannel.h"
@@ -110,18 +111,31 @@ SVGDocumentWrapper::FlushImageTransformI
   FlushLayout();
   mIgnoreInvalidation = false;
 }
 
 bool
 SVGDocumentWrapper::IsAnimated()
 {
   nsIDocument* doc = mViewer->GetDocument();
-  return doc && doc->HasAnimationController() &&
-    doc->GetAnimationController()->HasRegisteredAnimations();
+  if (!doc) {
+    return false;
+  }
+  if (doc->Timeline()->HasAnimations()) {
+    // CSS animations (technically HasAnimations() also checks for CSS
+    // transitions and Web animations but since SVG-as-an-image doesn't run
+    // script they will never run in the document that we wrap).
+    return true;
+  }
+  if (doc->HasAnimationController() &&
+      doc->GetAnimationController()->HasRegisteredAnimations()) {
+    // SMIL animations
+    return true;
+  }
+  return false;
 }
 
 void
 SVGDocumentWrapper::StartAnimation()
 {
   // Can be called for animated images during shutdown, after we've
   // already Observe()'d XPCOM shutdown and cleared out our mViewer pointer.
   if (!mViewer) {