Skip to content

Commit

Permalink
Reset font subproperties to their initial value
Browse files Browse the repository at this point in the history
Reset font subproperties such as font-size-adjust, font-kerning,
font-feature-settings, font-optical-sizing and
font-variation-settings to their initial values, compare:
https://drafts.csswg.org/css-fonts-4/#font-prop

Also fixed the serialization of font shorthand property: when any of
subproperties are non initial, font shorthand property should be
serialized to an empty string.

Intent to ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/22MU6QJK7l0/m/Ezu0RZMYAQAJ

Bug: 1379236
Change-Id: If5ac2faffc9e956a38ef4c5ccf2130d3623d3582
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4018412
Commit-Queue: Munira Tursunova <[email protected]>
Reviewed-by: Yoav Weiss <[email protected]>
Reviewed-by: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1093915}
  • Loading branch information
tursunova authored and chromium-wpt-export-bot committed Jan 18, 2023
1 parent ad88d36 commit 775f81f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions css/css-fonts/font-shorthand-subproperties-reset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts Module Level 4: Resetting font shorthand subproperties</title>
<link rel="author" title="Munira Tursunova" href="[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-fonts/#font-prop">
<meta name="assert" content="All subproperties of the font property are first reset to their initial values.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="test"></div>
<script>

function set_font_subproperty(property, value) {
const element = document.getElementById('test')
element.style = ''
element.style[property] = value
}

function test_font_shorthand_resetting_subproperty(property, newValue) {
if (!CSS.supports(property, newValue))
return
test(() => {
let testElem = document.getElementById('test');
let computed = window.getComputedStyle(testElem);
let initialValue = computed[property];
set_font_subproperty(property, newValue);
document.getElementById('test').style.font = '16px serif';
assert_equals(computed[property], initialValue);
assert_not_equals(computed.font, "");
}, 'Property ' + property + ' should be reset to its initial value.')
}

test_font_shorthand_resetting_subproperty('font-size-adjust', '0')
test_font_shorthand_resetting_subproperty('font-kerning', 'normal')
test_font_shorthand_resetting_subproperty('font-variant-caps', 'all-small-caps')
test_font_shorthand_resetting_subproperty('font-variant-ligatures', 'none')
test_font_shorthand_resetting_subproperty('font-variant-position', 'sub')
test_font_shorthand_resetting_subproperty('font-variant-numeric', 'ordinal')
test_font_shorthand_resetting_subproperty('font-variant-alternates', 'historical-forms')
test_font_shorthand_resetting_subproperty('font-variant-east-asian', 'full-width')
test_font_shorthand_resetting_subproperty('font-variant-emoji', 'text')
test_font_shorthand_resetting_subproperty('font-feature-settings', '"sinf"')
test_font_shorthand_resetting_subproperty('font-language-override', '"SRB"')
test_font_shorthand_resetting_subproperty('font-optical-sizing', 'none')
test_font_shorthand_resetting_subproperty('font-variation-settings', '"aaaa" 1')

</script>

0 comments on commit 775f81f

Please sign in to comment.