Bug 1846516 - Minor fix ups and logical animation clean-up. r=zrhoffman

Differential Revision: https://phabricator.services.mozilla.com/D196341
This commit is contained in:
Emilio Cobos Álvarez 2023-12-18 09:24:09 +00:00
Родитель 0060ff08b2
Коммит 6dcb5187bc
2 изменённых файлов: 30 добавлений и 16 удалений

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

@ -23,19 +23,21 @@ struct AnimatedPropertyID {
}
explicit AnimatedPropertyID(RefPtr<nsAtom> aCustomName)
: mID(eCSSPropertyExtra_variable), mCustomName(std::move(aCustomName)) {}
: mID(eCSSPropertyExtra_variable), mCustomName(std::move(aCustomName)) {
MOZ_ASSERT(mCustomName, "Null custom property name");
}
nsCSSPropertyID mID = eCSSProperty_UNKNOWN;
RefPtr<nsAtom> mCustomName;
bool IsCustom() const { return mID == eCSSPropertyExtra_variable; }
bool operator==(const AnimatedPropertyID& aOther) const {
return mID == aOther.mID &&
(!IsCustom() || mCustomName == aOther.mCustomName);
return mID == aOther.mID && mCustomName == aOther.mCustomName;
}
bool operator!=(const AnimatedPropertyID& aOther) const {
return !(*this == aOther);
}
bool IsValid() const {
if (mID == eCSSProperty_UNKNOWN) {
return false;
@ -56,8 +58,24 @@ struct AnimatedPropertyID {
HashNumber hash = mCustomName ? mCustomName->hash() : 0;
return AddToHash(hash, mID);
}
AnimatedPropertyID ToPhysical(const ComputedStyle& aStyle) const {
if (IsCustom()) {
return *this;
}
return AnimatedPropertyID{nsCSSProps::Physicalize(mID, aStyle)};
}
};
// MOZ_DBG support for AnimatedPropertyId
inline std::ostream& operator<<(std::ostream& aOut,
const AnimatedPropertyID& aProperty) {
if (aProperty.IsCustom()) {
return aOut << nsAtomCString(aProperty.mCustomName);
}
return aOut << nsCSSProps::GetStringValue(aProperty.mID);
}
} // namespace mozilla
#endif // mozilla_AnimatedPropertyID_h

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

@ -72,6 +72,7 @@ static void ExpandTransitionProperty(nsCSSPropertyID aProperty,
if (aProperty == eCSSPropertyExtra_variable) {
AnimatedPropertyID property(aCustomName);
aHandler(property);
return;
}
@ -142,14 +143,12 @@ bool nsTransitionManager::DoUpdateTransitions(
AnimatedPropertyIDSet allTransitionProperties;
if (checkProperties) {
for (uint32_t i = aStyle.mTransitionPropertyCount; i-- != 0;) {
ExpandTransitionProperty(
aStyle.GetTransitionProperty(i),
aStyle.GetTransitionUnknownProperty(i),
[&](const AnimatedPropertyID& aProperty) {
AnimatedPropertyID property = aProperty;
property.mID = nsCSSProps::Physicalize(aProperty.mID, aNewStyle);
allTransitionProperties.AddProperty(aProperty);
});
ExpandTransitionProperty(aStyle.GetTransitionProperty(i),
aStyle.GetTransitionUnknownProperty(i),
[&](const AnimatedPropertyID& aProperty) {
allTransitionProperties.AddProperty(
aProperty.ToPhysical(aNewStyle));
});
}
}
@ -267,10 +266,7 @@ bool nsTransitionManager::ConsiderInitiatingTransition(
!aElementTransitions || &aElementTransitions->mElement == aElement,
"Element mismatch");
AnimatedPropertyID property = aProperty;
if (!property.IsCustom()) {
property.mID = nsCSSProps::Physicalize(property.mID, aNewStyle);
}
AnimatedPropertyID property = aProperty.ToPhysical(aNewStyle);
// A later item in transition-property already specified a transition for
// this property, so we ignore this one.
@ -317,7 +313,7 @@ bool nsTransitionManager::ConsiderInitiatingTransition(
AnimationValue startValue, endValue;
const StyleShouldTransitionResult result =
Servo_ComputedValues_ShouldTransition(
&aOldStyle, &aNewStyle, &aProperty,
&aOldStyle, &aNewStyle, &property,
oldTransition ? oldTransition->ToValue().mServo.get() : nullptr,
&startValue.mServo, &endValue.mServo);