Commit d5af67a8 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Don't compare px rounded font sizes.

Sub-pixel size changes to the root element font-size did not update rem
unit lengths if the px rounded root element font-size did not change.

Bug: 928371
Change-Id: Id9fab5ac4ab5a126b39a0d2bd7373d01802d29fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083175Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746344}
parent 9ff4415c
...@@ -1649,8 +1649,8 @@ bool StyleEngine::UpdateRemUnits(const ComputedStyle* old_root_style, ...@@ -1649,8 +1649,8 @@ bool StyleEngine::UpdateRemUnits(const ComputedStyle* old_root_style,
const ComputedStyle* new_root_style) { const ComputedStyle* new_root_style) {
if (!new_root_style || !UsesRemUnits()) if (!new_root_style || !UsesRemUnits())
return false; return false;
if (!old_root_style || if (!old_root_style || old_root_style->SpecifiedFontSize() !=
old_root_style->FontSize() != new_root_style->FontSize()) { new_root_style->SpecifiedFontSize()) {
DCHECK(Resolver()); DCHECK(Resolver());
// Resolved rem units are stored in the matched properties cache so we need // Resolved rem units are stored in the matched properties cache so we need
// to make sure to invalidate the cache if the documentElement font size // to make sure to invalidate the cache if the documentElement font size
......
<!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.1px";
assert_equals(getComputedStyle(remElement).width, "161px");
}, "Check that a 0.1px change in root font-size affect rem units.");
</script>
<body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment