Bug 1205475 - Early return in nsLayoutUtils::HasAnimationOfProperty if there is no animation on the target frame. draft
authorcku <cku@mozilla.com>
Tue, 16 May 2017 12:17:34 +0800
changeset 578546 ef466482efab50cf69f97992f211b68c2af0d4bf
parent 578175 3e166b6838931b3933ca274331f9e0e115af5cc0
child 628744 236d40d5fcea030ce6d47131a7e60d811ffa0b41
push id58952
push userbmo:cku@mozilla.com
push dateTue, 16 May 2017 05:41:48 +0000
bugs1205475
milestone55.0a1
Bug 1205475 - Early return in nsLayoutUtils::HasAnimationOfProperty if there is no animation on the target frame. Early return in nsLayoutUtils::HasAnimationOfProperty to save execution time of the callers, which includes nsIFrame::HasAnimationOfTransform, nsIFrame::HasOpacityInternal and nsIFrame::BuildDisplayListForStackingContext. MozReview-Commit-ID: DN364gphpUq
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -505,16 +505,22 @@ nsLayoutUtils::HasCurrentTransitions(con
     }
   );
 }
 
 bool
 nsLayoutUtils::HasAnimationOfProperty(const nsIFrame* aFrame,
                                       nsCSSPropertyID aProperty)
 {
+  if (aFrame->GetContent() && aFrame->GetContent()->MayHaveAnimations()) {
+    return false; // Early return if there is no possibility to have any
+                  // animation on this frame to prevent hash table searching in
+                  // aEffect.HasAnimationOfProperty.
+  }
+
   return HasMatchingAnimations(aFrame,
     [&aProperty](KeyframeEffectReadOnly& aEffect)
     {
       return (aEffect.IsInEffect() || aEffect.IsCurrent()) &&
              aEffect.HasAnimationOfProperty(aProperty);
     }
   );
 }