Implement support for ::target-text behind a flag.

This implements the style support for the pseudo element. The paint code
needs to query the pseudo style during painting and paint invalidation
needs to be added.

Bug: 1136817
Change-Id: I933c4de5f473c25000f9a34efa00a5af2cc52232
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463563
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818939}
diff --git a/css/css-pseudo/parsing/target-text.html b/css/css-pseudo/parsing/target-text.html
new file mode 100644
index 0000000..37cbdd4
--- /dev/null
+++ b/css/css-pseudo/parsing/target-text.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Pseudo-Elements Test: ::target-text parsing</title>
+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+<script>
+  test_valid_selector("::target-text");
+  test_valid_selector(".a::target-text");
+  test_valid_selector("div ::target-text");
+  test_valid_selector("::part(my-part)::target-text");
+
+  test_invalid_selector("::before::target-text");
+  test_invalid_selector("::target-text.a");
+  test_invalid_selector("::target-text div");
+  test_invalid_selector("::target-text::after");
+  test_invalid_selector("::target-text:hover");
+  test_invalid_selector(":not(::target-text)");
+</script>
diff --git a/css/css-pseudo/target-text-computed.html b/css/css-pseudo/target-text-computed.html
new file mode 100644
index 0000000..4299030
--- /dev/null
+++ b/css/css-pseudo/target-text-computed.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Pseudo-Elements Test: ::target-text getComputedStyle</title>
+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+  #target::target-text {
+    background-color: green;
+  }
+  #target::target-text {
+    color: lime;
+  }
+</style>
+<div id="target"></div>
+<script>
+  test(() => {
+    let style = getComputedStyle(target, "::target-text");
+    assert_equals(style.backgroundColor, "rgb(0, 128, 0)", "Background color is green.");
+    assert_equals(style.color, "rgb(0, 255, 0)", "Color is lime.");
+  }, "getComputedStyle() for ::target-text");
+</script>