mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Implement compositing of font-variation-settings values
This commit is contained in:
parent
f9452b77b7
commit
b64cb89b9d
|
|
@ -1812,6 +1812,16 @@ RefPtr<StyleValue const> composite_value(StyleValue const& underlying_value, Sty
|
|||
auto result = composite_raw_values(underlying_value.as_number().number(), animated_value.as_number().number());
|
||||
return NumberStyleValue::create(result);
|
||||
}
|
||||
case StyleValue::Type::OpenTypeTagged: {
|
||||
auto& underlying_open_type_tagged = underlying_value.as_open_type_tagged();
|
||||
auto& animated_open_type_tagged = animated_value.as_open_type_tagged();
|
||||
if (underlying_open_type_tagged.tag() != animated_open_type_tagged.tag())
|
||||
return {};
|
||||
auto composited_value = composite_value(underlying_open_type_tagged.value(), animated_open_type_tagged.value(), composite_operation);
|
||||
if (!composited_value)
|
||||
return {};
|
||||
return OpenTypeTaggedStyleValue::create(OpenTypeTaggedStyleValue::Mode::FontVariationSettings, underlying_open_type_tagged.tag(), composited_value.release_nonnull());
|
||||
}
|
||||
case StyleValue::Type::Percentage: {
|
||||
auto result = composite_raw_values(underlying_value.as_percentage().percentage().value(), animated_value.as_percentage().percentage().value());
|
||||
return PercentageStyleValue::create(Percentage { result });
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 30 tests
|
||||
|
||||
30 Pass
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to add ['test' 200] at (-0.3) should be ['test' 120]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to add ['test' 200] at (0) should be ['test' 150]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to add ['test' 200] at (0.5) should be ['test' 200]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to add ['test' 200] at (1) should be ['test' 250]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to add ['test' 200] at (1.5) should be ['test' 300]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to replace ['test' 200] at (-0.3) should be ['test' 135]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to replace ['test' 200] at (0) should be ['test' 150]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to replace ['test' 200] at (0.5) should be ['test' 175]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to replace ['test' 200] at (1) should be ['test' 200]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 50] from add ['test' 100] to replace ['test' 200] at (1.5) should be ['test' 225]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to replace ['test' 200] at (-0.3) should be [normal]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to replace ['test' 200] at (0) should be [normal]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to replace ['test' 200] at (0.5) should be ['test' 200]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to replace ['test' 200] at (1) should be ['test' 200]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to replace ['test' 200] at (1.5) should be ['test' 200]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to add ['test' 200] at (-0.3) should be [normal]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to add ['test' 200] at (0) should be [normal]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to add ['test' 200] at (0.5) should be ['test' 300]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to add ['test' 200] at (1) should be ['test' 300]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add [normal] to add ['test' 200] at (1.5) should be ['test' 300]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['aaaa' 100, 'bbbb' 200] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (-0.3) should be ['aaaa' 117, 'bbbb' 235]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['aaaa' 100, 'bbbb' 200] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (0) should be ['aaaa' 120, 'bbbb' 250]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['aaaa' 100, 'bbbb' 200] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (0.5) should be ['aaaa' 125, 'bbbb' 275]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['aaaa' 100, 'bbbb' 200] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (1) should be ['aaaa' 130, 'bbbb' 300]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['aaaa' 100, 'bbbb' 200] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (1.5) should be ['aaaa' 135, 'bbbb' 325]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (-0.3) should be ['aaaa' 17, 'bbbb' 35]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (0) should be ['aaaa' 20, 'bbbb' 50]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (0.5) should be ['aaaa' 25, 'bbbb' 75]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (1) should be ['aaaa' 30, 'bbbb' 100]
|
||||
Pass Compositing: property <font-variation-settings> underlying ['test' 100] from add ['aaaa' 20, 'bbbb' 50] to add ['aaaa' 30, 'bbbb' 100] at (1.5) should be ['aaaa' 35, 'bbbb' 125]
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="UTF-8">
|
||||
<title>font-variation-settings composition</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#propdef-font-variation-settings">
|
||||
<meta name="assert" content="font-variation-settings supports animation pairwise by 'like' properties">
|
||||
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../css/support/interpolation-testcommon.js"></script>
|
||||
|
||||
<body></body>
|
||||
|
||||
<script>
|
||||
function compareVariationSettings(actual, expected) {
|
||||
// The order of <axis, value> pairs in the variation-settings list is arbitrary,
|
||||
// so we sort the pairs before attempting to compare. (We only need to use this
|
||||
// when multiple settings are expected, otherwise the default comparison is OK.)
|
||||
assert_equals(normalizeValue(actual).split(", ").sort().join(", "),
|
||||
normalizeValue(expected).split(", ").sort().join(", "));
|
||||
};
|
||||
|
||||
test_composition({
|
||||
property: 'font-variation-settings',
|
||||
underlying: "'test' 50",
|
||||
addFrom: "'test' 100",
|
||||
addTo: "'test' 200",
|
||||
}, [
|
||||
{at: -0.3, expect: "'test' 120"},
|
||||
{at: 0, expect: "'test' 150"},
|
||||
{at: 0.5, expect: "'test' 200"},
|
||||
{at: 1, expect: "'test' 250"},
|
||||
{at: 1.5, expect: "'test' 300"},
|
||||
]);
|
||||
|
||||
test_composition({
|
||||
property: 'font-variation-settings',
|
||||
underlying: "'test' 50",
|
||||
addFrom: "'test' 100",
|
||||
replaceTo: "'test' 200",
|
||||
}, [
|
||||
{at: -0.3, expect: "'test' 135"},
|
||||
{at: 0, expect: "'test' 150"},
|
||||
{at: 0.5, expect: "'test' 175"},
|
||||
{at: 1, expect: "'test' 200"},
|
||||
{at: 1.5, expect: "'test' 225"},
|
||||
]);
|
||||
|
||||
test_composition({
|
||||
property: 'font-variation-settings',
|
||||
underlying: "'test' 100",
|
||||
addFrom: 'normal',
|
||||
replaceTo: "'test' 200",
|
||||
}, [
|
||||
{at: -0.3, expect: 'normal'},
|
||||
{at: 0, expect: 'normal'},
|
||||
{at: 0.5, expect: "'test' 200"},
|
||||
{at: 1, expect: "'test' 200"},
|
||||
{at: 1.5, expect: "'test' 200"},
|
||||
]);
|
||||
|
||||
test_composition({
|
||||
property: 'font-variation-settings',
|
||||
underlying: "'test' 100",
|
||||
addFrom: 'normal',
|
||||
addTo: "'test' 200",
|
||||
}, [
|
||||
{at: -0.3, expect: 'normal'},
|
||||
{at: 0, expect: 'normal'},
|
||||
{at: 0.5, expect: "'test' 300"},
|
||||
{at: 1, expect: "'test' 300"},
|
||||
{at: 1.5, expect: "'test' 300"},
|
||||
]);
|
||||
|
||||
test_composition({
|
||||
property: 'font-variation-settings',
|
||||
underlying: "'aaaa' 100, 'bbbb' 200",
|
||||
addFrom: "'aaaa' 20, 'bbbb' 50",
|
||||
addTo: "'aaaa' 30, 'bbbb' 100",
|
||||
comparisonFunction: compareVariationSettings,
|
||||
}, [
|
||||
{at: -0.3, expect: "'aaaa' 117, 'bbbb' 235"},
|
||||
{at: 0, expect: "'aaaa' 120, 'bbbb' 250"},
|
||||
{at: 0.5, expect: "'aaaa' 125, 'bbbb' 275"},
|
||||
{at: 1, expect: "'aaaa' 130, 'bbbb' 300"},
|
||||
{at: 1.5, expect: "'aaaa' 135, 'bbbb' 325"},
|
||||
]);
|
||||
|
||||
test_composition({
|
||||
property: 'font-variation-settings',
|
||||
underlying: "'test' 100",
|
||||
addFrom: "'aaaa' 20, 'bbbb' 50",
|
||||
addTo: "'aaaa' 30, 'bbbb' 100",
|
||||
comparisonFunction: compareVariationSettings,
|
||||
}, [
|
||||
{at: -0.3, expect: "'aaaa' 17, 'bbbb' 35"},
|
||||
{at: 0, expect: "'aaaa' 20, 'bbbb' 50"},
|
||||
{at: 0.5, expect: "'aaaa' 25, 'bbbb' 75"},
|
||||
{at: 1, expect: "'aaaa' 30, 'bbbb' 100"},
|
||||
{at: 1.5, expect: "'aaaa' 35, 'bbbb' 125"},
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
Loading…
Reference in New Issue
Block a user