Skip to content

fix(html): a pdf's selection shows the text it marks - #916

Merged
andiwand merged 1 commit into
mainfrom
fix/selection-shows-the-text-it-marks
Sep 20, 2026
Merged

andiwand merged 1 commit into
mainfrom
fix/selection-shows-the-text-it-marks

Conversation

@andiwand

@andiwand andiwand commented Sep 20, 2026

Copy link
Copy Markdown
Member

v7.2.0 gave the ::selection rules a background, because an author ::selection drops the UA's own and the selection was painting nothing. The background it states is Highlight, and Highlight is opaque - while the layer carrying it, .sel, comes after .vis in the page and therefore paints over the glyphs. So a reader who selected a word saw the word disappear behind its own highlight.

Reported from the device, and reproduced: the selected "Hough" is a blank blue box.

The background is see-through now. Two declarations, the second winning where it parses:

background-color: rgba(70,130,220,.32);
background-color: color-mix(in srgb, Highlight 45%, transparent);

so a current engine follows the platform's own highlight colour, and an older one still gets a sane translucent blue rather than nothing.

Checked

The real document this was reported on, rendered by cli/translate and selected in both engines:

engine ::selection background resolves to the word
Chrome 153 (desktop) color(srgb 0.502 0.737 0.996 / 0.27) legible through the tint
Chrome 91 (android WebView, emulator) the rgba fallback legible through the tint

Nothing renders differently outside a selection, so the reference output is unchanged.

v7.2.0 gave the `::selection` rules a background, because an author rule
drops the UA's own and the selection painted nothing. That background is
`Highlight`, which is opaque, and the layer carrying it paints over the
glyph layer - so selecting a word hid it.

It is see-through now: a `color-mix` of the platform's highlight, over an
rgba fallback for an engine that cannot parse one.

Checked on the reported document in chrome 153 and in an android WebView
on chrome 91, where the fallback is what paints.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJJdfqpnVCKBNHXjAVxSou
@andiwand
andiwand merged commit 4a3e5f9 into main Sep 20, 2026
29 checks passed
@andiwand
andiwand deleted the fix/selection-shows-the-text-it-marks branch September 20, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant