[css-selectors-4] Implement :nth-child(An+B of S) behind a flag.

Implement the :nth-child(An+B of S) syntax from CSS Selectors level 4,
behind an experimental flag. The following caveats exist:

 - We do not have microbenchmarks.
 - We have not thought about invalidation at all yet.

:nth-of-type is now formally defined as a :nth-child() with selector
(in the spec), but we still keep its hard-coded implementation.

Bug: 304163
Change-Id: Id4a3328961640ad4bf33f634c24a7973caccdfdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4140995
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090362}
diff --git a/css/selectors/nth-child-of-complex-selector-many-children-ref.html b/css/selectors/nth-child-of-complex-selector-many-children-ref.html
new file mode 100644
index 0000000..031f3f1
--- /dev/null
+++ b/css/selectors/nth-child-of-complex-selector-many-children-ref.html
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<body>
+    <p>This test the styling of paragraphs with :nth-child(An+B of selector). If the test succeed, paragraphs that say "green" should have a green background.</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p style="background-color: lime">Green</p>
+</body>
+</html>
diff --git a/css/selectors/nth-child-of-complex-selector-many-children.html b/css/selectors/nth-child-of-complex-selector-many-children.html
new file mode 100644
index 0000000..72f58cd
--- /dev/null
+++ b/css/selectors/nth-child-of-complex-selector-many-children.html
@@ -0,0 +1,57 @@
+<!doctype html>
+<html>
+<head>
+<title>:nth-child with complex selector list argument and more than 32 elements</title>
+<link rel="help" href="https://w3c.github.io/csswg-drafts/selectors-4/#child-index">
+<link rel="match" href="nth-child-of-complex-selector-many-children-ref.html">
+<style>
+/* At least 4 pair of <p> above, can be overlapping. The other selectors of the list are useless. */
+p:nth-child(4n of html:root>body>p+p:not(empty), :not(*), p:not(p), span, .notthere) {
+    background-color: lime;
+}
+</style>
+</head>
+<body>
+    <p>This test the styling of paragraphs with :nth-child(An+B of selector). If the test succeed, paragraphs that say "green" should have a green background.</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+    <p>White</p>
+    <p>White</p>
+    <p>White</p>
+    <p>Green</p>
+</body>
+</html>