pretext icon indicating copy to clipboard operation
pretext copied to clipboard

WebKit profile: a tab skips its stop when under half a `0` from it, not half a space

Open LewisAlderman opened this issue 1 month ago • 0 comments

The WebKit profile gives a tab its stop unless that stop is under half a space away (tabMinimumCharacter: engine === 'gecko' ? '0' : ' ' in src/measurement.ts). WebKit skips to the next stop when the stop is under half a 0 away, as Gecko does, so a tab between the two can land a whole stop further in WebKit than the profile has it.

Scan. An inline-block of width w, then ⇥Y, in white-space: pre, 15px Inter (Variable, latin subset); the w where Y jumps a stop:

Engine Space / 0 (Canvas) Stop Y jumps at w = Distance to the stop there
Chromium 156.0.8078.4 4.22 / 9.46 33.75 31.75 2.0 (half a space: 2.11)
Firefox 157.0 4.22 / 9.46 33.73 29.125 4.6 (half a 0: 4.73)
WebKit 27.2 (Playwright build 2370, macOS) 4.22 / 9.46 33.75 29.125 4.6 (half a 0: 4.73)

With 1px letter spacing WebKit jumps at the same w, from the same stops (it keeps letter spacing out of them and puts one after the tab, as the profile has it).

On a line. ",\t~/Projects/atlas/src\tre-entry AVATAR مرحبا " in 15px Inter, pre-wrap, 1px letter spacing, at 128px: the third line starts /src, which ends at 31.3px, 2.45px before the stop at 33.75. WebKit takes the stop after, 67.5, and wraps entry to a fifth line; the profile keeps the stop, 4 lines, with /src⇥re-entry 100.62px wide.

// In WebKit: Y's x jumps from ~34 to ~68 between w = 29 and w = 29.125.
const box = document.createElement("span");
box.style.cssText = "display:inline-block;height:1px;width:29.125px";
const div = document.createElement("div");
div.style.cssText = 'font:15px "Inter Variable";white-space:pre';
div.append(box, "\tY");
document.body.append(div);

The change that matches it: tabMinimumCharacter: engine === 'blink' ? ' ' : '0'. I measured Playwright's WebKit, not Safari or webkit-host, so it wants checking there; the harness has no case that lands a tab between the two minimums in WebKit, which may be why it held.

LewisAlderman avatar Oct 19 '26 20:10 LewisAlderman