Bug 1370502 - stylo: Implement ServoStyleRule::SelectorMatchesElement. r?emilio draft
authorFernando Jimenez Moreno <ferjmoreno@gmail.com>
Tue, 04 Jul 2017 15:37:34 +0200
changeset 603745 2e5e76764b1ff0e883a5f2528d7e39375e6ff3a6
parent 603741 5bed7af5695125fa7aca66239fe15698e0fd4a3c
child 635982 f26096ee823ddd7cbeaa239b61326b621e156956
push id66842
push userferjmoreno@gmail.com
push dateTue, 04 Jul 2017 13:38:03 +0000
reviewersemilio
bugs1370502
milestone56.0a1
Bug 1370502 - stylo: Implement ServoStyleRule::SelectorMatchesElement. r?emilio MozReview-Commit-ID: JMoBRHzDQZq
layout/style/ServoBindingList.h
layout/style/ServoStyleRule.cpp
--- 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