Files
sousa-gecko/testing/web-platform/tests/css/css-values/update-subpixel-rem-unit.html
T
Jonathan Kew a39bd5a226 Bug 2042294 - Quantize font-size at computed-value time, so that "random" floating-point sizes don't overwhelm our caches. r=perftest-reviewers,firefox-style-system-reviewers,layout-reviewers,dshin,sparky
We do this by reducing precision proportionately to the value, rather than simply
rounding to a certain number of decimals or similar, so that small sizes maintain
finer precision. This is particularly important for cases where content specifies
tiny font-size values with the expectation that a large scale() factor will later
be applied.

A perftest with lots of "random" floating-point font sizes is added, based on the
testcase in the report.

(A few existing tests get minor adjustments to allow for the modified precision.)

Differential Revision: https://phabricator.services.mozilla.com/D306131
2026-06-18 12:59:39 +00:00

22 lines
726 B
HTML

<!doctype html>
<html style="font-size:16px">
<head>
<title>CSS Values and Units Test: rem subpixel change</title>
<link rel="help" href="https://drafts.csswg.org/css-values/#rem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div style="font-size:16px">
<div id="remElement" style="width: 10rem"></div>
</div>
<script>
test(() => {
assert_equals(getComputedStyle(remElement).width, "160px");
document.documentElement.style.fontSize = "16.125px";
assert_equals(getComputedStyle(remElement).width, "161.25px");
}, "Check that a 0.125px change in root font-size affect rem units.");
</script>
<body>
</html>