SelectionHitTest
Line and codepoint navigation helpers shared by the caret hit-test path (HitTestCaret), the editing layer (vertical caret movement, line edges), and selection-extension code.
Remarks
Finds the codepoint index on lineIndex closest to targetX in text-local coordinates. Snaps to grapheme cluster boundaries to keep multi-codepoint sequences atomic. Never returns a position past a trailing mandatory break (see LineCaretEnd). Scans only the line's own glyph span (glyphStart/glyphCount) — the per-call cost is bounded by the line, not the document. Clicks past a visual line edge resolve to the logical line start / end when the edge run follows the paragraph direction, otherwise to the edge glyph's BiDi codepoint (the visual edge — Android getOffsetForHorizontal / Chromium PositionForPoint behavior on mixed-direction lines).
