[Reland] Disable input until we present something to the user

Reland of https://chromium-review.googlesource.com/c/chromium/src/+/1590415

When a document loads, there is a significant period between when
the frame is created and when the user sees content. During this time,
the document is not processing lifecycle updates but Javascript is
scheduled and the RenderWidget exists to handle input.

A major concern is that users might click on some place where there is
something reactive laid-out and available for hit testing and processing
(an ad, a link, start a video) before they have actually seen anything to
click on. Think of something like a last ditch attempt to click on
something on the page you're navigating away from only to hit something
on the page you're navigating to.

It seems safer to avoid this rather than have unexpected and potentially
very nasty behavior. In theory this situation was possible before with
deferred lifecycle updates though it apparently never warranted concern.
But we're preparing to enable the flag that defers the first compositor
commit until we have some content ready to raster (or a timeout), in
which case document lifecycles are running and there is content there
to hit-test against and send events to, but the user hasn't seen it yet
(for half a second at most, right now).

This patch suppresses all input from the time when RenderWidget navigates
to a frame to the time we are notified of the first compositor commit and
paint, which is the best estimate we have for the user seeing something.

This patch may affect the FirstInputDelay (FID) web platform metric.
FID may improve because dropped input won't be measured at all, and
the delay for the first event we actually process will be smaller because
it will come when the system is less stressed. i.e. after initial layout
and paint. Regardless, the impact on FID will be monitored when this
patch lands.

A command line switch is added to allow early input for tests. Many tests
are flaky with this patch because they do not reliably wait for input,
and in some cases we cannot easily modify the tests to wait (for example,
web_tests and Android java-based tests). The open issue crbug.com/987626
exists to burn down the set of tests needing the flag, and possibly remove it.

Sheriffs, please to not revert this for flakiness. Flakiness can be
addressed by modifying individual flaky tests with the
"allow-pre-commit-input" command line flag.

Bug: 958424
Change-Id: Iea30f5b3bb2b1505a7ab7bfe749d0700f6db1027
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729803
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687220}
33 files changed