Bug 1417354 - Add a method to clear all pending restyle requests for a given element and its pseudos. r?birtles
MozReview-Commit-ID: DZkbwUPiPTd
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -361,16 +361,44 @@ EffectCompositor::PostRestyleForThrottle
PostRestyleForAnimation(iter.Key().mElement,
iter.Key().mPseudoType,
cascadeLevel);
postedRestyle = true;
}
}
}
+void
+EffectCompositor::ClearRestyleRequestsFor(Element* aElement)
+{
+ MOZ_ASSERT(aElement);
+
+ auto& elementsToRestyle = mElementsToRestyle[CascadeLevel::Animations];
+
+ CSSPseudoElementType pseudoType = aElement->GetPseudoElementType();
+ if (pseudoType == CSSPseudoElementType::NotPseudo) {
+ PseudoElementHashEntry::KeyType notPseudoKey =
+ { aElement, CSSPseudoElementType::NotPseudo };
+ PseudoElementHashEntry::KeyType beforePseudoKey =
+ { aElement, CSSPseudoElementType::before };
+ PseudoElementHashEntry::KeyType afterPseudoKey =
+ { aElement, CSSPseudoElementType::after };
+
+ elementsToRestyle.Remove(notPseudoKey);
+ elementsToRestyle.Remove(beforePseudoKey);
+ elementsToRestyle.Remove(afterPseudoKey);
+ } else if (pseudoType == CSSPseudoElementType::before ||
+ pseudoType == CSSPseudoElementType::after) {
+ Element* parentElement = aElement->GetParentElement();
+ MOZ_ASSERT(parentElement);
+ PseudoElementHashEntry::KeyType key = { parentElement, pseudoType };
+ elementsToRestyle.Remove(key);
+ }
+}
+
template<typename StyleType>
void
EffectCompositor::UpdateEffectProperties(StyleType* aStyleType,
Element* aElement,
CSSPseudoElementType aPseudoType)
{
EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
if (!effectSet) {
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -116,16 +116,20 @@ public:
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);
// Posts an animation restyle for any elements whose animation style rule
// is out of date but for which an animation restyle has not yet been
// posted because updates on the main thread are throttled.
void PostRestyleForThrottledAnimations();
+ // Clear all pending restyle requests for the given (pseudo-) element (and its
+ // ::before and ::after elements if the given element is not pseudo).
+ void ClearRestyleRequestsFor(dom::Element* aElement);
+
// Called when computed style on the specified (pseudo-) element might
// have changed so that any context-sensitive values stored within
// animation effects (e.g. em-based endpoints used in keyframe effects)
// can be re-resolved to computed values.
template<typename StyleType>
void UpdateEffectProperties(StyleType* aStyleType,
dom::Element* aElement,
CSSPseudoElementType aPseudoType);