Files
ladybird/Tests/LibWeb/Ref/expected/selection-background-ref.html
Jelle Raaijmakers 98b4feb406 LibWeb: Apply CSS ::selection styling to text and form controls
Previously, text selection always used the system highlight color. This
implements support for the ::selection pseudo-element's background-color
and color properties.

For form controls like <input> and <textarea>, the selection style is
looked up on the shadow host element, since the actual text lives inside
their shadow DOM.

The text painting logic has been refactored to split fragments into
styled spans (before selection, selected, after selection) so that each
portion can be rendered with its appropriate colors, taking care not to
allocate in 99%+ of fragment rendering cases.
2026-02-06 10:47:50 +00:00

22 lines
461 B
HTML

<!DOCTYPE html>
<style>
p {
font-size: 20px;
line-height: 1.5;
margin: 10px 0;
}
.selected {
background-color: red;
}
.selected-default {
background: Highlight;
}
</style>
<div>
<p><span>P</span><span class="selected-default">ar</span><span class="selected">tial start</span></p>
<p><span class="selected">Full selection</span></p>
<p><span class="selected">Partial </span><span class="selected-default">en</span><span>d</span></p>
</div>