mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1928352: Make SMILCompositor fail earlier when adding an incorrectly configured animation. r=longsonr
If multiple animations of the same element is an error (as asserted in `SMILCompositor::ComposeAttribute`), then this patch will catch that when the animation is added. Differential Revision: https://phabricator.services.mozilla.com/D227737
This commit is contained in:
parent
7bd39a617f
commit
9cccb8ffb3
@ -258,7 +258,10 @@ int8_t SMILAnimationFunction::CompareTo(
|
||||
const SMILAnimationFunction* aOther) const {
|
||||
NS_ENSURE_TRUE(aOther, 0);
|
||||
|
||||
NS_ASSERTION(aOther != this, "Trying to compare to self");
|
||||
if (aOther == this) {
|
||||
// std::sort will sometimes compare an element to itself. It's fine.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Inactive animations sort first
|
||||
if (!IsActiveOrFrozen() && aOther->IsActiveOrFrozen()) return -1;
|
||||
@ -279,7 +282,7 @@ int8_t SMILAnimationFunction::CompareTo(
|
||||
|
||||
// Animations that appear later in the document sort after those earlier in
|
||||
// the document
|
||||
MOZ_ASSERT(mAnimationElement != aOther->mAnimationElement,
|
||||
MOZ_ASSERT(!HasSameAnimationElement(aOther),
|
||||
"Two animations cannot have the same animation content element!");
|
||||
|
||||
return (nsContentUtils::PositionIsBefore(mAnimationElement,
|
||||
|
@ -46,6 +46,10 @@ class SMILAnimationFunction {
|
||||
void SetAnimationElement(
|
||||
mozilla::dom::SVGAnimationElement* aAnimationElement);
|
||||
|
||||
bool HasSameAnimationElement(const SMILAnimationFunction* aOther) const {
|
||||
return aOther && aOther->mAnimationElement == mAnimationElement;
|
||||
};
|
||||
|
||||
/*
|
||||
* Sets animation-specific attributes (or marks them dirty, in the case
|
||||
* of from/to/by/values).
|
||||
|
@ -40,6 +40,17 @@ void SMILCompositor::Traverse(nsCycleCollectionTraversalCallback* aCallback) {
|
||||
// Other methods
|
||||
void SMILCompositor::AddAnimationFunction(SMILAnimationFunction* aFunc) {
|
||||
if (aFunc) {
|
||||
#ifdef DEBUG
|
||||
// Check that we don't already have an animation function that references
|
||||
// the animation element used by aFunc. This will be an assert when we
|
||||
// later sort the list. Let's catch the assert now. We use the same
|
||||
// assert message from the sort.
|
||||
for (const SMILAnimationFunction* func : mAnimationFunctions) {
|
||||
MOZ_ASSERT(
|
||||
!aFunc->HasSameAnimationElement(func),
|
||||
"Two animations cannot have the same animation content element!");
|
||||
}
|
||||
#endif
|
||||
mAnimationFunctions.AppendElement(aFunc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user