Bug 1410624: style: Hook QuerySelector into stylo. r=heycam
MozReview-Commit-ID: 4uKWN9uqi3r
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2924,25 +2924,36 @@ struct ElementHolder {
Element* ElementAt(uint32_t aIndex) { return nullptr; }
Element* mElement;
};
Element*
nsINode::QuerySelector(const nsAString& aSelector, ErrorResult& aResult)
{
- nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aResult);
- if (!selectorList) {
- // Either we failed (and aResult already has the exception), or this
- // is a pseudo-element-only selector that matches nothing.
- return nullptr;
- }
- ElementHolder holder;
- FindMatchingElements<true, ElementHolder>(this, selectorList, holder, aResult);
- return holder.mElement;
+ return WithSelectorList<Element*>(
+ aSelector,
+ aResult,
+ [&](const RawServoSelectorList* aList) -> Element* {
+ if (!aList) {
+ return nullptr;
+ }
+ return const_cast<Element*>(Servo_SelectorList_QueryFirst(this, aList));
+ },
+ [&](nsCSSSelectorList* aList) -> Element* {
+ if (!aList) {
+ // Either we failed (and aResult already has the exception), or this
+ // is a pseudo-element-only selector that matches nothing.
+ return nullptr;
+ }
+ ElementHolder holder;
+ FindMatchingElements<true, ElementHolder>(this, aList, holder, aResult);
+ return holder.mElement;
+ }
+ );
}
already_AddRefed<nsINodeList>
nsINode::QuerySelectorAll(const nsAString& aSelector, ErrorResult& aResult)
{
RefPtr<nsSimpleContentList> contentList = new nsSimpleContentList(this);
WithSelectorList<void>(