From 707ec189802ee4f3e0c44a0f37e057b5eeef25ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 22 Oct 2017 02:19:14 +0200 Subject: [PATCH] Bug 1410624: Integrate QuerySelectorAll in Gecko. r=heycam MozReview-Commit-ID: 2Jf3Z6ikjXB --- dom/base/nsINode.cpp | 27 +++++++++++++++++---------- layout/style/ServoBindings.cpp | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index b379e8289f78..6e7acc1dcdda 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -2945,16 +2945,23 @@ nsINode::QuerySelectorAll(const nsAString& aSelector, ErrorResult& aResult) { RefPtr contentList = new nsSimpleContentList(this); - nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aResult); - if (selectorList) { - FindMatchingElements>(this, - selectorList, - *contentList, - aResult); - } else { - // Either we failed (and aResult already has the exception), or this - // is a pseudo-element-only selector that matches nothing. - } + WithSelectorList( + aSelector, + aResult, + [&](const RawServoSelectorList* aList) { + if (!aList) { + return; + } + Servo_SelectorList_QueryAll(this, aList, contentList.get()); + }, + [&](nsCSSSelectorList* aList) { + if (!aList) { + return; + } + FindMatchingElements>( + this, aList, *contentList, aResult); + } + ); return contentList.forget(); } diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 0448928739fc..429cf22be63b 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -2866,6 +2866,7 @@ Gecko_ContentList_AppendAll( MOZ_ASSERT(aList); aList->SetCapacity(aLength); + for (size_t i = 0; i < aLength; ++i) { aList->AppendElement(const_cast(aElements[i])); }