Bug 948531 - Layerize elements with transition or animation immediately. r=mattwoodrow
☠☠ backed out by 9389007688e1 ☠ ☠
authorBenoit Girard <b56girard@gmail.com>
Wed, 11 Dec 2013 15:48:06 -0500
changeset 159971 d8fb025ca7d21bb74677c82965d0b3ac40ae0762
parent 159970 c028800412cae48128b0e83dfac6f911c5af0c5d
child 159972 9e6bdc10cf33f0d165b3597ebcb3c10536e21f02
push id37471
push userb56girard@gmail.com
push dateWed, 11 Dec 2013 21:26:41 +0000
treeherdermozilla-inbound@d8fb025ca7d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs948531
milestone29.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 948531 - Layerize elements with transition or animation immediately. r=mattwoodrow
layout/base/ActiveLayerTracker.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
--- a/layout/base/ActiveLayerTracker.cpp
+++ b/layout/base/ActiveLayerTracker.cpp
@@ -5,16 +5,18 @@
 #include "ActiveLayerTracker.h"
 
 #include "nsExpirationTracker.h"
 #include "nsIFrame.h"
 #include "nsIContent.h"
 #include "nsRefreshDriver.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocument.h"
+#include "nsAnimationManager.h"
+#include "nsTransitionManager.h"
 
 namespace mozilla {
 
 /**
  * This tracks the state of a frame that may need active layers due to
  * ongoing content changes or style changes that indicate animation.
  *
  * When no changes of *any* kind are detected after 75-100ms we remove this
@@ -210,16 +212,28 @@ ActiveLayerTracker::IsStyleAnimated(nsIF
   if (layerActivity) {
     if (layerActivity->RestyleCountForProperty(aProperty) >= 2) {
       return true;
     }
   }
   if (aProperty == eCSSProperty_transform && aFrame->Preserves3D()) {
     return IsStyleAnimated(aFrame->GetParent(), aProperty);
   }
+  nsIContent* content = aFrame->GetContent();
+  if (content) {
+    if (mozilla::HasAnimationOrTransition<ElementAnimations>(
+          content, nsGkAtoms::animationsProperty, aProperty)) {
+      return true;
+    }
+    if (mozilla::HasAnimationOrTransition<ElementTransitions>(
+          content, nsGkAtoms::transitionsProperty, aProperty)) {
+      return true;
+    }
+  }
+
   return false;
 }
 
 /* static */ bool
 ActiveLayerTracker::IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame)
 {
   LayerActivity* layerActivity = GetLayerActivity(aFrame);
   if (layerActivity) {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -225,33 +225,44 @@ nsLayoutUtils::HasAnimationsForComposito
     return false;
   return HasAnimationOrTransitionForCompositor<ElementAnimations>
             (aContent, nsGkAtoms::animationsProperty, aProperty) ||
          HasAnimationOrTransitionForCompositor<ElementTransitions>
             (aContent, nsGkAtoms::transitionsProperty, aProperty);
 }
 
 template <class AnimationsOrTransitions>
-static AnimationsOrTransitions*
-HasAnimationOrTransition(nsIContent* aContent,
+AnimationsOrTransitions*
+mozilla::HasAnimationOrTransition(nsIContent* aContent,
                          nsIAtom* aAnimationProperty,
                          nsCSSProperty aProperty)
 {
   AnimationsOrTransitions* animations =
     static_cast<AnimationsOrTransitions*>(aContent->GetProperty(aAnimationProperty));
   if (animations) {
     bool propertyMatches = animations->HasAnimationOfProperty(aProperty);
     if (propertyMatches) {
       return animations;
     }
   }
 
   return nullptr;
 }
 
+template ElementAnimations*
+mozilla::HasAnimationOrTransition<ElementAnimations>(nsIContent* aContent,
+                         nsIAtom* aAnimationProperty,
+                         nsCSSProperty aProperty);
+
+template ElementTransitions*
+mozilla::HasAnimationOrTransition<ElementTransitions>(nsIContent* aContent,
+                         nsIAtom* aAnimationProperty,
+                         nsCSSProperty aProperty);
+
+
 bool
 nsLayoutUtils::HasAnimations(nsIContent* aContent,
                              nsCSSProperty aProperty)
 {
   if (!aContent->MayHaveAnimations())
     return false;
   return HasAnimationOrTransition<ElementAnimations>
             (aContent, nsGkAtoms::animationsProperty, aProperty) ||
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -65,16 +65,22 @@ class DOMRectList;
 class Element;
 class HTMLImageElement;
 class HTMLCanvasElement;
 class HTMLVideoElement;
 } // namespace dom
 namespace layers {
 class Layer;
 }
+
+template <class AnimationsOrTransitions>
+extern AnimationsOrTransitions* HasAnimationOrTransition(nsIContent* aContent,
+                                                         nsIAtom* aAnimationProperty,
+                                                         nsCSSProperty aProperty);
+
 } // namespace mozilla
 
 /**
  * nsLayoutUtils is a namespace class used for various helper
  * functions that are useful in multiple places in layout.  The goal
  * is not to define multiple copies of the same static helper.
  */
 class nsLayoutUtils