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 578505 10a21c7f82de7c1f96c037a3f4e8c8fed4e6fad6
parent 578175 3e166b6838931b3933ca274331f9e0e115af5cc0
child 628734 524bec719fe711c415ec62ffdb779a77b71ff979
push id58941
push userbmo:cku@mozilla.com
push dateTue, 16 May 2017 04:28:46 +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->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);
     }
   );
 }