Let editing scroll hidden cursor into nearest edge instead of the center

When writing text inside a scroll container with fixed height, the
cursor eventually moves outside the visible area. At that point it's
scrolled back into view.

Before this patch it was moved as much as possible into the center of
the visible area, the problem with this was when writing text at the end
of a container with bottom padding. When the cursor was overflowing the
content area but still in the padding area, it was still into view, so
no scroll happened. But after leaving the padding area, the scrollbar
was scrolled to the bottom, moving the cursor into the content area.

This behavior seemed inconsistent, giving the impression that sometimes
it was trying to keep the cursor inside the content area and sometimes
not caring that the cursor was in the padding area.

After this patch, a hidden cursor is only scrolled into the nearest edge
of the visible area. This aligns Chromium with Firefox and Edge.

BUG=931838

TEST=editing/input/caret-at-the-edge-of-contenteditable.html
TEST=editing/input/caret-at-the-edge-of-input.html
TEST=editing/input/reveal-caret-of-multiline-contenteditable.html
TEST=editing/input/reveal-caret-of-multiline-input.html
TEST=editing/input/reveal-contenteditable-on-input-vertically.html
TEST=editing/input/reveal-edit-on-input-vertically.html
TEST=fast/forms/text/input-text-scroll-left-on-blur.html

Change-Id: I584e9c85d3eabd4ace1b694906cd6f7649c58443
Reviewed-on: https://chromium-review.googlesource.com/c/1477255
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Oriol Brufau <obrufau@igalia.com>
Cr-Commit-Position: refs/heads/master@{#634393}
33 files changed