Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="selection-highlight-painting-ref.html">
<meta name="flags" content="ahem">
<link rel="stylesheet" href="/fonts/ahem.css">
<style>
#grow-consistent {
font: 20px/2 Ahem;
width: 160px;
text-fit: grow consistent;
white-space: pre;
border: 1px solid gray;
}
#grow-line {
font: 20px/2 Ahem;
width: 160px;
text-fit: grow per-line-all;
white-space: pre;
border: 1px solid gray;
}
#shrink-consistent {
font: 20px/2 Ahem;
width: 64px;
text-fit: shrink consistent;
white-space: pre;
border: 1px solid gray;
}
#shrink-line {
font: 20px/2 Ahem;
line-height: 2;
width: 64px;
text-fit: shrink per-line-all;
white-space: pre;
border: 1px solid gray;
}
::highlight(my-highlight) {
background-color: rgba(255,128,128,0.5);
}
</style>
<div id="grow-consistent">ppp
pppp</div>
<div id="grow-line">pp
pppp</div>
<div id="shrink-consistent">ppp
pppppppp</div>
<div id="shrink-line">pppp
pppppppp</div>
<script>
document.fonts.ready.then(() => {
getSelection().selectAllChildren(document.querySelector('#grow-consistent'));
const text2 = document.querySelector('#grow-line').firstChild;
const r2 = new StaticRange({startContainer:text2, startOffset:1,
endContainer:text2, endOffset:text2.length-1});
const text3 = document.querySelector('#shrink-consistent').firstChild;
const r3 = new StaticRange({startContainer:text3, startOffset:2,
endContainer:text3, endOffset:text3.length-2});
const text4 = document.querySelector('#shrink-line').firstChild;
const r4 = new StaticRange({startContainer:text4, startOffset:3,
endContainer:text4, endOffset:text4.length-3});
CSS.highlights.set('my-highlight', new Highlight(r2, r3, r4));
document.documentElement.classList.remove('reftest-wait');
});
</script>