зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1712394 [wpt PR 29078] - [a11y] System font sizes should obey user's font size setting, a=testonly
Automatic update from web-platform-tests [a11y] System font sizes should obey user's font size setting Some form controls get assigned a system font in UA origin: input, textarea, select, button { font: -webkit-small-control; } The font size of that is supposed to be 2pt smaller than the default font size. However, that "default" was hardcoded to 16px, without taking into account that the user can change the actual default. For example, someone with suboptimal vision may use a bigger default in order to be able to read the text with ease. But form controls would ignore that preference. This was bad for accessibility. So this patch uses the actual default size when calculating the size of system fonts. Doing so requires a Document from which to retrieve the settings, but CSSParserContext::GetDocument() is null for UA stylesheets. Therefore, instead of resolving at parse time, the font longhands are set to a CSSPendingSystemFontValue, and their resolution is deferred until computed-value time, when we can use StyleResolverState::GetDocument(). Bug: 1054031 TEST=StyleEngineTest.SystemFontsObeyDefaultFontSize TEST=external/wpt/css/css-fonts/system-fonts-serialization.tentative.html TEST=fast/css/font-shorthand.html Change-Id: I5e9b41a2baa45cea7f1a54190bf593e025153adb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2891582 Commit-Queue: Oriol Brufau <obrufau@igalia.com> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/master@{#885715} -- wpt-commits: 5b5b129bec0a6cf84c79bca04cef769dce5414ee wpt-pr: 29078
This commit is contained in:
Родитель
915cfff3f2
Коммит
8b1fa89f41
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Fonts Test: Serialization of system fonts</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-fonts/#valdef-font-caption">
|
||||
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
|
||||
<div id="target"></div>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
const target = document.getElementById("target");
|
||||
target.style.font = "initial";
|
||||
const fontLonghands = [...target.style];
|
||||
|
||||
const cs = getComputedStyle(target);
|
||||
function copyComputedStyle() {
|
||||
const data = {};
|
||||
data.font = cs.font;
|
||||
for (const longhand of fontLonghands) {
|
||||
data[longhand] = cs[longhand];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function check(systemFont) {
|
||||
target.style.cssText = "";
|
||||
target.style.font = systemFont;
|
||||
|
||||
assert_equals(target.style.font, systemFont, "System font serializes as-is");
|
||||
assert_array_equals([...target.style], fontLonghands, "System font sets all longhands");
|
||||
for (const longhand of fontLonghands) {
|
||||
assert_equals(target.style[longhand], "", `Longhand '${longhand}' serializes as empty string`);
|
||||
}
|
||||
|
||||
const copy = copyComputedStyle();
|
||||
for (const longhand of fontLonghands) {
|
||||
const resolvedStyle = cs[longhand];
|
||||
assert_not_equals(resolvedStyle, "");
|
||||
|
||||
target.style[longhand] = resolvedStyle;
|
||||
assert_equals(target.style[longhand], resolvedStyle, `Can set longhand '${longhand}'`);
|
||||
|
||||
assert_equals(target.style.font, "", `Shorthand serializes as empty string after setting '${longhand}'`);
|
||||
assert_object_equals(copyComputedStyle(), copy, `Other longhands still work after setting '${longhand}'`);
|
||||
|
||||
target.style.font = systemFont;
|
||||
}
|
||||
}
|
||||
|
||||
// Standard system fonts
|
||||
const systemFonts = ["caption", "icon", "menu", "message-box", "small-caption", "status-bar"];
|
||||
|
||||
// Some browsers also support these non-standard system fonts
|
||||
const extras = ["-webkit-mini-control", "-webkit-small-control", "-webkit-control"];
|
||||
|
||||
for (const extra of extras) {
|
||||
if (CSS.supports("font", extra)) {
|
||||
systemFonts.push(extra);
|
||||
}
|
||||
}
|
||||
|
||||
for (let systemFont of systemFonts) {
|
||||
test(() => check(systemFont), systemFont);
|
||||
}
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче