diff --git a/layout/style/CounterStyleManager.h b/layout/style/CounterStyleManager.h index eddf4d2e92d2..47851fd528ae 100644 --- a/layout/style/CounterStyleManager.h +++ b/layout/style/CounterStyleManager.h @@ -238,18 +238,6 @@ public: bool IsResolved() const { return !IsUnresolved(); } inline void Resolve(CounterStyleManager* aManager); - nsIAtom* AsAtom() const - { - MOZ_ASSERT(IsUnresolved()); - return reinterpret_cast(mRaw & ~eMask); - } - AnonymousCounterStyle* AsAnonymous() const - { - MOZ_ASSERT(IsAnonymous()); - return static_cast( - reinterpret_cast(mRaw & ~eMask)); - } - private: CounterStyle* Get() const { @@ -278,6 +266,17 @@ private: Type GetType() const { return static_cast(mRaw & eMask); } bool IsUnresolved() const { return GetType() == eUnresolvedAtom; } bool IsAnonymous() const { return GetType() == eAnonymousCounterStyle; } + nsIAtom* AsAtom() + { + MOZ_ASSERT(IsUnresolved()); + return reinterpret_cast(mRaw & ~eMask); + } + AnonymousCounterStyle* AsAnonymous() + { + MOZ_ASSERT(IsAnonymous()); + return static_cast( + reinterpret_cast(mRaw & ~eMask)); + } void Reset() { diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 7533588cfb5a..65c3506b848e 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -1453,19 +1453,53 @@ Gecko_CopyCounterStyle(CounterStylePtr* aDst, const CounterStylePtr* aSrc) *aDst = *aSrc; } -nsIAtom* -Gecko_CounterStyle_GetName(const CounterStylePtr* aPtr) -{ - if (!aPtr->IsResolved()) { - return aPtr->AsAtom(); - } - return (*aPtr)->GetStyleName(); +bool +Gecko_CounterStyle_IsNone(const CounterStylePtr* aPtr) { + MOZ_ASSERT(aPtr); + return (*aPtr)->IsNone(); } -const AnonymousCounterStyle* -Gecko_CounterStyle_GetAnonymous(const CounterStylePtr* aPtr) -{ - return aPtr->AsAnonymous(); +bool +Gecko_CounterStyle_IsName(const CounterStylePtr* aPtr) { + return !Gecko_CounterStyle_IsNone(aPtr) && !(*aPtr)->AsAnonymous(); +} + +void +Gecko_CounterStyle_GetName(const CounterStylePtr* aPtr, + nsAString* aResult) { + MOZ_ASSERT(Gecko_CounterStyle_IsName(aPtr)); + nsIAtom* name = (*aPtr)->GetStyleName(); + *aResult = nsDependentAtomString(name); +} + +const nsTArray& +Gecko_CounterStyle_GetSymbols(const CounterStylePtr* aPtr) { + MOZ_ASSERT((*aPtr)->AsAnonymous()); + AnonymousCounterStyle* anonymous = (*aPtr)->AsAnonymous(); + return anonymous->GetSymbols(); +} + +uint8_t +Gecko_CounterStyle_GetSystem(const CounterStylePtr* aPtr) { + MOZ_ASSERT((*aPtr)->AsAnonymous()); + AnonymousCounterStyle* anonymous = (*aPtr)->AsAnonymous(); + return anonymous->GetSystem(); +} + +bool +Gecko_CounterStyle_IsSingleString(const CounterStylePtr* aPtr) { + MOZ_ASSERT(aPtr); + AnonymousCounterStyle* anonymous = (*aPtr)->AsAnonymous(); + return anonymous ? anonymous->IsSingleString() : false; +} + +void +Gecko_CounterStyle_GetSingleString(const CounterStylePtr* aPtr, + nsAString* aResult) { + MOZ_ASSERT(Gecko_CounterStyle_IsSingleString(aPtr)); + const nsTArray& symbols = Gecko_CounterStyle_GetSymbols(aPtr); + MOZ_ASSERT(symbols.Length() == 1); + aResult->Assign(symbols[0]); } already_AddRefed diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index ad189e17ed84..957800e35cab 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -332,9 +332,15 @@ void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr, const nsACString* symbol); void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst, const mozilla::CounterStylePtr* src); -nsIAtom* Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr); -const mozilla::AnonymousCounterStyle* -Gecko_CounterStyle_GetAnonymous(const mozilla::CounterStylePtr* ptr); +bool Gecko_CounterStyle_IsNone(const mozilla::CounterStylePtr* ptr); +bool Gecko_CounterStyle_IsName(const mozilla::CounterStylePtr* ptr); +void Gecko_CounterStyle_GetName(const mozilla::CounterStylePtr* ptr, + nsAString* result); +const nsTArray& Gecko_CounterStyle_GetSymbols(const mozilla::CounterStylePtr* ptr); +uint8_t Gecko_CounterStyle_GetSystem(const mozilla::CounterStylePtr* ptr); +bool Gecko_CounterStyle_IsSingleString(const mozilla::CounterStylePtr* ptr); +void Gecko_CounterStyle_GetSingleString(const mozilla::CounterStylePtr* ptr, + nsAString* result); // background-image style. void Gecko_SetNullImageValue(nsStyleImage* image); diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 5f210d21d4ee..ea720cc89c97 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -123,7 +123,6 @@ whitelist-vars = [ whitelist-types = [ "RawGecko.*", "mozilla::AnimationPropertySegment", - "mozilla::AnonymousCounterStyle", "mozilla::ComputedTiming", "mozilla::ComputedTimingFunction", "mozilla::ComputedTimingFunction::BeforeFlag", @@ -371,7 +370,6 @@ structs-types = [ "mozilla::css::ImageValue", "mozilla::css::URLValue", "mozilla::css::URLValueData", - "mozilla::AnonymousCounterStyle", "mozilla::MallocSizeOf", "mozilla::OriginFlags", "mozilla::Side",