Improve interaction of pointer-events with scroll gesture hit testing, scrollability decisions, and overlay scrollbars

* First, this change stops considering pointer-events when deciding
  whether a paint layer is scrollable.  This avoids pointer-events
  having strange effects on decisions about whether to show overlay
  scrollbars.  These strange effects include the backdrop of a <dialog>
  causing the things behind it to become inert (and thus have
  pointer-events: none) and cause overlay scrollbars to spontaneously
  appear.

  This is done by changing a test of
  ComputedStyle::VisibleToHitTesting() to test only
  ComputedStyle::Visibility(), which is one of the two parts of
  VisibleToHitTesting().  This test dates back to
  https://chromium.googlesource.com/chromium/src/+/9de09a320e201ea651b23587850050a67654271f%5E%21/
  and I don't think the pointer-events part of the test makes sense.
  (I'm somewhat suspicious of the visibility part of the test as well,
  although the authors of the tests at
  web_tests/fast/scrolling/scrollable-area-{frame{,-scrolling-no}-visibility-hidden-child,overflow-auto-visibility-hidden{,-in-parent}}.html
  believed in that part at least enough to write 4 tests for it.)  It
  doesn't seem to me that pointer-events (or, really, visibility) should
  affect the result of ScrollsOverflow since it doesn't affect whether
  something can be scrolled programmatically (or, for pointer-events,
  via the keyboard).

  Additionally, this CL then undoes the effect that the above change
  would have on decisions about implicit promotion to the root scroller.

  On Mac (but not Linux), the two added tests show the bug without this
  change, when run in virtual/overlay-scrollbar/, but are fixed by this
  change.

* Second, in order to both fix regressions from the above change and
  fix existing bugs that exist prior to it, this change changes how
  gesture scrolls are targeted when some but not all elements have
  pointer-events: none, so that gesture scrolls are reliably hit tested
  based on the pointer-events values of the elements involved.  In
  particular, it forces a scrollable region that is not visible to hit
  testing to use the main thread hit testing codepath (since it may have
  arbitrary descendants, scrollable or not, that are visible to hit
  testing).  It also adjusts the hit testing of scrollbars themselves to
  match.

  This is needed to avoid regressing
  external/wpt/pointerevents/pointerevent_hit_test_scroll.html on Mac
  only, and to avoid
  pointerevent_hit_test_scroll_visible_descendant.html starting to fail
  again (after being fixed by the first part) on Linux and Windows.  (I
  don't fully understand why the regression in
  pointerevent_hit_test_scroll.html is Mac-only, but I know that on
  Linux, UpdateNonFastScrollableRegion fails to bail out early in some
  cases where on Mac it does bail out early because layer.element_id()
  == scroll_element_id; in these cases, on Linux, layer.element_id() is
  0 while scroll_element_id is not zero.)

* Third, this change also makes virtual/overlay-scrollbar/ and
  virtual/non-overlay-scrollbar/ never expire, because they test
  something that varies based on OS and settings rather than a feature
  being rolled out (e.g., virtual/overlay-scrollbar/ matches the default
  behavior on a Mac, whereas running outside that virtual suite does
  not), and renames the README.txt to README.md to satisfy
  https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/tools/blinkpy/web_tests/lint_test_expectations.py;l=345-348;drc=fdd1781f121a555a8f4b771b970147e1a7ec4876

Fixed: 1414142
Change-Id: Ic26cfb933948bca55e4042ed360ed07692d14a0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4237636
Commit-Queue: David Baron <dbaron@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1121965}
diff --git a/css/css-ui/pointer-events-no-scrollbars-001-ref.html b/css/css-ui/pointer-events-no-scrollbars-001-ref.html
new file mode 100644
index 0000000..096eb16
--- /dev/null
+++ b/css/css-ui/pointer-events-no-scrollbars-001-ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<html>
+<title>CSS Test Reference: differences in pointer-events shouldn't cause overlay scrollbars to appear</title>
+<link rel="author" title="L. David Baron" href="https://dbaron.org/">
+<link rel="author" title="Google" href="http://www.google.com/">
+
+<style>
+
+#scroll {
+  width: 200px;
+  height: 200px;
+  overflow: auto;
+}
+
+#big {
+  width: 500px;
+  height: 500px;
+}
+
+</style>
+
+
+<div id="scroll">
+  <div id="big">
+  </div>
+</div>
diff --git a/css/css-ui/pointer-events-no-scrollbars-001.html b/css/css-ui/pointer-events-no-scrollbars-001.html
new file mode 100644
index 0000000..fc438f7
--- /dev/null
+++ b/css/css-ui/pointer-events-no-scrollbars-001.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<title>CSS Test: differences in pointer-events shouldn't cause overlay scrollbars to appear</title>
+<link rel="author" title="L. David Baron" href="https://dbaron.org/">
+<link rel="author" title="Google" href="http://www.google.com/">
+<link rel="help" href="https://drafts.csswg.org/css-ui-4/#pointer-events-control">
+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1414142">
+<meta name="assert" content="Differences in pointer-events shouldn't cause overlay scrollbars to appear.  (I concede this could perhaps be allowed by the wording in the spec that makes basically everything related to scrollbar rendering UA-defined.  However, there is no allowance for pointer-events affecting scrollbar rendering, so I think it's defensible.)">
+<link rel="match" href="pointer-events-no-scrollbars-001-ref.html">
+
+<style>
+
+#scroll {
+  width: 200px;
+  height: 200px;
+  overflow: auto;
+  pointer-events: none;
+}
+
+#big {
+  width: 500px;
+  height: 500px;
+}
+
+</style>
+
+
+<div id="scroll">
+  <div id="big">
+  </div>
+</div>
diff --git a/css/css-ui/pointer-events-no-scrollbars-002.html b/css/css-ui/pointer-events-no-scrollbars-002.html
new file mode 100644
index 0000000..1371c12
--- /dev/null
+++ b/css/css-ui/pointer-events-no-scrollbars-002.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait">
+<title>CSS Test: dynamic changes to pointer-events shouldn't cause overlay scrollbars to appear</title>
+<link rel="author" title="L. David Baron" href="https://dbaron.org/">
+<link rel="author" title="Google" href="http://www.google.com/">
+<link rel="help" href="https://drafts.csswg.org/css-ui-4/#pointer-events-control">
+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1414142">
+<meta name="assert" content="Dynamic changes to pointer-events shouldn't cause overlay scrollbars to appear.  (I concede this could perhaps be allowed by the wording in the spec that makes basically everything related to scrollbar rendering UA-defined.  However, there is no allowance for pointer-events affecting scrollbar rendering, so I think it's defensible.)">
+<link rel="match" href="pointer-events-no-scrollbars-001-ref.html">
+
+<style>
+
+#scroll {
+  width: 200px;
+  height: 200px;
+  overflow: auto;
+}
+
+#big {
+  width: 500px;
+  height: 500px;
+}
+
+</style>
+
+
+<div id="scroll">
+  <div id="big">
+  </div>
+</div>
+
+<script>
+
+document.documentElement.addEventListener("TestRendered", (event) => {
+  document.getElementById("scroll").style.pointerEvents = "none";
+  document.documentElement.classList.remove("reftest-wait");
+});
+
+</script>