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

--HG--
extra : rebase_source : e2f72a7d807bfbe026fbd1a603cd993c3d502584
This commit is contained in:
Brian Birtles 2017-03-30 13:10:08 +09:00
Родитель 1efabc2e0b
Коммит e96d223104
2 изменённых файлов: 32 добавлений и 16 удалений

Просмотреть файл

@ -128,28 +128,40 @@ nsSMILCompositor::ClearAnimationEffects()
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()
{

Просмотреть файл

@ -76,6 +76,10 @@ public:
// 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.