Bug 1328319 part 7 - Enable querying counter-style rule on Servo backend. r?heycam
MozReview-Commit-ID: Aj3AcW1KmRe
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -2003,33 +2003,26 @@ CounterStyleManager::Disconnect()
}
mStyles.Clear();
mPresContext = nullptr;
}
CounterStyle*
CounterStyleManager::BuildCounterStyle(nsIAtom* aName)
{
+ MOZ_ASSERT(NS_IsMainThread());
CounterStyle* data = mStyles.Get(aName);
if (data) {
return data;
}
// It is intentional that the predefined names are case-insensitive
// but the user-defined names case-sensitive.
- // XXXheycam ServoStyleSets do not support custom counter styles yet. Bug
- // 1328319.
StyleSetHandle styleSet = mPresContext->StyleSet();
- // When this assertion is removed, please remove the hack to avoid it in
- // nsStyleList::nsStyleList.
- NS_ASSERTION(styleSet->IsGecko(),
- "stylo: ServoStyleSets do not support custom counter "
- "styles yet");
- nsCSSCounterStyleRule* rule = styleSet->IsGecko() ?
- styleSet->AsGecko()->CounterStyleRuleForName(aName) : nullptr;
+ nsCSSCounterStyleRule* rule = styleSet->CounterStyleRuleForName(aName);
if (rule) {
MOZ_ASSERT(rule->Name() == aName);
data = new (mPresContext) CustomCounterStyle(aName, this, rule);
} else {
int32_t type;
nsDependentAtomString name(aName);
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(name);
if (nsCSSProps::FindKeyword(keyword, nsCSSProps::kListStyleKTable, type)) {
@@ -2060,26 +2053,18 @@ CounterStyleManager::GetBuiltinStyle(int
bool
CounterStyleManager::NotifyRuleChanged()
{
bool changed = false;
for (auto iter = mStyles.Iter(); !iter.Done(); iter.Next()) {
CounterStyle* style = iter.Data();
bool toBeUpdated = false;
bool toBeRemoved = false;
- // XXXheycam ServoStyleSets do not support custom counter styles yet. Bug
- // 1328319.
StyleSetHandle styleSet = mPresContext->StyleSet();
- // When this assertion is removed, please remove the hack to avoid it in
- // nsStyleList::nsStyleList.
- NS_ASSERTION(styleSet->IsGecko(),
- "stylo: ServoStyleSets do not support custom counter "
- "styles yet");
- nsCSSCounterStyleRule* newRule = styleSet->IsGecko() ?
- styleSet->AsGecko()->CounterStyleRuleForName(iter.Key()) : nullptr;
+ nsCSSCounterStyleRule* newRule = styleSet->CounterStyleRuleForName(iter.Key());
if (!newRule) {
if (style->IsCustomStyle()) {
toBeRemoved = true;
}
} else {
if (!style->IsCustomStyle()) {
toBeRemoved = true;
} else {
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -74,16 +74,18 @@ SERVO_BINDING_FUNC(Servo_StyleSet_GetKey
RawServoStyleSetBorrowed set,
const nsACString* property,
nsTimingFunctionBorrowed timing_function,
ServoComputedValuesBorrowed computed_values,
RawGeckoKeyframeListBorrowedMut keyframe_list)
SERVO_BINDING_FUNC(Servo_StyleSet_GetFontFaceRules, void,
RawServoStyleSetBorrowed set,
RawGeckoFontFaceRuleListBorrowedMut list)
+SERVO_BINDING_FUNC(Servo_StyleSet_GetCounterStyleRule, nsCSSCounterStyleRule*,
+ RawServoStyleSetBorrowed set, nsIAtom* name)
SERVO_BINDING_FUNC(Servo_StyleSet_ResolveForDeclarations,
ServoComputedValuesStrong,
RawServoStyleSetBorrowed set,
ServoComputedValuesBorrowedOrNull parent_style,
RawServoDeclarationBlockBorrowed declarations)
// CSSRuleList
SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1038,16 +1038,22 @@ ServoStyleSet::ResolveStyleLazily(Elemen
bool
ServoStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
{
MaybeRebuildStylist();
Servo_StyleSet_GetFontFaceRules(mRawSet.get(), &aArray);
return true;
}
+nsCSSCounterStyleRule*
+ServoStyleSet::CounterStyleRuleForName(nsIAtom* aName)
+{
+ return Servo_StyleSet_GetCounterStyleRule(mRawSet.get(), aName);
+}
+
already_AddRefed<ServoComputedValues>
ServoStyleSet::ResolveForDeclarations(
ServoComputedValuesBorrowedOrNull aParentOrNull,
RawServoDeclarationBlockBorrowed aDeclarations)
{
MaybeRebuildStylist();
return Servo_StyleSet_ResolveForDeclarations(mRawSet.get(),
aParentOrNull,
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -29,16 +29,17 @@ class Element;
} // namespace dom
class CSSStyleSheet;
class ServoRestyleManager;
class ServoStyleSheet;
struct Keyframe;
struct ServoComputedValuesWithParent;
class ServoElementSnapshotTable;
} // namespace mozilla
+class nsCSSCounterStyleRule;
class nsIContent;
class nsIDocument;
class nsStyleContext;
class nsPresContext;
struct nsTimingFunction;
struct RawServoRuleNode;
struct TreeMatchContext;
@@ -305,16 +306,18 @@ public:
nsTArray<ComputedKeyframeValues>
GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
const ServoComputedValuesWithParent&
aServoValues);
bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
+ nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
+
already_AddRefed<ServoComputedValues>
GetBaseComputedValuesForElement(dom::Element* aElement, nsIAtom* aPseudoTag);
/**
* Resolve style for a given declaration block with/without the parent style.
* If the parent style is not specified, the document default computed values
* is used.
*/
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -19,16 +19,17 @@
namespace mozilla {
class CSSStyleSheet;
class ServoStyleSet;
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
+class nsCSSCounterStyleRule;
struct nsFontFaceRuleContainer;
class nsIAtom;
class nsIContent;
class nsIDocument;
class nsStyleContext;
class nsStyleSet;
class nsPresContext;
struct TreeMatchContext;
@@ -169,16 +170,17 @@ public:
mozilla::CSSPseudoElementType aPseudoType,
dom::Element* aPseudoElement,
EventStates aStateMask);
inline void RootStyleContextAdded();
inline void RootStyleContextRemoved();
inline bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
+ inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
private:
// Stores a pointer to an nsStyleSet or a ServoStyleSet. The least
// significant bit is 0 for the former, 1 for the latter. This is
// valid as the least significant bit will never be used for a pointer
// value on platforms we care about.
uintptr_t mValue;
};
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -274,13 +274,19 @@ StyleSetHandle::Ptr::RootStyleContextRem
bool
StyleSetHandle::Ptr::
AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
{
FORWARD(AppendFontFaceRules, (aArray));
}
+nsCSSCounterStyleRule*
+StyleSetHandle::Ptr::CounterStyleRuleForName(nsIAtom* aName)
+{
+ FORWARD(CounterStyleRuleForName, (aName));
+}
+
} // namespace mozilla
#undef FORWARD
#endif // mozilla_StyleSetHandleInlines_h