mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 02:35:41 +00:00
Bug 1506956 [wpt PR 14039] - [css-properties-values-api] Support fallbacks., a=testonly
Automatic update from web-platform-tests[css-properties-values-api] Support fallbacks. According to css-variables-1, any custom property that participates in a cycle is invalid. This also applies to registered custom properties. In the current implementation, however, registered custom properties with an initial value can not become invalid; they compute to their initial value instead, as provided by registerProperty. A consequence of this, is that fallbacks (specified by var()-references) are never triggered if the referenced property is a registered property with an initial value defined. The value for any unregistered custom property, if no other value is specified, is the invalid initial value described by css-variables-1. This means we can just avoid storing the variable on ComputedStyle, to signify the invalid initial value. However, the value for any registered custom property, if no other value is specified, can be the initial value specified by registerProperty. When there is no value explicitly stored on ComputedStyle, we check StyleInitialData and fetch the initial value from there. Hence, we can not use the absence of a value to signify an invalid registered variable, as we already use this state to mean "initial value from registerProperty". This means that we must explicitly store a value for registered properties that participate in a cycle. This CL adds CSSInvalidVariableValue to do this. * When resolving a registered custom property, if a cycle is detected, set the registered value to CSSInvalidVariableValue. * When looking up a registered custom property, if we already have the value CSSInvalidVariableValue, return nullptr instead of initial data. This triggers fallbacks. * The code that set the cycle_detected flag was weird; a cycle could be marked as detected, even though ResolveTokenRange succeeded. This meant that any custom property which referenced a property in a cycle would also be treated as part of the cycle, which is wrong. Fixed by only setting the cycle_detected flag when we have cycle start points. * CSSInterpolationType did not initialize its cycle_detected variable, which led to undefined behavior. R=futhark@chromium.org Bug: 641877 Change-Id: I2c518b176de26f7b2f05b36b568041a228fcb0ea Reviewed-on: https://chromium-review.googlesource.com/c/1333758 Commit-Queue: Anders Ruud <andruud@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/master@{#608014} -- wpt-commits: f082fd63300fec7b6201cf5e0eaf0944ee7ccb6e wpt-pr: 14039
This commit is contained in:
parent
28d789381d
commit
2ef355c4a9
@ -25,14 +25,13 @@ test(function() {
|
||||
CSS.registerProperty({name: '--registered-1-d', syntax: '<length>', initialValue: '4px', inherits: false});
|
||||
|
||||
computedStyle = getComputedStyle(test1);
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-a'), '1px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-b'), '2px');
|
||||
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-c'), '2px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-d'), '2px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-1-a'), '1px');
|
||||
assert_equals(computedStyle.left, '1px');
|
||||
assert_equals(computedStyle.top, '2px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-a'), '');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-b'), '');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-c'), '30px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-1-d'), '4px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-1-a'), '');
|
||||
assert_equals(computedStyle.left, '50px');
|
||||
assert_equals(computedStyle.top, '60px');
|
||||
}, "A var() cycle between two registered properties is handled correctly.");
|
||||
</script>
|
||||
|
||||
@ -63,18 +62,18 @@ test(function() {
|
||||
CSS.registerProperty({name: '--registered-2-e', syntax: '<length>', initialValue: '5px', inherits: false});
|
||||
|
||||
computedStyle = getComputedStyle(test2);
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-a'), '1px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-a'), '');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-a'), '');
|
||||
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-b'), '1px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-c'), '1px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-b'), '30px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-c'), '3px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-d'), '40px');
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-2-e'), '5px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-b'), '1px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-c'), '1px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-b'), '50px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-c'), '');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-d'), '60px');
|
||||
assert_equals(computedStyle.getPropertyValue('--unregistered-2-e'), '');
|
||||
assert_equals(computedStyle.left, '1px');
|
||||
assert_equals(computedStyle.left, '70px');
|
||||
assert_equals(computedStyle.top, '80px');
|
||||
}, "A var() cycle between a registered properties and an unregistered property is handled correctly.");
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user