[Android] Add an ErrorProne check for clipped superscripts

Combining SuperscriptSpan with RelativeSizeSpan raises text above the
baseline without updating the line metrics. While Latin fonts usually
have enough headroom between top and ascent to hide this, tall scripts
like Thai clip the upper vowel marks off against the top of the line
box.

NewLabelUtils.withBadge() (from //components/browser_ui/styles) solves
this for "New" badges by using a ReplacementSpan that reserves the
necessary vertical room in FontMetricsInt. However, callers could still
accidentally hand-roll superscript badges using SuperscriptSpan and
RelativeSizeSpan and reintroduce clipping regressions.

This CL adds a custom ErrorProne BugChecker, NoClippedSuperscript, that
flags methods constructing both SuperscriptSpan and RelativeSizeSpan and
directs authors to NewLabelUtils.withBadge() (or @SuppressWarnings with
an explanation for non-badge superscripts).

TAG=agy

Bug: 512323229
Change-Id: I9c58c5b9af6a7caeca056045e1b7ec6fa53b39f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8421287
Reviewed-by: Tommy Nyquist <nyquist@chromium.org>
Commit-Queue: Moe Adel <adelm@google.com>
Cr-Commit-Position: refs/heads/main@{#1701189}
NOKEYCHECK=True
GitOrigin-RevId: 00a320a0cb6a35146022586539e9d181c69cb3c8
7 files changed
tree: a16c6a87a59d6d03fb4420d5d76ef00549e391eb
  1. src/
  2. test/
  3. BUILD.gn
  4. OWNERS