commit b314d21751072aaeca44a2823f6d549f2966ee58 parent 2fb9671026117893663d14c62234a45ff2a60a2a Author: Jan Varga <jan.varga@gmail.com> Date: Wed, 12 Nov 2025 06:09:06 +0000 Bug 1998365 - Rename nsCSSPropertyID to NonCustomCSSPropertyId and normalize ID naming; r=emilio,firefox-style-system-reviewers,layout-reviewers nsCSSPropertyID only enumerates non custom properties, but the name suggests otherwise. (eCSSPropertyExtra_variable only signals a custom property and does not carry the custom name.) This mismatch has been confusing and also blocks renaming AnimatedPropertyID to CSSPropertyId. This patch renames nsCSSPropertyID to NonCustomCSSPropertyId to make the non custom scope explicit. It also normalizes identifier naming (aPropID -> aPropId, mID -> mId, etc.) for consistency. No behavior changes intended. Potential follow-ups: - Move the enum to the mozilla namespace. - Convert the enum to an enum class. - Rename nsCSSPropertyIDSet. Differential Revision: https://phabricator.services.mozilla.com/D271443 Diffstat:
98 files changed, 728 insertions(+), 684 deletions(-)
diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp @@ -1270,7 +1270,7 @@ already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() { } const ComputedStyle& style = *f->Style(); - auto Atomize = [&](nsCSSPropertyID aId) -> RefPtr<nsAtom> { + auto Atomize = [&](NonCustomCSSPropertyId aId) -> RefPtr<nsAtom> { nsAutoCString value; style.GetComputedPropertyValue(aId, value); return NS_Atomize(value); @@ -4252,7 +4252,7 @@ void LocalAccessible::MaybeQueueCacheUpdateForStyleChanges() { const auto overflowProps = nsCSSPropertyIDSet({eCSSProperty_overflow_x, eCSSProperty_overflow_y}); - for (nsCSSPropertyID overflowProp : overflowProps) { + for (NonCustomCSSPropertyId overflowProp : overflowProps) { nsAutoCString oldOverflow, newOverflow; mOldComputedStyle->GetComputedPropertyValue(overflowProp, oldOverflow); newStyle->GetComputedPropertyValue(overflowProp, newOverflow); diff --git a/dom/animation/AnimationEventDispatcher.cpp b/dom/animation/AnimationEventDispatcher.cpp @@ -174,7 +174,7 @@ void AnimationEventInfo::MaybeAddMarker() const { properties.Append(prop); oncompositor.Append( !property.IsCustom() && - nsCSSProps::PropHasFlags(property.mID, + nsCSSProps::PropHasFlags(property.mId, CSSPropFlags::CanAnimateOnCompositor) ? "true" : "false"); @@ -218,7 +218,7 @@ void AnimationEventInfo::MaybeAddMarker() const { // probably. const bool onCompositor = !data.mProperty.IsCustom() && - nsCSSProps::PropHasFlags(data.mProperty.mID, + nsCSSProps::PropHasFlags(data.mProperty.mId, CSSPropFlags::CanAnimateOnCompositor); PROFILER_MARKER( "CSS transition", DOM, diff --git a/dom/animation/EffectCompositor.cpp b/dom/animation/EffectCompositor.cpp @@ -611,7 +611,8 @@ nsCSSPropertyIDSet EffectCompositor::GetOverriddenProperties( static constexpr size_t compositorAnimatableCount = nsCSSPropertyIDSet::CompositorAnimatableCount(); - AutoTArray<nsCSSPropertyID, compositorAnimatableCount> propertiesToTrack; + AutoTArray<NonCustomCSSPropertyId, compositorAnimatableCount> + propertiesToTrack; { nsCSSPropertyIDSet propertiesToTrackAsSet; for (KeyframeEffect* effect : aEffectSet) { @@ -621,11 +622,11 @@ nsCSSPropertyIDSet EffectCompositor::GetOverriddenProperties( continue; } - if (nsCSSProps::PropHasFlags(property.mProperty.mID, + if (nsCSSProps::PropHasFlags(property.mProperty.mId, CSSPropFlags::CanAnimateOnCompositor) && - !propertiesToTrackAsSet.HasProperty(property.mProperty.mID)) { - propertiesToTrackAsSet.AddProperty(property.mProperty.mID); - propertiesToTrack.AppendElement(property.mProperty.mID); + !propertiesToTrackAsSet.HasProperty(property.mProperty.mId)) { + propertiesToTrackAsSet.AddProperty(property.mProperty.mId); + propertiesToTrack.AppendElement(property.mProperty.mId); } } // Skip iterating over the rest of the effects if we've already @@ -698,7 +699,7 @@ void EffectCompositor::UpdateCascadeResults( // properties. // TODO: Bug 1869475. Support custom properties for compositor animations. if (overriddenProperties.HasProperty(prop.mProperty)) { - propertiesWithImportantRules.AddProperty(prop.mProperty.mID); + propertiesWithImportantRules.AddProperty(prop.mProperty.mId); } switch (cascadeLevel) { diff --git a/dom/animation/EffectCompositor.h b/dom/animation/EffectCompositor.h @@ -7,6 +7,7 @@ #ifndef mozilla_EffectCompositor_h #define mozilla_EffectCompositor_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/AnimationPerformanceWarning.h" #include "mozilla/AnimationTarget.h" #include "mozilla/EnumeratedArray.h" @@ -17,7 +18,6 @@ #include "mozilla/RefPtr.h" #include "mozilla/ServoTypes.h" #include "mozilla/dom/EndpointBehavior.h" -#include "nsCSSPropertyID.h" #include "nsCycleCollectionParticipant.h" #include "nsTArray.h" #include "nsTHashMap.h" diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp @@ -10,6 +10,7 @@ #include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/KeyframeAnimationOptionsBinding.h" // For UnrestrictedDoubleOrKeyframeAnimationOptions; +#include "NonCustomCSSPropertyId.h" #include "WindowRenderer.h" #include "js/PropertyAndElement.h" // JS_DefineProperty #include "mozilla/AnimationUtils.h" @@ -30,7 +31,6 @@ #include "mozilla/dom/KeyframeEffectBinding.h" #include "mozilla/dom/MutationObservers.h" #include "mozilla/layers/AnimationInfo.h" -#include "nsCSSPropertyID.h" #include "nsCSSPropertyIDSet.h" #include "nsCSSProps.h" // For nsCSSProps::PropHasFlags #include "nsCSSPseudoElements.h" // For PseudoStyleType @@ -360,19 +360,19 @@ nsCSSPropertyIDSet KeyframeEffect::GetPropertiesForCompositor( // need to evaluate them as a group. We build up a separate set here then // evaluate it as a separate step below. if (transformLikeProperties.HasProperty(property.mProperty)) { - transformSet.AddProperty(property.mProperty.mID); + transformSet.AddProperty(property.mProperty.mId); continue; } KeyframeEffect::MatchForCompositor matchResult = - IsMatchForCompositor(nsCSSPropertyIDSet{property.mProperty.mID}, aFrame, + IsMatchForCompositor(nsCSSPropertyIDSet{property.mProperty.mId}, aFrame, aEffects, dummyWarning); if (matchResult == KeyframeEffect::MatchForCompositor::NoAndBlockThisProperty || matchResult == KeyframeEffect::MatchForCompositor::No) { continue; } - properties.AddProperty(property.mProperty.mID); + properties.AddProperty(property.mProperty.mId); } if (!transformSet.IsEmpty()) { @@ -453,7 +453,7 @@ void KeyframeEffect::UpdateProperties(const ComputedStyle* aStyle, for (const AnimationProperty& property : mProperties) { if (property.mIsRunningOnCompositor) { - runningOnCompositorProperties.AddProperty(property.mProperty.mID); + runningOnCompositorProperties.AddProperty(property.mProperty.mId); } } @@ -686,7 +686,7 @@ bool KeyframeEffect::IsRunningOnCompositor() const { return false; } -void KeyframeEffect::SetIsRunningOnCompositor(nsCSSPropertyID aProperty, +void KeyframeEffect::SetIsRunningOnCompositor(NonCustomCSSPropertyId aProperty, bool aIsRunning) { MOZ_ASSERT(aProperty != eCSSPropertyExtra_variable, "Can't animate variables on compositor"); @@ -696,7 +696,7 @@ void KeyframeEffect::SetIsRunningOnCompositor(nsCSSPropertyID aProperty, "compositor-animatable property"); for (AnimationProperty& property : mProperties) { - if (property.mProperty.mID == aProperty) { + if (property.mProperty.mId == aProperty) { property.mIsRunningOnCompositor = aIsRunning; // We currently only set a performance warning message when animations // cannot be run on the compositor, so if this animation is running @@ -715,7 +715,7 @@ void KeyframeEffect::SetIsRunningOnCompositor( const nsCSSPropertyIDSet& aPropertySet, bool aIsRunning) { for (AnimationProperty& property : mProperties) { if (aPropertySet.HasProperty(property.mProperty)) { - MOZ_ASSERT(nsCSSProps::PropHasFlags(property.mProperty.mID, + MOZ_ASSERT(nsCSSProps::PropHasFlags(property.mProperty.mId, CSSPropFlags::CanAnimateOnCompositor), "Property being animated on compositor is a recognized " "compositor-animatable property"); @@ -1040,7 +1040,7 @@ void DumpAnimationProperties( nsTArray<AnimationProperty>& aAnimationProperties) { for (auto& p : aAnimationProperties) { printf("%s\n", - nsCString(nsCSSProps::GetStringValue(p.mProperty.mID)).get()); + nsCString(nsCSSProps::GetStringValue(p.mProperty.mId)).get()); for (auto& s : p.mSegments) { nsAutoCString fromValue, toValue; s.mFromValue.SerializeSpecifiedValue(p.mProperty, aRawData, fromValue); @@ -1300,20 +1300,20 @@ void KeyframeEffect::GetKeyframes(JSContext* aCx, nsTArray<JSObject*>& aResult, // https://drafts.csswg.org/web-animations/#property-name-conversion const char* name = nullptr; nsAutoCString customName; - switch (propertyValue.mProperty.mID) { - case nsCSSPropertyID::eCSSPropertyExtra_variable: + switch (propertyValue.mProperty.mId) { + case NonCustomCSSPropertyId::eCSSPropertyExtra_variable: customName.Append("--"); customName.Append(nsAtomCString(propertyValue.mProperty.mCustomName)); name = customName.get(); break; - case nsCSSPropertyID::eCSSProperty_offset: + case NonCustomCSSPropertyId::eCSSProperty_offset: name = "cssOffset"; break; - case nsCSSPropertyID::eCSSProperty_float: + case NonCustomCSSPropertyId::eCSSProperty_float: // FIXME: Bug 1582314: Should handle cssFloat manually if we remove it // from nsCSSProps::PropertyIDLName(). default: - name = nsCSSProps::PropertyIDLName(propertyValue.mProperty.mID); + name = nsCSSProps::PropertyIDLName(propertyValue.mProperty.mId); } JS::Rooted<JS::Value> value(aCx); @@ -1462,7 +1462,7 @@ bool KeyframeEffect::CanThrottle() const { DisplayItemType displayItemType = LayerAnimationInfo::GetDisplayItemTypeForProperty( - property.mProperty.mID); + property.mProperty.mId); // Note that AnimationInfo::GetGenarationFromFrame() is supposed to work // with the primary frame instead of the style frame. @@ -1603,7 +1603,8 @@ PresShell* KeyframeEffect::GetPresShell() const { } /* static */ -bool KeyframeEffect::IsGeometricProperty(const nsCSSPropertyID aProperty) { +bool KeyframeEffect::IsGeometricProperty( + const NonCustomCSSPropertyId aProperty) { MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty), "Property should be a longhand property"); @@ -1715,7 +1716,7 @@ bool KeyframeEffect::ShouldBlockAsyncTransformAnimations( // If there are any offset-path animations whose animation values are url(), // we have to sync with the main thread when resolving it. - if (property.mProperty.mID == eCSSProperty_offset_path) { + if (property.mProperty.mId == eCSSProperty_offset_path) { for (const auto& seg : property.mSegments) { if (seg.mFromValue.IsOffsetPathUrl() || seg.mToValue.IsOffsetPathUrl()) { @@ -1730,7 +1731,7 @@ bool KeyframeEffect::ShouldBlockAsyncTransformAnimations( bool KeyframeEffect::HasGeometricProperties() const { for (const AnimationProperty& property : mProperties) { - if (IsGeometricProperty(property.mProperty.mID)) { + if (IsGeometricProperty(property.mProperty.mId)) { return true; } } @@ -1747,7 +1748,7 @@ void KeyframeEffect::SetPerformanceWarning( continue; } property.SetPerformanceWarning(aWarning, mTarget.mElement); - curr.RemoveProperty(property.mProperty.mID); + curr.RemoveProperty(property.mProperty.mId); if (curr.IsEmpty()) { return; } @@ -1763,17 +1764,17 @@ void KeyframeEffect::CalculateCumulativeChangesForProperty( constexpr auto kInterestingFlags = CSSPropFlags::AffectsLayout | CSSPropFlags::AffectsOverflow; - if (aProperty.mProperty.mID == eCSSProperty_opacity) { + if (aProperty.mProperty.mId == eCSSProperty_opacity) { mCumulativeChanges.mOpacity = true; return; // We know opacity is visual-only. } - if (aProperty.mProperty.mID == eCSSProperty_visibility) { + if (aProperty.mProperty.mId == eCSSProperty_visibility) { mCumulativeChanges.mVisibility = true; return; // We know visibility is visual-only. } - if (aProperty.mProperty.mID == eCSSProperty_background_color) { + if (aProperty.mProperty.mId == eCSSProperty_background_color) { if (!mCumulativeChanges.mHasBackgroundColorCurrentColor) { mCumulativeChanges.mHasBackgroundColorCurrentColor = HasCurrentColor(aProperty.mSegments); @@ -1781,7 +1782,7 @@ void KeyframeEffect::CalculateCumulativeChangesForProperty( return; // We know background-color is visual-only. } - auto flags = nsCSSProps::PropFlags(aProperty.mProperty.mID); + auto flags = nsCSSProps::PropFlags(aProperty.mProperty.mId); if (!(flags & kInterestingFlags)) { return; // Property is visual-only. } @@ -1889,9 +1890,9 @@ bool KeyframeEffect::ContainsAnimatedScale(const nsIFrame* aFrame) const { } for (const AnimationProperty& prop : mProperties) { - if (prop.mProperty.mID != eCSSProperty_transform && - prop.mProperty.mID != eCSSProperty_scale && - prop.mProperty.mID != eCSSProperty_rotate) { + if (prop.mProperty.mId != eCSSProperty_transform && + prop.mProperty.mId != eCSSProperty_scale && + prop.mProperty.mId != eCSSProperty_rotate) { continue; } diff --git a/dom/animation/KeyframeEffect.h b/dom/animation/KeyframeEffect.h @@ -7,6 +7,7 @@ #ifndef mozilla_dom_KeyframeEffect_h #define mozilla_dom_KeyframeEffect_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/AnimatedPropertyID.h" #include "mozilla/AnimatedPropertyIDSet.h" #include "mozilla/AnimationPerformanceWarning.h" @@ -16,7 +17,6 @@ #include "mozilla/Keyframe.h" #include "mozilla/KeyframeEffectParams.h" #include "mozilla/PostRestyleMode.h" -#include "nsCSSPropertyID.h" #include "nsCSSPropertyIDSet.h" #include "nsCSSValue.h" #include "nsChangeHint.h" @@ -281,7 +281,8 @@ class KeyframeEffect : public AnimationEffect { // Returns true if at least one property is being animated on compositor. bool IsRunningOnCompositor() const; - void SetIsRunningOnCompositor(nsCSSPropertyID aProperty, bool aIsRunning); + void SetIsRunningOnCompositor(NonCustomCSSPropertyId aProperty, + bool aIsRunning); void SetIsRunningOnCompositor(const nsCSSPropertyIDSet& aPropertySet, bool aIsRunning); void ResetIsRunningOnCompositor(); @@ -493,7 +494,7 @@ class KeyframeEffect : public AnimationEffect { const ComputedTiming& aComputedTiming); already_AddRefed<const ComputedStyle> CreateComputedStyleForAnimationValue( - nsCSSPropertyID aProperty, const AnimationValue& aValue, + NonCustomCSSPropertyId aProperty, const AnimationValue& aValue, nsPresContext* aPresContext, const ComputedStyle* aBaseComputedStyle); // Return the primary frame for the target (pseudo-)element. @@ -516,7 +517,7 @@ class KeyframeEffect : public AnimationEffect { static bool CanAnimateTransformOnCompositor( const nsIFrame* aFrame, AnimationPerformanceWarning::Type& aPerformanceWarning /* out */); - static bool IsGeometricProperty(const nsCSSPropertyID aProperty); + static bool IsGeometricProperty(const NonCustomCSSPropertyId aProperty); static const TimeDuration OverflowRegionRefreshInterval(); diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp @@ -81,14 +81,14 @@ struct AdditionalProperty { } bool LessThan(const AdditionalProperty& aLhs, const AdditionalProperty& aRhs) const { - bool customLhs = - aLhs.mProperty.mID == nsCSSPropertyID::eCSSPropertyExtra_variable; - bool customRhs = - aRhs.mProperty.mID == nsCSSPropertyID::eCSSPropertyExtra_variable; + bool customLhs = aLhs.mProperty.mId == + NonCustomCSSPropertyId::eCSSPropertyExtra_variable; + bool customRhs = aRhs.mProperty.mId == + NonCustomCSSPropertyId::eCSSPropertyExtra_variable; if (!customLhs && !customRhs) { // Compare by IDL names. - return nsCSSProps::PropertyIDLNameSortPosition(aLhs.mProperty.mID) < - nsCSSProps::PropertyIDLNameSortPosition(aRhs.mProperty.mID); + return nsCSSProps::PropertyIDLNameSortPosition(aLhs.mProperty.mId) < + nsCSSProps::PropertyIDLNameSortPosition(aRhs.mProperty.mId); } if (customLhs && customRhs) { // Compare by custom property names. @@ -129,15 +129,15 @@ struct KeyframeValueEntry { static bool LessThan(const KeyframeValueEntry& aLhs, const KeyframeValueEntry& aRhs) { // First, sort by property name. - bool customLhs = - aLhs.mProperty.mID == nsCSSPropertyID::eCSSPropertyExtra_variable; - bool customRhs = - aRhs.mProperty.mID == nsCSSPropertyID::eCSSPropertyExtra_variable; + bool customLhs = aLhs.mProperty.mId == + NonCustomCSSPropertyId::eCSSPropertyExtra_variable; + bool customRhs = aRhs.mProperty.mId == + NonCustomCSSPropertyId::eCSSPropertyExtra_variable; if (!customLhs && !customRhs) { // Compare by IDL names. int32_t order = - nsCSSProps::PropertyIDLNameSortPosition(aLhs.mProperty.mID) - - nsCSSProps::PropertyIDLNameSortPosition(aRhs.mProperty.mID); + nsCSSProps::PropertyIDLNameSortPosition(aLhs.mProperty.mId) - + nsCSSProps::PropertyIDLNameSortPosition(aRhs.mProperty.mId); if (order != 0) { return order < 0; } @@ -353,7 +353,7 @@ bool KeyframeUtils::IsAnimatableProperty(const AnimatedPropertyID& 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.) - if (aProperty.mID == eCSSProperty_display) { + if (aProperty.mId == eCSSProperty_display) { return false; } return Servo_Property_IsAnimatable(&aProperty); @@ -499,7 +499,7 @@ static bool ConvertKeyframeSequence(JSContext* aCx, dom::Document* aDocument, // includes a chrome-only member that can be set to indicate that // ComputeValues should fail for shorthand property values on that // keyframe. - if (nsCSSProps::IsShorthand(pair.mProperty.mID) && + if (nsCSSProps::IsShorthand(pair.mProperty.mId) && keyframeDict.mSimulateComputeValuesFailure) { MarkAsComputeValuesFailureKey(keyframe->mPropertyValues.LastElement()); } @@ -555,26 +555,27 @@ static bool GetPropertyValuesPairs(JSContext* aCx, // This means if the attribute is the string "cssOffset"/"cssFloat", we use // CSS "offset"/"float" property. // https://drafts.csswg.org/web-animations/#property-name-conversion - nsCSSPropertyID propertyID = nsCSSPropertyID::eCSSProperty_UNKNOWN; + NonCustomCSSPropertyId propertyId = + NonCustomCSSPropertyId::eCSSProperty_UNKNOWN; if (nsCSSProps::IsCustomPropertyName(propName)) { - propertyID = eCSSPropertyExtra_variable; + propertyId = eCSSPropertyExtra_variable; } else if (propName.EqualsLiteral("cssOffset")) { - propertyID = nsCSSPropertyID::eCSSProperty_offset; + propertyId = NonCustomCSSPropertyId::eCSSProperty_offset; } else if (propName.EqualsLiteral("cssFloat")) { - propertyID = nsCSSPropertyID::eCSSProperty_float; + propertyId = NonCustomCSSPropertyId::eCSSProperty_float; } else if (!propName.EqualsLiteral("offset") && !propName.EqualsLiteral("float")) { - propertyID = nsCSSProps::LookupPropertyByIDLName( + propertyId = nsCSSProps::LookupPropertyByIDLName( propName, CSSEnabledState::ForAllContent); } // TODO(zrhoffman, bug 1811897) Add test coverage for removing the `--` // prefix here. AnimatedPropertyID property = - propertyID == eCSSPropertyExtra_variable + propertyId == eCSSPropertyExtra_variable ? AnimatedPropertyID( NS_Atomize(Substring(propName, 2, propName.Length() - 2))) - : AnimatedPropertyID(propertyID); + : AnimatedPropertyID(propertyId); if (KeyframeUtils::IsAnimatableProperty(property)) { properties.AppendElement(AdditionalProperty{std::move(property), i}); @@ -729,7 +730,7 @@ static bool HasValidOffsets(const nsTArray<Keyframe>& aKeyframes) { * a shorthand property. */ static void MarkAsComputeValuesFailureKey(PropertyValuePair& aPair) { - MOZ_ASSERT(nsCSSProps::IsShorthand(aPair.mProperty.mID), + MOZ_ASSERT(nsCSSProps::IsShorthand(aPair.mProperty.mId), "Only shorthand property values can be marked as failure values"); aPair.mSimulateComputeValuesFailure = true; diff --git a/dom/animation/KeyframeUtils.h b/dom/animation/KeyframeUtils.h @@ -7,10 +7,10 @@ #ifndef mozilla_KeyframeUtils_h #define mozilla_KeyframeUtils_h +#include "NonCustomCSSPropertyId.h" #include "js/RootingAPI.h" // For JS::Handle #include "mozilla/KeyframeEffectParams.h" // For CompositeOperation -#include "nsCSSPropertyID.h" -#include "nsTArrayForwardDeclare.h" // For nsTArray +#include "nsTArrayForwardDeclare.h" // For nsTArray struct JSContext; class JSObject; diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp @@ -6,6 +6,7 @@ #include "DOMIntersectionObserver.h" +#include "NonCustomCSSPropertyId.h" #include "Units.h" #include "mozilla/PresShell.h" #include "mozilla/ScrollContainerFrame.h" @@ -19,7 +20,6 @@ #include "mozilla/dom/ElementInlines.h" #include "mozilla/dom/HTMLIFrameElement.h" #include "mozilla/dom/HTMLImageElement.h" -#include "nsCSSPropertyID.h" #include "nsContainerFrame.h" #include "nsContentUtils.h" #include "nsIFrame.h" diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp @@ -29,6 +29,7 @@ #include "MobileViewportManager.h" #include "NSSErrorsService.h" #include "NodeUbiReporting.h" +#include "NonCustomCSSPropertyId.h" #include "PLDHashTable.h" #include "StorageAccessPermissionRequest.h" #include "ThirdPartyUtil.h" @@ -292,7 +293,6 @@ #include "nsBaseHashtable.h" #include "nsBidiUtils.h" #include "nsCRT.h" -#include "nsCSSPropertyID.h" #include "nsCSSProps.h" #include "nsCSSPseudoElements.h" #include "nsCSSRendering.h" @@ -17220,7 +17220,7 @@ bool Document::HasScriptsBlockedBySandbox() const { void Document::SetCssUseCounterBits() { if (StaticPrefs::layout_css_use_counters_enabled()) { for (size_t i = 0; i < eCSSProperty_COUNT_with_aliases; ++i) { - auto id = nsCSSPropertyID(i); + auto id = NonCustomCSSPropertyId(i); if (Servo_IsPropertyIdRecordedInUseCounter(mStyleUseCounters.get(), id)) { SetUseCounter(nsCSSProps::UseCounterFor(id)); } diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp @@ -3255,16 +3255,16 @@ nsDOMWindowUtils::ComputeAnimationDistance(Element* aElement, double* aResult) { NS_ENSURE_ARG_POINTER(aElement); - nsCSSPropertyID propertyID = + NonCustomCSSPropertyId propertyId = nsCSSProps::LookupProperty(NS_ConvertUTF16toUTF8(aProperty)); - if (propertyID == eCSSProperty_UNKNOWN || - nsCSSProps::IsShorthand(propertyID)) { + if (propertyId == eCSSProperty_UNKNOWN || + nsCSSProps::IsShorthand(propertyId)) { return NS_ERROR_ILLEGAL_VALUE; } - AnimatedPropertyID property = propertyID == eCSSPropertyExtra_variable + AnimatedPropertyID property = propertyId == eCSSPropertyExtra_variable ? AnimatedPropertyID(NS_Atomize(aProperty)) - : AnimatedPropertyID(propertyID); + : AnimatedPropertyID(propertyId); AnimationValue v1 = AnimationValue::FromString( property, NS_ConvertUTF16toUTF8(aValue1), aElement); @@ -3288,17 +3288,17 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(Element* aElement, return NS_ERROR_INVALID_ARG; } - nsCSSPropertyID propertyID = + NonCustomCSSPropertyId propertyId = nsCSSProps::LookupProperty(NS_ConvertUTF16toUTF8(aProperty)); - if (propertyID == eCSSProperty_UNKNOWN || - nsCSSProps::IsShorthand(propertyID)) { + if (propertyId == eCSSProperty_UNKNOWN || + nsCSSProps::IsShorthand(propertyId)) { return NS_ERROR_INVALID_ARG; } AnimatedPropertyID property = - propertyID == eCSSPropertyExtra_variable + propertyId == eCSSPropertyExtra_variable ? AnimatedPropertyID( NS_Atomize(Substring(aProperty, 2, aProperty.Length() - 2))) - : AnimatedPropertyID(propertyID); + : AnimatedPropertyID(propertyId); switch (aFlushType) { case FLUSH_NONE: diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp @@ -8,6 +8,7 @@ #include <iterator> +#include "NonCustomCSSPropertyId.h" #include "mozilla/Algorithm.h" #include "mozilla/DeclarationBlock.h" #include "mozilla/NullPrincipal.h" @@ -24,7 +25,6 @@ #include "mozilla/dom/ShadowIncludingTreeIterator.h" #include "nsAtom.h" #include "nsAttrName.h" -#include "nsCSSPropertyID.h" #include "nsComponentManagerUtils.h" #include "nsContentUtils.h" #include "nsHashtablesFwd.h" diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf @@ -2074,7 +2074,7 @@ TemplatedAttributes = { 'template': 'CSS2Property', 'getter': 'GetPropertyValue', 'setter': 'SetPropertyValue', - 'argument': ('nsCSSPropertyID', 'id'), + 'argument': ('NonCustomCSSPropertyId', 'id'), 'attrName': 'nsCSSProps::PropertyIDLName(id)', }, ], @@ -2084,7 +2084,7 @@ TemplatedAttributes = { 'template': 'CSSPageDescriptor', 'getter': 'GetPropertyValue', 'setter': 'SetPropertyValue', - 'argument': ('nsCSSPropertyID', 'id'), + 'argument': ('NonCustomCSSPropertyId', 'id'), 'attrName': 'nsCSSProps::PropertyIDLName(id)', }, ], @@ -2094,7 +2094,7 @@ TemplatedAttributes = { 'template': 'CSSPositionTryDescriptor', 'getter': 'GetPropertyValue', 'setter': 'SetPropertyValue', - 'argument': ('nsCSSPropertyID', 'id'), + 'argument': ('NonCustomCSSPropertyId', 'id'), 'attrName': 'nsCSSProps::PropertyIDLName(id)', }, ], diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp @@ -2787,7 +2787,7 @@ void CanvasRenderingContext2D::SetShadowColor(const nsACString& aShadowColor) { // static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( - nsCSSPropertyID aProperty, const nsACString& aPropertyValue, + NonCustomCSSPropertyId aProperty, const nsACString& aPropertyValue, Document* aDocument) { ServoCSSParser::ParsingEnvironment env{aDocument->DefaultStyleAttrURLData(), aDocument->GetCompatibilityMode(), @@ -2973,7 +2973,7 @@ void CanvasRenderingContext2D::SetFilter(const nsACString& aFilter, } static already_AddRefed<const ComputedStyle> ResolveStyleForServo( - nsCSSPropertyID aProperty, const nsACString& aString, + NonCustomCSSPropertyId aProperty, const nsACString& aString, const ComputedStyle* aParentStyle, PresShell* aPresShell, ErrorResult& aError) { RefPtr<StyleLockedDeclarationBlock> declarations = @@ -2992,8 +2992,8 @@ static already_AddRefed<const ComputedStyle> ResolveStyleForServo( } already_AddRefed<const ComputedStyle> -CanvasRenderingContext2D::ResolveStyleForProperty(nsCSSPropertyID aProperty, - const nsACString& aValue) { +CanvasRenderingContext2D::ResolveStyleForProperty( + NonCustomCSSPropertyId aProperty, const nsACString& aValue) { RefPtr<PresShell> presShell = GetPresShell(); if (NS_WARN_IF(!presShell)) { return nullptr; diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h @@ -622,7 +622,7 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal, nsACString& aNormalized); already_AddRefed<const ComputedStyle> ResolveStyleForProperty( - nsCSSPropertyID aProperty, const nsACString& aValue); + NonCustomCSSPropertyId aProperty, const nsACString& aValue); nsresult GetImageDataArray(JSContext* aCx, int32_t aX, int32_t aY, uint32_t aWidth, uint32_t aHeight, diff --git a/dom/html/HTMLHRElement.cpp b/dom/html/HTMLHRElement.cpp @@ -150,7 +150,7 @@ void HTMLHRElement::MapAttributesIntoRule(MappedDeclarationsBuilder& aBuilder) { // 10000px on all corners; this triggers the clamping to make // circular ends. This assumes the <hr> isn't larger than // that in *both* dimensions. - for (const nsCSSPropertyID* props = + for (const NonCustomCSSPropertyId* props = nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_radius); *props != eCSSProperty_UNKNOWN; ++props) { aBuilder.SetPixelValueIfUnset(*props, 10000.0f); diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp @@ -1401,7 +1401,7 @@ void nsGenericHTMLElement::MapVAlignAttributeInto( } void nsGenericHTMLElement::MapDimensionAttributeInto( - MappedDeclarationsBuilder& aBuilder, nsCSSPropertyID aProp, + MappedDeclarationsBuilder& aBuilder, NonCustomCSSPropertyId aProp, const nsAttrValue& aValue) { MOZ_ASSERT(!aBuilder.PropertyIsSet(aProp), "Why mapping the same property twice?"); diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h @@ -28,7 +28,7 @@ class nsILayoutHistoryState; class nsIURI; struct nsSize; -enum nsCSSPropertyID : int32_t; +enum NonCustomCSSPropertyId : int32_t; namespace mozilla { class EditorBase; @@ -568,7 +568,8 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase { * block, handling percentages and numbers. */ static void MapDimensionAttributeInto(mozilla::MappedDeclarationsBuilder&, - nsCSSPropertyID, const nsAttrValue&); + NonCustomCSSPropertyId, + const nsAttrValue&); /** * Maps the aspect ratio given width and height attributes. diff --git a/dom/smil/SMILCSSProperty.cpp b/dom/smil/SMILCSSProperty.cpp @@ -22,13 +22,13 @@ namespace mozilla { // Class Methods -SMILCSSProperty::SMILCSSProperty(nsCSSPropertyID aPropID, +SMILCSSProperty::SMILCSSProperty(NonCustomCSSPropertyId aPropId, dom::Element* aElement, const ComputedStyle* aBaseComputedStyle) - : mPropID(aPropID), + : mPropId(aPropId), mElement(aElement), mBaseComputedStyle(aBaseComputedStyle) { - MOZ_ASSERT(IsPropertyAnimatable(mPropID), + MOZ_ASSERT(IsPropertyAnimatable(mPropId), "Creating a SMILCSSProperty for a property " "that's not supported for animation"); } @@ -42,7 +42,7 @@ SMILValue SMILCSSProperty::GetBaseValue() const { // SPECIAL CASE: (a) Shorthands // (b) 'display' // (c) No base ComputedStyle - if (nsCSSProps::IsShorthand(mPropID) || mPropID == eCSSProperty_display || + if (nsCSSProps::IsShorthand(mPropId) || mPropId == eCSSProperty_display || !mBaseComputedStyle) { // We can't look up the base (computed-style) value of shorthand // properties because they aren't guaranteed to have a consistent computed @@ -63,7 +63,7 @@ SMILValue SMILCSSProperty::GetBaseValue() const { } AnimationValue computedValue; - AnimatedPropertyID property(mPropID); + AnimatedPropertyID property(mPropId); MOZ_ASSERT(!property.IsCustom(), "Cannot animate custom properties with SMIL"); computedValue.mServo = @@ -73,7 +73,7 @@ SMILValue SMILCSSProperty::GetBaseValue() const { return baseValue; } - baseValue = SMILCSSValueType::ValueFromAnimationValue(mPropID, mElement, + baseValue = SMILCSSValueType::ValueFromAnimationValue(mPropId, mElement, computedValue); return baseValue; } @@ -81,9 +81,9 @@ SMILValue SMILCSSProperty::GetBaseValue() const { nsresult SMILCSSProperty::ValueFromString( const nsAString& aStr, const dom::SVGAnimationElement* aSrcElement, SMILValue& aValue, bool& aPreventCachingOfSandwich) const { - NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE); + NS_ENSURE_TRUE(IsPropertyAnimatable(mPropId), NS_ERROR_FAILURE); - SMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue, + SMILCSSValueType::ValueFromString(mPropId, mElement, aStr, aValue, &aPreventCachingOfSandwich); if (aValue.IsNull()) { @@ -93,24 +93,24 @@ nsresult SMILCSSProperty::ValueFromString( // XXX Due to bug 536660 (or at least that seems to be the most likely // culprit), when we have animation setting display:none on a <use> element, // if we DON'T set the property every sample, chaos ensues. - if (!aPreventCachingOfSandwich && mPropID == eCSSProperty_display) { + if (!aPreventCachingOfSandwich && mPropId == eCSSProperty_display) { aPreventCachingOfSandwich = true; } return NS_OK; } nsresult SMILCSSProperty::SetAnimValue(const SMILValue& aValue) { - NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE); - return mElement->SMILOverrideStyle()->SetSMILValue(mPropID, aValue); + NS_ENSURE_TRUE(IsPropertyAnimatable(mPropId), NS_ERROR_FAILURE); + return mElement->SMILOverrideStyle()->SetSMILValue(mPropId, aValue); } void SMILCSSProperty::ClearAnimValue() { - mElement->SMILOverrideStyle()->ClearSMILValue(mPropID); + mElement->SMILOverrideStyle()->ClearSMILValue(mPropId); } // Based on http://www.w3.org/TR/SVG/propidx.html // static -bool SMILCSSProperty::IsPropertyAnimatable(nsCSSPropertyID aPropID) { +bool SMILCSSProperty::IsPropertyAnimatable(NonCustomCSSPropertyId aPropId) { // NOTE: Right now, Gecko doesn't recognize the following properties from // the SVG Property Index: // alignment-baseline @@ -121,7 +121,7 @@ bool SMILCSSProperty::IsPropertyAnimatable(nsCSSPropertyID aPropID) { // kerning // writing-mode - switch (aPropID) { + switch (aPropId) { case eCSSProperty_clip: case eCSSProperty_clip_rule: case eCSSProperty_clip_path: diff --git a/dom/smil/SMILCSSProperty.h b/dom/smil/SMILCSSProperty.h @@ -9,9 +9,9 @@ #ifndef DOM_SMIL_SMILCSSPROPERTY_H_ #define DOM_SMIL_SMILCSSPROPERTY_H_ +#include "NonCustomCSSPropertyId.h" #include "mozilla/SMILAttr.h" #include "nsAtom.h" -#include "nsCSSPropertyID.h" #include "nsCSSValue.h" namespace mozilla { @@ -29,14 +29,14 @@ class SMILCSSProperty : public SMILAttr { public: /** * Constructs a new SMILCSSProperty. - * @param aPropID The CSS property we're interested in animating. + * @param aPropId The CSS property we're interested in animating. * @param aElement The element whose CSS property is being animated. * @param aBaseComputedStyle The ComputedStyle to use when getting the base * value. If this is nullptr and GetBaseValue is * called, an empty SMILValue initialized with * the SMILCSSValueType will be returned. */ - SMILCSSProperty(nsCSSPropertyID aPropID, dom::Element* aElement, + SMILCSSProperty(NonCustomCSSPropertyId aPropId, dom::Element* aElement, const ComputedStyle* aBaseComputedStyle); // SMILAttr methods @@ -56,10 +56,10 @@ class SMILCSSProperty : public SMILAttr { * @return true if the given property is supported for SMIL animation, or * false otherwise */ - static bool IsPropertyAnimatable(nsCSSPropertyID aPropID); + static bool IsPropertyAnimatable(NonCustomCSSPropertyId aPropId); protected: - nsCSSPropertyID mPropID; + NonCustomCSSPropertyId mPropId; // Using non-refcounted pointer for mElement -- we know mElement will stay // alive for my lifetime because a SMILAttr (like me) only lives as long // as the Compositing step, and DOM elements don't get a chance to die during diff --git a/dom/smil/SMILCSSValueType.cpp b/dom/smil/SMILCSSValueType.cpp @@ -40,19 +40,19 @@ using ServoAnimationValues = CopyableAutoTArray<RefPtr<StyleAnimationValue>, 1>; SMILCSSValueType SMILCSSValueType::sSingleton; struct ValueWrapper { - ValueWrapper(nsCSSPropertyID aPropID, const AnimationValue& aValue) - : mPropID(aPropID) { + ValueWrapper(NonCustomCSSPropertyId aPropId, const AnimationValue& aValue) + : mPropId(aPropId) { MOZ_ASSERT(!aValue.IsNull()); mServoValues.AppendElement(aValue.mServo); } - ValueWrapper(nsCSSPropertyID aPropID, + ValueWrapper(NonCustomCSSPropertyId aPropId, const RefPtr<StyleAnimationValue>& aValue) - : mPropID(aPropID), mServoValues{(aValue)} {} - ValueWrapper(nsCSSPropertyID aPropID, ServoAnimationValues&& aValues) - : mPropID(aPropID), mServoValues{std::move(aValues)} {} + : mPropId(aPropId), mServoValues{(aValue)} {} + ValueWrapper(NonCustomCSSPropertyId aPropId, ServoAnimationValues&& aValues) + : mPropId(aPropId), mServoValues{std::move(aValues)} {} bool operator==(const ValueWrapper& aOther) const { - if (mPropID != aOther.mPropID) { + if (mPropId != aOther.mPropId) { return false; } @@ -74,7 +74,7 @@ struct ValueWrapper { return !(*this == aOther); } - nsCSSPropertyID mPropID; + NonCustomCSSPropertyId mPropId; ServoAnimationValues mServoValues; }; @@ -209,8 +209,8 @@ static bool AddOrAccumulate(SMILValue& aDest, const SMILValue& aValueToAdd, return false; } - nsCSSPropertyID property = - valueToAddWrapper ? valueToAddWrapper->mPropID : destWrapper->mPropID; + NonCustomCSSPropertyId property = + valueToAddWrapper ? valueToAddWrapper->mPropId : destWrapper->mPropId; // Special case: font-size-adjust and stroke-dasharray are explicitly // non-additive (even though StyleAnimationValue *could* support adding them) if (property == eCSSProperty_font_size_adjust || @@ -355,7 +355,7 @@ nsresult SMILCSSValueType::Interpolate(const SMILValue& aStartVal, // false. That's fine since most shorthands (like 'font' and // 'text-decoration') include non-discrete components. If authors want to // treat all components as discrete then they should use calcMode="discrete". - if (Servo_Property_IsDiscreteAnimatable(endWrapper->mPropID)) { + if (Servo_Property_IsDiscreteAnimatable(endWrapper->mPropId)) { return NS_ERROR_FAILURE; } @@ -382,13 +382,13 @@ nsresult SMILCSSValueType::Interpolate(const SMILValue& aStartVal, } results.AppendElement(result); } - aResult.mU.mPtr = new ValueWrapper(endWrapper->mPropID, std::move(results)); + aResult.mU.mPtr = new ValueWrapper(endWrapper->mPropId, std::move(results)); return NS_OK; } static ServoAnimationValues ValueFromStringHelper( - nsCSSPropertyID aPropID, Element* aTargetElement, + NonCustomCSSPropertyId aPropId, Element* aTargetElement, nsPresContext* aPresContext, const ComputedStyle* aComputedStyle, const nsAString& aString) { ServoAnimationValues result; @@ -403,7 +403,7 @@ static ServoAnimationValues ValueFromStringHelper( ServoCSSParser::GetParsingEnvironment(doc); RefPtr<StyleLockedDeclarationBlock> servoDeclarationBlock = ServoCSSParser::ParseProperty( - aPropID, NS_ConvertUTF16toUTF8(aString), env, + aPropId, NS_ConvertUTF16toUTF8(aString), env, StyleParsingMode::ALLOW_UNITLESS_LENGTH | StyleParsingMode::ALLOW_ALL_NUMERIC_VALUES); if (!servoDeclarationBlock) { @@ -418,7 +418,7 @@ static ServoAnimationValues ValueFromStringHelper( } // static -void SMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID, +void SMILCSSValueType::ValueFromString(NonCustomCSSPropertyId aPropId, Element* aTargetElement, const nsAString& aString, SMILValue& aValue, @@ -444,7 +444,7 @@ void SMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID, } ServoAnimationValues parsedValues = ValueFromStringHelper( - aPropID, aTargetElement, presContext, computedStyle, aString); + aPropId, aTargetElement, presContext, computedStyle, aString); if (aIsContextSensitive) { // FIXME: Bug 1358955 - detect context-sensitive values and set this value // appropriately. @@ -453,13 +453,13 @@ void SMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID, if (!parsedValues.IsEmpty()) { sSingleton.InitValue(aValue); - aValue.mU.mPtr = new ValueWrapper(aPropID, std::move(parsedValues)); + aValue.mU.mPtr = new ValueWrapper(aPropId, std::move(parsedValues)); } } // static SMILValue SMILCSSValueType::ValueFromAnimationValue( - nsCSSPropertyID aPropID, Element* aTargetElement, + NonCustomCSSPropertyId aPropId, Element* aTargetElement, const AnimationValue& aValue) { SMILValue result; @@ -475,13 +475,13 @@ SMILValue SMILCSSValueType::ValueFromAnimationValue( } sSingleton.InitValue(result); - result.mU.mPtr = new ValueWrapper(aPropID, aValue); + result.mU.mPtr = new ValueWrapper(aPropId, aValue); return result; } // static -bool SMILCSSValueType::SetPropertyValues(nsCSSPropertyID aPropertyId, +bool SMILCSSValueType::SetPropertyValues(NonCustomCSSPropertyId aPropertyId, const SMILValue& aValue, DeclarationBlock& aDecl) { MOZ_ASSERT(aValue.mType == &SMILCSSValueType::sSingleton, @@ -502,7 +502,8 @@ bool SMILCSSValueType::SetPropertyValues(nsCSSPropertyID aPropertyId, } // static -nsCSSPropertyID SMILCSSValueType::PropertyFromValue(const SMILValue& aValue) { +NonCustomCSSPropertyId SMILCSSValueType::PropertyFromValue( + const SMILValue& aValue) { if (aValue.mType != &SMILCSSValueType::sSingleton) { return eCSSProperty_UNKNOWN; } @@ -512,7 +513,7 @@ nsCSSPropertyID SMILCSSValueType::PropertyFromValue(const SMILValue& aValue) { return eCSSProperty_UNKNOWN; } - return wrapper->mPropID; + return wrapper->mPropId; } // static @@ -546,7 +547,7 @@ void SMILCSSValueType::FinalizeValue(SMILValue& aValue, zeroValues.AppendElement(std::move(zeroValue)); } aValue.mU.mPtr = - new ValueWrapper(valueToMatchWrapper->mPropID, std::move(zeroValues)); + new ValueWrapper(valueToMatchWrapper->mPropId, std::move(zeroValues)); } } // namespace mozilla diff --git a/dom/smil/SMILCSSValueType.h b/dom/smil/SMILCSSValueType.h @@ -9,8 +9,8 @@ #ifndef DOM_SMIL_SMILCSSVALUETYPE_H_ #define DOM_SMIL_SMILCSSVALUETYPE_H_ +#include "NonCustomCSSPropertyId.h" #include "mozilla/SMILType.h" -#include "nsCSSPropertyID.h" #include "nsStringFwd.h" namespace mozilla { @@ -55,7 +55,7 @@ class SMILCSSValueType : public SMILType { * On failure, this method leaves aValue.mType == SMILNullType::sSingleton. * Otherwise, this method leaves aValue.mType == this class's singleton. * - * @param aPropID The property for which we're parsing a value. + * @param aPropId The property for which we're parsing a value. * @param aTargetElement The target element to whom the property/value * setting applies. * @param aString The string to be parsed as a CSS value. @@ -70,7 +70,7 @@ class SMILCSSValueType : public SMILType { * @pre aValue.IsNull() * @post aValue.IsNull() || aValue.mType == SMILCSSValueType::sSingleton */ - static void ValueFromString(nsCSSPropertyID aPropID, + static void ValueFromString(NonCustomCSSPropertyId aPropId, dom::Element* aTargetElement, const nsAString& aString, SMILValue& aValue, bool* aIsContextSensitive); @@ -78,7 +78,7 @@ class SMILCSSValueType : public SMILType { /** * Creates a SMILValue to wrap the given animation value. * - * @param aPropID The property that |aValue| corresponds to. + * @param aPropId The property that |aValue| corresponds to. * @param aTargetElement The target element to which the animation value * applies. * @param aValue The animation value to use. @@ -86,7 +86,7 @@ class SMILCSSValueType : public SMILType { * SMILValue with the null type (i.e. rv.IsNull() * returns true). */ - static SMILValue ValueFromAnimationValue(nsCSSPropertyID aPropID, + static SMILValue ValueFromAnimationValue(NonCustomCSSPropertyId aPropId, dom::Element* aTargetElement, const AnimationValue& aValue); @@ -95,18 +95,18 @@ class SMILCSSValueType : public SMILType { * * Returns whether the declaration changed. */ - static bool SetPropertyValues(nsCSSPropertyID, const SMILValue&, + static bool SetPropertyValues(NonCustomCSSPropertyId, const SMILValue&, mozilla::DeclarationBlock&); /** * Return the CSS property animated by the specified value. * * @param aValue The SMILValue to examine. - * @return The nsCSSPropertyID enum value of the property animated - * by |aValue|, or eCSSProperty_UNKNOWN if the type of - * |aValue| is not SMILCSSValueType. + * @return The NonCustomCSSPropertyId enum value of the property + * animated by |aValue|, or eCSSProperty_UNKNOWN if the + * type of |aValue| is not SMILCSSValueType. */ - static nsCSSPropertyID PropertyFromValue(const SMILValue& aValue); + static NonCustomCSSPropertyId PropertyFromValue(const SMILValue& aValue); /** * If |aValue| is an empty value, converts it to a suitable zero value by diff --git a/dom/smil/SMILCompositor.cpp b/dom/smil/SMILCompositor.cpp @@ -134,10 +134,10 @@ void SMILCompositor::ClearAnimationEffects() { // -------------------------- UniquePtr<SMILAttr> SMILCompositor::CreateSMILAttr( const ComputedStyle* aBaseComputedStyle) { - nsCSSPropertyID propID = GetCSSPropertyToAnimate(); + NonCustomCSSPropertyId propId = GetCSSPropertyToAnimate(); - if (propID != eCSSProperty_UNKNOWN) { - return MakeUnique<SMILCSSProperty>(propID, mKey.mElement.get(), + if (propId != eCSSProperty_UNKNOWN) { + return MakeUnique<SMILCSSProperty>(propId, mKey.mElement.get(), aBaseComputedStyle); } @@ -145,15 +145,15 @@ UniquePtr<SMILAttr> SMILCompositor::CreateSMILAttr( mKey.mAttributeName); } -nsCSSPropertyID SMILCompositor::GetCSSPropertyToAnimate() const { +NonCustomCSSPropertyId SMILCompositor::GetCSSPropertyToAnimate() const { if (mKey.mAttributeNamespaceID != kNameSpaceID_None) { return eCSSProperty_UNKNOWN; } - nsCSSPropertyID propID = + NonCustomCSSPropertyId propId = nsCSSProps::LookupProperty(nsAtomCString(mKey.mAttributeName)); - if (!SMILCSSProperty::IsPropertyAnimatable(propID)) { + if (!SMILCSSProperty::IsPropertyAnimatable(propId)) { return eCSSProperty_UNKNOWN; } @@ -176,7 +176,7 @@ nsCSSPropertyID SMILCompositor::GetCSSPropertyToAnimate() const { // Indeed an outer <svg> element, fall through. } - return propID; + return propId; } bool SMILCompositor::MightNeedBaseStyle() const { diff --git a/dom/smil/SMILCompositor.h b/dom/smil/SMILCompositor.h @@ -9,12 +9,12 @@ #include <utility> +#include "NonCustomCSSPropertyId.h" #include "PLDHashTable.h" #include "SMILTargetIdentifier.h" #include "mozilla/SMILAnimationFunction.h" #include "mozilla/SMILCompositorTable.h" #include "mozilla/UniquePtr.h" -#include "nsCSSPropertyID.h" #include "nsString.h" #include "nsTHashtable.h" @@ -87,7 +87,7 @@ class SMILCompositor : public PLDHashEntryHdr { // Returns the CSS property this compositor should animate, or // eCSSProperty_UNKNOWN if this compositor does not animate a CSS property. - nsCSSPropertyID GetCSSPropertyToAnimate() const; + NonCustomCSSPropertyId GetCSSPropertyToAnimate() const; // Returns true if we might need to refer to base styles (i.e. we are // targeting a CSS property and have one or more animation functions that diff --git a/dom/svg/SVGCircleElement.cpp b/dom/svg/SVGCircleElement.cpp @@ -157,7 +157,7 @@ bool SVGCircleElement::IsLengthChangedViaCSS(const ComputedStyle& aNewStyle, newSVGReset.mCy != oldSVGReset.mCy || newSVGReset.mR != oldSVGReset.mR; } -nsCSSPropertyID SVGCircleElement::GetCSSPropertyIdForAttrEnum( +NonCustomCSSPropertyId SVGCircleElement::GetCSSPropertyIdForAttrEnum( uint8_t aAttrEnum) { switch (aAttrEnum) { case ATTR_CX: diff --git a/dom/svg/SVGCircleElement.h b/dom/svg/SVGCircleElement.h @@ -7,9 +7,9 @@ #ifndef DOM_SVG_SVGCIRCLEELEMENT_H_ #define DOM_SVG_SVGCIRCLEELEMENT_H_ +#include "NonCustomCSSPropertyId.h" #include "SVGAnimatedLength.h" #include "SVGGeometryElement.h" -#include "nsCSSPropertyID.h" nsresult NS_NewSVGCircleElement( nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); @@ -48,7 +48,7 @@ class SVGCircleElement final : public SVGCircleElementBase { static bool IsLengthChangedViaCSS(const ComputedStyle& aNewStyle, const ComputedStyle& aOldStyle); - static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); + static NonCustomCSSPropertyId GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); // WebIDL already_AddRefed<DOMSVGAnimatedLength> Cx(); diff --git a/dom/svg/SVGElement.cpp b/dom/svg/SVGElement.cpp @@ -208,7 +208,7 @@ nsresult SVGElement::CopyInnerTo(mozilla::dom::Element* aDest) { dest->GetLengthInfo().CopyAllFrom(lengthInfo); if (SVGGeometryProperty::ElementMapsLengthsToStyle(this)) { for (uint32_t i = 0; i < lengthInfo.mCount; i++) { - nsCSSPropertyID propId = + NonCustomCSSPropertyId propId = SVGGeometryProperty::AttrEnumToCSSPropId(this, i); // We don't map use element width/height currently. We can remove this @@ -1052,7 +1052,7 @@ already_AddRefed<DOMSVGAnimatedString> SVGElement::ClassName() { /* static */ bool SVGElement::UpdateDeclarationBlockFromLength( - const StyleLockedDeclarationBlock& aBlock, nsCSSPropertyID aPropId, + const StyleLockedDeclarationBlock& aBlock, NonCustomCSSPropertyId aPropId, const SVGAnimatedLength& aLength, ValToUse aValToUse) { float value; uint8_t units; @@ -1248,16 +1248,16 @@ class MOZ_STACK_CLASS MappedAttrParser { void MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName, const nsAString& aMappedAttrValue) { - // Get the nsCSSPropertyID ID for our mapped attribute. - nsCSSPropertyID propertyID = + // Get the NonCustomCSSPropertyId id for our mapped attribute. + NonCustomCSSPropertyId propertyId = nsCSSProps::LookupProperty(nsAutoAtomCString(aMappedAttrName)); - if (propertyID != eCSSProperty_UNKNOWN) { + if (propertyId != eCSSProperty_UNKNOWN) { bool changed = false; // outparam for ParseProperty. NS_ConvertUTF16toUTF8 value(aMappedAttrValue); auto* doc = mElement.OwnerDoc(); changed = Servo_DeclarationBlock_SetPropertyById( - &EnsureDeclarationBlock(), propertyID, &value, false, + &EnsureDeclarationBlock(), propertyId, &value, false, &EnsureExtraData(), StyleParsingMode::ALLOW_UNITLESS_LENGTH, doc->GetCompatibilityMode(), &doc->EnsureCSSLoader(), StyleCssRuleType::Style, {}); @@ -1266,7 +1266,7 @@ void MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName, // can pass the document use counters down the FFI call. For now manually // count them. if (changed && StaticPrefs::layout_css_use_counters_enabled()) { - UseCounter useCounter = nsCSSProps::UseCounterFor(propertyID); + UseCounter useCounter = nsCSSProps::UseCounterFor(propertyId); MOZ_ASSERT(useCounter != eUseCounter_UNKNOWN); doc->SetUseCounter(useCounter); } @@ -1276,16 +1276,16 @@ void MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName, "Only 'lang' should be unrecognized!"); // CSS parser doesn't know about 'lang', so we need to handle it specially. if (aMappedAttrName == nsGkAtoms::lang) { - propertyID = eCSSProperty__x_lang; + propertyId = eCSSProperty__x_lang; RefPtr<nsAtom> atom = NS_Atomize(aMappedAttrValue); Servo_DeclarationBlock_SetIdentStringValue(&EnsureDeclarationBlock(), - propertyID, atom); + propertyId, atom); } } void MappedAttrParser::TellStyleAlreadyParsedResult( nsAtom const* aAtom, SVGAnimatedLength const& aLength) { - nsCSSPropertyID propertyID = + NonCustomCSSPropertyId propertyID = nsCSSProps::LookupProperty(nsAutoAtomCString(aAtom)); SVGElement::UpdateDeclarationBlockFromLength(EnsureDeclarationBlock(), propertyID, aLength, @@ -1532,7 +1532,7 @@ void SVGElement::DidAnimateLength(uint8_t aAttrEnum) { ClearAnyCachedPath(); if (SVGGeometryProperty::ElementMapsLengthsToStyle(this)) { - nsCSSPropertyID propId = + NonCustomCSSPropertyId propId = SVGGeometryProperty::AttrEnumToCSSPropId(this, aAttrEnum); // We don't map use element width/height currently. We can remove this diff --git a/dom/svg/SVGElement.h b/dom/svg/SVGElement.h @@ -12,6 +12,7 @@ It implements all the common DOM interfaces and handles attributes. */ +#include "NonCustomCSSPropertyId.h" #include "gfxMatrix.h" #include "mozilla/Attributes.h" #include "mozilla/RefPtr.h" @@ -21,7 +22,6 @@ #include "mozilla/dom/DOMRect.h" #include "mozilla/dom/Element.h" #include "mozilla/gfx/MatrixFwd.h" -#include "nsCSSPropertyID.h" #include "nsChangeHint.h" #include "nsCycleCollectionParticipant.h" #include "nsError.h" @@ -166,7 +166,7 @@ class SVGElement : public SVGElementBase // nsIContent enum class ValToUse { Base, Anim }; static bool UpdateDeclarationBlockFromLength( - const StyleLockedDeclarationBlock&, nsCSSPropertyID, + const StyleLockedDeclarationBlock&, NonCustomCSSPropertyId, const SVGAnimatedLength&, ValToUse); static bool UpdateDeclarationBlockFromPath(const StyleLockedDeclarationBlock&, const SVGAnimatedPathSegList&, diff --git a/dom/svg/SVGEllipseElement.cpp b/dom/svg/SVGEllipseElement.cpp @@ -173,7 +173,7 @@ bool SVGEllipseElement::IsLengthChangedViaCSS(const ComputedStyle& aNewStyle, newSVGReset.mRy != oldSVGReset.mRy; } -nsCSSPropertyID SVGEllipseElement::GetCSSPropertyIdForAttrEnum( +NonCustomCSSPropertyId SVGEllipseElement::GetCSSPropertyIdForAttrEnum( uint8_t aAttrEnum) { switch (aAttrEnum) { case CX: diff --git a/dom/svg/SVGEllipseElement.h b/dom/svg/SVGEllipseElement.h @@ -7,9 +7,9 @@ #ifndef DOM_SVG_SVGELLIPSEELEMENT_H_ #define DOM_SVG_SVGELLIPSEELEMENT_H_ +#include "NonCustomCSSPropertyId.h" #include "SVGAnimatedLength.h" #include "SVGGeometryElement.h" -#include "nsCSSPropertyID.h" nsresult NS_NewSVGEllipseElement( nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); @@ -48,7 +48,7 @@ class SVGEllipseElement final : public SVGEllipseElementBase { static bool IsLengthChangedViaCSS(const ComputedStyle& aNewStyle, const ComputedStyle& aOldStyle); - static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); + static NonCustomCSSPropertyId GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); // WebIDL already_AddRefed<DOMSVGAnimatedLength> Cx(); diff --git a/dom/svg/SVGForeignObjectElement.cpp b/dom/svg/SVGForeignObjectElement.cpp @@ -107,7 +107,7 @@ SVGElement::LengthAttributesInfo SVGForeignObjectElement::GetLengthInfo() { std::size(sLengthInfo)); } -nsCSSPropertyID SVGForeignObjectElement::GetCSSPropertyIdForAttrEnum( +NonCustomCSSPropertyId SVGForeignObjectElement::GetCSSPropertyIdForAttrEnum( uint8_t aAttrEnum) { switch (aAttrEnum) { case ATTR_X: diff --git a/dom/svg/SVGForeignObjectElement.h b/dom/svg/SVGForeignObjectElement.h @@ -7,9 +7,9 @@ #ifndef DOM_SVG_SVGFOREIGNOBJECTELEMENT_H_ #define DOM_SVG_SVGFOREIGNOBJECTELEMENT_H_ +#include "NonCustomCSSPropertyId.h" #include "SVGAnimatedLength.h" #include "mozilla/dom/SVGGraphicsElement.h" -#include "nsCSSPropertyID.h" nsresult NS_NewSVGForeignObjectElement( nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); @@ -40,7 +40,7 @@ class SVGForeignObjectElement final : public SVGGraphicsElement { nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; - static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); + static NonCustomCSSPropertyId GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); // WebIDL already_AddRefed<DOMSVGAnimatedLength> X(); diff --git a/dom/svg/SVGGeometryProperty.cpp b/dom/svg/SVGGeometryProperty.cpp @@ -15,8 +15,8 @@ namespace mozilla::dom::SVGGeometryProperty { -nsCSSPropertyID AttrEnumToCSSPropId(const SVGElement* aElement, - uint8_t aAttrEnum) { +NonCustomCSSPropertyId AttrEnumToCSSPropId(const SVGElement* aElement, + uint8_t aAttrEnum) { // This is a very trivial function only applied to a few elements, // so we want to avoid making it virtual. if (aElement->IsSVGElement(nsGkAtoms::rect)) { @@ -40,7 +40,7 @@ nsCSSPropertyID AttrEnumToCSSPropId(const SVGElement* aElement, return eCSSProperty_UNKNOWN; } -bool IsNonNegativeGeometryProperty(nsCSSPropertyID aProp) { +bool IsNonNegativeGeometryProperty(NonCustomCSSPropertyId aProp) { return aProp == eCSSProperty_r || aProp == eCSSProperty_rx || aProp == eCSSProperty_ry || aProp == eCSSProperty_width || aProp == eCSSProperty_height; diff --git a/dom/svg/SVGGeometryProperty.h b/dom/svg/SVGGeometryProperty.h @@ -278,10 +278,10 @@ bool ResolveAll(const SVGElement* aElement, #undef SVGGEOMETRYPROPERTY_EVAL_ALL nsCSSUnit SpecifiedUnitTypeToCSSUnit(uint8_t aSpecifiedUnit); -nsCSSPropertyID AttrEnumToCSSPropId(const SVGElement* aElement, - uint8_t aAttrEnum); +NonCustomCSSPropertyId AttrEnumToCSSPropId(const SVGElement* aElement, + uint8_t aAttrEnum); -bool IsNonNegativeGeometryProperty(nsCSSPropertyID aProp); +bool IsNonNegativeGeometryProperty(NonCustomCSSPropertyId aProp); bool ElementMapsLengthsToStyle(SVGElement const* aElement); } // namespace mozilla::dom::SVGGeometryProperty diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp @@ -65,7 +65,7 @@ SVGImageElement::SVGImageElement( SVGImageElement::~SVGImageElement() { nsImageLoadingContent::Destroy(); } -nsCSSPropertyID SVGImageElement::GetCSSPropertyIdForAttrEnum( +NonCustomCSSPropertyId SVGImageElement::GetCSSPropertyIdForAttrEnum( uint8_t aAttrEnum) { switch (aAttrEnum) { case ATTR_X: diff --git a/dom/svg/SVGImageElement.h b/dom/svg/SVGImageElement.h @@ -102,7 +102,7 @@ class SVGImageElement final : public SVGImageElementBase, already_AddRefed<Promise> Decode(ErrorResult& aRv); - static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); + static NonCustomCSSPropertyId GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); gfx::Rect GeometryBounds(const gfx::Matrix& aToBoundsSpace); diff --git a/dom/svg/SVGRectElement.cpp b/dom/svg/SVGRectElement.cpp @@ -254,7 +254,8 @@ bool SVGRectElement::IsLengthChangedViaCSS(const ComputedStyle& aNewStyle, newSVGReset.mRy != oldSVGReset.mRy; } -nsCSSPropertyID SVGRectElement::GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum) { +NonCustomCSSPropertyId SVGRectElement::GetCSSPropertyIdForAttrEnum( + uint8_t aAttrEnum) { switch (aAttrEnum) { case ATTR_X: return eCSSProperty_x; diff --git a/dom/svg/SVGRectElement.h b/dom/svg/SVGRectElement.h @@ -7,9 +7,9 @@ #ifndef DOM_SVG_SVGRECTELEMENT_H_ #define DOM_SVG_SVGRECTELEMENT_H_ +#include "NonCustomCSSPropertyId.h" #include "SVGAnimatedLength.h" #include "SVGGeometryElement.h" -#include "nsCSSPropertyID.h" nsresult NS_NewSVGRectElement( nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); @@ -48,7 +48,7 @@ class SVGRectElement final : public SVGRectElementBase { static bool IsLengthChangedViaCSS(const ComputedStyle& aNewStyle, const ComputedStyle& aOldStyle); - static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); + static NonCustomCSSPropertyId GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); // WebIDL already_AddRefed<DOMSVGAnimatedLength> X(); diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp @@ -656,7 +656,8 @@ SVGUseElement::IsAttributeMapped(const nsAtom* name) const { SVGUseElementBase::IsAttributeMapped(name); } -nsCSSPropertyID SVGUseElement::GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum) { +NonCustomCSSPropertyId SVGUseElement::GetCSSPropertyIdForAttrEnum( + uint8_t aAttrEnum) { switch (aAttrEnum) { case ATTR_X: return eCSSProperty_x; diff --git a/dom/svg/SVGUseElement.h b/dom/svg/SVGUseElement.h @@ -71,7 +71,7 @@ class SVGUseElement final : public SVGUseElementBase, nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; - static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); + static NonCustomCSSPropertyId GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum); // WebIDL already_AddRefed<DOMSVGAnimatedString> Href(); diff --git a/dom/view-transitions/ViewTransition.cpp b/dom/view-transitions/ViewTransition.cpp @@ -587,7 +587,7 @@ static already_AddRefed<Element> MakePseudo(Document& aDoc, } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document* aDoc, - nsCSSPropertyID aProp, const nsACString& aValue) { + NonCustomCSSPropertyId aProp, const nsACString& aValue) { return Servo_DeclarationBlock_SetPropertyById( aDecls, aProp, &aValue, /* is_important = */ false, aDoc->DefaultStyleAttrURLData(), @@ -596,12 +596,14 @@ static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document* aDoc, } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document*, - nsCSSPropertyID aProp, float aLength, nsCSSUnit aUnit) { + NonCustomCSSPropertyId aProp, float aLength, + nsCSSUnit aUnit) { return Servo_DeclarationBlock_SetLengthValue(aDecls, aProp, aLength, aUnit); } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document*, - nsCSSPropertyID aProp, const CSSToCSSMatrix4x4Flagged& aM) { + NonCustomCSSPropertyId aProp, + const CSSToCSSMatrix4x4Flagged& aM) { MOZ_ASSERT(aProp == eCSSProperty_transform); AutoTArray<StyleTransformOperation, 1> ops; ops.AppendElement( @@ -612,37 +614,40 @@ static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document*, } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document* aDoc, - nsCSSPropertyID aProp, const StyleWritingModeProperty aWM) { + NonCustomCSSPropertyId aProp, + const StyleWritingModeProperty aWM) { return Servo_DeclarationBlock_SetKeywordValue(aDecls, aProp, (int32_t)aWM); } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document* aDoc, - nsCSSPropertyID aProp, const StyleDirection aDirection) { + NonCustomCSSPropertyId aProp, + const StyleDirection aDirection) { return Servo_DeclarationBlock_SetKeywordValue(aDecls, aProp, (int32_t)aDirection); } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document* aDoc, - nsCSSPropertyID aProp, + NonCustomCSSPropertyId aProp, const StyleTextOrientation aTextOrientation) { return Servo_DeclarationBlock_SetKeywordValue(aDecls, aProp, (int32_t)aTextOrientation); } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document* aDoc, - nsCSSPropertyID aProp, const StyleBlend aBlend) { + NonCustomCSSPropertyId aProp, const StyleBlend aBlend) { return Servo_DeclarationBlock_SetKeywordValue(aDecls, aProp, (int32_t)aBlend); } static bool SetProp( - StyleLockedDeclarationBlock* aDecls, Document*, nsCSSPropertyID aProp, + StyleLockedDeclarationBlock* aDecls, Document*, + NonCustomCSSPropertyId aProp, const StyleOwnedSlice<mozilla::StyleFilter>& aBackdropFilters) { return Servo_DeclarationBlock_SetBackdropFilter(aDecls, aProp, &aBackdropFilters); } static bool SetProp(StyleLockedDeclarationBlock* aDecls, Document*, - nsCSSPropertyID aProp, + NonCustomCSSPropertyId aProp, const StyleColorScheme& aColorScheme) { return Servo_DeclarationBlock_SetColorScheme(aDecls, aProp, &aColorScheme); } diff --git a/editor/libeditor/CSSEditUtils.cpp b/editor/libeditor/CSSEditUtils.cpp @@ -557,12 +557,12 @@ nsresult CSSEditUtils::GetSpecifiedCSSInlinePropertyBase(nsIContent& aContent, } // FIXME: Same comments as above. - nsCSSPropertyID prop = + NonCustomCSSPropertyId prop = nsCSSProps::LookupProperty(nsAtomCString(&aCSSProperty)); MOZ_ASSERT(prop != eCSSProperty_UNKNOWN); nsAutoCString value; - decl->GetPropertyValueByID(prop, value); + decl->GetPropertyValueById(prop, value); CopyUTF8toUTF16(value, aValue); return NS_OK; } diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp @@ -24,7 +24,7 @@ #include "mozilla/Maybe.h" // for Maybe<> #include "mozilla/MotionPathUtils.h" // for ResolveMotionPath() #include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc -#include "nsCSSPropertyID.h" // for eCSSProperty_offset_path, etc +#include "NonCustomCSSPropertyId.h" // for eCSSProperty_offset_path, etc #include "nsDisplayList.h" // for nsDisplayTransform, etc namespace mozilla::layers { @@ -452,7 +452,7 @@ AnimationStorageData AnimationHelper::ExtractAnimations( AnimationStorageData storageData; storageData.mLayersId = aLayersId; - nsCSSPropertyID prevID = eCSSProperty_UNKNOWN; + NonCustomCSSPropertyId prevId = eCSSProperty_UNKNOWN; PropertyAnimationGroup* currData = nullptr; DebugOnly<const layers::Animatable*> currBaseStyle = nullptr; @@ -460,7 +460,7 @@ AnimationStorageData AnimationHelper::ExtractAnimations( // Animations with same property are grouped together, so we can just // check if the current property is the same as the previous one for // knowing this is a new group. - if (prevID != animation.property()) { + if (prevId != animation.property()) { // Got a different group, we should create a different array. currData = storageData.mAnimation.AppendElement(); currData->mProperty = animation.property(); @@ -470,7 +470,7 @@ AnimationStorageData AnimationHelper::ExtractAnimations( storageData.mTransformData = animation.transformData(); } - prevID = animation.property(); + prevId = animation.property(); // Reset the debug pointer. currBaseStyle = nullptr; @@ -585,7 +585,7 @@ AnimationStorageData AnimationHelper::ExtractAnimations( if (!storageData.mAnimation.IsEmpty()) { nsCSSPropertyIDSet seenProperties; for (const auto& group : storageData.mAnimation) { - nsCSSPropertyID id = group.mProperty; + NonCustomCSSPropertyId id = group.mProperty; MOZ_ASSERT(!seenProperties.HasProperty(id), "Should be a new property"); seenProperties.AddProperty(id); @@ -653,7 +653,7 @@ gfx::Matrix4x4 AnimationHelper::ServoAnimationValueToMatrix4x4( MOZ_ASSERT(value); AnimatedPropertyID property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(value, &property); - switch (property.mID) { + switch (property.mId) { case eCSSProperty_transform: MOZ_ASSERT(!transform); transform = Servo_AnimationValue_GetTransform(value); diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp @@ -327,7 +327,7 @@ static Maybe<ScrollTimelineOptions> GetScrollTimelineOptions( return Some(ScrollTimelineOptions(source, timeline->Axis())); } -static void SetAnimatable(nsCSSPropertyID aProperty, +static void SetAnimatable(NonCustomCSSPropertyId aProperty, const AnimationValue& aAnimationValue, nsIFrame* aFrame, TransformReferenceBox& aRefBox, layers::Animatable& aAnimatable) { @@ -456,7 +456,7 @@ void AnimationInfo::AddAnimationForProperty( animation->fillMode() = static_cast<uint8_t>(computedTiming.mFill); MOZ_ASSERT(!aProperty.mProperty.IsCustom(), "We don't animate custom properties in the compositor"); - animation->property() = aProperty.mProperty.mID; + animation->property() = aProperty.mProperty.mId; animation->playbackRate() = static_cast<float>(aAnimation->CurrentOrPendingPlaybackRate()); animation->previousPlaybackRate() = @@ -487,7 +487,7 @@ void AnimationInfo::AddAnimationForProperty( aAnimation->GetEffect()->AsKeyframeEffect()->BaseStyle( aProperty.mProperty); if (!baseStyle.IsNull()) { - SetAnimatable(aProperty.mProperty.mID, baseStyle, aFrame, refBox, + SetAnimatable(aProperty.mProperty.mId, baseStyle, aFrame, refBox, animation->baseStyle()); } else { animation->baseStyle() = null_t(); @@ -495,9 +495,9 @@ void AnimationInfo::AddAnimationForProperty( for (const AnimationPropertySegment& segment : aProperty.mSegments) { AnimationSegment* animSegment = animation->segments().AppendElement(); - SetAnimatable(aProperty.mProperty.mID, segment.mFromValue, aFrame, refBox, + SetAnimatable(aProperty.mProperty.mId, segment.mFromValue, aFrame, refBox, animSegment->startState()); - SetAnimatable(aProperty.mProperty.mID, segment.mToValue, aFrame, refBox, + SetAnimatable(aProperty.mProperty.mId, segment.mToValue, aFrame, refBox, animSegment->endState()); animSegment->startPortion() = segment.mFromKey; @@ -552,10 +552,11 @@ void AnimationInfo::AddAnimationForProperty( // ] // // And then, for each transaction, we send this list to the compositor thread. -static HashMap<nsCSSPropertyID, nsTArray<RefPtr<dom::Animation>>> +static HashMap<NonCustomCSSPropertyId, nsTArray<RefPtr<dom::Animation>>> GroupAnimationsByProperty(const nsTArray<RefPtr<dom::Animation>>& aAnimations, const nsCSSPropertyIDSet& aPropertySet) { - HashMap<nsCSSPropertyID, nsTArray<RefPtr<dom::Animation>>> groupedAnims; + HashMap<NonCustomCSSPropertyId, nsTArray<RefPtr<dom::Animation>>> + groupedAnims; for (const RefPtr<dom::Animation>& anim : aAnimations) { const dom::KeyframeEffect* effect = anim->GetEffect()->AsKeyframeEffect(); MOZ_ASSERT(effect); @@ -566,10 +567,10 @@ GroupAnimationsByProperty(const nsTArray<RefPtr<dom::Animation>>& aAnimations, } auto animsForPropertyPtr = - groupedAnims.lookupForAdd(property.mProperty.mID); + groupedAnims.lookupForAdd(property.mProperty.mId); if (!animsForPropertyPtr) { DebugOnly<bool> rv = - groupedAnims.add(animsForPropertyPtr, property.mProperty.mID, + groupedAnims.add(animsForPropertyPtr, property.mProperty.mId, nsTArray<RefPtr<dom::Animation>>()); MOZ_ASSERT(rv, "Should have enough memory"); } @@ -582,8 +583,9 @@ GroupAnimationsByProperty(const nsTArray<RefPtr<dom::Animation>>& aAnimations, bool AnimationInfo::AddAnimationsForProperty( nsIFrame* aFrame, const EffectSet* aEffects, const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations, - const Maybe<TransformData>& aTransformData, nsCSSPropertyID aProperty, - Send aSendFlag, WebRenderLayerManager* aLayerManager) { + const Maybe<TransformData>& aTransformData, + NonCustomCSSPropertyId aProperty, Send aSendFlag, + WebRenderLayerManager* aLayerManager) { bool addedAny = false; // Add from first to last (since last overrides) for (dom::Animation* anim : aCompositorAnimations) { @@ -842,7 +844,7 @@ static Maybe<TransformData> CreateAnimationData( void AnimationInfo::AddNonAnimatingTransformLikePropertiesStyles( const nsCSSPropertyIDSet& aNonAnimatingProperties, nsIFrame* aFrame, Send aSendFlag) { - auto appendFakeAnimation = [this, aSendFlag](nsCSSPropertyID aProperty, + auto appendFakeAnimation = [this, aSendFlag](NonCustomCSSPropertyId aProperty, Animatable&& aBaseStyle) { layers::Animation* animation = (aSendFlag == Send::NextTransaction) ? AddAnimationForNextTransaction() @@ -860,7 +862,7 @@ void AnimationInfo::AddNonAnimatingTransformLikePropertiesStyles( !display->mOffsetPath.IsNone() || !aNonAnimatingProperties.HasProperty(eCSSProperty_offset_path); - for (nsCSSPropertyID id : aNonAnimatingProperties) { + for (NonCustomCSSPropertyId id : aNonAnimatingProperties) { switch (id) { case eCSSProperty_transform: if (!display->mTransform.IsNone()) { @@ -962,7 +964,7 @@ void AnimationInfo::AddAnimationsForDisplayItem( return; } - const HashMap<nsCSSPropertyID, nsTArray<RefPtr<dom::Animation>>> + const HashMap<NonCustomCSSPropertyId, nsTArray<RefPtr<dom::Animation>>> compositorAnimations = GroupAnimationsByProperty(matchedAnimations, propertySet); Maybe<TransformData> transformData = diff --git a/gfx/layers/AnimationInfo.h b/gfx/layers/AnimationInfo.h @@ -129,8 +129,9 @@ class AnimationInfo final { bool AddAnimationsForProperty( nsIFrame* aFrame, const EffectSet* aEffects, const nsTArray<RefPtr<dom::Animation>>& aCompositorAnimations, - const Maybe<TransformData>& aTransformData, nsCSSPropertyID aProperty, - Send aSendFlag, WebRenderLayerManager* aLayerManager); + const Maybe<TransformData>& aTransformData, + NonCustomCSSPropertyId aProperty, Send aSendFlag, + WebRenderLayerManager* aLayerManager); void AddNonAnimatingTransformLikePropertiesStyles( const nsCSSPropertyIDSet& aNonAnimatingProperties, nsIFrame* aFrame, diff --git a/gfx/layers/AnimationStorageData.h b/gfx/layers/AnimationStorageData.h @@ -66,7 +66,7 @@ struct PropertyAnimation { }; struct PropertyAnimationGroup { - nsCSSPropertyID mProperty; + NonCustomCSSPropertyId mProperty; nsTArray<PropertyAnimation> mAnimations; RefPtr<StyleAnimationValue> mBaseStyle; diff --git a/gfx/layers/CompositorAnimationStorage.cpp b/gfx/layers/CompositorAnimationStorage.cpp @@ -30,7 +30,8 @@ struct CompositorAnimationMarker { return MakeStringSpan("CompositorAnimation"); } static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, - uint64_t aId, nsCSSPropertyID aProperty) { + uint64_t aId, + NonCustomCSSPropertyId aProperty) { aWriter.IntProperty("pid", int64_t(aId >> 32)); aWriter.IntProperty("id", int64_t(aId & 0xffffffff)); aWriter.StringProperty("property", nsCSSProps::GetStringValue(aProperty)); @@ -55,7 +56,7 @@ namespace layers { using gfx::Matrix4x4; already_AddRefed<StyleAnimationValue> AnimatedValue::AsAnimationValue( - nsCSSPropertyID aProperty) const { + NonCustomCSSPropertyId aProperty) const { RefPtr<StyleAnimationValue> result; mValue.match( [&](const AnimationTransform& aTransform) { @@ -64,7 +65,7 @@ already_AddRefed<StyleAnimationValue> AnimatedValue::AsAnimationValue( for (const auto& value : Transform().mAnimationValues) { AnimatedPropertyID property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(value, &property); - if (property.mID == aProperty) { + if (property.mId == aProperty) { result = value; break; } @@ -231,7 +232,7 @@ static ParentLayerRect GetClipRectForPartialPrerender( } void CompositorAnimationStorage::StoreAnimatedValue( - nsCSSPropertyID aProperty, uint64_t aId, + NonCustomCSSPropertyId aProperty, uint64_t aId, const std::unique_ptr<AnimationStorageData>& aAnimationStorageData, SampledAnimationArray&& aAnimationValues, const MutexAutoLock& aProofOfMapLock, const RefPtr<APZSampler>& aApzSampler, @@ -336,7 +337,7 @@ bool CompositorAnimationStorage::SampleAnimations( continue; } - const nsCSSPropertyID lastPropertyAnimationGroupProperty = + const NonCustomCSSPropertyId lastPropertyAnimationGroupProperty = animationStorageData->mAnimation.LastElement().mProperty; isAnimating = true; SampledAnimationArray animationValues; diff --git a/gfx/layers/CompositorAnimationStorage.h b/gfx/layers/CompositorAnimationStorage.h @@ -90,7 +90,8 @@ struct AnimatedValue final { mValue.as<nscolor>() = aColor; } - already_AddRefed<StyleAnimationValue> AsAnimationValue(nsCSSPropertyID) const; + already_AddRefed<StyleAnimationValue> AsAnimationValue( + NonCustomCSSPropertyId) const; private: AnimatedValueType mValue; @@ -203,7 +204,7 @@ class CompositorAnimationStorage final { * Store the animated values from |aAnimationValues|. */ void StoreAnimatedValue( - nsCSSPropertyID aProperty, uint64_t aId, + NonCustomCSSPropertyId aProperty, uint64_t aId, const std::unique_ptr<AnimationStorageData>& aAnimationStorageData, SampledAnimationArray&& aAnimationValues, const MutexAutoLock& aProofOfMapLock, diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh @@ -28,7 +28,7 @@ using struct nsPoint from "nsPoint.h"; using mozilla::TimeDuration from "mozilla/TimeStamp.h"; using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; using mozilla::ScreenRotation from "mozilla/WidgetUtils.h"; -using nsCSSPropertyID from "nsCSSPropertyID.h"; +using NonCustomCSSPropertyId from "NonCustomCSSPropertyId.h"; using mozilla::hal::ScreenOrientation from "mozilla/HalIPCUtils.h"; using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; using mozilla::CSSCoord from "Units.h"; @@ -210,7 +210,7 @@ struct Animation { uint8_t direction; // This uses dom::FillMode. uint8_t fillMode; - nsCSSPropertyID property; + NonCustomCSSPropertyId property; float playbackRate; // When performing an asynchronous update to the playbackRate, |playbackRate| // above is the updated playbackRate while |previousPlaybackRate| is the diff --git a/ipc/glue/IPCMessageUtilsSpecializations.h b/ipc/glue/IPCMessageUtilsSpecializations.h @@ -33,7 +33,7 @@ #include "mozilla/dom/ipc/StructuredCloneData.h" #include "mozilla/dom/UserActivation.h" #include "gfxPlatform.h" -#include "nsCSSPropertyID.h" +#include "NonCustomCSSPropertyId.h" #include "nsContentPermissionHelper.h" #include "nsDebug.h" #include "nsIContentPolicy.h" @@ -374,9 +374,9 @@ struct ParamTraits<float> { }; template <> -struct ParamTraits<nsCSSPropertyID> - : public ContiguousEnumSerializer<nsCSSPropertyID, eCSSProperty_UNKNOWN, - eCSSProperty_COUNT> {}; +struct ParamTraits<NonCustomCSSPropertyId> + : public ContiguousEnumSerializer< + NonCustomCSSPropertyId, eCSSProperty_UNKNOWN, eCSSProperty_COUNT> {}; template <> struct ParamTraits<nsID> { diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp @@ -418,15 +418,15 @@ static Array<MinAndMaxScale, 2> GetMinAndMaxScaleForAnimationProperty( anim->GetEffect() ? anim->GetEffect()->AsKeyframeEffect() : nullptr; MOZ_ASSERT(effect, "A playing animation should have a keyframe effect"); for (const AnimationProperty& prop : effect->Properties()) { - if (prop.mProperty.mID != eCSSProperty_transform && - prop.mProperty.mID != eCSSProperty_scale) { + if (prop.mProperty.mId != eCSSProperty_transform && + prop.mProperty.mId != eCSSProperty_scale) { continue; } // 0: eCSSProperty_transform. // 1: eCSSProperty_scale. MinAndMaxScale& scales = - minAndMaxScales[prop.mProperty.mID == eCSSProperty_transform ? 0 : 1]; + minAndMaxScales[prop.mProperty.mId == eCSSProperty_transform ? 0 : 1]; // We need to factor in the scale of the base style if the base style // will be used on the compositor. diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h @@ -2483,7 +2483,7 @@ class nsLayoutUtils { * not overridden by !important rules. */ static bool HasEffectiveAnimation(const nsIFrame* aFrame, - nsCSSPropertyID aProperty); + NonCustomCSSPropertyId aProperty); /** * Returns true if |aFrame| has an animation where at least one of the diff --git a/layout/inspector/InspectorUtils.cpp b/layout/inspector/InspectorUtils.cpp @@ -286,7 +286,7 @@ class ReadOnlyInspectorDeclaration final : public nsDOMCSSDeclaration { void GetPropertyValue(const nsACString& aPropName, nsACString& aValue) final { Servo_DeclarationBlock_GetPropertyValue(mRaw, &aPropName, &aValue); } - void GetPropertyValue(nsCSSPropertyID aId, nsACString& aValue) final { + void GetPropertyValue(NonCustomCSSPropertyId aId, nsACString& aValue) final { Servo_DeclarationBlock_GetPropertyValueById(mRaw, aId, &aValue); } void IndexedGetter(uint32_t aIndex, bool& aFound, @@ -302,7 +302,7 @@ class ReadOnlyInspectorDeclaration final : public nsDOMCSSDeclaration { ErrorResult& aRv) final { aRv.ThrowInvalidModificationError("Can't mutate this declaration"); } - void SetPropertyValue(nsCSSPropertyID aId, const nsACString& aValue, + void SetPropertyValue(NonCustomCSSPropertyId aId, const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv) final { aRv.ThrowInvalidModificationError("Can't mutate this declaration"); @@ -626,7 +626,7 @@ void InspectorUtils::GetCSSPropertyNames(GlobalObject& aGlobalObject, : CSSEnabledState::ForAllContent; auto appendProperty = [enabledState, &aResult](uint32_t prop) { - nsCSSPropertyID cssProp = nsCSSPropertyID(prop); + NonCustomCSSPropertyId cssProp = NonCustomCSSPropertyId(prop); if (nsCSSProps::IsEnabled(cssProp, enabledState)) { aResult.AppendElement( NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(cssProp))); @@ -635,7 +635,7 @@ void InspectorUtils::GetCSSPropertyNames(GlobalObject& aGlobalObject, uint32_t prop = 0; for (; prop < eCSSProperty_COUNT_no_shorthands; ++prop) { - if (!nsCSSProps::PropHasFlags(nsCSSPropertyID(prop), + if (!nsCSSProps::PropHasFlags(NonCustomCSSPropertyId(prop), CSSPropFlags::Inaccessible)) { appendProperty(prop); } @@ -659,10 +659,10 @@ void InspectorUtils::GetCSSPropertyNames(GlobalObject& aGlobalObject, void InspectorUtils::GetCSSPropertyPrefs(GlobalObject& aGlobalObject, nsTArray<PropertyPref>& aResult) { for (const auto* src = nsCSSProps::kPropertyPrefTable; - src->mPropID != eCSSProperty_UNKNOWN; src++) { + src->mPropId != eCSSProperty_UNKNOWN; src++) { PropertyPref& dest = *aResult.AppendElement(); dest.mName.Assign( - NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(src->mPropID))); + NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(src->mPropId))); dest.mPref.AssignASCII(src->mPref); } } @@ -672,26 +672,26 @@ void InspectorUtils::GetSubpropertiesForCSSProperty(GlobalObject& aGlobal, const nsACString& aProperty, nsTArray<nsString>& aResult, ErrorResult& aRv) { - nsCSSPropertyID propertyID = nsCSSProps::LookupProperty(aProperty); + NonCustomCSSPropertyId propertyId = nsCSSProps::LookupProperty(aProperty); - if (propertyID == eCSSProperty_UNKNOWN) { + if (propertyId == eCSSProperty_UNKNOWN) { aRv.Throw(NS_ERROR_FAILURE); return; } - if (propertyID == eCSSPropertyExtra_variable) { + if (propertyId == eCSSPropertyExtra_variable) { aResult.AppendElement(NS_ConvertUTF8toUTF16(aProperty)); return; } - if (!nsCSSProps::IsShorthand(propertyID)) { + if (!nsCSSProps::IsShorthand(propertyId)) { nsString* name = aResult.AppendElement(); - CopyASCIItoUTF16(nsCSSProps::GetStringValue(propertyID), *name); + CopyASCIItoUTF16(nsCSSProps::GetStringValue(propertyId), *name); return; } - for (const nsCSSPropertyID* props = - nsCSSProps::SubpropertyEntryFor(propertyID); + for (const NonCustomCSSPropertyId* props = + nsCSSProps::SubpropertyEntryFor(propertyId); *props != eCSSProperty_UNKNOWN; ++props) { nsString* name = aResult.AppendElement(); CopyASCIItoUTF16(nsCSSProps::GetStringValue(*props), *name); diff --git a/layout/painting/ActiveLayerTracker.cpp b/layout/painting/ActiveLayerTracker.cpp @@ -59,11 +59,12 @@ class LayerActivity { } ~LayerActivity(); nsExpirationState* GetExpirationState() { return &mState; } - uint8_t& RestyleCountForProperty(nsCSSPropertyID aProperty) { + uint8_t& RestyleCountForProperty(NonCustomCSSPropertyId aProperty) { return mRestyleCounts[GetActivityIndexForProperty(aProperty)]; } - static ActivityIndex GetActivityIndexForProperty(nsCSSPropertyID aProperty) { + static ActivityIndex GetActivityIndexForProperty( + NonCustomCSSPropertyId aProperty) { switch (aProperty) { case eCSSProperty_opacity: return ACTIVITY_OPACITY; @@ -274,7 +275,7 @@ static void IncrementScaleRestyleCountIfNeeded(nsIFrame* aFrame, /* static */ void ActiveLayerTracker::NotifyRestyle(nsIFrame* aFrame, - nsCSSPropertyID aProperty) { + NonCustomCSSPropertyId aProperty) { LayerActivity* layerActivity = GetLayerActivityForUpdate(aFrame); uint8_t& mutationCount = layerActivity->RestyleCountForProperty(aProperty); IncrementMutationCount(&mutationCount); @@ -298,7 +299,7 @@ static bool IsPresContextInScriptAnimationCallback( /* static */ void ActiveLayerTracker::NotifyInlineStyleRuleModified( - nsIFrame* aFrame, nsCSSPropertyID aProperty) { + nsIFrame* aFrame, NonCustomCSSPropertyId aProperty) { if (IsPresContextInScriptAnimationCallback(aFrame->PresContext())) { LayerActivity* layerActivity = GetLayerActivityForUpdate(aFrame); // We know this is animated, so just hack the mutation count. diff --git a/layout/painting/ActiveLayerTracker.h b/layout/painting/ActiveLayerTracker.h @@ -7,7 +7,7 @@ #ifndef ACTIVELAYERTRACKER_H_ #define ACTIVELAYERTRACKER_H_ -#include "nsCSSPropertyID.h" +#include "NonCustomCSSPropertyId.h" class nsIFrame; class nsIContent; @@ -44,14 +44,14 @@ class ActiveLayerTracker { * Any such marking will time out after a short period. * @param aProperty the property that has changed */ - static void NotifyRestyle(nsIFrame* aFrame, nsCSSPropertyID aProperty); + static void NotifyRestyle(nsIFrame* aFrame, NonCustomCSSPropertyId aProperty); /** * Notify that a property in the inline style rule of aFrame's element * has been modified. */ static void NotifyInlineStyleRuleModified(nsIFrame* aFrame, - nsCSSPropertyID aProperty); + NonCustomCSSPropertyId aProperty); /** * Notify that a frame needs to be repainted. This is important for layering * decisions where, say, aFrame's transform is updated from JS, but we need diff --git a/layout/style/AnimatedPropertyID.h b/layout/style/AnimatedPropertyID.h @@ -7,39 +7,40 @@ #ifndef mozilla_AnimatedPropertyID_h #define mozilla_AnimatedPropertyID_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/HashFunctions.h" #include "mozilla/ServoBindings.h" -#include "nsCSSPropertyID.h" #include "nsCSSProps.h" #include "nsString.h" namespace mozilla { struct AnimatedPropertyID { - explicit AnimatedPropertyID(nsCSSPropertyID aProperty) : mID(aProperty) { + 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)) { + : mId(eCSSPropertyExtra_variable), mCustomName(std::move(aCustomName)) { MOZ_ASSERT(mCustomName, "Null custom property name"); } - nsCSSPropertyID mID = eCSSProperty_UNKNOWN; + NonCustomCSSPropertyId mId = eCSSProperty_UNKNOWN; RefPtr<nsAtom> mCustomName; - bool IsCustom() const { return mID == eCSSPropertyExtra_variable; } + bool IsCustom() const { return mId == eCSSPropertyExtra_variable; } bool operator==(const AnimatedPropertyID& aOther) const { - return mID == aOther.mID && 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) { + if (mId == eCSSProperty_UNKNOWN) { return false; } return IsCustom() == !!mCustomName; @@ -52,7 +53,7 @@ struct AnimatedPropertyID { aString.AssignLiteral("--"); AppendUTF16toUTF8(nsDependentAtomString(mCustomName), aString); } else { - aString.Assign(nsCSSProps::GetStringValue(mID)); + aString.Assign(nsCSSProps::GetStringValue(mId)); } } @@ -63,20 +64,20 @@ struct AnimatedPropertyID { aString.AssignLiteral("--"); aString.Append(nsDependentAtomString(mCustomName)); } else { - aString.Assign(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(mID))); + aString.Assign(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(mId))); } } HashNumber Hash() const { HashNumber hash = mCustomName ? mCustomName->hash() : 0; - return AddToHash(hash, mID); + return AddToHash(hash, mId); } AnimatedPropertyID ToPhysical(const ComputedStyle& aStyle) const { if (IsCustom()) { return *this; } - return AnimatedPropertyID{nsCSSProps::Physicalize(mID, aStyle)}; + return AnimatedPropertyID{nsCSSProps::Physicalize(mId, aStyle)}; } }; @@ -86,7 +87,7 @@ inline std::ostream& operator<<(std::ostream& aOut, if (aProperty.IsCustom()) { return aOut << nsAtomCString(aProperty.mCustomName); } - return aOut << nsCSSProps::GetStringValue(aProperty.mID); + return aOut << nsCSSProps::GetStringValue(aProperty.mId); } } // namespace mozilla diff --git a/layout/style/AnimatedPropertyIDSet.h b/layout/style/AnimatedPropertyIDSet.h @@ -34,7 +34,7 @@ class AnimatedPropertyIDSet { if (aProperty.IsCustom()) { mCustomNames.Insert(aProperty.mCustomName); } else { - mIDs.AddProperty(aProperty.mID); + mIDs.AddProperty(aProperty.mId); } } @@ -42,7 +42,7 @@ class AnimatedPropertyIDSet { if (aProperty.IsCustom()) { mCustomNames.Remove(aProperty.mCustomName); } else { - mIDs.RemoveProperty(aProperty.mID); + mIDs.RemoveProperty(aProperty.mId); } } @@ -50,7 +50,7 @@ class AnimatedPropertyIDSet { if (aProperty.IsCustom()) { return mCustomNames.Contains(aProperty.mCustomName); } - return mIDs.HasProperty(aProperty.mID); + return mIDs.HasProperty(aProperty.mId); } bool Intersects(const nsCSSPropertyIDSet& aIDs) const { @@ -162,14 +162,14 @@ class AnimatedPropertyIDSet { AnimatedPropertyID operator*() { if (mIDIterator != mPropertySet.mIDs.end()) { - mPropertyID.mID = *mIDIterator; + mPropertyID.mId = *mIDIterator; mPropertyID.mCustomName = nullptr; } else if (mCustomNameIterator != mPropertySet.mCustomNames.end()) { - mPropertyID.mID = eCSSPropertyExtra_variable; + mPropertyID.mId = eCSSPropertyExtra_variable; mPropertyID.mCustomName = *mCustomNameIterator; } else { MOZ_ASSERT_UNREACHABLE("Should not dereference beyond end"); - mPropertyID.mID = eCSSProperty_UNKNOWN; + mPropertyID.mId = eCSSProperty_UNKNOWN; mPropertyID.mCustomName = nullptr; } return mPropertyID; diff --git a/layout/style/ComputedStyle.h b/layout/style/ComputedStyle.h @@ -66,7 +66,8 @@ class ComputedStyle { ServoComputedDataForgotten aComputedValues); // Returns the computed (not resolved) value of the given property. - void GetComputedPropertyValue(nsCSSPropertyID aId, nsACString& aOut) const { + void GetComputedPropertyValue(NonCustomCSSPropertyId aId, + nsACString& aOut) const { Servo_GetComputedValue(this, aId, &aOut); } diff --git a/layout/style/DeclarationBlock.h b/layout/style/DeclarationBlock.h @@ -12,9 +12,9 @@ #ifndef mozilla_DeclarationBlock_h #define mozilla_DeclarationBlock_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/Atomics.h" #include "mozilla/ServoBindings.h" -#include "nsCSSPropertyID.h" #include "nsString.h" namespace mozilla { @@ -179,8 +179,9 @@ class DeclarationBlock final { Servo_DeclarationBlock_GetPropertyValue(mRaw, &aProperty, &aValue); } - void GetPropertyValueByID(nsCSSPropertyID aPropID, nsACString& aValue) const { - Servo_DeclarationBlock_GetPropertyValueById(mRaw, aPropID, &aValue); + void GetPropertyValueById(NonCustomCSSPropertyId aPropId, + nsACString& aValue) const { + Servo_DeclarationBlock_GetPropertyValueById(mRaw, aPropId, &aValue); } bool GetPropertyIsImportant(const nsACString& aProperty) const { @@ -201,7 +202,7 @@ class DeclarationBlock final { } // Returns whether the property was removed. - bool RemovePropertyByID(nsCSSPropertyID aProperty, + bool RemovePropertyById(NonCustomCSSPropertyId aProperty, DeclarationBlockMutationClosure aClosure = {}) { AssertMutable(); return Servo_DeclarationBlock_RemovePropertyById(mRaw, aProperty, aClosure); diff --git a/layout/style/GeckoBindings.cpp b/layout/style/GeckoBindings.cpp @@ -660,11 +660,11 @@ static CSSTransition* GetCurrentTransitionAt(const Element* aElement, return collection->mAnimations.SafeElementAt(aIndex); } -nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(const Element* aElement, - size_t aIndex) { +NonCustomCSSPropertyId Gecko_ElementTransitions_PropertyAt( + const Element* aElement, size_t aIndex) { CSSTransition* transition = GetCurrentTransitionAt(aElement, aIndex); - return transition ? transition->TransitionProperty().mID - : nsCSSPropertyID::eCSSProperty_UNKNOWN; + return transition ? transition->TransitionProperty().mId + : NonCustomCSSPropertyId::eCSSProperty_UNKNOWN; } const StyleAnimationValue* Gecko_ElementTransitions_EndValueAt( @@ -1443,7 +1443,7 @@ void Gecko_LoadStyleSheetAsync(SheetLoadDataHolder* aParentData, } void Gecko_AddPropertyToSet(nsCSSPropertyIDSet* aPropertySet, - nsCSSPropertyID aProperty) { + NonCustomCSSPropertyId aProperty) { aPropertySet->AddProperty(aProperty); } diff --git a/layout/style/GeckoBindings.h b/layout/style/GeckoBindings.h @@ -237,7 +237,7 @@ bool Gecko_ElementHasWebAnimations( size_t Gecko_ElementTransitions_Length( const mozilla::dom::Element* aElementOrPseudo); -nsCSSPropertyID Gecko_ElementTransitions_PropertyAt( +NonCustomCSSPropertyId Gecko_ElementTransitions_PropertyAt( const mozilla::dom::Element* aElementOrPseudo, size_t aIndex); const mozilla::StyleAnimationValue* Gecko_ElementTransitions_EndValueAt( @@ -499,7 +499,7 @@ nscolor Gecko_ComputeSystemColor(mozilla::StyleSystemColor, int32_t Gecko_GetLookAndFeelInt(int32_t int_id); float Gecko_GetLookAndFeelFloat(int32_t float_id); -void Gecko_AddPropertyToSet(nsCSSPropertyIDSet*, nsCSSPropertyID); +void Gecko_AddPropertyToSet(nsCSSPropertyIDSet*, NonCustomCSSPropertyId); // Style-struct management. #define DECLARE_GECKO_FUNCTIONS(name) \ diff --git a/layout/style/GenerateCSSPropsGenerated.py b/layout/style/GenerateCSSPropsGenerated.py @@ -88,12 +88,12 @@ def generate(output, dataFile): continue name = "g{}SubpropTable".format(p.method) names.append(name) - output.write("static const nsCSSPropertyID {}[] = {{\n".format(name)) + output.write("static const NonCustomCSSPropertyId {}[] = {{\n".format(name)) for subprop in p.subprops: output.write(" eCSSProperty_{},\n".format(subprop)) output.write(" eCSSProperty_UNKNOWN\n") output.write("};\n\n") - output.write("const nsCSSPropertyID* const\n") + output.write("const NonCustomCSSPropertyId* const\n") output.write( "nsCSSProps::kSubpropertyTable[" "eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands" @@ -106,7 +106,7 @@ def generate(output, dataFile): # Generate assertions msg = ( "GenerateCSSPropsGenerated.py did not list properties " - "in nsCSSPropertyID order" + "in NonCustomCSSPropertyId order" ) for p in properties: output.write( diff --git a/layout/style/LayerAnimationInfo.cpp b/layout/style/LayerAnimationInfo.cpp @@ -21,7 +21,7 @@ namespace mozilla { /* static */ DisplayItemType LayerAnimationInfo::GetDisplayItemTypeForProperty( - nsCSSPropertyID aProperty) { + NonCustomCSSPropertyId aProperty) { switch (aProperty) { case eCSSProperty_background_color: return DisplayItemType::TYPE_BACKGROUND_COLOR; diff --git a/layout/style/LayerAnimationInfo.h b/layout/style/LayerAnimationInfo.h @@ -7,8 +7,8 @@ #ifndef mozilla_LayerAnimationInfo_h #define mozilla_LayerAnimationInfo_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/Array.h" -#include "nsCSSPropertyID.h" #include "nsCSSPropertyIDSet.h" #include "nsChangeHint.h" #include "nsDisplayItemTypes.h" // For nsDisplayItem::Type @@ -21,7 +21,7 @@ struct LayerAnimationInfo { // Returns DisplayItemType::TYPE_ZERO if |aProperty| cannot be animated on the // compositor. static DisplayItemType GetDisplayItemTypeForProperty( - nsCSSPropertyID aProperty); + NonCustomCSSPropertyId aProperty); // Returns the corresponding CSS properties for |aDisplayItemType|. // diff --git a/layout/style/MappedDeclarationsBuilder.cpp b/layout/style/MappedDeclarationsBuilder.cpp @@ -13,7 +13,7 @@ namespace mozilla { -void MappedDeclarationsBuilder::SetIdentAtomValue(nsCSSPropertyID aId, +void MappedDeclarationsBuilder::SetIdentAtomValue(NonCustomCSSPropertyId aId, nsAtom* aValue) { Servo_DeclarationBlock_SetIdentStringValue(&EnsureDecls(), aId, aValue); if (aId == eCSSProperty__x_lang) { diff --git a/layout/style/MappedDeclarationsBuilder.h b/layout/style/MappedDeclarationsBuilder.h @@ -9,11 +9,11 @@ #ifndef mozilla_MappedDeclarationsBuilder_h #define mozilla_MappedDeclarationsBuilder_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/FontPropertyTypes.h" #include "mozilla/ServoBindingTypes.h" #include "mozilla/ServoBindings.h" #include "mozilla/dom/Element.h" -#include "nsCSSPropertyID.h" #include "nsCSSValue.h" #include "nsColor.h" @@ -46,36 +46,37 @@ class MOZ_STACK_CLASS MappedDeclarationsBuilder final { } // Check if we already contain a certain longhand - bool PropertyIsSet(nsCSSPropertyID aId) const { + bool PropertyIsSet(NonCustomCSSPropertyId aId) const { return mDecls && Servo_DeclarationBlock_PropertyIsSet(mDecls, aId); } // Set a property to an identifier (string) - void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue) { + void SetIdentStringValue(NonCustomCSSPropertyId aId, const nsString& aValue) { RefPtr<nsAtom> atom = NS_AtomizeMainThread(aValue); SetIdentAtomValue(aId, atom); } - void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue) { + void SetIdentStringValueIfUnset(NonCustomCSSPropertyId aId, + const nsString& aValue) { if (!PropertyIsSet(aId)) { SetIdentStringValue(aId, aValue); } } - void SetIdentAtomValue(nsCSSPropertyID aId, nsAtom* aValue); + void SetIdentAtomValue(NonCustomCSSPropertyId aId, nsAtom* aValue); - void SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsAtom* aValue) { + void SetIdentAtomValueIfUnset(NonCustomCSSPropertyId aId, nsAtom* aValue) { if (!PropertyIsSet(aId)) { SetIdentAtomValue(aId, aValue); } } // Set a property to a keyword (usually NS_STYLE_* or StyleFoo::*) - void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue) { + void SetKeywordValue(NonCustomCSSPropertyId aId, int32_t aValue) { Servo_DeclarationBlock_SetKeywordValue(&EnsureDecls(), aId, aValue); } - void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue) { + void SetKeywordValueIfUnset(NonCustomCSSPropertyId aId, int32_t aValue) { if (!PropertyIsSet(aId)) { SetKeywordValue(aId, aValue); } @@ -83,21 +84,21 @@ class MOZ_STACK_CLASS MappedDeclarationsBuilder final { template <typename T, typename = typename std::enable_if<std::is_enum<T>::value>::type> - void SetKeywordValue(nsCSSPropertyID aId, T aValue) { + void SetKeywordValue(NonCustomCSSPropertyId aId, T aValue) { static_assert(EnumTypeFitsWithin<T, int32_t>::value, "aValue must be an enum that fits within 32 bits"); SetKeywordValue(aId, static_cast<int32_t>(aValue)); } template <typename T, typename = typename std::enable_if<std::is_enum<T>::value>::type> - void SetKeywordValueIfUnset(nsCSSPropertyID aId, T aValue) { + void SetKeywordValueIfUnset(NonCustomCSSPropertyId aId, T aValue) { static_assert(EnumTypeFitsWithin<T, int32_t>::value, "aValue must be an enum that fits within 32 bits"); SetKeywordValueIfUnset(aId, static_cast<int32_t>(aValue)); } // Set a property to an integer value - void SetIntValue(nsCSSPropertyID aId, int32_t aValue) { + void SetIntValue(NonCustomCSSPropertyId aId, int32_t aValue) { Servo_DeclarationBlock_SetIntValue(&EnsureDecls(), aId, aValue); } @@ -120,61 +121,61 @@ class MOZ_STACK_CLASS MappedDeclarationsBuilder final { } // Set a property to a pixel value - void SetPixelValue(nsCSSPropertyID aId, float aValue) { + void SetPixelValue(NonCustomCSSPropertyId aId, float aValue) { Servo_DeclarationBlock_SetPixelValue(&EnsureDecls(), aId, aValue); } - void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue) { + void SetPixelValueIfUnset(NonCustomCSSPropertyId aId, float aValue) { if (!PropertyIsSet(aId)) { SetPixelValue(aId, aValue); } } - void SetLengthValue(nsCSSPropertyID aId, const nsCSSValue& aValue) { + void SetLengthValue(NonCustomCSSPropertyId aId, const nsCSSValue& aValue) { MOZ_ASSERT(aValue.IsLengthUnit()); Servo_DeclarationBlock_SetLengthValue( &EnsureDecls(), aId, aValue.GetFloatValue(), aValue.GetUnit()); } // Set a property to a percent value - void SetPercentValue(nsCSSPropertyID aId, float aValue) { + void SetPercentValue(NonCustomCSSPropertyId aId, float aValue) { Servo_DeclarationBlock_SetPercentValue(&EnsureDecls(), aId, aValue); } - void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue) { + void SetPercentValueIfUnset(NonCustomCSSPropertyId aId, float aValue) { if (!PropertyIsSet(aId)) { SetPercentValue(aId, aValue); } } // Set a property to `auto` - void SetAutoValue(nsCSSPropertyID aId) { + void SetAutoValue(NonCustomCSSPropertyId aId) { Servo_DeclarationBlock_SetAutoValue(&EnsureDecls(), aId); } - void SetAutoValueIfUnset(nsCSSPropertyID aId) { + void SetAutoValueIfUnset(NonCustomCSSPropertyId aId) { if (!PropertyIsSet(aId)) { SetAutoValue(aId); } } // Set a property to `currentcolor` - void SetCurrentColor(nsCSSPropertyID aId) { + void SetCurrentColor(NonCustomCSSPropertyId aId) { Servo_DeclarationBlock_SetCurrentColor(&EnsureDecls(), aId); } - void SetCurrentColorIfUnset(nsCSSPropertyID aId) { + void SetCurrentColorIfUnset(NonCustomCSSPropertyId aId) { if (!PropertyIsSet(aId)) { SetCurrentColor(aId); } } // Set a property to an RGBA nscolor value - void SetColorValue(nsCSSPropertyID aId, nscolor aValue) { + void SetColorValue(NonCustomCSSPropertyId aId, nscolor aValue) { Servo_DeclarationBlock_SetColorValue(&EnsureDecls(), aId, aValue); } - void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue) { + void SetColorValueIfUnset(NonCustomCSSPropertyId aId, nscolor aValue) { if (!PropertyIsSet(aId)) { SetColorValue(aId, aValue); } diff --git a/layout/style/NonCustomCSSPropertyId.h.in b/layout/style/NonCustomCSSPropertyId.h.in @@ -0,0 +1,87 @@ +/* -*- 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/. */ + +/* enum types for CSS properties and their values */ + +#ifndef NonCustomCSSPropertyId_h___ +#define NonCustomCSSPropertyId_h___ + +#include <nsHashKeys.h> + +/* + Declare the enum list using the magic of preprocessing + enum values are "eCSSProperty_foo" (where foo is the property) + + To change the list of properties, see ServoCSSPropList.h + + */ +enum NonCustomCSSPropertyId : int32_t { + eCSSProperty_UNKNOWN = -1, + +$property_ids + + // Some of the values below could probably overlap with each other + // if we had a need for them to do so. + + // Extra value to represent custom properties (--*). + eCSSPropertyExtra_variable, +}; + +// MOZ_DBG support is defined in nsCSSProps.h since it depends on +// nsCSSProps::GetStringValue + +const NonCustomCSSPropertyId + eCSSProperty_COUNT_no_shorthands = $longhand_count; +const NonCustomCSSPropertyId + eCSSProperty_COUNT = $shorthand_count; +const NonCustomCSSPropertyId + eCSSProperty_COUNT_with_aliases = eCSSPropertyExtra_variable; + +namespace mozilla { + +template<> +inline PLDHashNumber +Hash<NonCustomCSSPropertyId>(const NonCustomCSSPropertyId& aValue) +{ + return uint32_t(aValue); +} + +} // namespace mozilla + +// The "descriptors" that can appear in a @font-face rule. +// They have the syntax of properties but different value rules. +enum nsCSSFontDesc { + eCSSFontDesc_UNKNOWN = -1, +#define CSS_FONT_DESC(name_, method_) eCSSFontDesc_##method_, +#include "nsCSSFontDescList.h" +#undef CSS_FONT_DESC + eCSSFontDesc_COUNT +}; + +// The "descriptors" that can appear in a @counter-style rule. +// They have the syntax of properties but different value rules. +enum nsCSSCounterDesc { + eCSSCounterDesc_UNKNOWN = -1, +#define CSS_COUNTER_DESC(name_, method_) eCSSCounterDesc_##method_, +#include "nsCSSCounterDescList.h" +#undef CSS_COUNTER_DESC + eCSSCounterDesc_COUNT +}; + +namespace mozilla { + +// FIXME: The underlying type of this enum should be uint8_t, but we can't do +// that because of https://bugs.llvm.org/show_bug.cgi?id=44228. +enum class CountedUnknownProperty : uint32_t { +#define COUNTED_UNKNOWN_PROPERTY(name_, method_) method_, +#include "mozilla/CountedUnknownProperties.h" +#undef COUNTED_UNKNOWN_PROPERTY + Count, +}; + +} // namespace mozilla + +#endif /* NonCustomCSSPropertyId_h___ */ diff --git a/layout/style/ServoBindingTypes.h b/layout/style/ServoBindingTypes.h @@ -54,11 +54,11 @@ #ifndef mozilla_ServoBindingTypes_h #define mozilla_ServoBindingTypes_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/RefPtr.h" #include "mozilla/ServoTypes.h" #include "mozilla/UniquePtr.h" #include "mozilla/gfx/Types.h" -#include "nsCSSPropertyID.h" #include "nsStyleAutoArray.h" #include "nsTArray.h" diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml @@ -75,7 +75,7 @@ rusty-enums = [ "mozilla::LookAndFeel_FloatID", "nsCSSUnit", "nsCSSFontDesc", - "nsCSSPropertyID", + "NonCustomCSSPropertyId", "nsCSSCounterDesc", "nsresult", "nsAtom_AtomKind", @@ -237,7 +237,7 @@ allowlist-types = [ "nsCSSCounterDesc", "nsCSSFontDesc", "nsCSSKTableEntry", - "nsCSSPropertyID", + "NonCustomCSSPropertyId", "nsCSSPropertyIDSet", "nsCSSProps", "nsFont", diff --git a/layout/style/ServoCSSParser.cpp b/layout/style/ServoCSSParser.cpp @@ -55,7 +55,7 @@ bool ServoCSSParser::ColorTo(const nsACString& aFromColor, /* static */ already_AddRefed<StyleLockedDeclarationBlock> ServoCSSParser::ParseProperty( - nsCSSPropertyID aProperty, const nsACString& aValue, + NonCustomCSSPropertyId aProperty, const nsACString& aValue, const ParsingEnvironment& aParsingEnvironment, const StyleParsingMode& aParsingMode) { AnimatedPropertyID property(aProperty); diff --git a/layout/style/ServoCSSParser.h b/layout/style/ServoCSSParser.h @@ -9,9 +9,9 @@ #ifndef mozilla_ServoCSSParser_h #define mozilla_ServoCSSParser_h +#include "NonCustomCSSPropertyId.h" #include "mozilla/AlreadyAddRefed.h" #include "mozilla/gfx/Matrix.h" -#include "nsCSSPropertyID.h" #include "nsColor.h" #include "nsDOMCSSDeclaration.h" #include "nsStringFwd.h" @@ -133,7 +133,7 @@ class ServoCSSParser { * in Servo. */ static already_AddRefed<StyleLockedDeclarationBlock> ParseProperty( - nsCSSPropertyID aProperty, const nsACString& aValue, + NonCustomCSSPropertyId aProperty, const nsACString& aValue, const ParsingEnvironment& aParsingEnvironment, const StyleParsingMode& aParsingMode); static already_AddRefed<StyleLockedDeclarationBlock> ParseProperty( diff --git a/layout/style/ServoStyleConstsForwards.h b/layout/style/ServoStyleConstsForwards.h @@ -17,6 +17,7 @@ # include <atomic> +# include "NonCustomCSSPropertyId.h" # include "Units.h" # include "mozilla/AtomArray.h" # include "mozilla/CORSMode.h" @@ -27,7 +28,6 @@ # include "mozilla/Span.h" # include "mozilla/gfx/Types.h" # include "mozilla/image/Resolution.h" -# include "nsCSSPropertyID.h" # include "nsColor.h" # include "nsCompatibility.h" # include "nsCoord.h" diff --git a/layout/style/ServoTypes.h b/layout/style/ServoTypes.h @@ -9,10 +9,10 @@ #ifndef mozilla_ServoTypes_h #define mozilla_ServoTypes_h +#include "NonCustomCSSPropertyId.h" #include "X11UndefineNone.h" #include "mozilla/RefPtr.h" #include "mozilla/TypedEnumBits.h" -#include "nsCSSPropertyID.h" #include "nsCoord.h" namespace mozilla { @@ -127,7 +127,7 @@ class ServoStyleSetSizes { struct DeclarationBlockMutationClosure { // The callback function. The first argument is `data`, the second is the // property id that changed. - void (*function)(void*, nsCSSPropertyID) = nullptr; + void (*function)(void*, NonCustomCSSPropertyId) = nullptr; void* data = nullptr; }; diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp @@ -120,7 +120,7 @@ MatrixScales AnimationValue::GetScaleValue(const nsIFrame* aFrame) const { AnimatedPropertyID property(eCSSProperty_UNKNOWN); Servo_AnimationValue_GetPropertyId(mServo, &property); - switch (property.mID) { + switch (property.mId) { case eCSSProperty_scale: { const StyleScale& scale = GetScaleProperty(); return scale.IsNone() @@ -222,7 +222,7 @@ AnimationValue AnimationValue::FromString(AnimatedPropertyID& aProperty, /* static */ already_AddRefed<StyleAnimationValue> AnimationValue::FromAnimatable( - nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable) { + NonCustomCSSPropertyId aProperty, const layers::Animatable& aAnimatable) { switch (aAnimatable.type()) { case layers::Animatable::Tnull_t: break; diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h @@ -9,11 +9,11 @@ #ifndef mozilla_StyleAnimationValue_h_ #define mozilla_StyleAnimationValue_h_ +#include "NonCustomCSSPropertyId.h" #include "mozilla/AnimatedPropertyID.h" #include "mozilla/RefPtr.h" #include "mozilla/ServoBindingTypes.h" #include "mozilla/ServoStyleConsts.h" // Servo_AnimationValue_Dump -#include "nsCSSPropertyID.h" #include "nsColor.h" #include "nsStringFwd.h" #include "nsStyleTransformMatrix.h" @@ -108,7 +108,7 @@ struct AnimationValue { // StyleAnimationValue, so we return its already_AddRefed<> to avoid // adding/removing a redundant ref-count. static already_AddRefed<StyleAnimationValue> FromAnimatable( - nsCSSPropertyID aProperty, const layers::Animatable& aAnimatable); + NonCustomCSSPropertyId aProperty, const layers::Animatable& aAnimatable); RefPtr<StyleAnimationValue> mServo; }; diff --git a/layout/style/moz.build b/layout/style/moz.build @@ -49,7 +49,7 @@ XPIDL_SOURCES += [ XPIDL_MODULE = "layout_style" EXPORTS += [ - "!nsCSSPropertyID.h", + "!NonCustomCSSPropertyId.h", "AnimationCommon.h", "CounterStyleManager.h", "nsAnimationManager.h", @@ -324,10 +324,10 @@ CONTENT_ACCESSIBLE_FILES += [ GeneratedFile( - "nsCSSPropertyID.h", + "NonCustomCSSPropertyId.h", script="GenerateCSSPropertyID.py", entry_point="generate", - inputs=["nsCSSPropertyID.h.in", "!ServoCSSPropList.py"], + inputs=["NonCustomCSSPropertyId.h.in", "!ServoCSSPropList.py"], ) GeneratedFile( "ServoCSSPropList.h", diff --git a/layout/style/nsCSSPropertyID.h.in b/layout/style/nsCSSPropertyID.h.in @@ -1,87 +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/. */ - -/* enum types for CSS properties and their values */ - -#ifndef nsCSSPropertyID_h___ -#define nsCSSPropertyID_h___ - -#include <nsHashKeys.h> - -/* - Declare the enum list using the magic of preprocessing - enum values are "eCSSProperty_foo" (where foo is the property) - - To change the list of properties, see ServoCSSPropList.h - - */ -enum nsCSSPropertyID : int32_t { - eCSSProperty_UNKNOWN = -1, - -$property_ids - - // Some of the values below could probably overlap with each other - // if we had a need for them to do so. - - // Extra value to represent custom properties (--*). - eCSSPropertyExtra_variable, -}; - -// MOZ_DBG support is defined in nsCSSProps.h since it depends on -// nsCSSProps::GetStringValue - -const nsCSSPropertyID - eCSSProperty_COUNT_no_shorthands = $longhand_count; -const nsCSSPropertyID - eCSSProperty_COUNT = $shorthand_count; -const nsCSSPropertyID - eCSSProperty_COUNT_with_aliases = eCSSPropertyExtra_variable; - -namespace mozilla { - -template<> -inline PLDHashNumber -Hash<nsCSSPropertyID>(const nsCSSPropertyID& aValue) -{ - return uint32_t(aValue); -} - -} // namespace mozilla - -// The "descriptors" that can appear in a @font-face rule. -// They have the syntax of properties but different value rules. -enum nsCSSFontDesc { - eCSSFontDesc_UNKNOWN = -1, -#define CSS_FONT_DESC(name_, method_) eCSSFontDesc_##method_, -#include "nsCSSFontDescList.h" -#undef CSS_FONT_DESC - eCSSFontDesc_COUNT -}; - -// The "descriptors" that can appear in a @counter-style rule. -// They have the syntax of properties but different value rules. -enum nsCSSCounterDesc { - eCSSCounterDesc_UNKNOWN = -1, -#define CSS_COUNTER_DESC(name_, method_) eCSSCounterDesc_##method_, -#include "nsCSSCounterDescList.h" -#undef CSS_COUNTER_DESC - eCSSCounterDesc_COUNT -}; - -namespace mozilla { - -// FIXME: The underlying type of this enum should be uint8_t, but we can't do -// that because of https://bugs.llvm.org/show_bug.cgi?id=44228. -enum class CountedUnknownProperty : uint32_t { -#define COUNTED_UNKNOWN_PROPERTY(name_, method_) method_, -#include "mozilla/CountedUnknownProperties.h" -#undef COUNTED_UNKNOWN_PROPERTY - Count, -}; - -} // namespace mozilla - -#endif /* nsCSSPropertyID_h___ */ diff --git a/layout/style/nsCSSPropertyIDSet.h b/layout/style/nsCSSPropertyIDSet.h @@ -15,10 +15,10 @@ #include "mozilla/ArrayUtils.h" // For COMPOSITOR_ANIMATABLE_PROPERTY_LIST and // COMPOSITOR_ANIMATABLE_PROPERTY_LIST_LENGTH +#include "NonCustomCSSPropertyId.h" #include "mozilla/AnimatedPropertyID.h" #include "mozilla/CompositorAnimatableProperties.h" -#include "nsCSSPropertyID.h" -#include "nsCSSProps.h" // For operator<< for nsCSSPropertyID +#include "nsCSSProps.h" // For operator<< for NonCustomCSSPropertyId /** * nsCSSPropertyIDSet maintains a set of non-shorthand CSS properties. In @@ -31,7 +31,7 @@ class nsCSSPropertyIDSet { // auto-generated copy-constructor OK explicit constexpr nsCSSPropertyIDSet( - std::initializer_list<nsCSSPropertyID> aProperties) + std::initializer_list<NonCustomCSSPropertyId> aProperties) : mProperties{0} { for (auto property : aProperties) { size_t p = property; @@ -40,7 +40,7 @@ class nsCSSPropertyIDSet { } } - void AssertInSetRange(nsCSSPropertyID aProperty) const { + void AssertInSetRange(NonCustomCSSPropertyId aProperty) const { MOZ_DIAGNOSTIC_ASSERT( 0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands, "out of bounds"); @@ -49,13 +49,13 @@ class nsCSSPropertyIDSet { // Conversion of aProperty to |size_t| after AssertInSetRange // lets the compiler generate significantly tighter code. - void AddProperty(nsCSSPropertyID aProperty) { + void AddProperty(NonCustomCSSPropertyId aProperty) { AssertInSetRange(aProperty); size_t p = aProperty; mProperties[p / kBitsInChunk] |= property_set_type(1) << (p % kBitsInChunk); } - void RemoveProperty(nsCSSPropertyID aProperty) { + void RemoveProperty(NonCustomCSSPropertyId aProperty) { AssertInSetRange(aProperty); size_t p = aProperty; mProperties[p / kBitsInChunk] &= @@ -63,10 +63,10 @@ class nsCSSPropertyIDSet { } bool HasProperty(const mozilla::AnimatedPropertyID& aProperty) const { - return !aProperty.IsCustom() && HasProperty(aProperty.mID); + return !aProperty.IsCustom() && HasProperty(aProperty.mId); } - bool HasProperty(nsCSSPropertyID aProperty) const { + bool HasProperty(NonCustomCSSPropertyId aProperty) const { AssertInSetRange(aProperty); size_t p = aProperty; return (mProperties[p / kBitsInChunk] & @@ -196,8 +196,8 @@ class nsCSSPropertyIDSet { bool HasPropertyAt(size_t aChunk, size_t aBit) const { return (mProperties[aChunk] & (property_set_type(1) << aBit)) != 0; } - static nsCSSPropertyID CSSPropertyAt(size_t aChunk, size_t aBit) { - return nsCSSPropertyID(aChunk * kBitsInChunk + aBit); + static NonCustomCSSPropertyId CSSPropertyAt(size_t aChunk, size_t aBit) { + return NonCustomCSSPropertyId(aChunk * kBitsInChunk + aBit); } // Iterator for use in range-based for loops @@ -256,7 +256,7 @@ class nsCSSPropertyIDSet { return *this; } - nsCSSPropertyID operator*() { + NonCustomCSSPropertyId operator*() { MOZ_ASSERT(mChunk < kChunkCount, "Should not dereference beyond end"); return nsCSSPropertyIDSet::CSSPropertyAt(mChunk, mBit); } @@ -286,8 +286,8 @@ class nsCSSPropertyIDSet { inline std::ostream& operator<<(std::ostream& aOut, const nsCSSPropertyIDSet& aPropertySet) { - AutoTArray<nsCSSPropertyID, 16> properties; - for (nsCSSPropertyID property : aPropertySet) { + AutoTArray<NonCustomCSSPropertyId, 16> properties; + for (NonCustomCSSPropertyId property : aPropertySet) { properties.AppendElement(property); } return aOut << properties; diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp @@ -31,7 +31,7 @@ using namespace mozilla; static StaticAutoPtr<nsStaticCaseInsensitiveNameTable> gFontDescTable; static StaticAutoPtr<nsStaticCaseInsensitiveNameTable> gCounterDescTable; -static StaticAutoPtr<nsTHashMap<nsCStringHashKey, nsCSSPropertyID>> +static StaticAutoPtr<nsTHashMap<nsCStringHashKey, NonCustomCSSPropertyId>> gPropertyIDLNameTable; static constexpr const char* const kCSSRawFontDescs[] = { @@ -74,17 +74,17 @@ void nsCSSProps::RecomputeEnabledState(const char* aPref, void*) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); DebugOnly<bool> foundPref = false; for (const PropertyPref* pref = kPropertyPrefTable; - pref->mPropID != eCSSProperty_UNKNOWN; pref++) { + pref->mPropId != eCSSProperty_UNKNOWN; pref++) { if (!aPref || !strcmp(aPref, pref->mPref)) { foundPref = true; - gPropertyEnabled[pref->mPropID] = Preferences::GetBool(pref->mPref); - if (pref->mPropID == eCSSProperty_backdrop_filter) { - gPropertyEnabled[pref->mPropID] &= + gPropertyEnabled[pref->mPropId] = Preferences::GetBool(pref->mPref); + if (pref->mPropId == eCSSProperty_backdrop_filter) { + gPropertyEnabled[pref->mPropId] &= gfx::gfxVars::GetAllowBackdropFilterOrDefault(); } #ifdef FUZZING // In fuzzing builds we want to enable all properties unconditionally. - gPropertyEnabled[pref->mPropID] = true; + gPropertyEnabled[pref->mPropId] = true; #endif } } @@ -100,9 +100,11 @@ void nsCSSProps::Init() { gCounterDescTable = CreateStaticTable(kCSSRawCounterDescs, eCSSCounterDesc_COUNT); - gPropertyIDLNameTable = new nsTHashMap<nsCStringHashKey, nsCSSPropertyID>; - for (nsCSSPropertyID p = nsCSSPropertyID(0); - size_t(p) < std::size(kIDLNameTable); p = nsCSSPropertyID(p + 1)) { + gPropertyIDLNameTable = + new nsTHashMap<nsCStringHashKey, NonCustomCSSPropertyId>; + for (NonCustomCSSPropertyId p = NonCustomCSSPropertyId(0); + size_t(p) < std::size(kIDLNameTable); + p = NonCustomCSSPropertyId(p + 1)) { if (kIDLNameTable[p]) { gPropertyIDLNameTable->InsertOrUpdate( nsDependentCString(kIDLNameTable[p]), p); @@ -114,7 +116,7 @@ void nsCSSProps::Init() { ClearOnShutdown(&gPropertyIDLNameTable); for (const PropertyPref* pref = kPropertyPrefTable; - pref->mPropID != eCSSProperty_UNKNOWN; pref++) { + pref->mPropId != eCSSProperty_UNKNOWN; pref++) { // https://bugzilla.mozilla.org/show_bug.cgi?id=1472523 // We need to use nsCString instead of substring because the preference // callback code stores them. Using AssignLiteral prevents any @@ -132,10 +134,10 @@ bool nsCSSProps::IsCustomPropertyName(const nsACString& aProperty) { StringBeginsWith(aProperty, "--"_ns); } -nsCSSPropertyID nsCSSProps::LookupPropertyByIDLName( +NonCustomCSSPropertyId nsCSSProps::LookupPropertyByIDLName( const nsACString& aPropertyIDLName, EnabledState aEnabled) { MOZ_ASSERT(gPropertyIDLNameTable, "no lookup table, needs addref"); - nsCSSPropertyID res; + NonCustomCSSPropertyId res; if (!gPropertyIDLNameTable->Get(aPropertyIDLName, &res)) { return eCSSProperty_UNKNOWN; } @@ -171,7 +173,7 @@ const nsCString& nsCSSProps::GetStringValue(nsCSSCounterDesc aCounterDescID) { return sDescNullStr; } -CSSPropFlags nsCSSProps::PropFlags(nsCSSPropertyID aProperty) { +CSSPropFlags nsCSSProps::PropFlags(NonCustomCSSPropertyId aProperty) { MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_with_aliases, "out of range"); return kFlagsTable[aProperty]; diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h @@ -14,11 +14,11 @@ #include <ostream> +#include "NonCustomCSSPropertyId.h" #include "mozilla/CSSEnabledState.h" #include "mozilla/CSSPropFlags.h" #include "mozilla/Preferences.h" #include "mozilla/UseCounter.h" -#include "nsCSSPropertyID.h" #include "nsString.h" #include "nsStyleStructFwd.h" @@ -34,10 +34,12 @@ class gfxVarReceiver; } // namespace mozilla extern "C" { -nsCSSPropertyID Servo_ResolveLogicalProperty(nsCSSPropertyID, - const mozilla::ComputedStyle*); -nsCSSPropertyID Servo_Property_LookupEnabledForAllContent(const nsACString*); -const uint8_t* Servo_Property_GetName(nsCSSPropertyID, uint32_t* aLength); +NonCustomCSSPropertyId Servo_ResolveLogicalProperty( + NonCustomCSSPropertyId, const mozilla::ComputedStyle*); +NonCustomCSSPropertyId Servo_Property_LookupEnabledForAllContent( + const nsACString*); +const uint8_t* Servo_Property_GetName(NonCustomCSSPropertyId, + uint32_t* aLength); } class nsCSSProps { @@ -48,25 +50,25 @@ class nsCSSProps { static void Init(); // Looks up the property with name aProperty and returns its corresponding - // nsCSSPropertyID value. If aProperty is the name of a custom property, - // then eCSSPropertyExtra_variable will be returned. + // NonCustomCSSPropertyId value. If aProperty is the name of a custom + // property, then eCSSPropertyExtra_variable will be returned. // // This only returns properties enabled for all content, and resolves aliases // to return the aliased property. - static nsCSSPropertyID LookupProperty(const nsACString& aProperty) { + static NonCustomCSSPropertyId LookupProperty(const nsACString& aProperty) { return Servo_Property_LookupEnabledForAllContent(&aProperty); } // As above, but looked up using a property's IDL name. // eCSSPropertyExtra_variable won't be returned from this method. - static nsCSSPropertyID LookupPropertyByIDLName( + static NonCustomCSSPropertyId LookupPropertyByIDLName( const nsACString& aPropertyIDLName, EnabledState aEnabled); // Returns whether aProperty is a custom property name, i.e. begins with // "--". This assumes that the CSS Variables pref has been enabled. static bool IsCustomPropertyName(const nsACString& aProperty); - static bool IsShorthand(nsCSSPropertyID aProperty) { + static bool IsShorthand(NonCustomCSSPropertyId aProperty) { if (aProperty == eCSSPropertyExtra_variable) { return false; } @@ -79,7 +81,7 @@ class nsCSSProps { static nsCSSFontDesc LookupFontDesc(const nsACString&); // The relevant invariants are asserted in Document.cpp - static mozilla::UseCounter UseCounterFor(nsCSSPropertyID aProperty) { + static mozilla::UseCounter UseCounterFor(NonCustomCSSPropertyId aProperty) { MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_with_aliases, "out of range"); return mozilla::UseCounter(size_t(mozilla::eUseCounter_FirstCSSProperty) + @@ -89,7 +91,8 @@ class nsCSSProps { // Given a property enum, get the string value // // This string is static. - static nsDependentCSubstring GetStringValue(nsCSSPropertyID aProperty) { + static nsDependentCSubstring GetStringValue( + NonCustomCSSPropertyId aProperty) { uint32_t len; const uint8_t* chars = Servo_Property_GetName(aProperty, &len); return nsDependentCSubstring(reinterpret_cast<const char*>(chars), len); @@ -98,13 +101,13 @@ class nsCSSProps { static const nsCString& GetStringValue(nsCSSFontDesc aFontDesc); static const nsCString& GetStringValue(nsCSSCounterDesc aCounterDesc); - static Flags PropFlags(nsCSSPropertyID); - static bool PropHasFlags(nsCSSPropertyID aProperty, Flags aFlags) { + static Flags PropFlags(NonCustomCSSPropertyId); + static bool PropHasFlags(NonCustomCSSPropertyId aProperty, Flags aFlags) { return (PropFlags(aProperty) & aFlags) == aFlags; } - static nsCSSPropertyID Physicalize(nsCSSPropertyID aProperty, - const mozilla::ComputedStyle& aStyle) { + static NonCustomCSSPropertyId Physicalize( + NonCustomCSSPropertyId aProperty, const mozilla::ComputedStyle& aStyle) { MOZ_ASSERT(!IsShorthand(aProperty)); if (PropHasFlags(aProperty, Flags::IsLogical)) { return Servo_ResolveLogicalProperty(aProperty, &aStyle); @@ -114,8 +117,8 @@ class nsCSSProps { private: // A table for shorthand properties. The appropriate index is the - // property ID minus eCSSProperty_COUNT_no_shorthands. - static const nsCSSPropertyID* const + // property id minus eCSSProperty_COUNT_no_shorthands. + static const NonCustomCSSPropertyId* const kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands]; public: @@ -139,7 +142,8 @@ class nsCSSProps { */ static mozilla::gfx::gfxVarReceiver& GfxVarReceiver(); - static const nsCSSPropertyID* SubpropertyEntryFor(nsCSSPropertyID aProperty) { + static const NonCustomCSSPropertyId* SubpropertyEntryFor( + NonCustomCSSPropertyId aProperty) { MOZ_ASSERT(eCSSProperty_COUNT_no_shorthands <= aProperty && aProperty < eCSSProperty_COUNT, "out of range"); @@ -163,7 +167,7 @@ class nsCSSProps { * As a special case, the string "cssFloat" is returned for the float * property. nullptr is returned for internal properties. */ - static const char* PropertyIDLName(nsCSSPropertyID aProperty) { + static const char* PropertyIDLName(NonCustomCSSPropertyId aProperty) { MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT, "out of range"); return kIDLNameTable[aProperty]; @@ -173,13 +177,14 @@ class nsCSSProps { * Returns the position of the specified property in a list of all * properties sorted by their IDL name. */ - static int32_t PropertyIDLNameSortPosition(nsCSSPropertyID aProperty) { + static int32_t PropertyIDLNameSortPosition(NonCustomCSSPropertyId aProperty) { MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT, "out of range"); return kIDLNameSortPositionTable[aProperty]; } - static bool IsEnabled(nsCSSPropertyID aProperty, EnabledState aEnabled) { + static bool IsEnabled(NonCustomCSSPropertyId aProperty, + EnabledState aEnabled) { MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_with_aliases, "out of range"); // In the child process, assert that we're not trying to parse stylesheets @@ -204,26 +209,28 @@ class nsCSSProps { } struct PropertyPref { - nsCSSPropertyID mPropID; + NonCustomCSSPropertyId mPropId; const char* mPref; }; static const PropertyPref kPropertyPrefTable[]; -// Storing the enabledstate_ value in an nsCSSPropertyID variable is a small -// hack to avoid needing a separate variable declaration for its real type +// Storing the enabledstate_ value in an NonCustomCSSPropertyId variable is a +// small hack to avoid needing a separate variable declaration for its real type // (CSSEnabledState), which would then require using a block and // therefore a pair of macros by consumers for the start and end of the loop. -#define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(it_, prop_, enabledstate_) \ - for (const nsCSSPropertyID * \ - it_ = nsCSSProps::SubpropertyEntryFor(prop_), \ - es_ = (nsCSSPropertyID)((enabledstate_) | CSSEnabledState(0)); \ - *it_ != eCSSProperty_UNKNOWN; ++it_) \ +#define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(it_, prop_, enabledstate_) \ + for (const NonCustomCSSPropertyId * \ + it_ = nsCSSProps::SubpropertyEntryFor(prop_), \ + es_ = \ + (NonCustomCSSPropertyId)((enabledstate_) | CSSEnabledState(0)); \ + *it_ != eCSSProperty_UNKNOWN; ++it_) \ if (nsCSSProps::IsEnabled(*it_, (mozilla::CSSEnabledState)es_)) }; -// MOZ_DBG support for nsCSSPropertyID +// MOZ_DBG support for NonCustomCSSPropertyId -inline std::ostream& operator<<(std::ostream& aOut, nsCSSPropertyID aProperty) { +inline std::ostream& operator<<(std::ostream& aOut, + NonCustomCSSPropertyId aProperty) { return aOut << nsCSSProps::GetStringValue(aProperty); } diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp @@ -162,7 +162,7 @@ struct ComputedStyleMap { // Create a pointer-to-member-function type. using ComputeMethod = already_AddRefed<CSSValue> (nsComputedDOMStyle::*)(); - nsCSSPropertyID mProperty; + NonCustomCSSPropertyId mProperty; // Whether the property can ever be exposed in getComputedStyle(). For // example, @page descriptors implemented as CSS properties or other @@ -199,7 +199,7 @@ struct ComputedStyleMap { * that should be exposed on an nsComputedDOMStyle, excluding any * disabled properties. */ - nsCSSPropertyID PropertyAt(uint32_t aIndex) { + NonCustomCSSPropertyId PropertyAt(uint32_t aIndex) { Update(); return kEntries[EntryIndex(aIndex)].mProperty; } @@ -209,13 +209,13 @@ struct ComputedStyleMap { * property, or nullptr if the property is not exposed on nsComputedDOMStyle * or is currently disabled. */ - const Entry* FindEntryForProperty(nsCSSPropertyID aPropID) { - if (size_t(aPropID) >= std::size(kEntryIndices)) { - MOZ_ASSERT(aPropID == eCSSProperty_UNKNOWN); + const Entry* FindEntryForProperty(NonCustomCSSPropertyId aPropId) { + if (size_t(aPropId) >= std::size(kEntryIndices)) { + MOZ_ASSERT(aPropId == eCSSProperty_UNKNOWN); return nullptr; } - MOZ_ASSERT(kEntryIndices[aPropID] < std::size(kEntries)); - const auto& entry = kEntries[kEntryIndices[aPropID]]; + MOZ_ASSERT(kEntryIndices[aPropId] < std::size(kEntries)); + const auto& entry = kEntries[kEntryIndices[aPropId]]; if (!entry.IsEnabled()) { return nullptr; } @@ -361,18 +361,18 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsComputedDOMStyle) NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(nsComputedDOMStyle, ClearComputedStyle()) -void nsComputedDOMStyle::GetPropertyValue(const nsCSSPropertyID aPropID, +void nsComputedDOMStyle::GetPropertyValue(const NonCustomCSSPropertyId aPropId, nsACString& aValue) { - return GetPropertyValue(aPropID, EmptyCString(), aValue); + return GetPropertyValue(aPropId, EmptyCString(), aValue); } -void nsComputedDOMStyle::SetPropertyValue(const nsCSSPropertyID aPropID, +void nsComputedDOMStyle::SetPropertyValue(const NonCustomCSSPropertyId aPropId, const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv) { aRv.ThrowNoModificationAllowedError(nsPrintfCString( "Can't set value for property '%s' in computed style", - PromiseFlatCString(nsCSSProps::GetStringValue(aPropID)).get())); + PromiseFlatCString(nsCSSProps::GetStringValue(aPropId)).get())); } void nsComputedDOMStyle::GetCssText(nsACString& aCssText) { @@ -405,24 +405,24 @@ css::Rule* nsComputedDOMStyle::GetParentRule() { return nullptr; } void nsComputedDOMStyle::GetPropertyValue(const nsACString& aPropertyName, nsACString& aReturn) { - nsCSSPropertyID prop = nsCSSProps::LookupProperty(aPropertyName); + NonCustomCSSPropertyId prop = nsCSSProps::LookupProperty(aPropertyName); GetPropertyValue(prop, aPropertyName, aReturn); } void nsComputedDOMStyle::GetPropertyValue( - nsCSSPropertyID aPropID, const nsACString& aMaybeCustomPropertyName, + NonCustomCSSPropertyId aPropId, const nsACString& aMaybeCustomPropertyName, nsACString& aReturn) { MOZ_ASSERT(aReturn.IsEmpty()); const ComputedStyleMap::Entry* entry = nullptr; - if (aPropID != eCSSPropertyExtra_variable) { - entry = GetComputedStyleMap()->FindEntryForProperty(aPropID); + if (aPropId != eCSSPropertyExtra_variable) { + entry = GetComputedStyleMap()->FindEntryForProperty(aPropId); if (!entry) { return; } } - UpdateCurrentStyleSources(aPropID); + UpdateCurrentStyleSources(aPropId); if (!mComputedStyle) { return; } @@ -438,21 +438,21 @@ void nsComputedDOMStyle::GetPropertyValue( return; } - if (nsCSSProps::PropHasFlags(aPropID, CSSPropFlags::IsLogical)) { + if (nsCSSProps::PropHasFlags(aPropId, CSSPropFlags::IsLogical)) { MOZ_ASSERT(entry); MOZ_ASSERT(entry->mGetter == &nsComputedDOMStyle::DummyGetter); - DebugOnly<nsCSSPropertyID> logicalProp = aPropID; + DebugOnly<NonCustomCSSPropertyId> logicalProp = aPropId; - aPropID = Servo_ResolveLogicalProperty(aPropID, mComputedStyle); - entry = GetComputedStyleMap()->FindEntryForProperty(aPropID); + aPropId = Servo_ResolveLogicalProperty(aPropId, mComputedStyle); + entry = GetComputedStyleMap()->FindEntryForProperty(aPropId); - MOZ_ASSERT(NeedsToFlushLayout(logicalProp) == NeedsToFlushLayout(aPropID), + MOZ_ASSERT(NeedsToFlushLayout(logicalProp) == NeedsToFlushLayout(aPropId), "Logical and physical property don't agree on whether layout is " "needed"); } - if (!nsCSSProps::PropHasFlags(aPropID, CSSPropFlags::SerializedByServo)) { + if (!nsCSSProps::PropHasFlags(aPropId, CSSPropFlags::SerializedByServo)) { if (RefPtr<CSSValue> value = (this->*entry->mGetter)()) { nsAutoString text; value->GetCssText(text); @@ -462,7 +462,7 @@ void nsComputedDOMStyle::GetPropertyValue( } MOZ_ASSERT(entry->mGetter == &nsComputedDOMStyle::DummyGetter); - Servo_GetResolvedValue(mComputedStyle, aPropID, + Servo_GetResolvedValue(mComputedStyle, aPropId, mPresShell->StyleSet()->RawData(), mElement, &aReturn); } @@ -651,7 +651,7 @@ static void AddImageURLs(const nsStyleImageLayers& aLayers, } } -static void CollectImageURLsForProperty(nsCSSPropertyID aProp, +static void CollectImageURLsForProperty(NonCustomCSSPropertyId aProp, const ComputedStyle& aStyle, nsTArray<nsCString>& aURLs) { if (nsCSSProps::IsShorthand(aProp)) { @@ -708,7 +708,7 @@ float nsComputedDOMStyle::UsedFontSize() { void nsComputedDOMStyle::GetCSSImageURLs(const nsACString& aPropertyName, nsTArray<nsCString>& aImageURLs, mozilla::ErrorResult& aRv) { - nsCSSPropertyID prop = nsCSSProps::LookupProperty(aPropertyName); + NonCustomCSSPropertyId prop = nsCSSProps::LookupProperty(aPropertyName); if (prop == eCSSProperty_UNKNOWN) { // Note: not using nsPrintfCString here in case aPropertyName contains // nulls. @@ -776,8 +776,8 @@ void nsComputedDOMStyle::SetFrameComputedStyle(mozilla::ComputedStyle* aStyle, mPresShellId = mPresShell->GetPresShellId(); } -static bool MayNeedToFlushLayout(nsCSSPropertyID aPropID) { - switch (aPropID) { +static bool MayNeedToFlushLayout(NonCustomCSSPropertyId aPropId) { + switch (aPropId) { case eCSSProperty_width: case eCSSProperty_height: case eCSSProperty_block_size: @@ -818,8 +818,9 @@ static bool MayNeedToFlushLayout(nsCSSPropertyID aPropID) { } } -bool nsComputedDOMStyle::NeedsToFlushStyle(nsCSSPropertyID aPropID) const { - bool mayNeedToFlushLayout = MayNeedToFlushLayout(aPropID); +bool nsComputedDOMStyle::NeedsToFlushStyle( + NonCustomCSSPropertyId aPropId) const { + bool mayNeedToFlushLayout = MayNeedToFlushLayout(aPropId); // We always compute styles from the element's owner document. if (ElementNeedsRestyle(mElement, mPseudo, mayNeedToFlushLayout)) { @@ -851,8 +852,9 @@ static bool IsNonReplacedInline(nsIFrame* aFrame) { !aFrame->IsColumnSetWrapperFrame(); } -static Side SideForPaddingOrMarginOrInsetProperty(nsCSSPropertyID aPropID) { - switch (aPropID) { +static Side SideForPaddingOrMarginOrInsetProperty( + NonCustomCSSPropertyId aPropId) { + switch (aPropId) { case eCSSProperty_top: case eCSSProperty_margin_top: case eCSSProperty_padding_top: @@ -880,9 +882,10 @@ static bool PaddingNeedsUsedValue(const LengthPercentage& aValue, return !aValue.ConvertsToLength() || aStyle.StyleDisplay()->HasAppearance(); } -bool nsComputedDOMStyle::NeedsToFlushLayout(nsCSSPropertyID aPropID) const { - MOZ_ASSERT(aPropID != eCSSProperty_UNKNOWN); - if (aPropID == eCSSPropertyExtra_variable) { +bool nsComputedDOMStyle::NeedsToFlushLayout( + NonCustomCSSPropertyId aPropId) const { + MOZ_ASSERT(aPropId != eCSSProperty_UNKNOWN); + if (aPropId == eCSSPropertyExtra_variable) { return false; } nsIFrame* outerFrame = GetOuterFrame(); @@ -891,11 +894,11 @@ bool nsComputedDOMStyle::NeedsToFlushLayout(nsCSSPropertyID aPropID) const { } nsIFrame* frame = nsLayoutUtils::GetStyleFrame(outerFrame); auto* style = frame->Style(); - if (nsCSSProps::PropHasFlags(aPropID, CSSPropFlags::IsLogical)) { - aPropID = Servo_ResolveLogicalProperty(aPropID, style); + if (nsCSSProps::PropHasFlags(aPropId, CSSPropFlags::IsLogical)) { + aPropId = Servo_ResolveLogicalProperty(aPropId, style); } - switch (aPropID) { + switch (aPropId) { case eCSSProperty_width: case eCSSProperty_height: return !IsNonReplacedInline(frame); @@ -920,7 +923,7 @@ bool nsComputedDOMStyle::NeedsToFlushLayout(nsCSSPropertyID aPropID) const { case eCSSProperty_padding_right: case eCSSProperty_padding_bottom: case eCSSProperty_padding_left: { - Side side = SideForPaddingOrMarginOrInsetProperty(aPropID); + Side side = SideForPaddingOrMarginOrInsetProperty(aPropId); // Theming can override used padding, sigh. // // TODO(emilio): If we make GetUsedPadding() stop returning 0 for an @@ -937,7 +940,7 @@ bool nsComputedDOMStyle::NeedsToFlushLayout(nsCSSPropertyID aPropID) const { // See https://github.com/w3c/csswg-drafts/issues/2328 // NOTE(dshin): Raw margin value access since we want to flush // anchor-dependent values here. - Side side = SideForPaddingOrMarginOrInsetProperty(aPropID); + Side side = SideForPaddingOrMarginOrInsetProperty(aPropId); return !style->StyleMargin()->mMargin.Get(side).ConvertsToLength(); } default: @@ -989,7 +992,8 @@ nsIFrame* nsComputedDOMStyle::GetOuterFrame() const { return pseudo ? pseudo->GetPrimaryFrame() : nullptr; } -void nsComputedDOMStyle::UpdateCurrentStyleSources(nsCSSPropertyID aPropID) { +void nsComputedDOMStyle::UpdateCurrentStyleSources( + NonCustomCSSPropertyId aPropId) { nsCOMPtr<Document> document(mDocumentWeak); if (!document) { ClearComputedStyle(); @@ -1012,16 +1016,16 @@ void nsComputedDOMStyle::UpdateCurrentStyleSources(nsCSSPropertyID aPropID) { } DebugOnly<bool> didFlush = false; - if (NeedsToFlushStyle(aPropID)) { + if (NeedsToFlushStyle(aPropId)) { didFlush = true; // We look at the frame in NeedsToFlushLayout, so flush frames, not only // styles. Flush(*document, FlushType::Frames); } - const bool needsToFlushLayoutForProp = NeedsToFlushLayout(aPropID); + const bool needsToFlushLayoutForProp = NeedsToFlushLayout(aPropId); if (needsToFlushLayoutForProp || NeedsToFlushLayoutForContainerQuery()) { - MOZ_ASSERT_IF(needsToFlushLayoutForProp, MayNeedToFlushLayout(aPropID)); + MOZ_ASSERT_IF(needsToFlushLayoutForProp, MayNeedToFlushLayout(aPropId)); didFlush = true; Flush(*document, FlushType::Layout); #ifdef DEBUG @@ -2357,7 +2361,7 @@ void nsComputedDOMStyle::RegisterPrefChangeCallbacks() { AutoTArray<const char*, 64> prefs; for (const auto* p = nsCSSProps::kPropertyPrefTable; - p->mPropID != eCSSProperty_UNKNOWN; p++) { + p->mPropId != eCSSProperty_UNKNOWN; p++) { // Many properties are controlled by the same preference, so de-duplicate // them before adding observers. // diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h @@ -70,9 +70,10 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration, NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER - void GetPropertyValue(const nsCSSPropertyID aPropID, + void GetPropertyValue(const NonCustomCSSPropertyId aPropId, nsACString& aValue) override; - void SetPropertyValue(const nsCSSPropertyID aPropID, const nsACString& aValue, + void SetPropertyValue(const NonCustomCSSPropertyId aPropId, + const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv) override; @@ -146,7 +147,7 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration, already_AddRefed<nsROCSSPrimitiveValue> PixelsToCSSValue(float); void SetValueToPixels(nsROCSSPrimitiveValue*, float); - void GetPropertyValue(const nsCSSPropertyID aPropID, + void GetPropertyValue(const NonCustomCSSPropertyId aPropId, const nsACString& aMaybeCustomPropertyNme, nsACString& aValue); using nsDOMCSSDeclaration::GetPropertyValue; @@ -161,7 +162,7 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration, nsMargin GetAdjustedValuesForBoxSizing(); // This indicates error by leaving mComputedStyle null. - void UpdateCurrentStyleSources(nsCSSPropertyID); + void UpdateCurrentStyleSources(NonCustomCSSPropertyId); void ClearCurrentStyleSources(); // Helper functions called by UpdateCurrentStyleSources. @@ -299,10 +300,10 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration, // Find out if we can safely skip flushing (i.e. pending restyles do not // affect our element). - bool NeedsToFlushStyle(nsCSSPropertyID) const; + bool NeedsToFlushStyle(NonCustomCSSPropertyId) const; // Find out if we need to flush layout of the document, depending on the // property that was requested. - bool NeedsToFlushLayout(nsCSSPropertyID) const; + bool NeedsToFlushLayout(NonCustomCSSPropertyId) const; // Find out if we need to flush layout of the document due to container // query being made before relevant query containers are reflowed at least // once. diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -164,26 +164,26 @@ nsresult nsDOMCSSAttributeDeclaration::SetSMILValueHelper(SetterFunc aFunc) { } nsresult nsDOMCSSAttributeDeclaration::SetSMILValue( - const nsCSSPropertyID aPropID, const SMILValue& aValue) { + const NonCustomCSSPropertyId aPropId, const SMILValue& aValue) { MOZ_ASSERT(aValue.mType == &SMILCSSValueType::sSingleton, "We should only try setting a CSS value type"); return SetSMILValueHelper([&](DeclarationBlock& aDecl) { - return SMILCSSValueType::SetPropertyValues(aPropID, aValue, aDecl); + return SMILCSSValueType::SetPropertyValues(aPropId, aValue, aDecl); }); } nsresult nsDOMCSSAttributeDeclaration::SetSMILValue( - const nsCSSPropertyID aPropID, const SVGAnimatedLength& aLength) { - return SetSMILValueHelper([aPropID, &aLength](DeclarationBlock& aDecl) { + const NonCustomCSSPropertyId aPropId, const SVGAnimatedLength& aLength) { + return SetSMILValueHelper([aPropId, &aLength](DeclarationBlock& aDecl) { MOZ_ASSERT(aDecl.IsMutable()); return SVGElement::UpdateDeclarationBlockFromLength( - *aDecl.Raw(), aPropID, aLength, SVGElement::ValToUse::Anim); + *aDecl.Raw(), aPropId, aLength, SVGElement::ValToUse::Anim); }); } nsresult nsDOMCSSAttributeDeclaration::SetSMILValue( - const nsCSSPropertyID aPropID, const SVGAnimatedPathSegList& aPath) { - MOZ_ASSERT(aPropID == eCSSProperty_d); + const NonCustomCSSPropertyId aPropId, const SVGAnimatedPathSegList& aPath) { + MOZ_ASSERT(aPropId == eCSSProperty_d); return SetSMILValueHelper([&aPath](DeclarationBlock& aDecl) { MOZ_ASSERT(aDecl.IsMutable()); return SVGElement::UpdateDeclarationBlockFromPath( @@ -192,9 +192,10 @@ nsresult nsDOMCSSAttributeDeclaration::SetSMILValue( } nsresult nsDOMCSSAttributeDeclaration::SetSMILValue( - const nsCSSPropertyID aPropID, const SVGAnimatedTransformList* aTransform, + const NonCustomCSSPropertyId aPropId, + const SVGAnimatedTransformList* aTransform, const gfx::Matrix* aAnimateMotionTransform) { - MOZ_ASSERT(aPropID == eCSSProperty_transform); + MOZ_ASSERT(aPropId == eCSSProperty_transform); return SetSMILValueHelper( [aTransform, aAnimateMotionTransform](DeclarationBlock& aDecl) { MOZ_ASSERT(aDecl.IsMutable()); @@ -211,8 +212,8 @@ nsresult nsDOMCSSAttributeDeclaration::SetSMILValue( // // FIXME: This is missing the margin shorthand and the logical versions of // the margin properties, see bug 1266287. -static bool IsActiveLayerProperty(nsCSSPropertyID aPropID) { - switch (aPropID) { +static bool IsActiveLayerProperty(NonCustomCSSPropertyId aPropId) { + switch (aPropId) { case eCSSProperty_opacity: case eCSSProperty_transform: case eCSSProperty_translate: @@ -230,14 +231,15 @@ static bool IsActiveLayerProperty(nsCSSPropertyID aPropID) { } void nsDOMCSSAttributeDeclaration::SetPropertyValue( - const nsCSSPropertyID aPropID, const nsACString& aValue, + const NonCustomCSSPropertyId aPropId, const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv) { - nsDOMCSSDeclaration::SetPropertyValue(aPropID, aValue, aSubjectPrincipal, + nsDOMCSSDeclaration::SetPropertyValue(aPropId, aValue, aSubjectPrincipal, aRv); } -static bool IsScrollLinkedEffectiveProperty(const nsCSSPropertyID aPropID) { - switch (aPropID) { +static bool IsScrollLinkedEffectiveProperty( + const NonCustomCSSPropertyId aPropId) { + switch (aPropId) { case eCSSProperty_background_position: case eCSSProperty_background_position_x: case eCSSProperty_background_position_y: @@ -270,7 +272,7 @@ static bool IsScrollLinkedEffectiveProperty(const nsCSSPropertyID aPropID) { } void nsDOMCSSAttributeDeclaration::MutationClosureFunction( - void* aData, nsCSSPropertyID aPropID) { + void* aData, NonCustomCSSPropertyId aPropId) { auto* data = static_cast<MutationClosureData*>(aData); MOZ_ASSERT( data->mShouldBeCalled, @@ -278,12 +280,12 @@ void nsDOMCSSAttributeDeclaration::MutationClosureFunction( if (data->mWasCalled) { return; } - if (IsScrollLinkedEffectiveProperty(aPropID)) { + if (IsScrollLinkedEffectiveProperty(aPropId)) { mozilla::layers::ScrollLinkedEffectDetector::PositioningPropertyMutated(); } - if (IsActiveLayerProperty(aPropID)) { + if (IsActiveLayerProperty(aPropId)) { if (nsIFrame* frame = data->mElement->GetPrimaryFrame()) { - ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropID); + ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropId); } } diff --git a/layout/style/nsDOMCSSAttrDeclaration.h b/layout/style/nsDOMCSSAttrDeclaration.h @@ -50,24 +50,26 @@ class nsDOMCSSAttributeDeclaration final : public nsDOMCSSDeclaration { nsINode* GetAssociatedNode() const override { return mElement; } nsINode* GetParentObject() const override { return mElement; } - nsresult SetSMILValue(const nsCSSPropertyID aPropID, const SMILValue& aValue); - nsresult SetSMILValue(const nsCSSPropertyID aPropID, + nsresult SetSMILValue(const NonCustomCSSPropertyId aPropId, + const SMILValue& aValue); + nsresult SetSMILValue(const NonCustomCSSPropertyId aPropId, const SVGAnimatedLength& aLength); - nsresult SetSMILValue(const nsCSSPropertyID, + nsresult SetSMILValue(const NonCustomCSSPropertyId, const mozilla::SVGAnimatedPathSegList& aPath); - nsresult SetSMILValue(const nsCSSPropertyID, + nsresult SetSMILValue(const NonCustomCSSPropertyId, const mozilla::SVGAnimatedTransformList*, const mozilla::gfx::Matrix* aAnimateMotion = nullptr); - void ClearSMILValue(const nsCSSPropertyID aPropID) { + void ClearSMILValue(const NonCustomCSSPropertyId aPropId) { // Put empty string in override style for our property - SetPropertyValue(aPropID, ""_ns, nullptr, mozilla::IgnoreErrors()); + SetPropertyValue(aPropId, ""_ns, nullptr, mozilla::IgnoreErrors()); } - void SetPropertyValue(const nsCSSPropertyID aPropID, const nsACString& aValue, + void SetPropertyValue(const NonCustomCSSPropertyId aPropId, + const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv) override; - static void MutationClosureFunction(void* aData, nsCSSPropertyID); + static void MutationClosureFunction(void* aData, NonCustomCSSPropertyId); void GetPropertyChangeClosure( mozilla::DeclarationBlockMutationClosure* aClosure, diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp @@ -32,19 +32,19 @@ JSObject* nsDOMCSSDeclaration::WrapObject(JSContext* aCx, NS_IMPL_QUERY_INTERFACE(nsDOMCSSDeclaration, nsICSSDeclaration) -void nsDOMCSSDeclaration::GetPropertyValue(const nsCSSPropertyID aPropID, +void nsDOMCSSDeclaration::GetPropertyValue(const NonCustomCSSPropertyId aPropId, nsACString& aValue) { - MOZ_ASSERT(aPropID != eCSSProperty_UNKNOWN, + MOZ_ASSERT(aPropId != eCSSProperty_UNKNOWN, "Should never pass eCSSProperty_UNKNOWN around"); MOZ_ASSERT(aValue.IsEmpty()); if (DeclarationBlock* decl = GetOrCreateCSSDeclaration(Operation::Read, nullptr)) { - decl->GetPropertyValueByID(aPropID, aValue); + decl->GetPropertyValueById(aPropId, aValue); } } -void nsDOMCSSDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID, +void nsDOMCSSDeclaration::SetPropertyValue(const NonCustomCSSPropertyId aPropId, const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv) { @@ -55,10 +55,10 @@ void nsDOMCSSDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID, if (aValue.IsEmpty()) { // If the new value of the property is an empty string we remove the // property. - return RemovePropertyInternal(aPropID, aRv); + return RemovePropertyInternal(aPropId, aRv); } - aRv = ParsePropertyValue(aPropID, aValue, false, aSubjectPrincipal); + aRv = ParsePropertyValue(aPropId, aValue, false, aSubjectPrincipal); } void nsDOMCSSDeclaration::GetCssText(nsACString& aCssText) { @@ -166,8 +166,8 @@ void nsDOMCSSDeclaration::SetProperty(const nsACString& aPropertyName, } // In the common (and fast) cases we can use the property id - nsCSSPropertyID propID = nsCSSProps::LookupProperty(aPropertyName); - if (propID == eCSSProperty_UNKNOWN) { + NonCustomCSSPropertyId propId = nsCSSProps::LookupProperty(aPropertyName); + if (propId == eCSSProperty_UNKNOWN) { return; } @@ -181,12 +181,12 @@ void nsDOMCSSDeclaration::SetProperty(const nsACString& aPropertyName, return; } - if (propID == eCSSPropertyExtra_variable) { + if (propId == eCSSPropertyExtra_variable) { aRv = ParseCustomPropertyValue(aPropertyName, aValue, important, aSubjectPrincipal); return; } - aRv = ParsePropertyValue(propID, aValue, important, aSubjectPrincipal); + aRv = ParsePropertyValue(propId, aValue, important, aSubjectPrincipal); } void nsDOMCSSDeclaration::RemoveProperty(const nsACString& aPropertyName, @@ -266,7 +266,7 @@ nsresult nsDOMCSSDeclaration::ModifyDeclaration( } nsresult nsDOMCSSDeclaration::ParsePropertyValue( - const nsCSSPropertyID aPropID, const nsACString& aPropValue, + const NonCustomCSSPropertyId aPropId, const nsACString& aPropValue, bool aIsImportant, nsIPrincipal* aSubjectPrincipal) { AUTO_PROFILER_LABEL_CATEGORY_PAIR_RELEVANT_FOR_JS(LAYOUT_CSSParsing); @@ -282,7 +282,7 @@ nsresult nsDOMCSSDeclaration::ParsePropertyValue( aSubjectPrincipal, &closureData, [&](DeclarationBlock* decl, ParsingEnvironment& env) { return Servo_DeclarationBlock_SetPropertyById( - decl->Raw(), aPropID, &aPropValue, aIsImportant, env.mUrlExtraData, + decl->Raw(), aPropId, &aPropValue, aIsImportant, env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, env.mLoader, env.mRuleType, closure); }); @@ -311,7 +311,7 @@ nsresult nsDOMCSSDeclaration::ParseCustomPropertyValue( }); } -void nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID, +void nsDOMCSSDeclaration::RemovePropertyInternal(NonCustomCSSPropertyId aPropId, ErrorResult& aRv) { DeclarationBlock* olddecl = GetOrCreateCSSDeclaration(Operation::RemoveProperty, nullptr); @@ -335,7 +335,7 @@ void nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID, GetPropertyChangeClosure(&closure, &closureData); RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable(); - if (!decl->RemovePropertyByID(aPropID, closure)) { + if (!decl->RemovePropertyById(aPropId, closure)) { return; } aRv = SetCSSDeclaration(decl, &closureData); diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h @@ -67,7 +67,7 @@ class nsDOMCSSDeclaration : public nsICSSDeclaration { * Method analogous to CSSStyleDeclaration::GetPropertyValue, * which obeys all the same restrictions. */ - virtual void GetPropertyValue(const nsCSSPropertyID aPropID, + virtual void GetPropertyValue(const NonCustomCSSPropertyId aPropId, nsACString& aValue); /** @@ -75,7 +75,7 @@ class nsDOMCSSDeclaration : public nsICSSDeclaration { * method does NOT allow setting a priority (the priority will * always be set to default priority). */ - virtual void SetPropertyValue(const nsCSSPropertyID aPropID, + virtual void SetPropertyValue(const NonCustomCSSPropertyId aPropId, const nsACString& aValue, nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv); @@ -161,7 +161,7 @@ class nsDOMCSSDeclaration : public nsICSSDeclaration { static ParsingEnvironment GetParsingEnvironmentForRule( const mozilla::css::Rule* aRule, mozilla::StyleCssRuleType); - nsresult ParsePropertyValue(const nsCSSPropertyID aPropID, + nsresult ParsePropertyValue(const NonCustomCSSPropertyId aPropId, const nsACString& aPropValue, bool aIsImportant, nsIPrincipal* aSubjectPrincipal); @@ -170,7 +170,7 @@ class nsDOMCSSDeclaration : public nsICSSDeclaration { bool aIsImportant, nsIPrincipal* aSubjectPrincipal); - void RemovePropertyInternal(nsCSSPropertyID aPropID, + void RemovePropertyInternal(NonCustomCSSPropertyId aPropId, mozilla::ErrorResult& aRv); void RemovePropertyInternal(const nsACString& aPropert, mozilla::ErrorResult& aRv); diff --git a/layout/style/nsICSSDeclaration.h b/layout/style/nsICSSDeclaration.h @@ -14,14 +14,14 @@ /** * This interface provides access to methods analogous to those of - * CSSStyleDeclaration; the difference is that these use nsCSSPropertyID + * CSSStyleDeclaration; the difference is that these use NonCustomCSSPropertyId * enums for the prop names instead of using strings. */ +#include "NonCustomCSSPropertyId.h" #include "mozilla/ErrorResult.h" #include "mozilla/dom/CSSValue.h" #include "nsCOMPtr.h" -#include "nsCSSPropertyID.h" #include "nsStringFwd.h" #include "nsWrapperCache.h" diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp @@ -1678,7 +1678,7 @@ ImageResolution StyleImage::GetResolution( // nsStyleImageLayers // -const nsCSSPropertyID nsStyleImageLayers::kBackgroundLayerTable[] = { +const NonCustomCSSPropertyId nsStyleImageLayers::kBackgroundLayerTable[] = { eCSSProperty_background, // shorthand eCSSProperty_background_color, // color eCSSProperty_background_image, // image @@ -1693,7 +1693,7 @@ const nsCSSPropertyID nsStyleImageLayers::kBackgroundLayerTable[] = { eCSSProperty_UNKNOWN // composite }; -const nsCSSPropertyID nsStyleImageLayers::kMaskLayerTable[] = { +const NonCustomCSSPropertyId nsStyleImageLayers::kMaskLayerTable[] = { eCSSProperty_mask, // shorthand eCSSProperty_UNKNOWN, // color eCSSProperty_mask_image, // image diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h @@ -331,8 +331,8 @@ struct nsStyleImageLayers { nsStyleImageLayers& operator=(nsStyleImageLayers&& aOther) = default; bool operator==(const nsStyleImageLayers& aOther) const; - static const nsCSSPropertyID kBackgroundLayerTable[]; - static const nsCSSPropertyID kMaskLayerTable[]; + static const NonCustomCSSPropertyId kBackgroundLayerTable[]; + static const NonCustomCSSPropertyId kMaskLayerTable[]; #define NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(var_, layers_) \ for (uint32_t var_ = (layers_).mImageCount; (var_)-- != 0;) diff --git a/layout/style/nsStyleUtil.h b/layout/style/nsStyleUtil.h @@ -6,8 +6,8 @@ #ifndef nsStyleUtil_h___ #define nsStyleUtil_h___ +#include "NonCustomCSSPropertyId.h" #include "nsCRT.h" -#include "nsCSSPropertyID.h" #include "nsColor.h" #include "nsCoord.h" #include "nsGkAtoms.h" diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp @@ -57,7 +57,7 @@ bool nsTransitionManager::UpdateTransitions( // This function expands the shorthands and "all" keyword specified in // transition-property, and then execute |aHandler| on the expanded longhand. -// |aHandler| should be a lamda function which accepts nsCSSPropertyID. +// |aHandler| should be a lamda function which accepts NonCustomCSSPropertyId. template <typename T> static void ExpandTransitionProperty(const StyleTransitionProperty& aProperty, T aHandler) { @@ -70,7 +70,8 @@ static void ExpandTransitionProperty(const StyleTransitionProperty& aProperty, break; } case StyleTransitionProperty::Tag::NonCustom: { - nsCSSPropertyID id = nsCSSPropertyID(aProperty.AsNonCustom()._0); + NonCustomCSSPropertyId id = + NonCustomCSSPropertyId(aProperty.AsNonCustom()._0); if (nsCSSProps::IsShorthand(id)) { CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, id, CSSEnabledState::ForAllContent) { @@ -262,7 +263,7 @@ bool nsTransitionManager::ConsiderInitiatingTransition( const ComputedStyle& aOldStyle, const ComputedStyle& aNewStyle, AnimatedPropertyIDSet& aPropertiesChecked) { // IsShorthand itself will assert if aProperty is not a property. - MOZ_ASSERT(aProperty.IsCustom() || !nsCSSProps::IsShorthand(aProperty.mID), + MOZ_ASSERT(aProperty.IsCustom() || !nsCSSProps::IsShorthand(aProperty.mId), "property out of range"); NS_ASSERTION( !aElementTransitions || &aElementTransitions->mElement == aElement, diff --git a/layout/style/typedom/StylePropertyMap.cpp b/layout/style/typedom/StylePropertyMap.cpp @@ -42,8 +42,8 @@ void StylePropertyMap::Set( ErrorResult& aRv) { // Step 2. - nsCSSPropertyID propID = nsCSSProps::LookupProperty(aProperty); - if (propID == eCSSProperty_UNKNOWN) { + NonCustomCSSPropertyId propId = nsCSSProps::LookupProperty(aProperty); + if (propId == eCSSProperty_UNKNOWN) { aRv.ThrowTypeError("Invalid property: "_ns + aProperty); return; } diff --git a/servo/components/style/properties/data.py b/servo/components/style/properties/data.py @@ -344,8 +344,8 @@ class Property(object): def is_prioritary(self): return self.name in PRIORITARY_PROPERTIES - def nscsspropertyid(self): - return "nsCSSPropertyID::eCSSProperty_" + self.ident + def noncustomcsspropertyid(self): + return "NonCustomCSSPropertyId::eCSSProperty_" + self.ident class Longhand(Property): @@ -761,8 +761,8 @@ class Alias(object): def enabled_in_content(self): return self.enabled_in == "content" - def nscsspropertyid(self): - return "nsCSSPropertyID::eCSSPropertyAlias_%s" % self.ident + def noncustomcsspropertyid(self): + return "NonCustomCSSPropertyId::eCSSPropertyAlias_%s" % self.ident class Method(object): diff --git a/servo/components/style/properties/helpers/animated_properties.mako.rs b/servo/components/style/properties/helpers/animated_properties.mako.rs @@ -9,7 +9,7 @@ from itertools import groupby %> -#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::nsCSSPropertyID; +#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::NonCustomCSSPropertyId; use crate::properties::{ longhands::{ self, visibility::computed_value::T as Visibility, @@ -36,12 +36,12 @@ use crate::values::generics::effects::Filter; use void::{self, Void}; use crate::properties_and_values::value::CustomAnimatedValue; -/// Convert nsCSSPropertyID to TransitionProperty +/// Convert NonCustomCSSPropertyId to TransitionProperty #[cfg(feature = "gecko")] #[allow(non_upper_case_globals)] -impl From<nsCSSPropertyID> for TransitionProperty { - fn from(property: nsCSSPropertyID) -> TransitionProperty { - TransitionProperty::NonCustom(NonCustomPropertyId::from_nscsspropertyid(property).unwrap()) +impl From<NonCustomCSSPropertyId> for TransitionProperty { + fn from(property: NonCustomCSSPropertyId) -> TransitionProperty { + TransitionProperty::NonCustom(NonCustomPropertyId::from_noncustomcsspropertyid(property).unwrap()) } } 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::{nsCSSPropertyID, AnimatedPropertyID, RefPtr}; +use crate::gecko_bindings::structs::{AnimatedPropertyID, NonCustomCSSPropertyId, RefPtr}; use crate::logical_geometry::WritingMode; use crate::parser::ParserContext; use crate::stylesheets::CssRuleType; @@ -218,23 +218,23 @@ impl NonCustomPropertyId { self.0 as usize } - /// Convert a `NonCustomPropertyId` into a `nsCSSPropertyID`. + /// Convert a `NonCustomPropertyId` into a `NonCustomCSSPropertyId`. #[cfg(feature = "gecko")] #[inline] - pub fn to_nscsspropertyid(self) -> nsCSSPropertyID { - // unsafe: guaranteed by static_assert_nscsspropertyid. + pub fn to_noncustomcsspropertyid(self) -> NonCustomCSSPropertyId { + // unsafe: guaranteed by static_assert_noncustomcsspropertyid. unsafe { mem::transmute(self.0 as i32) } } - /// Convert an `nsCSSPropertyID` into a `NonCustomPropertyId`. + /// Convert an `NonCustomCSSPropertyId` into a `NonCustomPropertyId`. #[cfg(feature = "gecko")] #[inline] - pub fn from_nscsspropertyid(prop: nsCSSPropertyID) -> Option<Self> { + pub fn from_noncustomcsspropertyid(prop: NonCustomCSSPropertyId) -> Option<Self> { let prop = prop as i32; if prop < 0 || prop >= property_counts::NON_CUSTOM as i32 { return None; } - // guaranteed by static_assert_nscsspropertyid above. + // guaranteed by static_assert_noncustomcsspropertyid above. Some(NonCustomPropertyId(prop as u16)) } @@ -419,11 +419,11 @@ impl PropertyId { Ok(id) } - /// Returns a property id from Gecko's nsCSSPropertyID. + /// Returns a property id from Gecko's NonCustomCSSPropertyId. #[cfg(feature = "gecko")] #[inline] - pub fn from_nscsspropertyid(id: nsCSSPropertyID) -> Option<Self> { - Some(NonCustomPropertyId::from_nscsspropertyid(id)?.to_property_id()) + pub fn from_noncustomcsspropertyid(id: NonCustomCSSPropertyId) -> Option<Self> { + Some(NonCustomPropertyId::from_noncustomcsspropertyid(id)?.to_property_id()) } /// Returns a property id from Gecko's AnimatedPropertyID. @@ -431,11 +431,13 @@ impl PropertyId { #[inline] pub fn from_gecko_animated_property_id(property: &AnimatedPropertyID) -> Option<Self> { Some( - if property.mID == nsCSSPropertyID::eCSSPropertyExtra_variable { + if property.mId == NonCustomCSSPropertyId::eCSSPropertyExtra_variable { debug_assert!(!property.mCustomName.mRawPtr.is_null()); Self::Custom(unsafe { crate::Atom::from_raw(property.mCustomName.mRawPtr) }) } else { - Self::NonCustom(NonCustomPropertyId::from_nscsspropertyid(property.mID)?) + Self::NonCustom(NonCustomPropertyId::from_noncustomcsspropertyid( + property.mId, + )?) }, ) } @@ -485,15 +487,15 @@ impl PropertyId { id.enabled_for_all_content() } - /// Converts this PropertyId in nsCSSPropertyID, resolving aliases to the + /// Converts this PropertyId in NonCustomCSSPropertyId, resolving aliases to the /// resolved property, and returning eCSSPropertyExtra_variable for custom /// properties. #[cfg(feature = "gecko")] #[inline] - pub fn to_nscsspropertyid_resolving_aliases(&self) -> nsCSSPropertyID { + pub fn to_noncustomcsspropertyid_resolving_aliases(&self) -> NonCustomCSSPropertyId { match self.non_custom_non_alias_id() { - Some(id) => id.to_nscsspropertyid(), - None => nsCSSPropertyID::eCSSPropertyExtra_variable, + Some(id) => id.to_noncustomcsspropertyid(), + None => NonCustomCSSPropertyId::eCSSPropertyExtra_variable, } } @@ -607,17 +609,17 @@ impl LonghandId { LonghandIdSet::discrete_animatable().contains(self) } - /// Converts from a LonghandId to an adequate nsCSSPropertyID. + /// Converts from a LonghandId to an adequate NonCustomCSSPropertyId. #[cfg(feature = "gecko")] #[inline] - pub fn to_nscsspropertyid(self) -> nsCSSPropertyID { - NonCustomPropertyId::from(self).to_nscsspropertyid() + pub fn to_noncustomcsspropertyid(self) -> NonCustomCSSPropertyId { + NonCustomPropertyId::from(self).to_noncustomcsspropertyid() } #[cfg(feature = "gecko")] - /// Returns a longhand id from Gecko's nsCSSPropertyID. - pub fn from_nscsspropertyid(id: nsCSSPropertyID) -> Option<Self> { - NonCustomPropertyId::from_nscsspropertyid(id)? + /// Returns a longhand id from Gecko's NonCustomCSSPropertyId. + pub fn from_noncustomcsspropertyid(id: NonCustomCSSPropertyId) -> Option<Self> { + NonCustomPropertyId::from_noncustomcsspropertyid(id)? .unaliased() .as_longhand() } @@ -646,18 +648,18 @@ impl ShorthandId { NonCustomPropertyId::from(*self).name() } - /// Converts from a ShorthandId to an adequate nsCSSPropertyID. + /// Converts from a ShorthandId to an adequate NonCustomCSSPropertyId. #[cfg(feature = "gecko")] #[inline] - pub fn to_nscsspropertyid(self) -> nsCSSPropertyID { - NonCustomPropertyId::from(self).to_nscsspropertyid() + pub fn to_noncustomcsspropertyid(self) -> NonCustomCSSPropertyId { + NonCustomPropertyId::from(self).to_noncustomcsspropertyid() } - /// Converts from a nsCSSPropertyID to a ShorthandId. + /// Converts from a NonCustomCSSPropertyId to a ShorthandId. #[cfg(feature = "gecko")] #[inline] - pub fn from_nscsspropertyid(id: nsCSSPropertyID) -> Option<Self> { - NonCustomPropertyId::from_nscsspropertyid(id)? + pub fn from_noncustomcsspropertyid(id: NonCustomCSSPropertyId) -> Option<Self> { + NonCustomPropertyId::from_noncustomcsspropertyid(id)? .unaliased() .as_shorthand() } @@ -1121,14 +1123,14 @@ impl<'a> PropertyDeclarationId<'a> { } } - /// Converts from a to an adequate nsCSSPropertyID, returning + /// Converts from a to an adequate NonCustomCSSPropertyId, returning /// eCSSPropertyExtra_variable for custom properties. #[cfg(feature = "gecko")] #[inline] - pub fn to_nscsspropertyid(self) -> nsCSSPropertyID { + pub fn to_noncustomcsspropertyid(self) -> NonCustomCSSPropertyId { match self { - PropertyDeclarationId::Longhand(id) => id.to_nscsspropertyid(), - PropertyDeclarationId::Custom(_) => nsCSSPropertyID::eCSSPropertyExtra_variable, + PropertyDeclarationId::Longhand(id) => id.to_noncustomcsspropertyid(), + PropertyDeclarationId::Custom(_) => NonCustomCSSPropertyId::eCSSPropertyExtra_variable, } } @@ -1141,12 +1143,12 @@ impl<'a> PropertyDeclarationId<'a> { pub fn to_gecko_animated_property_id(&self) -> AnimatedPropertyID { match self { Self::Longhand(id) => AnimatedPropertyID { - mID: id.to_nscsspropertyid(), + mId: id.to_noncustomcsspropertyid(), mCustomName: RefPtr::null(), }, Self::Custom(name) => { let mut property_id = AnimatedPropertyID { - mID: nsCSSPropertyID::eCSSPropertyExtra_variable, + mId: NonCustomCSSPropertyId::eCSSPropertyExtra_variable, mCustomName: RefPtr::null(), }; property_id.mCustomName.mRawPtr = (*name).clone().into_addrefed(); diff --git a/servo/components/style/properties/properties.mako.rs b/servo/components/style/properties/properties.mako.rs @@ -11,7 +11,7 @@ use std::{ops, ptr}; use std::{fmt, mem}; #[cfg(feature = "servo")] use euclid::SideOffsets2D; -#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::{self, nsCSSPropertyID}; +#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::{self, NonCustomCSSPropertyId}; #[cfg(feature = "servo")] use crate::logical_geometry::LogicalMargin; #[cfg(feature = "servo")] use crate::computed_values; use crate::logical_geometry::WritingMode; @@ -475,9 +475,9 @@ pub mod property_counts { % if engine == "gecko": #[allow(dead_code)] -unsafe fn static_assert_nscsspropertyid() { +unsafe fn static_assert_noncustomcsspropertyid() { % for i, property in enumerate(data.longhands + data.shorthands + data.all_aliases()): - std::mem::transmute::<[u8; ${i}], [u8; ${property.nscsspropertyid()} as usize]>([0; ${i}]); // ${property.name} + std::mem::transmute::<[u8; ${i}], [u8; ${property.noncustomcsspropertyid()} as usize]>([0; ${i}]); // ${property.name} % endfor } % endif diff --git a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml @@ -380,7 +380,7 @@ renaming_overrides_prefixing = true "ComputedTiming" = "ComputedTiming" "CountedUnknownProperty" = "CountedUnknownProperty" "RefPtr" = "RefPtr" -"nsCSSPropertyID" = "nsCSSPropertyID" +"NonCustomCSSPropertyId" = "NonCustomCSSPropertyId" "nsCSSPropertyIDSet" = "nsCSSPropertyIDSet" "AnimatedPropertyID" = "AnimatedPropertyID" "nsCSSValueSharedList" = "nsCSSValueSharedList" @@ -1207,7 +1207,7 @@ renaming_overrides_prefixing = true "TransitionProperty" = """ bool IsAll() const { return IsNonCustom() && - nsCSSPropertyID(AsNonCustom()._0) == eCSSProperty_all; + NonCustomCSSPropertyId(AsNonCustom()._0) == eCSSProperty_all; } """ diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs @@ -66,7 +66,6 @@ use style::gecko_bindings::structs::gfxFontFeatureValueSet; use style::gecko_bindings::structs::nsAtom; use style::gecko_bindings::structs::nsCSSCounterDesc; use style::gecko_bindings::structs::nsCSSFontDesc; -use style::gecko_bindings::structs::nsCSSPropertyID; use style::gecko_bindings::structs::nsChangeHint; use style::gecko_bindings::structs::nsCompatibility; use style::gecko_bindings::structs::nsresult; @@ -78,6 +77,7 @@ use style::gecko_bindings::structs::IterationCompositeOperation; use style::gecko_bindings::structs::Loader; use style::gecko_bindings::structs::LoaderReusableStyleSheets; use style::gecko_bindings::structs::MallocSizeOf as GeckoMallocSizeOf; +use style::gecko_bindings::structs::NonCustomCSSPropertyId; use style::gecko_bindings::structs::OriginFlags; use style::gecko_bindings::structs::PropertyValuePair; use style::gecko_bindings::structs::PseudoStyleType; @@ -197,8 +197,8 @@ impl ClosureHelper for DeclarationBlockMutationClosure { fn invoke(&self, property_id: Option<NonCustomPropertyId>) { if let Some(function) = self.function.as_ref() { let gecko_prop_id = match property_id { - Some(p) => p.to_nscsspropertyid(), - None => nsCSSPropertyID::eCSSPropertyExtra_variable, + Some(p) => p.to_noncustomcsspropertyid(), + None => NonCustomCSSPropertyId::eCSSPropertyExtra_variable, }; unsafe { function(self.data, gecko_prop_id) } } @@ -716,9 +716,9 @@ pub extern "C" fn Servo_AnimationCompose( value_map.insert(property, result); } -macro_rules! get_property_id_from_nscsspropertyid { +macro_rules! get_property_id_from_noncustomcsspropertyid { ($property_id: ident, $ret: expr) => {{ - match PropertyId::from_nscsspropertyid($property_id) { + match PropertyId::from_noncustomcsspropertyid($property_id) { Some(property_id) => property_id, None => { return $ret; @@ -809,13 +809,13 @@ pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> Strong<Animation #[no_mangle] pub extern "C" fn Servo_AnimationValue_Color( - color_property: nsCSSPropertyID, + color_property: NonCustomCSSPropertyId, color: structs::nscolor, ) -> Strong<AnimationValue> { use style::gecko::values::convert_nscolor_to_absolute_color; use style::values::animated::color::Color; - let property = LonghandId::from_nscsspropertyid(color_property) + let property = LonghandId::from_noncustomcsspropertyid(color_property) .expect("We don't have shorthand property animation value"); let animated = convert_nscolor_to_absolute_color(color); @@ -1332,33 +1332,33 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue( #[no_mangle] pub extern "C" fn Servo_ResolveLogicalProperty( - property_id: nsCSSPropertyID, + property_id: NonCustomCSSPropertyId, style: &ComputedValues, -) -> nsCSSPropertyID { - let longhand = LonghandId::from_nscsspropertyid(property_id) +) -> NonCustomCSSPropertyId { + let longhand = LonghandId::from_noncustomcsspropertyid(property_id) .expect("We shouldn't need to care about shorthands"); longhand .to_physical(style.writing_mode) - .to_nscsspropertyid() + .to_noncustomcsspropertyid() } #[no_mangle] pub unsafe extern "C" fn Servo_Property_LookupEnabledForAllContent( prop: &nsACString, -) -> nsCSSPropertyID { +) -> NonCustomCSSPropertyId { match PropertyId::parse_enabled_for_all_content(prop.as_str_unchecked()) { - Ok(p) => p.to_nscsspropertyid_resolving_aliases(), - Err(..) => nsCSSPropertyID::eCSSProperty_UNKNOWN, + Ok(p) => p.to_noncustomcsspropertyid_resolving_aliases(), + Err(..) => NonCustomCSSPropertyId::eCSSProperty_UNKNOWN, } } #[no_mangle] pub unsafe extern "C" fn Servo_Property_GetName( - prop: nsCSSPropertyID, + prop: NonCustomCSSPropertyId, out_length: *mut u32, ) -> *const u8 { - let (ptr, len) = match NonCustomPropertyId::from_nscsspropertyid(prop) { + let (ptr, len) = match NonCustomPropertyId::from_noncustomcsspropertyid(prop) { Some(p) => { let name = p.name(); (name.as_bytes().as_ptr(), name.len()) @@ -1458,8 +1458,8 @@ pub extern "C" fn Servo_Property_IsAnimatable(prop: &structs::AnimatedPropertyID } #[no_mangle] -pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) -> bool { - match LonghandId::from_nscsspropertyid(property) { +pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: NonCustomCSSPropertyId) -> bool { + match LonghandId::from_noncustomcsspropertyid(property) { Some(longhand) => longhand.is_discrete_animatable(), None => return false, } @@ -5085,7 +5085,7 @@ pub extern "C" fn Servo_SerializeEasing(easing: &ComputedTimingFunction, output: #[no_mangle] pub extern "C" fn Servo_GetProperties_Overriding_Animation( element: &RawGeckoElement, - list: &nsTArray<nsCSSPropertyID>, + list: &nsTArray<NonCustomCSSPropertyId>, set: &mut structs::nsCSSPropertyIDSet, ) { let element = GeckoElement(element); @@ -5102,7 +5102,7 @@ pub extern "C" fn Servo_GetProperties_Overriding_Animation( .rules() .get_properties_overriding_animations(&guards); for p in list.iter() { - match NonCustomPropertyId::from_nscsspropertyid(*p) { + match NonCustomPropertyId::from_noncustomcsspropertyid(*p) { Some(property) => { if let Some(id) = property.as_longhand() { if overridden.contains(id) { @@ -5111,7 +5111,7 @@ pub extern "C" fn Servo_GetProperties_Overriding_Animation( } }, None => { - if *p == nsCSSPropertyID::eCSSPropertyExtra_variable && custom { + if *p == NonCustomCSSPropertyId::eCSSPropertyExtra_variable && custom { unsafe { Gecko_AddPropertyToSet(set, *p) }; } }, @@ -5357,12 +5357,12 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_GetPropertyValue( #[no_mangle] pub unsafe extern "C" fn Servo_DeclarationBlock_GetPropertyValueById( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: &mut nsACString, ) { get_property_value( declarations, - get_property_id_from_nscsspropertyid!(property, ()), + get_property_id_from_noncustomcsspropertyid!(property, ()), value, ) } @@ -5576,7 +5576,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyToAnimationValue( #[no_mangle] pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyById( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: &nsACString, is_important: bool, data: *mut URLExtraData, @@ -5588,7 +5588,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyById( ) -> bool { set_property( declarations, - get_property_id_from_nscsspropertyid!(property, false), + get_property_id_from_noncustomcsspropertyid!(property, false), value, is_important, UrlExtraData::from_ptr_ref(&data), @@ -5638,12 +5638,12 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_RemoveProperty( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_RemovePropertyById( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, before_change_closure: DeclarationBlockMutationClosure, ) -> bool { remove_property( declarations, - get_property_id_from_nscsspropertyid!(property, false), + get_property_id_from_noncustomcsspropertyid!(property, false), before_change_closure, ) } @@ -5680,9 +5680,9 @@ pub extern "C" fn Servo_MediaList_Matches( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_HasCSSWideKeyword( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, ) -> bool { - let property_id = get_property_id_from_nscsspropertyid!(property, false); + let property_id = get_property_id_from_noncustomcsspropertyid!(property, false); read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| { decls.has_css_wide_keyword(&property_id) }) @@ -5829,7 +5829,7 @@ pub extern "C" fn Servo_MediaList_SizeOfIncludingThis( macro_rules! get_longhand_from_id { ($id:expr) => { - match LonghandId::from_nscsspropertyid($id) { + match LonghandId::from_noncustomcsspropertyid($id) { Some(lh) => lh, _ => panic!("stylo: unknown presentation property with id"), } @@ -5852,7 +5852,7 @@ macro_rules! match_wrap_declared { #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, ) -> bool { read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| { decls.contains(PropertyDeclarationId::Longhand(get_longhand_from_id!( @@ -5864,7 +5864,7 @@ pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet( #[no_mangle] pub unsafe extern "C" fn Servo_DeclarationBlock_SetIdentStringValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: *mut nsAtom, ) { use style::properties::longhands::_x_lang::computed_value::T as Lang; @@ -5883,7 +5883,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetIdentStringValue( #[allow(unreachable_code)] pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: i32, ) -> bool { use num_traits::FromPrimitive; @@ -5960,7 +5960,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetIntValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: i32, ) { use style::properties::PropertyDeclaration; @@ -6035,7 +6035,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetCounterSetListItem( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetPixelValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: f32, ) { use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing; @@ -6095,7 +6095,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetLengthValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: f32, unit: structs::nsCSSUnit, ) -> bool { @@ -6183,7 +6183,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetTransform( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, ops: &nsTArray<computed::TransformOperation>, ) -> bool { use style::properties::PropertyDeclaration; @@ -6210,7 +6210,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetTransform( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetBackdropFilter( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, filters: &style::OwnedSlice<Filter>, ) -> bool { use style::properties::longhands::backdrop_filter::SpecifiedValue as BackdropFilters; @@ -6238,7 +6238,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackdropFilter( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetColorScheme( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, color_scheme: &style::values::computed::ColorScheme, ) -> bool { use style::properties::PropertyDeclaration; @@ -6260,7 +6260,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetColorScheme( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetPathValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, path: &specified::SVGPathData, ) { use style::properties::PropertyDeclaration; @@ -6366,7 +6366,7 @@ pub extern "C" fn Servo_SVGPathData_Interpolate( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetPercentValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: f32, ) { use style::properties::PropertyDeclaration; @@ -6405,7 +6405,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetAutoValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, ) { use style::properties::PropertyDeclaration; use style::values::generics::length::{GenericMargin, Size}; @@ -6430,7 +6430,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, ) { use style::properties::PropertyDeclaration; use style::values::specified::Color; @@ -6452,7 +6452,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor( #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetColorValue( declarations: &LockedDeclarationBlock, - property: nsCSSPropertyID, + property: NonCustomCSSPropertyId, value: structs::nscolor, ) { use style::gecko::values::convert_nscolor_to_absolute_color; @@ -6954,7 +6954,7 @@ impl<'a> PrioritizedPropertyIter<'a> { fn new(properties: &'a [PropertyValuePair]) -> Self { use style::values::animated::compare_property_priority; - // If we fail to convert a nsCSSPropertyID into a PropertyId we + // If we fail to convert a NonCustomCSSPropertyId into a PropertyId we // shouldn't fail outright but instead by treating that property as the // 'all' property we make it sort last. let mut sorted_property_indices: Box<[PropertyAndIndex]> = properties @@ -8428,24 +8428,24 @@ fn computed_or_resolved_value( #[no_mangle] pub unsafe extern "C" fn Servo_GetComputedValue( style: &ComputedValues, - prop: nsCSSPropertyID, + prop: NonCustomCSSPropertyId, value: &mut nsACString, ) { - let prop = NonCustomPropertyId::from_nscsspropertyid(prop).unwrap(); + let prop = NonCustomPropertyId::from_noncustomcsspropertyid(prop).unwrap(); computed_or_resolved_value(style, prop, None, value) } #[no_mangle] pub unsafe extern "C" fn Servo_GetResolvedValue( style: &ComputedValues, - prop: nsCSSPropertyID, + prop: NonCustomCSSPropertyId, raw_data: &PerDocumentStyleData, element: &RawGeckoElement, value: &mut nsACString, ) { let data = raw_data.borrow(); let device = data.stylist.device(); - let prop = NonCustomPropertyId::from_nscsspropertyid(prop).unwrap(); + let prop = NonCustomPropertyId::from_noncustomcsspropertyid(prop).unwrap(); let mut context = resolved::Context { style, device, @@ -9444,9 +9444,9 @@ pub unsafe extern "C" fn Servo_UseCounters_Merge( #[no_mangle] pub unsafe extern "C" fn Servo_IsPropertyIdRecordedInUseCounter( use_counters: &UseCounters, - id: nsCSSPropertyID, + id: NonCustomCSSPropertyId, ) -> bool { - let id = NonCustomPropertyId::from_nscsspropertyid(id).unwrap(); + let id = NonCustomPropertyId::from_noncustomcsspropertyid(id).unwrap(); use_counters.non_custom_properties.recorded(id) }