Bug 1410624: Integrate QuerySelectorAll in Gecko. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 22 Oct 2017 02:19:14 +0200
changeset 443449 2d930b3c9a7eecf49a4864d6ab2929fcdf1b25c9
parent 443448 6c3451eba82a6ba28226c328d6cc0451c9494f74
child 443450 cea3b79ef85fc0220514d5b1848a9ffa13fb21a0
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1410624
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1410624: Integrate QuerySelectorAll in Gecko. r=heycam MozReview-Commit-ID: 2Jf3Z6ikjXB
dom/base/nsINode.cpp
layout/style/ServoBindings.cpp
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2940,26 +2940,33 @@ nsINode::QuerySelector(const nsAString& 
   return holder.mElement;
 }
 
 already_AddRefed<nsINodeList>
 nsINode::QuerySelectorAll(const nsAString& aSelector, ErrorResult& aResult)
 {
   RefPtr<nsSimpleContentList> contentList = new nsSimpleContentList(this);
 
-  nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aResult);
-  if (selectorList) {
-    FindMatchingElements<false, AutoTArray<Element*, 128>>(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<void>(
+    aSelector,
+    aResult,
+    [&](const RawServoSelectorList* aList) {
+      if (!aList) {
+        return;
+      }
+      Servo_SelectorList_QueryAll(this, aList, contentList.get());
+    },
+    [&](nsCSSSelectorList* aList) {
+      if (!aList) {
+        return;
+      }
+      FindMatchingElements<false, AutoTArray<Element*, 128>>(
+        this, aList, *contentList, aResult);
+    }
+  );
 
   return contentList.forget();
 }
 
 Element*
 nsINode::GetElementById(const nsAString& aId)
 {
   MOZ_ASSERT(IsElement() || IsNodeOfType(eDOCUMENT_FRAGMENT),
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2861,12 +2861,13 @@ Gecko_ContentList_AppendAll(
   const Element** aElements,
   size_t aLength)
 {
   MOZ_ASSERT(aElements);
   MOZ_ASSERT(aLength);
   MOZ_ASSERT(aList);
 
   aList->SetCapacity(aLength);
+
   for (size_t i = 0; i < aLength; ++i) {
     aList->AppendElement(const_cast<Element*>(aElements[i]));
   }
 }