tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit af94611fd2fcf7daeab877542fd0bcd5b1afb507
parent 2947348bb6b019843b3901a653adfaa255eeb80b
Author: Jan Varga <jan.varga@gmail.com>
Date:   Sat, 15 Nov 2025 00:48:20 +0000

Bug 1998896 - Rename AnimatedPropertyID to CSSPropertyId; r=emilio,firefox-style-system-reviewers

This patch renames AnimatedPropertyID to CSSPropertyId and updates all uses
accordingly. No behavior changes intended.

AnimatedPropertyID has long served as the general property identifier,
covering both non custom and custom properties. The name is currently
misleading.

Potential follow-ups:
- Rename AnimatedPropertyIDSet

Differential Revision: https://phabricator.services.mozilla.com/D271750

Diffstat:
Mdom/animation/Animation.cpp | 2+-
Mdom/animation/AnimationEventDispatcher.cpp | 2+-
Mdom/animation/AnimationEventDispatcher.h | 4++--
Mdom/animation/CSSTransition.cpp | 2+-
Mdom/animation/CSSTransition.h | 8++++----
Mdom/animation/Keyframe.h | 8++++----
Mdom/animation/KeyframeEffect.cpp | 8++++----
Mdom/animation/KeyframeEffect.h | 13++++++-------
Mdom/animation/KeyframeUtils.cpp | 29++++++++++++++---------------
Mdom/animation/KeyframeUtils.h | 4++--
Mdom/base/nsDOMWindowUtils.cpp | 17++++++++---------
Mdom/smil/SMILCSSProperty.cpp | 4++--
Mdom/view-transitions/ViewTransition.cpp | 16++++++++--------
Mgfx/layers/AnimationHelper.cpp | 4++--
Mgfx/layers/AnimationInfo.cpp | 2+-
Mgfx/layers/CompositorAnimationStorage.cpp | 2+-
Dlayout/style/AnimatedPropertyID.h | 95-------------------------------------------------------------------------------
Mlayout/style/AnimatedPropertyIDSet.h | 32++++++++++++++++----------------
Alayout/style/CSSPropertyId.h | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlayout/style/GeckoBindings.cpp | 4++--
Mlayout/style/GeckoBindings.h | 4++--
Mlayout/style/ServoBindings.toml | 4++--
Mlayout/style/ServoCSSParser.cpp | 6+++---
Mlayout/style/ServoCSSParser.h | 4++--
Mlayout/style/ServoStyleConstsForwards.h | 2+-
Mlayout/style/StyleAnimationValue.cpp | 10+++++-----
Mlayout/style/StyleAnimationValue.h | 10+++++-----
Mlayout/style/moz.build | 4++--
Mlayout/style/nsCSSPropertyIDSet.h | 4++--
Mlayout/style/nsTransitionManager.cpp | 48+++++++++++++++++++++++-------------------------
Mlayout/style/nsTransitionManager.h | 5++---
Mservo/components/style/properties/mod.rs | 28+++++++++++++---------------
Mservo/ports/geckolib/cbindgen.toml | 2+-
Mservo/ports/geckolib/glue.rs | 63+++++++++++++++++++++++++++++++--------------------------------
34 files changed, 267 insertions(+), 277 deletions(-)

diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp @@ -905,7 +905,7 @@ void Animation::CommitStyles(ErrorResult& aRv) { // Set the animated styles bool changed = false; const AnimatedPropertyIDSet& properties = keyframeEffect->GetPropertySet(); - for (const AnimatedPropertyID& property : properties) { + for (const CSSPropertyId& property : properties) { RefPtr<StyleAnimationValue> computedValue = Servo_AnimationValueMap_GetValue(animationValues.get(), &property) .Consume(); diff --git a/dom/animation/AnimationEventDispatcher.cpp b/dom/animation/AnimationEventDispatcher.cpp @@ -164,7 +164,7 @@ void AnimationEventInfo::MaybeAddMarker() const { } nsAutoCString properties; nsAutoCString oncompositor; - for (const AnimatedPropertyID& property : propertySet) { + for (const CSSPropertyId& property : propertySet) { if (!properties.IsEmpty()) { properties.AppendLiteral(", "); oncompositor.AppendLiteral(", "); diff --git a/dom/animation/AnimationEventDispatcher.h b/dom/animation/AnimationEventDispatcher.h @@ -47,7 +47,7 @@ struct AnimationEventInfo { struct CssTransitionData : public CssAnimationOrTransitionData { // For transition events only. - const AnimatedPropertyID mProperty; + const CSSPropertyId mProperty; }; struct WebAnimationData { @@ -110,7 +110,7 @@ struct AnimationEventInfo { } // For CSS transition events - AnimationEventInfo(const AnimatedPropertyID& aProperty, + AnimationEventInfo(const CSSPropertyId& aProperty, const NonOwningAnimationTarget& aTarget, EventMessage aMessage, double aElapsedTime, uint64_t aTransitionGeneration, diff --git a/dom/animation/CSSTransition.cpp b/dom/animation/CSSTransition.cpp @@ -213,7 +213,7 @@ void CSSTransition::Tick(TickState& aState) { QueueEvents(); } -const AnimatedPropertyID& CSSTransition::TransitionProperty() const { +const CSSPropertyId& CSSTransition::TransitionProperty() const { MOZ_ASSERT(mTransitionProperty.IsValid(), "Transition property should be initialized"); return mTransitionProperty; diff --git a/dom/animation/CSSTransition.h b/dom/animation/CSSTransition.h @@ -8,7 +8,7 @@ #define mozilla_dom_CSSTransition_h #include "AnimationCommon.h" -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/ComputedTiming.h" #include "mozilla/StyleAnimationValue.h" #include "mozilla/dom/Animation.h" @@ -21,7 +21,7 @@ namespace dom { class CSSTransition final : public Animation { public: explicit CSSTransition(nsIGlobalObject* aGlobal, - const AnimatedPropertyID& aProperty) + const CSSPropertyId& aProperty) : Animation(aGlobal), mPreviousTransitionPhase(TransitionPhase::Idle), mNeedsNewAnimationIndexWhenRun(false), @@ -78,7 +78,7 @@ class CSSTransition final : public Animation { void Tick(TickState&) override; - const AnimatedPropertyID& TransitionProperty() const; + const CSSPropertyId& TransitionProperty() const; AnimationValue ToValue() const; int32_t CompareCompositeOrder(const Maybe<EventContext>& aContext, @@ -214,7 +214,7 @@ class CSSTransition final : public Animation { // information in order to determine if there is an existing transition // for a given style change. We can't store that information on the // effect however since it can be replaced using the Web Animations API. - AnimatedPropertyID mTransitionProperty; + CSSPropertyId mTransitionProperty; AnimationValue mTransitionToValue; // This is the start value to be used for a check for whether a diff --git a/dom/animation/Keyframe.h b/dom/animation/Keyframe.h @@ -7,7 +7,7 @@ #ifndef mozilla_dom_Keyframe_h #define mozilla_dom_Keyframe_h -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" #include "mozilla/ServoStyleConsts.h" @@ -22,16 +22,16 @@ struct StyleLockedDeclarationBlock; * A property-value pair specified on a keyframe. */ struct PropertyValuePair { - explicit PropertyValuePair(const AnimatedPropertyID& aProperty) + explicit PropertyValuePair(const CSSPropertyId& aProperty) : mProperty(aProperty) {} - PropertyValuePair(const AnimatedPropertyID& aProperty, + PropertyValuePair(const CSSPropertyId& aProperty, RefPtr<StyleLockedDeclarationBlock>&& aValue) : mProperty(aProperty), mServoDeclarationBlock(std::move(aValue)) { MOZ_ASSERT(mServoDeclarationBlock, "Should be valid property value"); } - AnimatedPropertyID mProperty; + CSSPropertyId mProperty; // The specified value when using the Servo backend. RefPtr<StyleLockedDeclarationBlock> mServoDeclarationBlock; diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp @@ -288,7 +288,7 @@ void KeyframeEffect::ReplaceTransitionStartValue(AnimationValue&& aStartValue) { // Check that the value we are about to substitute in is actually for the // same property. - AnimatedPropertyID property(eCSSProperty_UNKNOWN); + CSSPropertyId property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(aStartValue.mServo, &property); if (property != mProperties[0].mProperty) { return; @@ -300,13 +300,13 @@ void KeyframeEffect::ReplaceTransitionStartValue(AnimationValue&& aStartValue) { } static bool IsEffectiveProperty(const EffectSet& aEffects, - const AnimatedPropertyID& aProperty) { + const CSSPropertyId& aProperty) { return !aEffects.PropertiesWithImportantRules().HasProperty(aProperty) || !aEffects.PropertiesForAnimationsLevel().HasProperty(aProperty); } const AnimationProperty* KeyframeEffect::GetEffectiveAnimationOfProperty( - const AnimatedPropertyID& aProperty, const EffectSet& aEffects) const { + const CSSPropertyId& aProperty, const EffectSet& aEffects) const { MOZ_ASSERT(mTarget && &aEffects == EffectSet::Get(mTarget)); for (const AnimationProperty& property : mProperties) { @@ -1124,7 +1124,7 @@ void KeyframeEffect::SetPseudoElement(const nsAString& aPseudoElement, } static void CreatePropertyValue( - const AnimatedPropertyID& aProperty, float aOffset, + const CSSPropertyId& aProperty, float aOffset, const Maybe<StyleComputedTimingFunction>& aTimingFunction, const AnimationValue& aValue, dom::CompositeOperation aComposite, const StylePerDocumentStyleData* aRawData, diff --git a/dom/animation/KeyframeEffect.h b/dom/animation/KeyframeEffect.h @@ -8,11 +8,11 @@ #define mozilla_dom_KeyframeEffect_h #include "NonCustomCSSPropertyId.h" -#include "mozilla/AnimatedPropertyID.h" #include "mozilla/AnimatedPropertyIDSet.h" #include "mozilla/AnimationPerformanceWarning.h" #include "mozilla/AnimationPropertySegment.h" #include "mozilla/AnimationTarget.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/EffectCompositor.h" #include "mozilla/Keyframe.h" #include "mozilla/KeyframeEffectParams.h" @@ -56,7 +56,7 @@ struct AnimationPropertyDetails; } // namespace dom struct AnimationProperty { - AnimatedPropertyID mProperty; + CSSPropertyId mProperty; // If true, the propery is currently being animated on the compositor. // @@ -222,12 +222,12 @@ class KeyframeEffect : public AnimationEffect { // properties where an !important rule on another transform property may // cause all transform properties to be run on the main thread. That check is // performed by GetPropertiesForCompositor. - bool HasEffectiveAnimationOfProperty(const AnimatedPropertyID& aProperty, + bool HasEffectiveAnimationOfProperty(const CSSPropertyId& aProperty, const EffectSet& aEffect) const { return GetEffectiveAnimationOfProperty(aProperty, aEffect) != nullptr; } const AnimationProperty* GetEffectiveAnimationOfProperty( - const AnimatedPropertyID&, const EffectSet&) const; + const CSSPropertyId&, const EffectSet&) const; // Similar to HasEffectiveAnimationOfProperty, above, but for // an nsCSSPropertyIDSet. Returns true if this keyframe effect has at least @@ -330,7 +330,7 @@ class KeyframeEffect : public AnimationEffect { // |aFrame| is used for calculation of scale values. bool ContainsAnimatedScale(const nsIFrame* aFrame) const; - AnimationValue BaseStyle(const AnimatedPropertyID& aProperty) const { + AnimationValue BaseStyle(const CSSPropertyId& aProperty) const { AnimationValue result; bool hasProperty = false; // We cannot use getters_AddRefs on StyleAnimationValue because it is @@ -461,8 +461,7 @@ class KeyframeEffect : public AnimationEffect { // least one animation value that is composited with the underlying value // (i.e. it uses the additive or accumulate composite mode). using BaseValuesHashmap = - nsRefPtrHashtable<nsGenericHashKey<AnimatedPropertyID>, - StyleAnimationValue>; + nsRefPtrHashtable<nsGenericHashKey<CSSPropertyId>, StyleAnimationValue>; BaseValuesHashmap mBaseValues; private: diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp @@ -12,7 +12,7 @@ #include "js/ForOfIterator.h" // For JS::ForOfIterator #include "js/PropertyAndElement.h" // JS_Enumerate, JS_GetProperty, JS_GetPropertyById #include "jsapi.h" // For most JSAPI -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/ComputedStyle.h" #include "mozilla/ErrorResult.h" #include "mozilla/ServoBindingTypes.h" @@ -62,7 +62,7 @@ enum class ListAllowance { eDisallow, eAllow }; struct PropertyValuesPair { PropertyValuesPair() : mProperty(eCSSProperty_UNKNOWN) {} - AnimatedPropertyID mProperty; + CSSPropertyId mProperty; nsTArray<nsCString> mValues; }; @@ -71,7 +71,7 @@ struct PropertyValuesPair { * BaseKeyframe or BasePropertyIndexedKeyframe object. */ struct AdditionalProperty { - AnimatedPropertyID mProperty; + CSSPropertyId mProperty; size_t mJsidIndex = 0; // Index into |ids| in GetPropertyValuesPairs. struct PropertyComparator { @@ -114,7 +114,7 @@ struct KeyframeValueEntry { KeyframeValueEntry() : mProperty(eCSSProperty_UNKNOWN), mOffset(), mComposite() {} - AnimatedPropertyID mProperty; + CSSPropertyId mProperty; AnimationValue mValue; float mOffset; @@ -198,7 +198,7 @@ static bool AppendValueAsString(JSContext* aCx, nsTArray<nsCString>& aValues, JS::Handle<JS::Value> aValue); static Maybe<PropertyValuePair> MakePropertyValuePair( - const AnimatedPropertyID& aProperty, const nsACString& aStringValue, + const CSSPropertyId& aProperty, const nsACString& aStringValue, dom::Document* aDocument); static bool HasValidOffsets(const nsTArray<Keyframe>& aKeyframes); @@ -349,7 +349,7 @@ nsTArray<AnimationProperty> KeyframeUtils::GetAnimationPropertiesFromKeyframes( } /* static */ -bool KeyframeUtils::IsAnimatableProperty(const AnimatedPropertyID& aProperty) { +bool KeyframeUtils::IsAnimatableProperty(const CSSPropertyId& aProperty) { // Regardless of the backend type, treat the 'display' property as not // animatable. (Servo will report it as being animatable, since it is // in fact animatable by SMIL.) @@ -571,11 +571,10 @@ static bool GetPropertyValuesPairs(JSContext* aCx, // TODO(zrhoffman, bug 1811897) Add test coverage for removing the `--` // prefix here. - AnimatedPropertyID property = - propertyId == eCSSPropertyExtra_variable - ? AnimatedPropertyID( - NS_Atomize(Substring(propName, 2, propName.Length() - 2))) - : AnimatedPropertyID(propertyId); + CSSPropertyId property = propertyId == eCSSPropertyExtra_variable + ? CSSPropertyId(NS_Atomize(Substring( + propName, 2, propName.Length() - 2))) + : CSSPropertyId(propertyId); if (KeyframeUtils::IsAnimatableProperty(property)) { properties.AppendElement(AdditionalProperty{std::move(property), i}); @@ -658,8 +657,8 @@ static bool AppendValueAsString(JSContext* aCx, nsTArray<nsCString>& aValues, } static void ReportInvalidPropertyValueToConsole( - const AnimatedPropertyID& aProperty, - const nsACString& aInvalidPropertyValue, dom::Document* aDoc) { + const CSSPropertyId& aProperty, const nsACString& aInvalidPropertyValue, + dom::Document* aDoc) { AutoTArray<nsString, 2> params; params.AppendElement(NS_ConvertUTF8toUTF16(aInvalidPropertyValue)); aProperty.ToString(*params.AppendElement()); @@ -679,7 +678,7 @@ static void ReportInvalidPropertyValueToConsole( * an invalid property value. */ static Maybe<PropertyValuePair> MakePropertyValuePair( - const AnimatedPropertyID& aProperty, const nsACString& aStringValue, + const CSSPropertyId& aProperty, const nsACString& aStringValue, dom::Document* aDocument) { MOZ_ASSERT(aDocument); Maybe<PropertyValuePair> result; @@ -861,7 +860,7 @@ static void BuildSegmentsFromValueEntries( // care to identify properties that lack a value at offset 0.0/1.0 and drops // those properties from |aResult|. - AnimatedPropertyID lastProperty(eCSSProperty_UNKNOWN); + CSSPropertyId lastProperty(eCSSProperty_UNKNOWN); AnimationProperty* animationProperty = nullptr; size_t i = 0, n = aEntries.Length(); diff --git a/dom/animation/KeyframeUtils.h b/dom/animation/KeyframeUtils.h @@ -16,9 +16,9 @@ struct JSContext; class JSObject; namespace mozilla { -struct AnimatedPropertyID; struct AnimationProperty; class ComputedStyle; +struct CSSPropertyId; enum class PseudoStyleType : uint8_t; class ErrorResult; @@ -103,7 +103,7 @@ class KeyframeUtils { * if the property is animatable or not. * @return true if |aProperty| is animatable. */ - static bool IsAnimatableProperty(const AnimatedPropertyID& aProperty); + static bool IsAnimatableProperty(const CSSPropertyId& aProperty); }; } // namespace mozilla diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp @@ -102,7 +102,7 @@ // #include "nsWidgetsCID.h" #include "HTMLCanvasElement.h" #include "HTMLImageElement.h" -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/DisplayPortUtils.h" #include "mozilla/IMEContentObserver.h" @@ -3263,9 +3263,9 @@ nsDOMWindowUtils::ComputeAnimationDistance(Element* aElement, return NS_ERROR_ILLEGAL_VALUE; } - AnimatedPropertyID property = propertyId == eCSSPropertyExtra_variable - ? AnimatedPropertyID(NS_Atomize(aProperty)) - : AnimatedPropertyID(propertyId); + CSSPropertyId property = propertyId == eCSSPropertyExtra_variable + ? CSSPropertyId(NS_Atomize(aProperty)) + : CSSPropertyId(propertyId); AnimationValue v1 = AnimationValue::FromString( property, NS_ConvertUTF16toUTF8(aValue1), aElement); @@ -3295,11 +3295,10 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(Element* aElement, nsCSSProps::IsShorthand(propertyId)) { return NS_ERROR_INVALID_ARG; } - AnimatedPropertyID property = - propertyId == eCSSPropertyExtra_variable - ? AnimatedPropertyID( - NS_Atomize(Substring(aProperty, 2, aProperty.Length() - 2))) - : AnimatedPropertyID(propertyId); + CSSPropertyId property = propertyId == eCSSPropertyExtra_variable + ? CSSPropertyId(NS_Atomize(Substring( + aProperty, 2, aProperty.Length() - 2))) + : CSSPropertyId(propertyId); switch (aFlushType) { case FLUSH_NONE: diff --git a/dom/smil/SMILCSSProperty.cpp b/dom/smil/SMILCSSProperty.cpp @@ -10,7 +10,7 @@ #include <utility> -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/SMILCSSValueType.h" #include "mozilla/SMILValue.h" #include "mozilla/ServoBindings.h" @@ -63,7 +63,7 @@ SMILValue SMILCSSProperty::GetBaseValue() const { } AnimationValue computedValue; - AnimatedPropertyID property(mPropId); + CSSPropertyId property(mPropId); MOZ_ASSERT(!property.IsCustom(), "Cannot animate custom properties with SMIL"); computedValue.mServo = diff --git a/dom/view-transitions/ViewTransition.cpp b/dom/view-transitions/ViewTransition.cpp @@ -666,26 +666,26 @@ static nsTArray<Keyframe> BuildGroupKeyframes( Keyframe firstKeyframe; firstKeyframe.mOffset = Some(0.0); PropertyValuePair transform{ - AnimatedPropertyID(eCSSProperty_transform), + CSSPropertyId(eCSSProperty_transform), Servo_DeclarationBlock_CreateEmpty().Consume(), }; SetProp(transform.mServoDeclarationBlock, aDoc, eCSSProperty_transform, aTransform); PropertyValuePair width{ - AnimatedPropertyID(eCSSProperty_width), + CSSPropertyId(eCSSProperty_width), Servo_DeclarationBlock_CreateEmpty().Consume(), }; CSSSize cssSize = CSSSize::FromAppUnits(aSize); SetProp(width.mServoDeclarationBlock, aDoc, eCSSProperty_width, cssSize.width, eCSSUnit_Pixel); PropertyValuePair height{ - AnimatedPropertyID(eCSSProperty_height), + CSSPropertyId(eCSSProperty_height), Servo_DeclarationBlock_CreateEmpty().Consume(), }; SetProp(height.mServoDeclarationBlock, aDoc, eCSSProperty_height, cssSize.height, eCSSUnit_Pixel); PropertyValuePair backdropFilters{ - AnimatedPropertyID(eCSSProperty_backdrop_filter), + CSSPropertyId(eCSSProperty_backdrop_filter), Servo_DeclarationBlock_CreateEmpty().Consume(), }; SetProp(backdropFilters.mServoDeclarationBlock, aDoc, @@ -698,13 +698,13 @@ static nsTArray<Keyframe> BuildGroupKeyframes( Keyframe lastKeyframe; lastKeyframe.mOffset = Some(1.0); lastKeyframe.mPropertyValues.AppendElement( - PropertyValuePair{AnimatedPropertyID(eCSSProperty_transform)}); + PropertyValuePair{CSSPropertyId(eCSSProperty_transform)}); lastKeyframe.mPropertyValues.AppendElement( - PropertyValuePair{AnimatedPropertyID(eCSSProperty_width)}); + PropertyValuePair{CSSPropertyId(eCSSProperty_width)}); lastKeyframe.mPropertyValues.AppendElement( - PropertyValuePair{AnimatedPropertyID(eCSSProperty_height)}); + PropertyValuePair{CSSPropertyId(eCSSProperty_height)}); lastKeyframe.mPropertyValues.AppendElement( - PropertyValuePair{AnimatedPropertyID(eCSSProperty_backdrop_filter)}); + PropertyValuePair{CSSPropertyId(eCSSProperty_backdrop_filter)}); nsTArray<Keyframe> result; result.AppendElement(std::move(firstKeyframe)); diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp @@ -19,7 +19,7 @@ #include "mozilla/dom/KeyframeEffect.h" // for dom::KeyFrameEffectReadOnly #include "mozilla/dom/Nullable.h" // for dom::Nullable #include "mozilla/layers/APZSampler.h" // for APZSampler -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/LayerAnimationInfo.h" // for GetCSSPropertiesFor() #include "mozilla/Maybe.h" // for Maybe<> #include "mozilla/MotionPathUtils.h" // for ResolveMotionPath() @@ -651,7 +651,7 @@ gfx::Matrix4x4 AnimationHelper::ServoAnimationValueToMatrix4x4( for (const auto& value : aValues) { MOZ_ASSERT(value); - AnimatedPropertyID property(eCSSProperty_UNKNOWN); + CSSPropertyId property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(value, &property); switch (property.mId) { case eCSSProperty_transform: diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp @@ -598,7 +598,7 @@ bool AnimationInfo::AddAnimationsForProperty( dom::KeyframeEffect* keyframeEffect = anim->GetEffect()->AsKeyframeEffect(); const AnimationProperty* property = keyframeEffect->GetEffectiveAnimationOfProperty( - AnimatedPropertyID(aProperty), *aEffects); + CSSPropertyId(aProperty), *aEffects); if (!property) { continue; } diff --git a/gfx/layers/CompositorAnimationStorage.cpp b/gfx/layers/CompositorAnimationStorage.cpp @@ -63,7 +63,7 @@ already_AddRefed<StyleAnimationValue> AnimatedValue::AsAnimationValue( // Linear search. It's likely that the length of the array is one in // most common case, so it shouldn't have much performance impact. for (const auto& value : Transform().mAnimationValues) { - AnimatedPropertyID property(eCSSProperty_UNKNOWN); + CSSPropertyId property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(value, &property); if (property.mId == aProperty) { result = value; diff --git a/layout/style/AnimatedPropertyID.h b/layout/style/AnimatedPropertyID.h @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_AnimatedPropertyID_h -#define mozilla_AnimatedPropertyID_h - -#include "NonCustomCSSPropertyId.h" -#include "mozilla/HashFunctions.h" -#include "mozilla/ServoBindings.h" -#include "nsCSSProps.h" -#include "nsString.h" - -namespace mozilla { - -struct AnimatedPropertyID { - explicit AnimatedPropertyID(NonCustomCSSPropertyId aProperty) - : mId(aProperty) { - MOZ_ASSERT(aProperty != eCSSPropertyExtra_variable, - "Cannot create an AnimatedPropertyID from only a " - "eCSSPropertyExtra_variable."); - } - - explicit AnimatedPropertyID(RefPtr<nsAtom> aCustomName) - : mId(eCSSPropertyExtra_variable), mCustomName(std::move(aCustomName)) { - MOZ_ASSERT(mCustomName, "Null custom property name"); - } - - NonCustomCSSPropertyId mId = eCSSProperty_UNKNOWN; - RefPtr<nsAtom> mCustomName; - - bool IsCustom() const { return mId == eCSSPropertyExtra_variable; } - bool operator==(const AnimatedPropertyID& aOther) const { - 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; - } - return IsCustom() == !!mCustomName; - } - - void ToString(nsACString& aString) const { - if (IsCustom()) { - MOZ_ASSERT(mCustomName, "Custom property should have a name"); - // mCustomName does not include the "--" prefix - aString.AssignLiteral("--"); - AppendUTF16toUTF8(nsDependentAtomString(mCustomName), aString); - } else { - aString.Assign(nsCSSProps::GetStringValue(mId)); - } - } - - void ToString(nsAString& aString) const { - if (IsCustom()) { - MOZ_ASSERT(mCustomName, "Custom property should have a name"); - // mCustomName does not include the "--" prefix - aString.AssignLiteral("--"); - aString.Append(nsDependentAtomString(mCustomName)); - } else { - aString.Assign(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(mId))); - } - } - - HashNumber Hash() const { - 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 diff --git a/layout/style/AnimatedPropertyIDSet.h b/layout/style/AnimatedPropertyIDSet.h @@ -7,7 +7,7 @@ #ifndef mozilla_AnimatedPropertyIDSet_h #define mozilla_AnimatedPropertyIDSet_h -#include "AnimatedPropertyID.h" +#include "CSSPropertyId.h" #include "mozilla/ServoBindings.h" #include "nsCSSPropertyIDSet.h" #include "nsTHashSet.h" @@ -30,7 +30,7 @@ class AnimatedPropertyIDSet { return *this; } - void AddProperty(const AnimatedPropertyID& aProperty) { + void AddProperty(const CSSPropertyId& aProperty) { if (aProperty.IsCustom()) { mCustomNames.Insert(aProperty.mCustomName); } else { @@ -38,7 +38,7 @@ class AnimatedPropertyIDSet { } } - void RemoveProperty(const AnimatedPropertyID& aProperty) { + void RemoveProperty(const CSSPropertyId& aProperty) { if (aProperty.IsCustom()) { mCustomNames.Remove(aProperty.mCustomName); } else { @@ -46,7 +46,7 @@ class AnimatedPropertyIDSet { } } - bool HasProperty(const AnimatedPropertyID& aProperty) const { + bool HasProperty(const CSSPropertyId& aProperty) const { if (aProperty.IsCustom()) { return mCustomNames.Contains(aProperty.mCustomName); } @@ -127,7 +127,7 @@ class AnimatedPropertyIDSet { : mPropertySet(aOther.mPropertySet), mIDIterator(std::move(aOther.mIDIterator)), mCustomNameIterator(std::move(aOther.mCustomNameIterator)), - mPropertyID(eCSSProperty_UNKNOWN) {} + mPropertyId(eCSSProperty_UNKNOWN) {} Iterator() = delete; Iterator(const Iterator&) = delete; Iterator& operator=(const Iterator&) = delete; @@ -160,19 +160,19 @@ class AnimatedPropertyIDSet { return *this; } - AnimatedPropertyID operator*() { + CSSPropertyId operator*() { if (mIDIterator != mPropertySet.mIDs.end()) { - mPropertyID.mId = *mIDIterator; - mPropertyID.mCustomName = nullptr; + mPropertyId.mId = *mIDIterator; + mPropertyId.mCustomName = nullptr; } else if (mCustomNameIterator != mPropertySet.mCustomNames.end()) { - mPropertyID.mId = eCSSPropertyExtra_variable; - mPropertyID.mCustomName = *mCustomNameIterator; + mPropertyId.mId = eCSSPropertyExtra_variable; + mPropertyId.mCustomName = *mCustomNameIterator; } else { MOZ_ASSERT_UNREACHABLE("Should not dereference beyond end"); - mPropertyID.mId = eCSSProperty_UNKNOWN; - mPropertyID.mCustomName = nullptr; + mPropertyId.mId = eCSSProperty_UNKNOWN; + mPropertyId.mCustomName = nullptr; } - return mPropertyID; + return mPropertyId; } private: @@ -182,12 +182,12 @@ class AnimatedPropertyIDSet { : mPropertySet(aPropertySet), mIDIterator(std::move(aIDIterator)), mCustomNameIterator(std::move(aCustomNameIterator)), - mPropertyID(eCSSProperty_UNKNOWN) {} + mPropertyId(eCSSProperty_UNKNOWN) {} const AnimatedPropertyIDSet& mPropertySet; nsCSSPropertyIDSet::Iterator mIDIterator; CustomNameSet::const_iterator mCustomNameIterator; - AnimatedPropertyID mPropertyID; + CSSPropertyId mPropertyId; }; Iterator begin() const { return Iterator::BeginIterator(*this); } @@ -215,7 +215,7 @@ struct InvertibleAnimatedPropertyIDSet { mIsInverted = aIsInverted; } - bool HasProperty(const AnimatedPropertyID& aProperty) const { + bool HasProperty(const CSSPropertyId& aProperty) const { return mSet && mIsInverted != mSet->HasProperty(aProperty); } }; diff --git a/layout/style/CSSPropertyId.h b/layout/style/CSSPropertyId.h @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_CSSPropertyId_h +#define mozilla_CSSPropertyId_h + +#include "NonCustomCSSPropertyId.h" +#include "mozilla/HashFunctions.h" +#include "mozilla/ServoBindings.h" +#include "nsCSSProps.h" +#include "nsString.h" + +namespace mozilla { + +struct CSSPropertyId { + explicit CSSPropertyId(NonCustomCSSPropertyId aProperty) : mId(aProperty) { + MOZ_ASSERT(aProperty != eCSSPropertyExtra_variable, + "Cannot create an CSSPropertyId from only a " + "eCSSPropertyExtra_variable."); + } + + explicit CSSPropertyId(RefPtr<nsAtom> aCustomName) + : mId(eCSSPropertyExtra_variable), mCustomName(std::move(aCustomName)) { + MOZ_ASSERT(mCustomName, "Null custom property name"); + } + + NonCustomCSSPropertyId mId = eCSSProperty_UNKNOWN; + RefPtr<nsAtom> mCustomName; + + bool IsCustom() const { return mId == eCSSPropertyExtra_variable; } + bool operator==(const CSSPropertyId& aOther) const { + return mId == aOther.mId && mCustomName == aOther.mCustomName; + } + bool operator!=(const CSSPropertyId& aOther) const { + return !(*this == aOther); + } + + bool IsValid() const { + if (mId == eCSSProperty_UNKNOWN) { + return false; + } + return IsCustom() == !!mCustomName; + } + + void ToString(nsACString& aString) const { + if (IsCustom()) { + MOZ_ASSERT(mCustomName, "Custom property should have a name"); + // mCustomName does not include the "--" prefix + aString.AssignLiteral("--"); + AppendUTF16toUTF8(nsDependentAtomString(mCustomName), aString); + } else { + aString.Assign(nsCSSProps::GetStringValue(mId)); + } + } + + void ToString(nsAString& aString) const { + if (IsCustom()) { + MOZ_ASSERT(mCustomName, "Custom property should have a name"); + // mCustomName does not include the "--" prefix + aString.AssignLiteral("--"); + aString.Append(nsDependentAtomString(mCustomName)); + } else { + aString.Assign(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(mId))); + } + } + + HashNumber Hash() const { + HashNumber hash = mCustomName ? mCustomName->hash() : 0; + return AddToHash(hash, mId); + } + + CSSPropertyId ToPhysical(const ComputedStyle& aStyle) const { + if (IsCustom()) { + return *this; + } + return CSSPropertyId{nsCSSProps::Physicalize(mId, aStyle)}; + } +}; + +// MOZ_DBG support for AnimatedPropertyId +inline std::ostream& operator<<(std::ostream& aOut, + const CSSPropertyId& aProperty) { + if (aProperty.IsCustom()) { + return aOut << nsAtomCString(aProperty.mCustomName); + } + return aOut << nsCSSProps::GetStringValue(aProperty.mId); +} + +} // namespace mozilla + +#endif // mozilla_CSSPropertyId_h diff --git a/layout/style/GeckoBindings.cpp b/layout/style/GeckoBindings.cpp @@ -694,9 +694,9 @@ double Gecko_GetPositionInSegment(const AnimationPropertySegment* aSegment, const StyleAnimationValue* Gecko_AnimationGetBaseStyle( const RawServoAnimationValueTable* aBaseStyles, - const mozilla::AnimatedPropertyID* aProperty) { + const mozilla::CSSPropertyId* aProperty) { const auto* base = reinterpret_cast<const nsRefPtrHashtable< - nsGenericHashKey<AnimatedPropertyID>, StyleAnimationValue>*>(aBaseStyles); + nsGenericHashKey<CSSPropertyId>, StyleAnimationValue>*>(aBaseStyles); return base->GetWeak(*aProperty); } diff --git a/layout/style/GeckoBindings.h b/layout/style/GeckoBindings.h @@ -250,13 +250,13 @@ double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*, // Get servo's AnimationValue for |aProperty| from the cached base style // |aBaseStyles|. -// |aBaseStyles| is nsRefPtrHashtable<nsGenericHashKey<AnimatedPropertyID>, +// |aBaseStyles| is nsRefPtrHashtable<nsGenericHashKey<CSSPropertyId>, // StyleAnimationValue>. // We use RawServoAnimationValueTableBorrowed to avoid exposing // nsRefPtrHashtable in FFI. const mozilla::StyleAnimationValue* Gecko_AnimationGetBaseStyle( const RawServoAnimationValueTable* aBaseStyles, - const mozilla::AnimatedPropertyID* aProperty); + const mozilla::CSSPropertyId* aProperty); void Gecko_StyleTransition_SetUnsupportedProperty( mozilla::StyleTransition* aTransition, nsAtom* aAtom); diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml @@ -4,7 +4,7 @@ headers = [ "mozilla/StyleAnimationValue.h", "nsStyleConsts.h", "nsCSSValue.h", - "mozilla/AnimatedPropertyID.h", + "mozilla/CSSPropertyId.h", "mozilla/css/SheetLoadData.h", "mozilla/DeclarationBlock.h", "mozilla/dom/HTMLSlotElement.h", @@ -190,7 +190,7 @@ allowlist-types = [ "mozilla::Keyframe", "mozilla::PropertyValuePair", "mozilla::DeclarationBlockMutationClosure", - "mozilla::AnimatedPropertyID", + "mozilla::CSSPropertyId", "mozilla::AnimationPropertySegment", "mozilla::AtomArray", "mozilla::ComputedTiming", diff --git a/layout/style/ServoCSSParser.cpp b/layout/style/ServoCSSParser.cpp @@ -8,7 +8,7 @@ #include "ServoCSSParser.h" -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/ServoBindings.h" #include "mozilla/ServoStyleSet.h" #include "mozilla/dom/Document.h" @@ -58,13 +58,13 @@ already_AddRefed<StyleLockedDeclarationBlock> ServoCSSParser::ParseProperty( NonCustomCSSPropertyId aProperty, const nsACString& aValue, const ParsingEnvironment& aParsingEnvironment, const StyleParsingMode& aParsingMode) { - AnimatedPropertyID property(aProperty); + CSSPropertyId property(aProperty); return ParseProperty(property, aValue, aParsingEnvironment, aParsingMode); } /* static */ already_AddRefed<StyleLockedDeclarationBlock> ServoCSSParser::ParseProperty( - const AnimatedPropertyID& aProperty, const nsACString& aValue, + const CSSPropertyId& aProperty, const nsACString& aValue, const ParsingEnvironment& aParsingEnvironment, const StyleParsingMode& aParsingMode) { return Servo_ParseProperty( diff --git a/layout/style/ServoCSSParser.h b/layout/style/ServoCSSParser.h @@ -22,7 +22,7 @@ class RefPtr; namespace mozilla { -struct AnimatedPropertyID; +struct CSSPropertyId; class ServoStyleSet; struct URLExtraData; struct StyleAbsoluteColor; @@ -137,7 +137,7 @@ class ServoCSSParser { const ParsingEnvironment& aParsingEnvironment, const StyleParsingMode& aParsingMode); static already_AddRefed<StyleLockedDeclarationBlock> ParseProperty( - const AnimatedPropertyID& aProperty, const nsACString& aValue, + const CSSPropertyId& aProperty, const nsACString& aValue, const ParsingEnvironment& aParsingEnvironment, const StyleParsingMode& aParsingMode); diff --git a/layout/style/ServoStyleConstsForwards.h b/layout/style/ServoStyleConstsForwards.h @@ -100,10 +100,10 @@ class StyleParserState; template <typename T> struct StyleForgottenArcSlicePtr; -struct AnimatedPropertyID; struct AnimationPropertySegment; struct AspectRatio; struct ComputedTiming; +struct CSSPropertyId; struct URLExtraData; enum HalfCorner : uint8_t; diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp @@ -117,7 +117,7 @@ bool AnimationValue::IsOffsetPathUrl() const { MatrixScales AnimationValue::GetScaleValue(const nsIFrame* aFrame) const { using namespace nsStyleTransformMatrix; - AnimatedPropertyID property(eCSSProperty_UNKNOWN); + CSSPropertyId property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(mServo, &property); switch (property.mId) { case eCSSProperty_scale: { @@ -151,13 +151,13 @@ MatrixScales AnimationValue::GetScaleValue(const nsIFrame* aFrame) const { } void AnimationValue::SerializeSpecifiedValue( - const AnimatedPropertyID& aProperty, - const StylePerDocumentStyleData* aRawData, nsACString& aString) const { + const CSSPropertyId& aProperty, const StylePerDocumentStyleData* aRawData, + nsACString& aString) const { MOZ_ASSERT(mServo); Servo_AnimationValue_Serialize(mServo, &aProperty, aRawData, &aString); } -bool AnimationValue::IsInterpolableWith(const AnimatedPropertyID& aProperty, +bool AnimationValue::IsInterpolableWith(const CSSPropertyId& aProperty, const AnimationValue& aToValue) const { if (IsNull() || aToValue.IsNull()) { return false; @@ -182,7 +182,7 @@ double AnimationValue::ComputeDistance(const AnimationValue& aOther) const { } /* static */ -AnimationValue AnimationValue::FromString(AnimatedPropertyID& aProperty, +AnimationValue AnimationValue::FromString(CSSPropertyId& aProperty, const nsACString& aValue, Element* aElement) { MOZ_ASSERT(aElement); diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h @@ -10,7 +10,7 @@ #define mozilla_StyleAnimationValue_h_ #include "NonCustomCSSPropertyId.h" -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/RefPtr.h" #include "mozilla/ServoBindingTypes.h" #include "mozilla/ServoStyleConsts.h" // Servo_AnimationValue_Dump @@ -84,12 +84,12 @@ struct AnimationValue { mozilla::gfx::MatrixScales GetScaleValue(const nsIFrame* aFrame) const; // Uncompute this AnimationValue and then serialize it. - void SerializeSpecifiedValue(const AnimatedPropertyID& aProperty, + void SerializeSpecifiedValue(const CSSPropertyId& aProperty, const StylePerDocumentStyleData* aRawData, nsACString& aString) const; // Check if |*this| and |aToValue| can be interpolated. - bool IsInterpolableWith(const AnimatedPropertyID& aProperty, + bool IsInterpolableWith(const CSSPropertyId& aProperty, const AnimationValue& aToValue) const; // Compute the distance between *this and aOther. @@ -98,7 +98,7 @@ struct AnimationValue { // Create an AnimaitonValue from a string. This method flushes style, so we // should use this carefully. Now, it is only used by // nsDOMWindowUtils::ComputeAnimationDistance. - static AnimationValue FromString(AnimatedPropertyID& aProperty, + static AnimationValue FromString(CSSPropertyId& aProperty, const nsACString& aValue, dom::Element* aElement); @@ -122,7 +122,7 @@ inline std::ostream& operator<<(std::ostream& aOut, } struct PropertyStyleAnimationValuePair { - AnimatedPropertyID mProperty; + CSSPropertyId mProperty; AnimationValue mValue; }; } // namespace mozilla diff --git a/layout/style/moz.build b/layout/style/moz.build @@ -22,7 +22,7 @@ with Files("nsDOM*"): with Files("AnimationCollection.*"): BUG_COMPONENT = ("Core", "CSS Transitions and Animations") -with Files("AnimatedPropertyID*"): +with Files("CSSPropertyId*"): BUG_COMPONENT = ("Core", "CSS Transitions and Animations") with Files("AnimationCommon.*"): @@ -83,7 +83,6 @@ EXPORTS += [ EXPORTS.mozilla += [ "!ServoCSSPropList.h", - "AnimatedPropertyID.h", "AnimatedPropertyIDSet.h", "AnimationCollection.h", "AttributeStyles.h", @@ -94,6 +93,7 @@ EXPORTS.mozilla += [ "ComputedStyle.h", "ComputedStyleInlines.h", "CSSEnabledState.h", + "CSSPropertyId.h", "CSSPropFlags.h", "DeclarationBlock.h", "DocumentStyleRootIterator.h", diff --git a/layout/style/nsCSSPropertyIDSet.h b/layout/style/nsCSSPropertyIDSet.h @@ -16,7 +16,7 @@ // For COMPOSITOR_ANIMATABLE_PROPERTY_LIST and // COMPOSITOR_ANIMATABLE_PROPERTY_LIST_LENGTH #include "NonCustomCSSPropertyId.h" -#include "mozilla/AnimatedPropertyID.h" +#include "mozilla/CSSPropertyId.h" #include "mozilla/CompositorAnimatableProperties.h" #include "nsCSSProps.h" // For operator<< for NonCustomCSSPropertyId @@ -62,7 +62,7 @@ class nsCSSPropertyIDSet { ~(property_set_type(1) << (p % kBitsInChunk)); } - bool HasProperty(const mozilla::AnimatedPropertyID& aProperty) const { + bool HasProperty(const mozilla::CSSPropertyId& aProperty) const { return !aProperty.IsCustom() && HasProperty(aProperty.mId); } diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp @@ -8,8 +8,8 @@ #include "nsTransitionManager.h" -#include "AnimatedPropertyID.h" #include "AnimatedPropertyIDSet.h" +#include "CSSPropertyId.h" #include "mozilla/ComputedStyle.h" #include "mozilla/EffectSet.h" #include "mozilla/ElementAnimationData.h" @@ -65,7 +65,7 @@ static void ExpandTransitionProperty(const StyleTransitionProperty& aProperty, case StyleTransitionProperty::Tag::Unsupported: break; case StyleTransitionProperty::Tag::Custom: { - AnimatedPropertyID property(aProperty.AsCustom().AsAtom()); + CSSPropertyId property(aProperty.AsCustom().AsAtom()); aHandler(property); break; } @@ -75,11 +75,11 @@ static void ExpandTransitionProperty(const StyleTransitionProperty& aProperty, if (nsCSSProps::IsShorthand(id)) { CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, id, CSSEnabledState::ForAllContent) { - AnimatedPropertyID property(*subprop); + CSSPropertyId property(*subprop); aHandler(property); } } else { - AnimatedPropertyID property(id); + CSSPropertyId property(id); aHandler(property); } break; @@ -116,17 +116,16 @@ bool nsTransitionManager::DoUpdateTransitions( } const auto behavior = aStyle.GetTransitionBehavior(i); - ExpandTransitionProperty(aStyle.GetTransitionProperty(i), - [&](const AnimatedPropertyID& aProperty) { - // We might have something to transition. See if - // any of the properties in question changed and - // are animatable. - startedAny |= ConsiderInitiatingTransition( - aProperty, aStyle, i, delay, duration, - behavior, aElement, aPseudoRequest, - aElementTransitions, aOldStyle, aNewStyle, - propertiesChecked); - }); + ExpandTransitionProperty( + aStyle.GetTransitionProperty(i), [&](const CSSPropertyId& aProperty) { + // We might have something to transition. See if + // any of the properties in question changed and + // are animatable. + startedAny |= ConsiderInitiatingTransition( + aProperty, aStyle, i, delay, duration, behavior, aElement, + aPseudoRequest, aElementTransitions, aOldStyle, aNewStyle, + propertiesChecked); + }); } // Stop any transitions for properties that are no longer in @@ -142,7 +141,7 @@ bool nsTransitionManager::DoUpdateTransitions( if (checkProperties) { for (uint32_t i = aStyle.mTransitionPropertyCount; i-- != 0;) { ExpandTransitionProperty(aStyle.GetTransitionProperty(i), - [&](const AnimatedPropertyID& aProperty) { + [&](const CSSPropertyId& aProperty) { allTransitionProperties.AddProperty( aProperty.ToPhysical(aNewStyle)); }); @@ -156,7 +155,7 @@ bool nsTransitionManager::DoUpdateTransitions( do { --i; CSSTransition* anim = animations[i]; - const AnimatedPropertyID& property = anim->TransitionProperty(); + const CSSPropertyId& property = anim->TransitionProperty(); if ( // Properties no longer in `transition-property`. (checkProperties && !allTransitionProperties.HasProperty(property)) || @@ -175,8 +174,7 @@ bool nsTransitionManager::DoUpdateTransitions( return startedAny; } -static Keyframe& AppendKeyframe(double aOffset, - const AnimatedPropertyID& aProperty, +static Keyframe& AppendKeyframe(double aOffset, const CSSPropertyId& aProperty, AnimationValue&& aValue, nsTArray<Keyframe>& aKeyframes) { Keyframe& frame = *aKeyframes.AppendElement(); @@ -189,9 +187,9 @@ static Keyframe& AppendKeyframe(double aOffset, return frame; } -static nsTArray<Keyframe> GetTransitionKeyframes( - const AnimatedPropertyID& aProperty, AnimationValue&& aStartValue, - AnimationValue&& aEndValue) { +static nsTArray<Keyframe> GetTransitionKeyframes(const CSSPropertyId& aProperty, + AnimationValue&& aStartValue, + AnimationValue&& aEndValue) { nsTArray<Keyframe> keyframes(2); AppendKeyframe(0.0, aProperty, std::move(aStartValue), keyframes); @@ -255,7 +253,7 @@ static Maybe<ReplacedTransitionProperties> GetReplacedTransitionProperties( } bool nsTransitionManager::ConsiderInitiatingTransition( - const AnimatedPropertyID& aProperty, const nsStyleUIReset& aStyle, + const CSSPropertyId& aProperty, const nsStyleUIReset& aStyle, uint32_t aTransitionIndex, float aDelay, float aDuration, mozilla::StyleTransitionBehavior aBehavior, dom::Element* aElement, const PseudoStyleRequest& aPseudoRequest, @@ -269,7 +267,7 @@ bool nsTransitionManager::ConsiderInitiatingTransition( !aElementTransitions || &aElementTransitions->mElement == aElement, "Element mismatch"); - AnimatedPropertyID property = aProperty.ToPhysical(aNewStyle); + CSSPropertyId property = aProperty.ToPhysical(aNewStyle); // A later item in transition-property already specified a transition for // this property, so we ignore this one. @@ -477,7 +475,7 @@ bool nsTransitionManager::ConsiderInitiatingTransition( } already_AddRefed<CSSTransition> nsTransitionManager::DoCreateTransition( - const AnimatedPropertyID& aProperty, dom::Element* aElement, + const CSSPropertyId& aProperty, dom::Element* aElement, const PseudoStyleRequest& aPseudoRequest, const mozilla::ComputedStyle& aNewStyle, CSSTransitionCollection*& aElementTransitions, TimingParams&& aTiming, diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h @@ -61,7 +61,7 @@ class nsTransitionManager final // Returns whether the transition actually started. bool ConsiderInitiatingTransition( - const mozilla::AnimatedPropertyID&, const nsStyleUIReset& aStyle, + const mozilla::CSSPropertyId&, const nsStyleUIReset& aStyle, uint32_t aTransitionIndex, float aDelay, float aDuration, mozilla::StyleTransitionBehavior aBehavior, mozilla::dom::Element* aElement, @@ -72,8 +72,7 @@ class nsTransitionManager final mozilla::AnimatedPropertyIDSet& aPropertiesChecked); already_AddRefed<mozilla::dom::CSSTransition> DoCreateTransition( - const mozilla::AnimatedPropertyID& aProperty, - mozilla::dom::Element* aElement, + const mozilla::CSSPropertyId& aProperty, mozilla::dom::Element* aElement, const mozilla::PseudoStyleRequest& aPseudoRequest, const mozilla::ComputedStyle& aNewStyle, CSSTransitionCollection*& aElementTransitions, diff --git a/servo/components/style/properties/mod.rs b/servo/components/style/properties/mod.rs @@ -21,7 +21,7 @@ pub mod generated { use crate::custom_properties::{self, ComputedCustomProperties}; #[cfg(feature = "gecko")] -use crate::gecko_bindings::structs::{AnimatedPropertyID, NonCustomCSSPropertyId, RefPtr}; +use crate::gecko_bindings::structs::{CSSPropertyId, NonCustomCSSPropertyId, RefPtr}; use crate::logical_geometry::WritingMode; use crate::parser::ParserContext; use crate::stylesheets::CssRuleType; @@ -426,10 +426,10 @@ impl PropertyId { Some(NonCustomPropertyId::from_noncustomcsspropertyid(id)?.to_property_id()) } - /// Returns a property id from Gecko's AnimatedPropertyID. + /// Returns a property id from Gecko's CSSPropertyId. #[cfg(feature = "gecko")] #[inline] - pub fn from_gecko_animated_property_id(property: &AnimatedPropertyID) -> Option<Self> { + pub fn from_gecko_css_property_id(property: &CSSPropertyId) -> Option<Self> { Some( if property.mId == NonCustomCSSPropertyId::eCSSPropertyExtra_variable { debug_assert!(!property.mCustomName.mRawPtr.is_null()); @@ -981,16 +981,14 @@ impl OwnedPropertyDeclarationId { } } - /// Convert an `AnimatedPropertyID` into an `OwnedPropertyDeclarationId`. + /// Convert an `CSSPropertyId` into an `OwnedPropertyDeclarationId`. #[cfg(feature = "gecko")] #[inline] - pub fn from_gecko_animated_property_id(property: &AnimatedPropertyID) -> Option<Self> { - Some( - match PropertyId::from_gecko_animated_property_id(property)? { - PropertyId::Custom(name) => Self::Custom(name), - PropertyId::NonCustom(id) => Self::Longhand(id.as_longhand()?), - }, - ) + pub fn from_gecko_css_property_id(property: &CSSPropertyId) -> Option<Self> { + Some(match PropertyId::from_gecko_css_property_id(property)? { + PropertyId::Custom(name) => Self::Custom(name), + PropertyId::NonCustom(id) => Self::Longhand(id.as_longhand()?), + }) } } @@ -1134,20 +1132,20 @@ impl<'a> PropertyDeclarationId<'a> { } } - /// Convert a `PropertyDeclarationId` into an `AnimatedPropertyID` + /// Convert a `PropertyDeclarationId` into an `CSSPropertyId` /// /// FIXME(emilio, bug 1870107): We should consider using cbindgen to generate the property id /// representation or so. #[cfg(feature = "gecko")] #[inline] - pub fn to_gecko_animated_property_id(&self) -> AnimatedPropertyID { + pub fn to_gecko_css_property_id(&self) -> CSSPropertyId { match self { - Self::Longhand(id) => AnimatedPropertyID { + Self::Longhand(id) => CSSPropertyId { mId: id.to_noncustomcsspropertyid(), mCustomName: RefPtr::null(), }, Self::Custom(name) => { - let mut property_id = AnimatedPropertyID { + let mut property_id = CSSPropertyId { mId: NonCustomCSSPropertyId::eCSSPropertyExtra_variable, mCustomName: RefPtr::null(), }; diff --git a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml @@ -382,7 +382,7 @@ renaming_overrides_prefixing = true "RefPtr" = "RefPtr" "NonCustomCSSPropertyId" = "NonCustomCSSPropertyId" "nsCSSPropertyIDSet" = "nsCSSPropertyIDSet" -"AnimatedPropertyID" = "AnimatedPropertyID" +"CSSPropertyId" = "CSSPropertyId" "nsCSSValueSharedList" = "nsCSSValueSharedList" "AnimationPropertySegment" = "AnimationPropertySegment" "RawServoAnimationValueTable" = "RawServoAnimationValueTable" diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs @@ -651,7 +651,7 @@ pub extern "C" fn Servo_ComposeAnimationSegment( pub extern "C" fn Servo_AnimationCompose( value_map: &mut AnimationValueMap, base_values: &structs::RawServoAnimationValueTable, - css_property: &structs::AnimatedPropertyID, + css_property: &structs::CSSPropertyId, segment: &structs::AnimationPropertySegment, last_segment: &structs::AnimationPropertySegment, computed_timing: &structs::ComputedTiming, @@ -661,7 +661,7 @@ pub extern "C" fn Servo_AnimationCompose( use style::gecko_bindings::bindings::Gecko_GetPositionInSegment; use style::gecko_bindings::bindings::Gecko_GetProgressFromComputedTiming; - let property = match OwnedPropertyDeclarationId::from_gecko_animated_property_id(css_property) { + let property = match OwnedPropertyDeclarationId::from_gecko_css_property_id(css_property) { Some(property) if property.as_borrowed().is_animatable() => property, _ => return, }; @@ -727,9 +727,9 @@ macro_rules! get_property_id_from_noncustomcsspropertyid { }}; } -macro_rules! get_property_id_from_animatedpropertyid { +macro_rules! get_property_id_from_csspropertyid { ($property_id: ident, $ret: expr) => {{ - match PropertyId::from_gecko_animated_property_id($property_id) { + match PropertyId::from_gecko_css_property_id($property_id) { Some(property_id) => property_id, None => { return $ret; @@ -741,7 +741,7 @@ macro_rules! get_property_id_from_animatedpropertyid { #[no_mangle] pub extern "C" fn Servo_AnimationValue_Serialize( value: &AnimationValue, - property: &structs::AnimatedPropertyID, + property: &structs::CSSPropertyId, raw_data: &PerDocumentStyleData, buffer: &mut nsACString, ) { @@ -749,7 +749,7 @@ pub extern "C" fn Servo_AnimationValue_Serialize( let data = raw_data.borrow(); let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal) .single_value_to_css( - &get_property_id_from_animatedpropertyid!(property, ()), + &get_property_id_from_csspropertyid!(property, ()), buffer, None, &data.stylist, @@ -1120,9 +1120,9 @@ pub unsafe extern "C" fn Servo_AnimationValueMap_Drop(value_map: *mut AnimationV #[no_mangle] pub extern "C" fn Servo_AnimationValueMap_GetValue( value_map: &AnimationValueMap, - property_id: &structs::AnimatedPropertyID, + property_id: &structs::CSSPropertyId, ) -> Strong<AnimationValue> { - let property = match OwnedPropertyDeclarationId::from_gecko_animated_property_id(property_id) { + let property = match OwnedPropertyDeclarationId::from_gecko_css_property_id(property_id) { Some(property) => property, None => return Strong::null(), }; @@ -1209,7 +1209,7 @@ fn is_transitionable(prop: PropertyDeclarationId, behavior: computed::Transition pub extern "C" fn Servo_ComputedValues_ShouldTransition( old: &ComputedValues, new: &ComputedValues, - prop: &structs::AnimatedPropertyID, + prop: &structs::CSSPropertyId, behavior: computed::TransitionBehavior, old_transition_end_value: Option<&AnimationValue>, current_start_value: Option<&AnimationValue>, @@ -1218,7 +1218,7 @@ pub extern "C" fn Servo_ComputedValues_ShouldTransition( start: &mut structs::RefPtr<AnimationValue>, end: &mut structs::RefPtr<AnimationValue>, ) -> ShouldTransitionResult { - let Some(prop) = OwnedPropertyDeclarationId::from_gecko_animated_property_id(prop) else { + let Some(prop) = OwnedPropertyDeclarationId::from_gecko_css_property_id(prop) else { return Default::default(); }; let prop = prop.as_borrowed(); @@ -1298,10 +1298,10 @@ pub extern "C" fn Servo_ComputedValues_ShouldTransition( #[no_mangle] pub extern "C" fn Servo_ComputedValues_TransitionValueMatches( style: &ComputedValues, - prop: &structs::AnimatedPropertyID, + prop: &structs::CSSPropertyId, transition_value: &AnimationValue, ) -> bool { - let Some(prop) = OwnedPropertyDeclarationId::from_gecko_animated_property_id(prop) else { + let Some(prop) = OwnedPropertyDeclarationId::from_gecko_css_property_id(prop) else { return false; }; // Note: the running transitions should be transitionable, so it is always allow-discrete. @@ -1318,9 +1318,9 @@ pub extern "C" fn Servo_ComputedValues_TransitionValueMatches( #[no_mangle] pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue( computed_values: &ComputedValues, - property_id: &structs::AnimatedPropertyID, + property_id: &structs::CSSPropertyId, ) -> Strong<AnimationValue> { - let property = match OwnedPropertyDeclarationId::from_gecko_animated_property_id(property_id) { + let property = match OwnedPropertyDeclarationId::from_gecko_css_property_id(property_id) { Some(property) => property, None => return Strong::null(), }; @@ -1453,8 +1453,8 @@ pub unsafe extern "C" fn Servo_Property_GetCSSValuesForProperty( } #[no_mangle] -pub extern "C" fn Servo_Property_IsAnimatable(prop: &structs::AnimatedPropertyID) -> bool { - PropertyId::from_gecko_animated_property_id(prop).map_or(false, |p| p.is_animatable()) +pub extern "C" fn Servo_Property_IsAnimatable(prop: &structs::CSSPropertyId) -> bool { + PropertyId::from_gecko_css_property_id(prop).map_or(false, |p| p.is_animatable()) } #[no_mangle] @@ -5012,7 +5012,7 @@ fn parse_property_into( #[no_mangle] pub unsafe extern "C" fn Servo_ParseProperty( - property: &structs::AnimatedPropertyID, + property: &structs::CSSPropertyId, value: &nsACString, data: *mut URLExtraData, parsing_mode: ParsingMode, @@ -5020,7 +5020,7 @@ pub unsafe extern "C" fn Servo_ParseProperty( loader: *mut Loader, rule_type: CssRuleType, ) -> Strong<LockedDeclarationBlock> { - let id = get_property_id_from_animatedpropertyid!(property, Strong::null()); + let id = get_property_id_from_csspropertyid!(property, Strong::null()); let mut declarations = SourcePropertyDeclaration::default(); let reporter = ErrorReporter::new(ptr::null_mut(), loader, data); let data = UrlExtraData::from_ptr_ref(&data); @@ -5257,12 +5257,12 @@ pub extern "C" fn Servo_DeclarationBlock_GetCssText( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SerializeOneValue( decls: &LockedDeclarationBlock, - property_id: &structs::AnimatedPropertyID, + property_id: &structs::CSSPropertyId, buffer: &mut nsACString, computed_values: Option<&ComputedValues>, data: &PerDocumentStyleData, ) { - let property_id = get_property_id_from_animatedpropertyid!(property_id, ()); + let property_id = get_property_id_from_csspropertyid!(property_id, ()); let global_style_data = &*GLOBAL_STYLE_DATA; let guard = global_style_data.shared_lock.read(); @@ -6909,7 +6909,7 @@ pub extern "C" fn Servo_ReparentStyle( #[cfg(feature = "gecko_debug")] fn simulate_compute_values_failure(property: &PropertyValuePair) -> bool { let p = &property.mProperty; - let id = get_property_id_from_animatedpropertyid!(p, false); + let id = get_property_id_from_csspropertyid!(p, false); id.as_shorthand().is_ok() && property.mSimulateComputeValuesFailure } @@ -6962,7 +6962,7 @@ impl<'a> PrioritizedPropertyIter<'a> { .iter() .enumerate() .map(|(index, pair)| { - let property = PropertyId::from_gecko_animated_property_id(&pair.mProperty) + let property = PropertyId::from_gecko_css_property_id(&pair.mProperty) .unwrap_or(PropertyId::NonCustom(ShorthandId::All.into())); PropertyAndIndex { property, index } }) @@ -7053,11 +7053,10 @@ pub extern "C" fn Servo_GetComputedKeyframeValues( ); let priority = CascadePriority::same_tree_author_normal_at_root_layer(); for property in &mut iter { - let is_custom = - match PropertyId::from_gecko_animated_property_id(&property.mProperty) { - Some(PropertyId::Custom(..)) => true, - _ => false, - }; + let is_custom = match PropertyId::from_gecko_css_property_id(&property.mProperty) { + Some(PropertyId::Custom(..)) => true, + _ => false, + }; if !is_custom { break; // Custom props are guaranteed to sort earlier. } @@ -7107,7 +7106,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues( seen.insert(property); animation_values.push(structs::PropertyStyleAnimationValuePair { - mProperty: property.to_gecko_animated_property_id(), + mProperty: property.to_gecko_css_property_id(), mValue: structs::AnimationValue { mServo: value.map_or(structs::RefPtr::null(), |v| { structs::RefPtr::from_arc(Arc::new(v)) @@ -7119,7 +7118,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues( if property.mServoDeclarationBlock.mRawPtr.is_null() { if let Some(prop) = - OwnedPropertyDeclarationId::from_gecko_animated_property_id(&property.mProperty) + OwnedPropertyDeclarationId::from_gecko_css_property_id(&property.mProperty) { maybe_append_animation_value(prop.as_borrowed(), None); } @@ -7178,9 +7177,9 @@ pub extern "C" fn Servo_GetAnimationValues( #[no_mangle] pub extern "C" fn Servo_AnimationValue_GetPropertyId( value: &AnimationValue, - property_id: &mut structs::AnimatedPropertyID, + property_id: &mut structs::CSSPropertyId, ) { - *property_id = value.id().to_gecko_animated_property_id(); + *property_id = value.id().to_gecko_css_property_id(); } #[no_mangle] @@ -7270,7 +7269,7 @@ enum Offset { fn property_value_pair_for(id: &PropertyDeclarationId) -> structs::PropertyValuePair { structs::PropertyValuePair { - mProperty: id.to_gecko_animated_property_id(), + mProperty: id.to_gecko_css_property_id(), mServoDeclarationBlock: structs::RefPtr::null(), #[cfg(feature = "gecko_debug")] mSimulateComputeValuesFailure: false,