Bug 1370502 - stylo: Implement ServoStyleRule::SelectorMatchesElement. r?emilio
MozReview-Commit-ID: JMoBRHzDQZq
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -152,16 +152,19 @@ SERVO_BINDING_FUNC(Servo_StyleRule_GetSe
SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorTextAtIndex, void,
RawServoStyleRuleBorrowed rule, uint32_t index,
nsAString* result)
SERVO_BINDING_FUNC(Servo_StyleRule_GetSpecificityAtIndex, void,
RawServoStyleRuleBorrowed rule, uint32_t index,
uint64_t* specificity)
SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorCount, void,
RawServoStyleRuleBorrowed rule, uint32_t* count)
+SERVO_BINDING_FUNC(Servo_StyleRule_SelectorMatchesElement, bool,
+ RawServoStyleRuleBorrowed, RawGeckoElementBorrowed,
+ uint32_t index, mozilla::CSSPseudoElementType pseudo_type)
SERVO_BINDING_FUNC(Servo_ImportRule_GetHref, void,
RawServoImportRuleBorrowed rule, nsAString* result)
SERVO_BINDING_FUNC(Servo_ImportRule_GetSheet,
const mozilla::ServoStyleSheet*,
RawServoImportRuleBorrowed rule)
SERVO_BINDING_FUNC(Servo_Keyframe_GetKeyText, void,
RawServoKeyframeBorrowed keyframe, nsAString* result)
// Returns whether it successfully changes the key text.
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -274,13 +274,20 @@ ServoStyleRule::GetSpecificity(uint32_t
}
nsresult
ServoStyleRule::SelectorMatchesElement(Element* aElement,
uint32_t aSelectorIndex,
const nsAString& aPseudo,
bool* aMatches)
{
- // TODO Bug 1370502
+ nsCOMPtr<nsIAtom> pseudoElt = NS_Atomize(aPseudo);
+ const CSSPseudoElementType pseudoType =
+ nsCSSPseudoElements::GetPseudoType(pseudoElt,
+ CSSEnabledState::eIgnoreEnabledState);
+ *aMatches = Servo_StyleRule_SelectorMatchesElement(mRawRule,
+ aElement,
+ aSelectorIndex,
+ pseudoType);
return NS_OK;
}
} // namespace mozilla