[wpt-sync] Sync PR 64476 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=321297
Categories
(Core :: Graphics: Canvas2D, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 64476 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/64476
Details from upstream follow.
Ahmad Saleem <ahmad.saleem792+github@gmail.com> wrote:
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=321297
WebKit export from bug: Root font relative units in canvas ctx.<!---->font resolve against the canvas element instead of the root element
<pre>
Root font relative units in canvas ctx.font resolve against the canvas element instead of the root elementStyle::resolveLength()'s DirectDataAdaptor took a single FontCascade and returned it from both
fontCascadeForFontUnits() and fontCascadeForRootFontUnits(), so 'rem' was an alias for 'em'. With
html { font-size: 5px }and a canvas element at 20px,ctx.font = "2rem sans-serif"produced 40px
rather than the correct 10px. The sibling CSSToLengthConversionData adaptor already gets this right
via conversionData.rootStyle().Give DirectDataAdaptor a second FontCascade for the root font and return it from
fontCascadeForRootFontUnits(). That one accessor feeds all five root font relative units, so rex,
rcap, rch and ric are fixed along with rem. Style::resolveLength() grows a matching required parameter;
callers with no separate root font, such as a worker, pass the element's font for both.Add Style::rootFontCascadeForRootFontUnits(), which returns the document element's
existingComputedStyle()->fontCascade(). It deliberately never resolves style: callers run under
ScriptDisallowedScope and the entry points are responsible for flushing.Recording the root font also has to be part of the memoization in
CanvasRenderingContext2D::setFontWithoutUpdatingStyle(). It compared only the canvas element's font
description, which does not observe a root font-size change, soctx.font = "2rem X"assigned twice
across a root restyle would stay stale.HTML does not yet say how non-absolute <length> values behave here; that is open in
<a href="https://github.com/whatwg/html/issues/10893">https://github.com/whatwg/html/issues/10893</a>, where one suggestion is that the root font relative
units simply alias the non-root ones. Resolving them against the root element is what they mean in
CSS and what the CSSToLengthConversionData path already does for the document case, so take that
for now. Viewport and container units, and the fully detached OffscreenCanvas case, are left alone.ctx.letterSpacing and ctx.wordSpacing reach the same resolveLength overload and have the same bug,
but fixing them needs those setters to update style first, which is a larger change; they pass the
context's font for both for now with a FIXME.WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=321297">https://bugs.webkit.org/show_bug.cgi?id=321297</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/325391@main">https://commits.webkit.org/325391@main</a>
</pre>
| Assignee | ||
Updated•17 days ago
|
| Assignee | ||
Updated•12 days ago
|
| Assignee | ||
Updated•12 days ago
|
| Assignee | ||
Comment 1•12 days ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=117231
| Assignee | ||
Comment 2•12 days ago
|
||
CI Results
Ran 0 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 1 tests and 11 subtests
Status Summary
Firefox
OK : 1
PASS: 5
FAIL: 6
Chrome
OK : 1
PASS: 5
FAIL: 6
Safari
OK : 1
PASS: 1
FAIL: 10
Links
Details
New Tests That Don't Pass
- /html/canvas/element/2d.text-root-font-relative-units.html [wpt.fyi]
- font: re-setting the same rem font string picks up the new root font-size:
FAIL(Chrome:FAIL, Safari:FAIL) - font: save and restore keep the root-resolved font of each saved state:
FAIL(Chrome:FAIL, Safari:FAIL) - font: rex resolves against the root element:
FAIL(Chrome:FAIL, Safari:FAIL) - font: rch resolves against the root element:
FAIL(Chrome:FAIL, Safari:FAIL) - font: rcap resolves against the root element:
FAIL(Chrome:FAIL, Safari:FAIL) - font: ric resolves against the root element:
FAIL(Chrome:FAIL, Safari:FAIL)
- font: re-setting the same rem font string picks up the new root font-size:
Comment 4•9 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/10ddf7c17513
https://hg.mozilla.org/mozilla-central/rev/4f5faffa645a
Comment 5•9 days ago
|
||
| bugherder | ||
Description
•