Bug 960465 patch 1 - Add parameter to skip animations work to ResolveStyleWithReplacement. r=birtles
This is used in patch 2.
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1572,17 +1572,18 @@ nsStyleSet::RuleNodeWithReplacement(Elem
return ruleWalker.CurrentNode();
}
already_AddRefed<nsStyleContext>
nsStyleSet::ResolveStyleWithReplacement(Element* aElement,
nsStyleContext* aNewParentContext,
nsStyleContext* aOldStyleContext,
- nsRestyleHint aReplacements)
+ nsRestyleHint aReplacements,
+ uint32_t aFlags)
{
nsRuleNode* ruleNode =
RuleNodeWithReplacement(aElement, aOldStyleContext->RuleNode(),
aOldStyleContext->GetPseudoType(), aReplacements);
nsRuleNode* visitedRuleNode = nullptr;
nsStyleContext* oldStyleIfVisited = aOldStyleContext->GetStyleIfVisited();
if (oldStyleIfVisited) {
@@ -1605,19 +1606,20 @@ nsStyleSet::ResolveStyleWithReplacement(
// is visited.
if (aOldStyleContext->RelevantLinkVisited()) {
flags |= eIsVisitedLink;
}
}
nsCSSPseudoElements::Type pseudoType = aOldStyleContext->GetPseudoType();
Element* elementForAnimation = nullptr;
- if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
- pseudoType == nsCSSPseudoElements::ePseudo_before ||
- pseudoType == nsCSSPseudoElements::ePseudo_after) {
+ if (!(aFlags & eSkipStartingAnimations) &&
+ (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
+ pseudoType == nsCSSPseudoElements::ePseudo_before ||
+ pseudoType == nsCSSPseudoElements::ePseudo_after)) {
// We want to compute a correct elementForAnimation to pass in
// because at this point the parameter is more than just the element
// for animation; it's also used for the SetBodyTextColor call when
// it's the body element.
// However, we only want to set the flag to call CheckAnimationRule
// if we're dealing with a replacement (such as style attribute
// replacement) that could lead to the animation property changing,
// and we explicitly do NOT want to call CheckAnimationRule when
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -128,21 +128,26 @@ class nsStyleSet
// for CSS transitions.)
already_AddRefed<nsStyleContext>
ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
const nsCOMArray<nsIStyleRule> &aRules);
// Resolve style by making replacements in the list of style rules as
// described by aReplacements, but otherwise maintaining the status
// quo.
+ enum { // flags for aFlags
+ // Skip starting CSS animations that result from the style.
+ eSkipStartingAnimations = (1<<0),
+ };
already_AddRefed<nsStyleContext>
ResolveStyleWithReplacement(mozilla::dom::Element* aElement,
nsStyleContext* aNewParentContext,
nsStyleContext* aOldStyleContext,
- nsRestyleHint aReplacements);
+ nsRestyleHint aReplacements,
+ uint32_t aFlags = 0);
// Get a style context for a non-element (which no rules will match),
// such as text nodes, placeholder frames, and the nsFirstLetterFrame
// for everything after the first letter.
//
// Perhaps this should go away and we shouldn't even create style
// contexts for such content nodes. However, not doing any rule
// matching for them is a first step.