Bug 1305325 - Part 4: Add a function that returns the resolved base style on an element for a given property with nsStyleContext. r?birtles
MozReview-Commit-ID: FPzyX9fxxx3
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -12,16 +12,17 @@
#include "mozilla/AnimationComparator.h"
#include "mozilla/AnimationPerformanceWarning.h"
#include "mozilla/AnimationTarget.h"
#include "mozilla/AnimationUtils.h"
#include "mozilla/EffectSet.h"
#include "mozilla/LayerAnimationInfo.h"
#include "mozilla/RestyleManagerHandle.h"
#include "mozilla/RestyleManagerHandleInlines.h"
+#include "mozilla/StyleAnimationValue.h"
#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
#include "nsCSSPropertyIDSet.h"
#include "nsCSSProps.h"
#include "nsIPresShell.h"
#include "nsLayoutUtils.h"
#include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
#include "nsRuleProcessorData.h" // For ElementRuleProcessorData etc.
#include "nsTArray.h"
@@ -811,16 +812,40 @@ EffectCompositor::SetPerformanceWarning(
return;
}
for (KeyframeEffectReadOnly* effect : *effects) {
effect->SetPerformanceWarning(aProperty, aWarning);
}
}
+/* static */ StyleAnimationValue
+EffectCompositor::GetBaseStyle(nsCSSPropertyID aProperty,
+ nsStyleContext* aStyleContext,
+ dom::Element& aElement)
+{
+ MOZ_ASSERT(aStyleContext, "Need style context to resolve the base value");
+ MOZ_ASSERT(!aStyleContext->StyleSource().IsServoComputedValues(),
+ "Bug 1311257: Servo backend does not support the base value yet");
+
+ RefPtr<nsStyleContext> styleContextWithoutAnimation =
+ aStyleContext->PresContext()->StyleSet()->AsGecko()->
+ ResolveStyleWithoutAnimation(&aElement, aStyleContext,
+ eRestyle_AllHintsWithAnimations);
+
+ StyleAnimationValue baseStyle;
+ DebugOnly<bool> result =
+ StyleAnimationValue::ExtractComputedValue(aProperty,
+ styleContextWithoutAnimation,
+ baseStyle);
+ MOZ_ASSERT(result, "could not extract computed value");
+
+ return baseStyle;
+}
+
// ---------------------------------------------------------
//
// Nested class: AnimationStyleRuleProcessor
//
// ---------------------------------------------------------
NS_IMPL_ISUPPORTS(EffectCompositor::AnimationStyleRuleProcessor,
nsIStyleRuleProcessor)
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -23,16 +23,17 @@ class nsIFrame;
class nsIStyleRule;
class nsPresContext;
class nsStyleContext;
namespace mozilla {
class EffectSet;
class RestyleTracker;
+class StyleAnimationValue;
struct AnimationPerformanceWarning;
struct NonOwningAnimationTarget;
namespace dom {
class Animation;
class Element;
}
@@ -210,16 +211,20 @@ public:
// Associates a performance warning with effects on |aFrame| that animates
// |aProperty|.
static void SetPerformanceWarning(
const nsIFrame* aFrame,
nsCSSPropertyID aProperty,
const AnimationPerformanceWarning& aWarning);
+ // Get resolved base style on |aElement| for |aProperty| with |aStyleContext|.
+ static StyleAnimationValue GetBaseStyle(nsCSSPropertyID aProperty,
+ nsStyleContext* aStyleContext,
+ dom::Element& aElement);
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,