LibWeb: Parse the scroll-timeline-name CSS property

This commit is contained in:
Callum Law 2025-11-20 22:43:11 +13:00 committed by Sam Atkins
parent 826e947920
commit e95f326f3d
Notes: github-actions[bot] 2025-11-28 13:26:40 +00:00
9 changed files with 133 additions and 0 deletions

View file

@ -745,6 +745,8 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue const>> Parser::parse_css_value(Pr
return parse_all_as(tokens, [this](auto& tokens) { return parse_translate_value(tokens); }); return parse_all_as(tokens, [this](auto& tokens) { return parse_translate_value(tokens); });
case PropertyID::Scale: case PropertyID::Scale:
return parse_all_as(tokens, [this](auto& tokens) { return parse_scale_value(tokens); }); return parse_all_as(tokens, [this](auto& tokens) { return parse_scale_value(tokens); });
case PropertyID::ScrollTimelineName:
return parse_all_as(tokens, [this, property_id](auto& tokens) { return parse_simple_comma_separated_value_list(property_id, tokens); });
case PropertyID::WhiteSpace: case PropertyID::WhiteSpace:
return parse_all_as(tokens, [this](auto& tokens) { return parse_white_space_shorthand(tokens); }); return parse_all_as(tokens, [this](auto& tokens) { return parse_white_space_shorthand(tokens); });
case PropertyID::WhiteSpaceTrim: case PropertyID::WhiteSpaceTrim:

View file

@ -3440,6 +3440,19 @@
"affects-layout": false, "affects-layout": false,
"affects-stacking-context": true "affects-stacking-context": true
}, },
"scroll-timeline-name": {
"affects-layout": false,
"animation-type": "none",
"inherited": false,
"initial": "none",
"valid-identifiers": [
"none"
],
"valid-types": [
"dashed-ident"
],
"multiplicity": "coordinating-list"
},
"scrollbar-color": { "scrollbar-color": {
"affects-layout": false, "affects-layout": false,
"animation-type": "by-computed-value", "animation-type": "by-computed-value",

View file

@ -259,6 +259,7 @@ All properties associated with getComputedStyle(document.body):
"rx", "rx",
"ry", "ry",
"scale", "scale",
"scroll-timeline-name",
"scrollbar-color", "scrollbar-color",
"scrollbar-gutter", "scrollbar-gutter",
"scrollbar-width", "scrollbar-width",

View file

@ -694,6 +694,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'rx': 'auto' 'rx': 'auto'
'ry': 'auto' 'ry': 'auto'
'scale': 'none' 'scale': 'none'
'scrollTimelineName': 'none'
'scroll-timeline-name': 'none'
'scrollbarColor': 'auto' 'scrollbarColor': 'auto'
'scrollbar-color': 'auto' 'scrollbar-color': 'auto'
'scrollbarGutter': 'auto' 'scrollbarGutter': 'auto'

View file

@ -257,6 +257,7 @@ row-gap: normal
rx: auto rx: auto
ry: auto ry: auto
scale: none scale: none
scroll-timeline-name: none
scrollbar-color: auto scrollbar-color: auto
scrollbar-gutter: auto scrollbar-gutter: auto
scrollbar-width: auto scrollbar-width: auto

View file

@ -0,0 +1,19 @@
Harness status: OK
Found 13 tests
12 Pass
1 Fail
Pass Property scroll-timeline-name value 'initial'
Pass Property scroll-timeline-name value 'inherit'
Pass Property scroll-timeline-name value 'unset'
Pass Property scroll-timeline-name value 'revert'
Pass Property scroll-timeline-name value 'none'
Pass Property scroll-timeline-name value '--foo'
Pass Property scroll-timeline-name value '--foo, --bar'
Pass Property scroll-timeline-name value '--bar, --foo'
Pass Property scroll-timeline-name value '--a, --b, --c, --D, --e'
Fail Property scroll-timeline-name value 'none, none'
Pass Property scroll-timeline-name value '--a, --b, --c, none, --d, --e'
Pass The scroll-timeline-name property shows up in CSSStyleDeclaration enumeration
Pass The scroll-timeline-name property shows up in CSSStyleDeclaration.cssText

View file

@ -0,0 +1,26 @@
Harness status: OK
Found 20 tests
19 Pass
1 Fail
Pass e.style['scroll-timeline-name'] = "initial" should set the property value
Pass e.style['scroll-timeline-name'] = "inherit" should set the property value
Pass e.style['scroll-timeline-name'] = "unset" should set the property value
Pass e.style['scroll-timeline-name'] = "revert" should set the property value
Pass e.style['scroll-timeline-name'] = "none" should set the property value
Pass e.style['scroll-timeline-name'] = "--abc" should set the property value
Pass e.style['scroll-timeline-name'] = " --abc" should set the property value
Pass e.style['scroll-timeline-name'] = "--aBc" should set the property value
Pass e.style['scroll-timeline-name'] = "--foo, --bar" should set the property value
Pass e.style['scroll-timeline-name'] = "--bar, --foo" should set the property value
Fail e.style['scroll-timeline-name'] = "none, none" should set the property value
Pass e.style['scroll-timeline-name'] = "--a, none, --b" should set the property value
Pass e.style['scroll-timeline-name'] = "auto" should not set the property value
Pass e.style['scroll-timeline-name'] = "abc" should not set the property value
Pass e.style['scroll-timeline-name'] = "default" should not set the property value
Pass e.style['scroll-timeline-name'] = "10px" should not set the property value
Pass e.style['scroll-timeline-name'] = "foo bar" should not set the property value
Pass e.style['scroll-timeline-name'] = "\"foo\" \"bar\"" should not set the property value
Pass e.style['scroll-timeline-name'] = "rgb(1, 2, 3)" should not set the property value
Pass e.style['scroll-timeline-name'] = "#fefefe" should not set the property value

View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#scroll-timeline-name">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../css/support/computed-testcommon.js"></script>
</head>
<style>
#outer { scroll-timeline-name: --foo; }
#target { scroll-timeline-name: --bar; }
</style>
<div id="outer">
<div id="target"></div>
</div>
<script>
test_computed_value('scroll-timeline-name', 'initial', 'none');
test_computed_value('scroll-timeline-name', 'inherit', '--foo');
test_computed_value('scroll-timeline-name', 'unset', 'none');
test_computed_value('scroll-timeline-name', 'revert', 'none');
test_computed_value('scroll-timeline-name', 'none');
test_computed_value('scroll-timeline-name', '--foo');
test_computed_value('scroll-timeline-name', '--foo, --bar');
test_computed_value('scroll-timeline-name', '--bar, --foo');
test_computed_value('scroll-timeline-name', '--a, --b, --c, --D, --e');
test_computed_value('scroll-timeline-name', 'none, none');
test_computed_value('scroll-timeline-name', '--a, --b, --c, none, --d, --e');
test(() => {
let style = getComputedStyle(document.getElementById('target'));
assert_not_equals(Array.from(style).indexOf('scroll-timeline-name'), -1);
}, 'The scroll-timeline-name property shows up in CSSStyleDeclaration enumeration');
test(() => {
let style = document.getElementById('target').style;
assert_not_equals(style.cssText.indexOf('scroll-timeline-name'), -1);
}, 'The scroll-timeline-name property shows up in CSSStyleDeclaration.cssText');
</script>

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#scroll-timeline-name">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../css/support/parsing-testcommon.js"></script>
<div id="target"></div>
<script>
test_valid_value('scroll-timeline-name', 'initial');
test_valid_value('scroll-timeline-name', 'inherit');
test_valid_value('scroll-timeline-name', 'unset');
test_valid_value('scroll-timeline-name', 'revert');
test_valid_value('scroll-timeline-name', 'none');
test_valid_value('scroll-timeline-name', '--abc');
test_valid_value('scroll-timeline-name', ' --abc', '--abc');
test_valid_value('scroll-timeline-name', '--aBc');
test_valid_value('scroll-timeline-name', '--foo, --bar');
test_valid_value('scroll-timeline-name', '--bar, --foo');
test_valid_value('scroll-timeline-name', 'none, none');
test_valid_value('scroll-timeline-name', '--a, none, --b');
test_invalid_value('scroll-timeline-name', 'auto');
test_invalid_value('scroll-timeline-name', 'abc');
test_invalid_value('scroll-timeline-name', 'default');
test_invalid_value('scroll-timeline-name', '10px');
test_invalid_value('scroll-timeline-name', 'foo bar');
test_invalid_value('scroll-timeline-name', '"foo" "bar"');
test_invalid_value('scroll-timeline-name', 'rgb(1, 2, 3)');
test_invalid_value('scroll-timeline-name', '#fefefe');
</script>