Bug 1506956 [wpt PR 14039] - [css-properties-values-api] Support fallbacks., a=testonly
authorAnders Hartvoll Ruud <andruud@chromium.org>
Thu, 15 Nov 2018 10:15:22 +0000
changeset 503424 499050dcc920fd05ded045c1d837fc181e024215
parent 503423 e27d257fa11474bb5ce26458da2538838f36dfad
child 503425 f3c83031b453d733501d8db59ebd17e78e191f35
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1506956, 14039, 641877, 1333758, 608014
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/web-platform/tests/css/css-properties-values-api/var-reference-registered-properties-cycles.html
--- a/testing/web-platform/tests/css/css-properties-values-api/var-reference-registered-properties-cycles.html
+++ b/testing/web-platform/tests/css/css-properties-values-api/var-reference-registered-properties-cycles.html
@@ -20,24 +20,23 @@
 <script>
 test(function() {
     CSS.registerProperty({name: '--registered-1-a', syntax: '<length>', initialValue: '1px', inherits: false});
     CSS.registerProperty({name: '--registered-1-b', syntax: '<length>', initialValue: '2px', inherits: false});
     CSS.registerProperty({name: '--registered-1-c', syntax: '<length>', initialValue: '3px', inherits: false});
     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>
 
 <style>
 #test2 {
     --registered-2-a: var(--unregistered-2-a, 10px);
     --unregistered-2-a:var(--registered-2-a,20px);
 
@@ -58,28 +57,28 @@ test(function() {
 test(function() {
     CSS.registerProperty({name: '--registered-2-a', syntax: '<length>', initialValue: '1px', inherits: false});
     CSS.registerProperty({name: '--registered-2-b', syntax: '<length>', initialValue: '2px', inherits: false});
     CSS.registerProperty({name: '--registered-2-c', syntax: '<length>', initialValue: '3px', inherits: false});
     CSS.registerProperty({name: '--registered-2-d', syntax: '<length>', initialValue: '4px', inherits: false});
     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>
 
 <style>
 #test3 {
     --unregistered-3-a:var(--unregistered-3-b,10px);
     --unregistered-3-b:var(--unregistered-3-a,20px);