Bug 226819

Summary: Inaccurate background-size with ch units
Product: WebKit Reporter: Gabor Vajda <g.vajda>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bfulgham, heycam, ntim, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 11   
Attachments:
Description Flags
Inaccurate background layout in Safari none

Description Gabor Vajda 2021-06-09 08:06:37 PDT
Created attachment 430966 [details]
Inaccurate background layout in Safari

The issue is demonstrated here: https://codepen.io/vajdagabor/pen/VwpBRQG

I'm trying to create a (monospace) code display with repeated background pattern, where background-image is positioned precisely to every character. Setting background-size with ch unit would be ideal, but the result is inaccurate on Safari. The example works well on Chrome and Firefox.

Also, the pattern in the example is not visible when the font is small.

This is the CSS:

pre {
  background-image: linear-gradient(to right, black 0%, black 1px, transparent 1px, transparent 100%);
  background-size: 1ch;
}
Comment 1 Radar WebKit Bug Importer 2021-06-16 08:07:17 PDT
<rdar://problem/79398089>