Bug 1344619 - Part 2: Introduce EffectCompositor::PreTraverse(). r?birtles
MozReview-Commit-ID: 6ijDJttB9eo
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -935,16 +935,50 @@ EffectCompositor::SetPerformanceWarning(
return;
}
for (KeyframeEffectReadOnly* effect : *effects) {
effect->SetPerformanceWarning(aProperty, aWarning);
}
}
+void
+EffectCompositor::PreTraverse()
+{
+ MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(mPresContext->RestyleManager()->IsServo());
+
+ for (auto& elementsToRestyle : mElementsToRestyle) {
+ for (auto iter = elementsToRestyle.Iter(); !iter.Done(); iter.Next()) {
+ bool postedRestyle = iter.Data();
+ // Ignore throttled restyle.
+ if (!postedRestyle) {
+ continue;
+ }
+
+ NonOwningAnimationTarget target = iter.Key();
+ EffectSet* effects =
+ EffectSet::GetEffectSet(target.mElement, target.mPseudoType);
+ if (!effects) {
+ // Drop the EffectSets that have been destroyed.
+ iter.Remove();
+ continue;
+ }
+
+ for (KeyframeEffectReadOnly* effect : *effects) {
+ effect->GetAnimation()->WillComposeStyle();
+ }
+
+ // Remove the element from the list of elements to restyle since we are
+ // about to restyle it.
+ iter.Remove();
+ }
+ }
+}
+
// ---------------------------------------------------------
//
// Nested class: AnimationStyleRuleProcessor
//
// ---------------------------------------------------------
NS_IMPL_ISUPPORTS(EffectCompositor::AnimationStyleRuleProcessor,
nsIStyleRuleProcessor)
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -228,16 +228,21 @@ public:
// Associates a performance warning with effects on |aFrame| that animates
// |aProperty|.
static void SetPerformanceWarning(
const nsIFrame* aFrame,
nsCSSPropertyID aProperty,
const AnimationPerformanceWarning& aWarning);
+ // Do a bunch of stuff that we should avoid doing during the parallel
+ // traversal (e.g. changing member variables) for all elements that we expect
+ // to restyle on the next traversal.
+ void PreTraverse();
+
private:
~EffectCompositor() = default;
// Rebuilds the animation rule corresponding to |aCascadeLevel| on the
// EffectSet associated with the specified (pseudo-)element.
static void ComposeAnimationRule(dom::Element* aElement,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);