Bug 1322291 - Part 1: Block nested calls of KeyframeEffectReadOnly::ComposeStyle(). r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 21 Dec 2016 13:52:19 +0900
changeset 452169 0522b9c09b877837b88395d0fb93ac0f85dced37
parent 451680 f81e340379bb8962c7c50497156c81ce5ecea362
child 452170 f634da356ea9b58a3e00d2cd7df527ec48845d67
push id39335
push userhiikezoe@mozilla-japan.org
push dateWed, 21 Dec 2016 07:23:19 +0000
reviewersbirtles
bugs1322291
milestone53.0a1
Bug 1322291 - Part 1: Block nested calls of KeyframeEffectReadOnly::ComposeStyle(). r?birtles KeyframeEffectReadOnly::ComposeStyle() might call nsStyleSet::ResolveStyleFor(), and KeyframeEffectReadOnly::ComposeStyle() itself is called from nsStyleSet::ResolveStyleFor(). So we have to carefully avoid nested calls of ComposeStyle. MozReview-Commit-ID: IRM99bGUFLa
dom/animation/KeyframeEffectReadOnly.cpp
dom/animation/KeyframeEffectReadOnly.h
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -6,16 +6,17 @@
 
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 
 #include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
   // For UnrestrictedDoubleOrKeyframeAnimationOptions;
 #include "mozilla/dom/CSSPseudoElement.h"
 #include "mozilla/dom/KeyframeEffectBinding.h"
 #include "mozilla/AnimationUtils.h"
+#include "mozilla/AutoRestore.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/FloatingPoint.h" // For IsFinite
 #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
 #include "mozilla/KeyframeUtils.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "Layers.h" // For Layer
 #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetStyleContextForElement
@@ -386,16 +387,23 @@ KeyframeEffectReadOnly::CompositeValue(
                         aCompositeOperation);
 }
 
 void
 KeyframeEffectReadOnly::ComposeStyle(
   RefPtr<AnimValuesStyleRule>& aStyleRule,
   const nsCSSPropertyIDSet& aPropertiesToSkip)
 {
+  if (mIsComposingStyle) {
+    return;
+  }
+
+  AutoRestore<bool> isComposingStyle(mIsComposingStyle);
+  mIsComposingStyle = true;
+
   ComputedTiming computedTiming = GetComputedTiming();
   mProgressOnLastCompose = computedTiming.mProgress;
   mCurrentIterationOnLastCompose = computedTiming.mCurrentIteration;
 
   // If the progress is null, we don't have fill data for the current
   // time so we shouldn't animate.
   if (computedTiming.mProgress.IsNull()) {
     return;
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -472,14 +472,17 @@ private:
   // animations for |aFrame|. When returning true, the reason for the
   // limitation is stored in |aOutPerformanceWarning|.
   static bool CanAnimateTransformOnCompositor(
     const nsIFrame* aFrame,
     AnimationPerformanceWarning::Type& aPerformanceWarning);
   static bool IsGeometricProperty(const nsCSSPropertyID aProperty);
 
   static const TimeDuration OverflowRegionRefreshInterval();
+
+  // FIXME: This flag will be removed in bug 1324966.
+  bool mIsComposingStyle = false;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_KeyframeEffectReadOnly_h