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
--- 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