Bug 1353208 - Factor out nsSMILCompositor::GetCSSPropertyToAnimate helper method; r?dholbert
In
bug 1315874 we will create a method to check if we're likely to need to
resolve base styles or not, and for that we need to extract the check for
whether or not we're animating a CSS property.
MozReview-Commit-ID: 9Ybsi91fro8
--- a/dom/smil/nsSMILCompositor.cpp
+++ b/dom/smil/nsSMILCompositor.cpp
@@ -123,38 +123,50 @@ nsSMILCompositor::ClearAnimationEffects(
smilAttr->ClearAnimValue();
}
// Protected Helper Functions
// --------------------------
UniquePtr<nsISMILAttr>
nsSMILCompositor::CreateSMILAttr()
{
- nsCSSPropertyID propID =
- nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName),
- CSSEnabledState::eForAllContent);
- if (nsSMILCSSProperty::IsPropertyAnimatable(propID)) {
- // If we are animating the 'width' or 'height' of an outer SVG
- // element we should animate it as a CSS property, but for other elements
- // (e.g. <rect>) we should animate it as a length attribute.
- // The easiest way to test for an outer SVG element, is to see if it is an
- // SVG-namespace element mapping its width/height attribute to style.
- bool animateAsAttr = (mKey.mAttributeName == nsGkAtoms::width ||
- mKey.mAttributeName == nsGkAtoms::height) &&
- mKey.mElement->GetNameSpaceID() == kNameSpaceID_SVG &&
- !mKey.mElement->IsAttributeMapped(mKey.mAttributeName);
- if (!animateAsAttr) {
- return MakeUnique<nsSMILCSSProperty>(propID, mKey.mElement.get());
- }
+ nsCSSPropertyID propID = GetCSSPropertyToAnimate();
+
+ if (propID != eCSSProperty_UNKNOWN) {
+ return MakeUnique<nsSMILCSSProperty>(propID, mKey.mElement.get());
}
return mKey.mElement->GetAnimatedAttr(mKey.mAttributeNamespaceID,
mKey.mAttributeName);
}
+nsCSSPropertyID
+nsSMILCompositor::GetCSSPropertyToAnimate() const
+{
+ nsCSSPropertyID propID =
+ nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName),
+ CSSEnabledState::eForAllContent);
+
+ if (!nsSMILCSSProperty::IsPropertyAnimatable(propID)) {
+ return eCSSProperty_UNKNOWN;
+ }
+
+ // If we are animating the 'width' or 'height' of an outer SVG
+ // element we should animate it as a CSS property, but for other elements
+ // (e.g. <rect>) we should animate it as a length attribute.
+ // The easiest way to test for an outer SVG element, is to see if it is an
+ // SVG-namespace element mapping its width/height attribute to style.
+ bool animateAsAttr = (mKey.mAttributeName == nsGkAtoms::width ||
+ mKey.mAttributeName == nsGkAtoms::height) &&
+ mKey.mElement->GetNameSpaceID() == kNameSpaceID_SVG &&
+ !mKey.mElement->IsAttributeMapped(mKey.mAttributeName);
+
+ return animateAsAttr ? eCSSProperty_UNKNOWN : propID;
+}
+
uint32_t
nsSMILCompositor::GetFirstFuncToAffectSandwich()
{
// For performance reasons, we throttle most animations on elements in
// display:none subtrees. (We can't throttle animations that target the
// "display" property itself, though -- if we did, display:none elements
// could never be dynamically displayed via animations.)
// To determine whether we're in a display:none subtree, we will check the
--- a/dom/smil/nsSMILCompositor.h
+++ b/dom/smil/nsSMILCompositor.h
@@ -71,16 +71,20 @@ public:
void StealCachedBaseValue(nsSMILCompositor* aOther) {
mCachedBaseValue = mozilla::Move(aOther->mCachedBaseValue);
}
private:
// Create a nsISMILAttr for my target, on the heap.
mozilla::UniquePtr<nsISMILAttr> CreateSMILAttr();
+ // Returns the CSS property this compositor should animate, or
+ // eCSSProperty_UNKNOWN if this compositor does not animate a CSS property.
+ nsCSSPropertyID GetCSSPropertyToAnimate() const;
+
// Finds the index of the first function that will affect our animation
// sandwich. Also toggles the 'mForceCompositing' flag if it finds that any
// (used) functions have changed.
uint32_t GetFirstFuncToAffectSandwich();
// If the passed-in base value differs from our cached base value, this
// method updates the cached value (and toggles the 'mForceCompositing' flag)
void UpdateCachedBaseValue(const nsSMILValue& aBaseValue);