Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[css-properties-values-api] non-inherited custom property fails to in…
…herit from parent when "inherit" is set

https://bugs.webkit.org/show_bug.cgi?id=251590

Reviewed by Antti Koivisto.

We would only look at the map of inherited custom properties when applying the "inherit" value
for a custom property. However, a non-inherited value should also use its parent's value in that
case.

* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-properties-inheritance.html:
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyInheritCustomProperty):

Canonical link: https://commits.webkit.org/259809@main
  • Loading branch information
graouts committed Feb 3, 2023
1 parent b1a5811 commit 06e3540
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Expand Up @@ -2,6 +2,7 @@
PASS Registered properties are correctly inherited (or not) depending on the inherits flag.
PASS Explicitly inheriting from a parent with an invalid value results in initial value.
PASS Explicitly inheriting from a parent with no value results in initial value.
PASS Explicitly inheriting from a parent with a value results in that value.
PASS Reference to undefined variable results in inherited value
PASS Reference to syntax-incompatible variable results in inherited value
PASS Font-relative units are absolutized before before inheritance
Expand Down
Expand Up @@ -58,6 +58,13 @@
assert_equals(getComputedStyle(inner).getPropertyValue('--initial-length-2'), '0px');
}, "Explicitly inheriting from a parent with no value results in initial value.");

test(function(){
CSS.registerProperty({name: '--initial-length-3', syntax: '<length>', initialValue: '0px', inherits: false});
outer.style = '--initial-length-3: 100px';
inner.style = '--initial-length-3: inherit';
assert_equals(getComputedStyle(inner).getPropertyValue('--initial-length-3'), '100px');
}, "Explicitly inheriting from a parent with a value results in that value.");

test(function(){
CSS.registerProperty({name: '--inherited-length-4', syntax: '<length>', initialValue: '0px', inherits: true});
outer.style = '--inherited-length-4: 42px';
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/style/StyleBuilderCustom.h
Expand Up @@ -2167,6 +2167,8 @@ inline void BuilderCustom::applyInheritCustomProperty(BuilderState& builderState
auto* parentValue = builderState.parentStyle().inheritedCustomProperties().get(name);
if (parentValue && !(registered && !registered->inherits))
applyValueCustomProperty(builderState, registered, const_cast<CSSCustomPropertyValue&>(*parentValue));
else if (auto* nonInheritedParentValue = builderState.parentStyle().nonInheritedCustomProperties().get(name))
applyValueCustomProperty(builderState, registered, const_cast<CSSCustomPropertyValue&>(*nonInheritedParentValue));
else
applyInitialCustomProperty(builderState, registered, name);
}
Expand Down

0 comments on commit 06e3540

Please sign in to comment.