PDFiumPage::GetTextRunInfo() already has good heuristics to calculate
the set of characters that form a text run. Use it in
PDFiumRange::GetScreenRects() to create a rectangle for every text run.
Then add more heuristics to merge the rectangles when they have
sufficient overlap in the horizontal direction. As a result, the text
selection, which is based on GetScreenRects() calculations, will appear
more continuous and less jagged.
Update test expectations to match the new code's behavior.
Keep the original FPDFText_CountRects()-based implementation around,
behind an emergency kill switch, in case the new code has serious
problems.
Bug: 40448046
Change-Id: I17b9dd744671c6721faaf9060622cff788371f1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6237116
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1417508}