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
22 lines
726 B
HTML
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>
|