Changeset 239365 in webkit
- Timestamp:
- Dec 18, 2018 7:21:15 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r239357 r239365 1 2018-12-18 Justin Michaud <justin_michaud@apple.com> 2 3 Update CSS Properties and Values API to use new cycle fallback behaviour 4 https://bugs.webkit.org/show_bug.cgi?id=192800 5 6 Reviewed by Antti Koivisto. 7 8 * css-custom-properties-api/crash.html: 9 * css-custom-properties-api/inherits-expected.txt: 10 * css-custom-properties-api/inherits.html: 11 * css-custom-properties-api/registerProperty-expected.txt: 12 * css-custom-properties-api/registerProperty.html: 13 1 14 2018-12-18 Myles C. Maxfield <mmaxfield@apple.com> 2 15 -
trunk/LayoutTests/css-custom-properties-api/crash.html
r237697 r239365 49 49 inlineStyle.setProperty('--baz', ' 40px'); 50 50 assert_equals(computedStyle.getPropertyValue('--baz'), '40px'); 51 assert_equals(computedStyle.getPropertyValue('--foo'), ' 200px');52 assert_equals(computedStyle.getPropertyValue('--bar'), ' 200px');51 assert_equals(computedStyle.getPropertyValue('--foo'), ''); 52 assert_equals(computedStyle.getPropertyValue('--bar'), ''); 53 53 assert_equals(computedStyle.getPropertyValue('--baz'), '40px'); 54 assert_equals(computedStyle.getPropertyValue('font-size'), ' 200px');54 assert_equals(computedStyle.getPropertyValue('font-size'), '30px'); 55 55 inlineStyle.removeProperty('--baz'); 56 56 assert_equals(computedStyle.getPropertyValue('--baz'), '200px'); 57 assert_equals(computedStyle.getPropertyValue('--foo'), ' 200px');58 assert_equals(computedStyle.getPropertyValue('--bar'), ' 200px');59 assert_equals(computedStyle.getPropertyValue('font-size'), ' 200px');57 assert_equals(computedStyle.getPropertyValue('--foo'), ''); 58 assert_equals(computedStyle.getPropertyValue('--bar'), ''); 59 assert_equals(computedStyle.getPropertyValue('font-size'), '30px'); 60 60 assert_equals(computedStyle.getPropertyValue('--baz'), '200px'); 61 61 }, "Setting the inline style is handled correctly when registered"); -
trunk/LayoutTests/css-custom-properties-api/inherits-expected.txt
r236828 r239365 1 1 Specified in parent, inherits=true 2 2 3 100px green 3 test 4 4 5 5 Specified in parent, inherits=false 6 6 7 200px green 7 test 8 8 9 9 Specified in parent, not registered 10 10 11 100px green 11 test 12 12 13 13 Initial 14 14 15 200px green 15 test 16 16 17 17 Unset, inherits=true 18 18 19 100px green 19 test 20 20 21 21 Unset, inherits=false 22 22 23 200px green 23 test 24 24 25 25 A cycle between an inherits=true and inherits=false property 26 26 27 200px green 27 test 28 28 29 29 A cycle between an inherits=true and inherits=false property 30 30 31 200px green 31 test 32 32 33 33 A cycle between an inherits=true and inherits=false property with fallback 34 34 35 200px green 35 test 36 36 37 37 Inheritance should not create a cycle 38 38 39 110px green 39 test 40 40 41 41 A cycle between two unregistered properties 42 42 43 300px green 43 test 44 44 45 45 Revert, inherits=true 46 46 47 190px purple 47 test 48 48 49 49 Revert, inherits=false 50 50 51 200px purple 51 test 52 52 53 53 Revert, unregistered 54 54 55 purple 55 test 56 56 57 57 Inherit, unregistered 58 58 59 purple 59 test 60 60 61 61 Test that inherited properties do variable substitution before being inherited - registered … … 69 69 No initial value in registered property should act like unregistered 70 70 71 200px green 71 test 72 72 73 73 (unregistered) 74 74 75 500px green 75 test 76 76 77 77 Inherit should be substituted for unregistered property 78 78 79 500px green 79 test 80 80 81 81 -
trunk/LayoutTests/css-custom-properties-api/inherits.html
r236828 r239365 245 245 <div> 246 246 <p> Specified in parent, inherits=true</p> 247 <div id="parent1"><div id="child1"><p> 100px green</p></div> </div>247 <div id="parent1"><div id="child1"><p>test</p></div> </div> 248 248 <p> Specified in parent, inherits=false </p> 249 <div id="parent2"><div id="child2"><p> 200px green</p></div> </div>249 <div id="parent2"><div id="child2"><p>test</p></div> </div> 250 250 <p> Specified in parent, not registered </p> 251 <div id="parent3"><div id="child3"><p> 100px green</p></div> </div>251 <div id="parent3"><div id="child3"><p>test</p></div> </div> 252 252 <p> Initial </p> 253 <div id="parent4"><div id="child4"><p> 200px green</p></div> </div>253 <div id="parent4"><div id="child4"><p>test</p></div> </div> 254 254 <p> Unset, inherits=true </p> 255 <div id="parent5"><div id="child5"><p> 100px green</p></div> </div>255 <div id="parent5"><div id="child5"><p>test</p></div> </div> 256 256 <p> Unset, inherits=false </p> 257 <div id="parent6"><div id="child6"><p> 200px green</p></div> </div>257 <div id="parent6"><div id="child6"><p>test</p></div> </div> 258 258 <p> A cycle between an inherits=true and inherits=false property </p> 259 <div id="parent7"><div id="child7"><p> 200px green</p></div> </div>259 <div id="parent7"><div id="child7"><p>test</p></div> </div> 260 260 <p> A cycle between an inherits=true and inherits=false property </p> 261 <div id="parent8"><div id="child8"><p> 200px green</p></div> </div>261 <div id="parent8"><div id="child8"><p>test</p></div> </div> 262 262 <p> A cycle between an inherits=true and inherits=false property with fallback </p> 263 <div id="parent9"><div id="child9"><p> 200px green</p></div> </div>263 <div id="parent9"><div id="child9"><p>test</p></div> </div> 264 264 <p> Inheritance should not create a cycle </p> 265 <div id="parent10"><div id="child10"><p> 110px green</p></div></div>265 <div id="parent10"><div id="child10"><p>test</p></div></div> 266 266 <p> A cycle between two unregistered properties </p> 267 <div id="parent11"><div id="child11"><p> 300px green</p></div> </div>267 <div id="parent11"><div id="child11"><p>test</p></div> </div> 268 268 269 269 <p> Revert, inherits=true </p> 270 <div id="parent12"><div id="child12"><div id="childchild12"><p> 190px purple</p></div></div></div>270 <div id="parent12"><div id="child12"><div id="childchild12"><p>test</p></div></div></div> 271 271 <p> Revert, inherits=false </p> 272 <div id="parent13"><div id="child13"><div id="childchild13"><p> 200px purple</p></div></div> </div>272 <div id="parent13"><div id="child13"><div id="childchild13"><p>test</p></div></div> </div> 273 273 <p> Revert, unregistered </p> 274 <div id="parent14"><div id="child14"><div id="childchild14"><p> purple</p></div></div> </div>274 <div id="parent14"><div id="child14"><div id="childchild14"><p>test</p></div></div> </div> 275 275 <p> Inherit, unregistered </p> 276 <div id="parent14-1"><div id="child14-1"><div id="childchild14-1"><p> purple</p></div></div> </div>276 <div id="parent14-1"><div id="child14-1"><div id="childchild14-1"><p>test</p></div></div> </div> 277 277 278 278 <p> Test that inherited properties do variable substitution before being inherited - registered</p> … … 282 282 283 283 <p> No initial value in registered property should act like unregistered</p> 284 <div id="parent17"><div id="child17"><p> 200px green</p></div> </div>284 <div id="parent17"><div id="child17"><p>test</p></div> </div> 285 285 <p> (unregistered) </p> 286 <div id="parent18"><div id="child18"><p> 500px green</p></div> </div>286 <div id="parent18"><div id="child18"><p>test</p></div> </div> 287 287 288 288 <p>Inherit should be substituted for unregistered property</p> 289 <div id="parent19"><div id="child19"><p> 500px green</p></div> </div>289 <div id="parent19"><div id="child19"><p>test</p></div> </div> 290 290 </div> 291 291 <script> … … 347 347 }, "JS Attributes are valid for element 6"); 348 348 test(function() { 349 test_prop('child7', 'width', ' 200px');350 test_prop('child7', '--my-custom-prop', ' 100px');351 test_prop('child7', '--my-custom-prop2', ' 200px');349 test_prop('child7', 'width', '300px'); 350 test_prop('child7', '--my-custom-prop', ''); 351 test_prop('child7', '--my-custom-prop2', ''); 352 352 }, "JS Attributes are valid for element 7"); 353 353 test(function() { 354 test_prop('child8', 'width', ' 200px');355 test_prop('child8', '--my-custom-prop', ' 200px');356 test_prop('child8', '--my-custom-prop2', ' 200px');354 test_prop('child8', 'width', '300px'); 355 test_prop('child8', '--my-custom-prop', ''); 356 test_prop('child8', '--my-custom-prop2', ''); 357 357 }, "JS Attributes are valid for element 8"); 358 358 test(function() { 359 test_prop('child9', 'width', ' 200px');360 test_prop('child9', '--my-custom-prop', ' 100px');361 test_prop('child9', '--my-custom-prop2', ' 200px');359 test_prop('child9', 'width', '300px'); 360 test_prop('child9', '--my-custom-prop', ''); 361 test_prop('child9', '--my-custom-prop2', ''); 362 362 }, "JS Attributes are valid for element 9"); 363 363 test(function() { -
trunk/LayoutTests/css-custom-properties-api/registerProperty-expected.txt
r236379 r239365 4 4 PASS registerProperty always allows omitting initialValue and syntax, requires name and inherits 5 5 PASS registerProperty requires inherits and name 6 PASS registerProperty requires initialValue to be computationally independent 6 7 -
trunk/LayoutTests/css-custom-properties-api/registerProperty.html
r236379 r239365 3 3 <script src="../resources/testharness.js"></script> 4 4 <script src="../resources/testharnessreport.js"></script> 5 <div id="el"></div> 5 6 <script> 6 7 // Tests for error checking during property registration … … 19 20 CSS.registerProperty({name: ['--name', 3], inherits: false}); 20 21 // Invalid property names 21 //assert_throws(new SyntaxError(), () => CSS.registerProperty({name: 'no-leading-dash', inherits: false}));22 //assert_throws(new SyntaxError(), () => CSS.registerProperty({name: '', inherits: false}));23 //assert_throws(new SyntaxError(), () => CSS.registerProperty({name: '\\--name', inherits: false}));22 assert_throws(new SyntaxError(), () => CSS.registerProperty({name: 'no-leading-dash', inherits: false})); 23 assert_throws(new SyntaxError(), () => CSS.registerProperty({name: '', inherits: false})); 24 assert_throws(new SyntaxError(), () => CSS.registerProperty({name: '\\--name', inherits: false})); 24 25 }, "registerProperty requires a name matching <custom-property-name>"); 25 26 test(function() { … … 38 39 CSS.registerProperty({name: '--syntax-test-5', inherits: false, syntax: ' * '}); 39 40 }, "registerProperty requires inherits and name"); 41 test(function() { 42 CSS.registerProperty({name: '--initialvalue-test-0', inherits: false, syntax: '<length>', initialValue: 'calc(10px + 10in)'}); 43 assert_equals(window.getComputedStyle(el).getPropertyValue('--initialvalue-test-0').toString(), '970px'); 44 45 assert_throws(new SyntaxError(), 46 () => CSS.registerProperty({name: '--initialvalue-test-1', inherits: false, syntax: '<length>', initialValue: '10em'})); 47 assert_throws(new SyntaxError(), 48 () => CSS.registerProperty({name: '--initialvalue-test-2', inherits: false, syntax: '<length>', initialValue: 'calc(10px + 10em)'})); 49 assert_throws(new SyntaxError(), 50 () => CSS.registerProperty({name: '--initialvalue-test-3', inherits: false, syntax: '<length>', initialValue: 'calc(10px + 10%)'})); 51 }, "registerProperty requires initialValue to be computationally independent"); 40 52 </script> -
trunk/LayoutTests/imported/w3c/ChangeLog
r239341 r239365 1 2018-12-18 Justin Michaud <justin_michaud@apple.com> 2 3 Update CSS Properties and Values API to use new cycle fallback behaviour 4 https://bugs.webkit.org/show_bug.cgi?id=192800 5 6 Reviewed by Antti Koivisto. 7 8 Re-import tests and adjust expected results. Some of the tests go from pass to fail because 9 this patch adds some extra dependency checking to property registrations to fix a crash, but 10 now unsupported syntaxes like <length-percentage> do not register properly. 11 12 * web-platform-tests/css/css-properties-values-api/register-property-expected.txt: 13 * web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt: 14 * web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing.html: 15 * web-platform-tests/css/css-properties-values-api/register-property.html: 16 * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: 17 * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance.html: 18 * web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt: 19 * web-platform-tests/css/css-properties-values-api/registered-property-computation.html: 20 * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: 21 * web-platform-tests/css/css-properties-values-api/registered-property-cssom.html: 22 * web-platform-tests/css/css-properties-values-api/registered-property-initial-expected.txt: 23 * web-platform-tests/css/css-properties-values-api/registered-property-initial.html: 24 * web-platform-tests/css/css-properties-values-api/resources/utils.js: Added. 25 (generate_name): 26 (any_initial_value): 27 (generate_property): 28 (all_syntaxes): 29 * web-platform-tests/css/css-properties-values-api/resources/w3c-import.log: Added. 30 * web-platform-tests/css/css-properties-values-api/self-utils-expected.txt: Added. 31 * web-platform-tests/css/css-properties-values-api/self-utils.html: Added. 32 * web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt: 33 * web-platform-tests/css/css-properties-values-api/typedom.tentative.html: 34 * web-platform-tests/css/css-properties-values-api/unit-cycles-expected.txt: 35 * web-platform-tests/css/css-properties-values-api/unit-cycles.html: 36 * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles.html: 37 * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt: 38 * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties.html: 39 * web-platform-tests/css/css-properties-values-api/w3c-import.log: 40 1 41 2018-12-18 Justin Michaud <justin_michaud@apple.com> 2 42 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-expected.txt
r236444 r239365 1 1 2 2 PASS registerProperty requires a Dictionary type 3 FAIL registerProperty requires a name matching <custom-property-name> assert_throws: function "() => CSS.registerProperty({name: 'no-leading-dash', inherits: false})" did not throw 3 PASS registerProperty requires a name matching <custom-property-name> 4 4 FAIL registerProperty only allows omitting initialValue if syntax is '*' assert_throws: function "() => CSS.registerProperty({name: '--syntax-test-3', syntax: 'length', inherits: false})" did not throw 5 PASS registerProperty fails for an already registered property 5 FAIL registerProperty fails for an already registered property assert_throws: function "() => CSS.registerProperty({name: '--re-register', syntax: '<percentage>', initialValue: '0%', inherits: false})" threw object "SyntaxError: The given initial value does not parse for the given syntax." ("SyntaxError") expected object "[object Object]" ("InvalidModificationError") 6 6 PASS registerProperty requires inherits 7 FAIL Registering a property should not cause a transition The given initial value does not parse for the given syntax. 7 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt
r237697 r239365 4 4 PASS syntax:'<length>', initialValue:'2px' is valid 5 5 FAIL syntax:' <number>', initialValue:'5' is valid The given initial value does not parse for the given syntax. 6 PASS syntax:'<percentage> ', initialValue:'10%' is valid 6 FAIL syntax:'<percentage> ', initialValue:'10%' is valid The given initial value does not parse for the given syntax. 7 7 FAIL syntax:'<color>+', initialValue:'red' is valid The given initial value does not parse for the given syntax. 8 8 FAIL syntax:' <length>+ | <percentage>', initialValue:'2px 8px' is valid The given initial value does not parse for the given syntax. … … 22 22 PASS syntax:'<length>', initialValue:'calc(7in - 12px)' is valid 23 23 FAIL syntax:'<length>+', initialValue:'2px 7px calc(8px)' is valid The given initial value does not parse for the given syntax. 24 FAIL syntax:'<length>#', initialValue:'2px, 7px, calc(8px)' is valid The given initial value does not parse for the given syntax. 24 25 FAIL syntax:'<percentage>', initialValue:'-9.3e3%' is valid The given initial value does not parse for the given syntax. 25 26 FAIL syntax:'<length-percentage>', initialValue:'-54%' is valid The given initial value does not parse for the given syntax. 26 27 PASS syntax:'<length-percentage>', initialValue:'0' is valid 27 PASS syntax:'<length-percentage>', initialValue:'calc(-11px + 10.4%)' is valid 28 FAIL syntax:'<length-percentage>', initialValue:'calc(-11px + 10.4%)' is valid The given initial value does not parse for the given syntax. 28 29 FAIL syntax:'<number>', initialValue:'-109' is valid The given initial value does not parse for the given syntax. 29 30 FAIL syntax:'<number>', initialValue:'2.3e4' is valid The given initial value does not parse for the given syntax. 30 31 FAIL syntax:'<integer>', initialValue:'-109' is valid The given initial value does not parse for the given syntax. 31 32 FAIL syntax:'<integer>', initialValue:'19' is valid The given initial value does not parse for the given syntax. 33 FAIL syntax:'<integer>', initialValue:'calc(1)' is valid The given initial value does not parse for the given syntax. 34 FAIL syntax:'<integer>', initialValue:'calc(1 + 2)' is valid The given initial value does not parse for the given syntax. 35 FAIL syntax:'<integer>', initialValue:'calc(3.1415)' is valid The given initial value does not parse for the given syntax. 36 FAIL syntax:'<integer>', initialValue:'calc(3.1415 + 3.1415)' is valid The given initial value does not parse for the given syntax. 32 37 FAIL syntax:'<angle>', initialValue:'10deg' is valid The given initial value does not parse for the given syntax. 33 38 FAIL syntax:'<angle>', initialValue:'20.5rad' is valid The given initial value does not parse for the given syntax. … … 86 91 FAIL syntax:'<length>|initial', initialValue:'10px' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 87 92 FAIL syntax:'<length>|INHERIT', initialValue:'10px' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 88 FAIL syntax:'<percentage>|unsEt', initialValue:'2%' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 93 PASS syntax:'<percentage>|unsEt', initialValue:'2%' is invalid 89 94 FAIL syntax:'*', initialValue:'initial' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 90 95 FAIL syntax:'*', initialValue:'inherit' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw … … 105 110 PASS syntax:'<length>', initialValue:'var(--moo)' is invalid 106 111 PASS syntax:'<length>', initialValue:'10' is invalid 107 FAIL syntax:'<length>', initialValue:'10%' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 108 FAIL syntax:'<length>', initialValue:'calc(5px + 10%)' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 112 PASS syntax:'<length>', initialValue:'10%' is invalid 113 PASS syntax:'<length>', initialValue:'calc(5px + 10%)' is invalid 109 114 PASS syntax:'<length>', initialValue:'calc(5px * 3px / 6px)' is invalid 110 FAIL syntax:'<length>', initialValue:'10em' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 115 PASS syntax:'<length>', initialValue:'10em' is invalid 111 116 FAIL syntax:'<length>', initialValue:'10vmin' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 112 FAIL syntax:'<length>', initialValue:'calc(4px + 3em)' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 113 FAIL syntax:'<length>', initialValue:'calc(4px + calc(8 * 2em))' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 114 FAIL syntax:'<length>+', initialValue:'calc(2ex + 16px)' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 117 PASS syntax:'<length>', initialValue:'calc(4px + 3em)' is invalid 118 PASS syntax:'<length>', initialValue:'calc(4px + calc(8 * 2em))' is invalid 119 PASS syntax:'<length>+', initialValue:'calc(2ex + 16px)' is invalid 115 120 PASS syntax:'<length>+', initialValue:'10px calc(20px + 4rem)' is invalid 121 FAIL syntax:'<length>+', initialValue:'' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 122 FAIL syntax:'<length>#', initialValue:'' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 116 123 PASS syntax:'<percentage> | <length>+', initialValue:'calc(100vh - 10px) 30px' is invalid 117 124 PASS syntax:'<length>', initialValue:'10px;' is invalid 118 FAIL syntax:'<length-percentage>', initialValue:'calc(2px + 10% + 7ex)' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 125 PASS syntax:'<length-percentage>', initialValue:'calc(2px + 10% + 7ex)' is invalid 119 126 FAIL syntax:'<percentage>', initialValue:'0' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 120 127 PASS syntax:'<integer>', initialValue:'1.0' is invalid … … 122 129 PASS syntax:'<number>|foo', initialValue:'foo var(--foo, bla)' is invalid 123 130 FAIL syntax:'<angle>', initialValue:'0' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 124 FAIL syntax:'<angle>', initialValue:'10%' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 131 PASS syntax:'<angle>', initialValue:'10%' is invalid 125 132 FAIL syntax:'<time>', initialValue:'2px' is invalid assert_throws: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw 126 133 PASS syntax:'<resolution>', initialValue:'10' is invalid -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing.html
r236444 r239365 47 47 assert_valid("<length>", "calc(7in - 12px)"); 48 48 assert_valid("<length>+", "2px 7px calc(8px)"); 49 assert_valid("<length>#", "2px, 7px, calc(8px)"); 49 50 assert_valid("<percentage>", "-9.3e3%"); 50 51 assert_valid("<length-percentage>", "-54%"); … … 56 57 assert_valid("<integer>", "-109"); 57 58 assert_valid("<integer>", "19"); 59 assert_valid("<integer>", "calc(1)"); 60 assert_valid("<integer>", "calc(1 + 2)"); 61 assert_valid("<integer>", "calc(3.1415)"); 62 assert_valid("<integer>", "calc(3.1415 + 3.1415)"); 58 63 59 64 assert_valid("<angle>", "10deg"); … … 148 153 assert_invalid("<length>+", "calc(2ex + 16px)"); 149 154 assert_invalid("<length>+", "10px calc(20px + 4rem)"); 155 assert_invalid("<length>+", ""); 156 assert_invalid("<length>#", ""); 150 157 assert_invalid("<percentage> | <length>+", "calc(100vh - 10px) 30px"); 151 158 assert_invalid("<length>", "10px;"); -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property.html
r236444 r239365 3 3 <script src="/resources/testharness.js"></script> 4 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="./resources/utils.js"></script> 6 <div id=target></div> 5 7 <script> 6 8 // Tests for error checking during property registration … … 46 48 assert_throws(new TypeError(), () => CSS.registerProperty({name: '--inherit-test-3', syntax: '<length>', initialValue: '0px'})); 47 49 }, "registerProperty requires inherits"); 50 51 test(function(){ 52 try { 53 let name = generate_name(); 54 55 target.style.setProperty(name, 'green'); 56 target.style.transitionProperty = name; 57 target.style.transitionDuration = '1s'; 58 target.style.transitionTimingFunction = 'steps(1, end)'; 59 60 assert_equals(getComputedStyle(target).getPropertyValue(name), 'green'); 61 62 CSS.registerProperty({ 63 name: name, 64 syntax: '<color>', 65 initialValue: 'red', 66 inherits: false 67 }); 68 69 assert_equals(getComputedStyle(target).getPropertyValue(name), 'rgb(0, 128, 0)'); 70 } finally { 71 target.style = ''; 72 } 73 }, 'Registering a property should not cause a transition'); 74 48 75 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt
r237697 r239365 5 5 PASS Reference to undefined variable results in inherited value 6 6 PASS Reference to syntax-incompatible variable results in inherited value 7 PASS Font-relative units are absolutized before before inheritance 8 PASS Calc expressions are resolved before inheritance 7 9 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-properties-inheritance.html
r236444 r239365 73 73 }, "Reference to syntax-incompatible variable results in inherited value"); 74 74 75 test(function(){ 76 CSS.registerProperty({name: '--inherited-em', syntax: '<length>', initialValue: '0px', inherits: true}); 77 outer.style = 'font-size: 11px; --inherited-em: 10em;'; 78 inner.style = 'font-size: 22px; --unregistered:var(--inherited-em);'; 79 assert_equals(getComputedStyle(inner).getPropertyValue('--unregistered'), '110px'); 80 }, "Font-relative units are absolutized before before inheritance"); 81 82 test(function(){ 83 CSS.registerProperty({name: '--calc-length', syntax: '<length>', initialValue: '0px', inherits: true}); 84 outer.style = '--calc-length: calc(10px + 10px);'; 85 inner.style = '--unregistered:var(--calc-length);'; 86 assert_equals(getComputedStyle(inner).getPropertyValue('--unregistered'), '20px'); 87 }, "Calc expressions are resolved before inheritance"); 88 75 89 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt
r236895 r239365 1 1 2 FAIL CSS.registerProperty The given initial value does not parse for the given syntax. 3 PASS <length> values are computed correctly for divWithFontSizeSet 4 FAIL <length-percentage> values are computed correctly for divWithFontSizeSet assert_equals: expected "calc(190px + -2%)" but got "calc(190px - 2%)" 5 FAIL <length># values are computed correctly for divWithFontSizeSet assert_equals: expected "10px, 30px" but got "0px" 6 FAIL <length-percentage># values are computed correctly for divWithFontSizeSet assert_equals: expected "3%, 80px, 22px" but got "0px" 7 FAIL <length>+ values are computed correctly for divWithFontSizeSet assert_equals: expected "10px 30px" but got "0px" 8 FAIL <length-percentage>+ values are computed correctly for divWithFontSizeSet assert_equals: expected "3% 80px 22px" but got "0px" 9 FAIL <transform-function> values are computed correctly for divWithFontSizeSet assert_equals: expected "translateX(2px)" but got " translateX(2px)" 10 PASS <length> values are computed correctly for divWithFontSizeInherited 11 FAIL <length-percentage> values are computed correctly for divWithFontSizeInherited assert_equals: expected "calc(190px + -2%)" but got "calc(190px - 2%)" 12 FAIL <length># values are computed correctly for divWithFontSizeInherited assert_equals: expected "10px, 30px" but got "0px" 13 FAIL <length-percentage># values are computed correctly for divWithFontSizeInherited assert_equals: expected "3%, 80px, 22px" but got "0px" 14 FAIL <length>+ values are computed correctly for divWithFontSizeInherited assert_equals: expected "10px 30px" but got "0px" 15 FAIL <length-percentage>+ values are computed correctly for divWithFontSizeInherited assert_equals: expected "3% 80px 22px" but got "0px" 16 FAIL <transform-function> values are computed correctly for divWithFontSizeInherited assert_equals: expected "translateX(2px)" but got " translateX(2px)" 2 PASS <length> values computed are correctly via var()-reference 3 PASS <length> values computed are correctly via var()-reference when font-size is inherited 4 PASS <length> values are computed correctly when font-size is inherited [14em] 5 PASS <length> values are computed correctly when font-size is inherited [calc(14em + 10px)] 6 PASS <length> values are computed correctly [12px] 7 PASS <length> values are computed correctly [13vw] 8 PASS <length> values are computed correctly [14em] 9 PASS <length> values are computed correctly [15vmin] 10 PASS <length> values are computed correctly [calc(16px - 7em + 10vh)] 11 PASS <length-percentage> values are computed correctly [17em] 12 FAIL <length-percentage> values are computed correctly [18%] assert_equals: expected "18%" but got "0px" 13 FAIL <length-percentage> values are computed correctly [calc(19em - 2%)] assert_equals: expected "calc(-2% + 190px)" but got "0px" 14 FAIL <length># values are computed correctly [10px, 3em] assert_equals: expected "10px, 30px" but got "0px" 15 FAIL <length># values are computed correctly [4em ,9px] assert_equals: expected "40px, 9px" but got "0px" 16 PASS <length># values are computed correctly [8em] 17 FAIL <length-percentage># values are computed correctly [3% , 10vmax , 22px] assert_equals: expected "3%, 80px, 22px" but got "0px" 18 FAIL <length-percentage># values are computed correctly [calc(50% + 1em), 4px] assert_equals: expected "calc(50% + 10px), 4px" but got "0px" 19 FAIL <length-percentage># values are computed correctly [calc(13% + 37px)] assert_equals: expected "calc(13% + 37px)" but got "0px" 20 FAIL <length>+ values are computed correctly [10px 3em] assert_equals: expected "10px 30px" but got "0px" 21 FAIL <length>+ values are computed correctly [4em 9px] assert_equals: expected "40px 9px" but got "0px" 22 FAIL <length-percentage>+ values are computed correctly [3% 10vmax 22px] assert_equals: expected "3% 80px 22px" but got "0px" 23 FAIL <length-percentage>+ values are computed correctly [calc(50% + 1em) 4px] assert_equals: expected "calc(50% + 10px) 4px" but got "0px" 24 FAIL <transform-function> values are computed correctly [translateX(2px)] The given initial value does not parse for the given syntax. 25 FAIL <transform-function> values are computed correctly [translateX(10em)] The given initial value does not parse for the given syntax. 26 FAIL <transform-function> values are computed correctly [translateX(calc(11em + 10%))] The given initial value does not parse for the given syntax. 27 FAIL <transform-function>+ values are computed correctly [translateX(10%) scale(2)] The given initial value does not parse for the given syntax. 28 FAIL <integer> values are computed correctly [15] assert_equals: expected "15" but got "0px" 29 FAIL <integer> values are computed correctly [calc(15 + 15)] assert_equals: expected "30" but got "0px" 30 FAIL <integer> values are computed correctly [calc(2.4)] assert_equals: expected "2" but got "0px" 31 FAIL <integer> values are computed correctly [calc(2.6)] assert_equals: expected "3" but got "0px" 32 FAIL <integer> values are computed correctly [calc(2.6 + 3.1)] assert_equals: expected "6" but got "0px" 33 FAIL <integer>+ values are computed correctly [15 calc(2.4) calc(2.6)] assert_equals: expected "15 2 3" but got "0px" 34 FAIL <color> values are computed correctly [#ff0000] The given initial value does not parse for the given syntax. 35 FAIL <color> values are computed correctly [#000f00] The given initial value does not parse for the given syntax. 36 FAIL <color> values are computed correctly [#00000a] The given initial value does not parse for the given syntax. 37 FAIL <color> values are computed correctly [#badbee] The given initial value does not parse for the given syntax. 38 FAIL <color> values are computed correctly [#badbee33] The given initial value does not parse for the given syntax. 39 FAIL <color> values are computed correctly [tomato] The given initial value does not parse for the given syntax. 40 FAIL <color> values are computed correctly [plum] The given initial value does not parse for the given syntax. 41 FAIL <color> values are computed correctly [currentcolor] The given initial value does not parse for the given syntax. 42 PASS * values are computed correctly [tomato] 43 FAIL tomato | plum values are computed correctly [plum] The given initial value does not parse for the given syntax. 44 FAIL tomato | plum | <color> values are computed correctly [plum] The given initial value does not parse for the given syntax. 45 PASS * values are computed correctly [-50grad] 46 FAIL <angle> values are computed correctly [180deg] The given initial value does not parse for the given syntax. 47 FAIL <angle> values are computed correctly [400grad] The given initial value does not parse for the given syntax. 48 FAIL <angle> values are computed correctly [calc(360deg + 400grad)] The given initial value does not parse for the given syntax. 49 PASS * values are computed correctly [50s] 50 FAIL <time> values are computed correctly [1s] The given initial value does not parse for the given syntax. 51 FAIL <time> values are computed correctly [1000ms] The given initial value does not parse for the given syntax. 52 FAIL <time> values are computed correctly [calc(1000ms + 1s)] The given initial value does not parse for the given syntax. 53 PASS * values are computed correctly [50dpi] 54 FAIL <resolution> values are computed correctly [1dppx] The given initial value does not parse for the given syntax. 55 FAIL <resolution> values are computed correctly [96dpi] The given initial value does not parse for the given syntax. 56 FAIL <resolution> values are computed correctly [calc(1dppx + 96dpi)] The given initial value does not parse for the given syntax. 17 57 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation.html
r236444 r239365 1 <!DOCTYPE HTML>1 <!DOCTYPE html> 2 2 <link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#calculation-of-computed-values" /> 3 3 <script src="/resources/testharness.js"></script> 4 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="./resources/utils.js"></script> 5 6 6 7 <style> 7 8 #divWithFontSizeSet, #parentDiv { 8 9 font-size: 10px; 9 }10 #divWithFontSizeSet, #divWithFontSizeInherited {11 --length-1: 12px;12 --length-2: 13vw;13 --length-3: 14em;14 --length-4: 15vmin;15 --length-5: calc(16px - 7em + 10vh);16 --length-6: var(--length-3);17 --length-percentage-1: 17em;18 --length-percentage-2: 18%;19 --length-percentage-3: calc(19em - 2%);20 --csv-1: 10px, 3em;21 --csv-2: 4em ,9px;22 --csv-3: 8em;23 --csv-4: 3% , 10vmax , 22px;24 --csv-5: calc(50% + 1em), 4px;25 --csv-6: calc(13% + 37px);26 --list-1: 10px 3em;27 --list-2: 4em 9px;28 --list-3: 3% 10vmax 22px;29 --list-4: calc(50% + 1em) 4px;30 --transform-function-1: translateX(2px);31 --transform-function-2: translateX(10em);32 --transform-function-3: translateX(calc(11em + 10%));33 --transform-function-4: translateX(10%) scale(2);34 10 } 35 11 </style> … … 39 15 <div id=divWithFontSizeInherited></div> 40 16 </div> 17 <div id="ref"></div> 41 18 42 19 <script> 43 test(() => {44 CSS.registerProperty({name: '--length-1', syntax: '<length>', initialValue: '0px', inherits: false});45 CSS.registerProperty({name: '--length-2', syntax: '<length>', initialValue: '0px', inherits: false});46 CSS.registerProperty({name: '--length-3', syntax: '<length>', initialValue: '0px', inherits: false});47 CSS.registerProperty({name: '--length-4', syntax: '<length>', initialValue: '0px', inherits: false});48 CSS.registerProperty({name: '--length-5', syntax: '<length>', initialValue: '0px', inherits: false});49 CSS.registerProperty({name: '--length-6', syntax: '<length>', initialValue: '0px', inherits: false});50 CSS.registerProperty({name: '--length-percentage-1', syntax: '<length-percentage>', initialValue: '0px', inherits: false});51 CSS.registerProperty({name: '--length-percentage-2', syntax: '<length-percentage>', initialValue: '0px', inherits: false});52 CSS.registerProperty({name: '--length-percentage-3', syntax: '<length-percentage>', initialValue: '0px', inherits: false});53 CSS.registerProperty({name: '--csv-1', syntax: '<length>#', initialValue: '0px', inherits: false});54 CSS.registerProperty({name: '--csv-2', syntax: '<length>#', initialValue: '0px', inherits: false});55 CSS.registerProperty({name: '--csv-3', syntax: '<length>#', initialValue: '0px', inherits: false});56 CSS.registerProperty({name: '--csv-4', syntax: '<length-percentage>#', initialValue: '0px', inherits: false});57 CSS.registerProperty({name: '--csv-5', syntax: '<length-percentage>#', initialValue: '0px', inherits: false});58 CSS.registerProperty({name: '--csv-6', syntax: '<length-percentage>#', initialValue: '0px', inherits: false});59 CSS.registerProperty({name: '--list-1', syntax: '<length>+', initialValue: '0px', inherits: false});60 CSS.registerProperty({name: '--list-2', syntax: '<length>+', initialValue: '0px', inherits: false});61 CSS.registerProperty({name: '--list-3', syntax: '<length-percentage>+', initialValue: '0px', inherits: false});62 CSS.registerProperty({name: '--list-4', syntax: '<length-percentage>+', initialValue: '0px', inherits: false});63 CSS.registerProperty({name: '--transform-function-1', syntax: '<transform-function>', initialValue: 'translateX(0px)', inherits: false});64 CSS.registerProperty({name: '--transform-function-2', syntax: '<transform-function>', initialValue: 'translateX(0px)', inherits: false});65 CSS.registerProperty({name: '--transform-function-3', syntax: '<transform-function>', initialValue: 'translateX(0px)', inherits: false});66 CSS.registerProperty({name: '--transform-function-4', syntax: '<transform-function>+', initialValue: 'translateX(0px)', inherits: false});67 }, "CSS.registerProperty");68 20 69 for (var element of [divWithFontSizeSet, divWithFontSizeInherited]) { 70 var id = element.id; 71 var computedStyle = getComputedStyle(element); 21 // Generate a property and temporarily set its value. Then call 'fn' with 22 // the name of the generated property. 23 function with_custom_property(element, reg, value, fn) { 24 if (element.id.length == 0) 25 throw 'The specified element must have an ID'; 72 26 27 let name = generate_property(reg); 28 29 // Because we want to include the parsing step, insert a stylesheet 30 // node with textContent. 31 let node = document.createElement('style'); 32 node.textContent = `#${element.id} { ${name}:${value}; }`; 33 document.body.append(node); 34 35 try { 36 fn(name); 37 } finally { 38 node.remove(); 39 } 40 } 41 42 function assert_computed_value(element, syntax, value, expected) { 43 with_custom_property(element, syntax, value, (name) => { 44 let actual = getComputedStyle(element).getPropertyValue(name); 45 assert_equals(actual, expected); 46 }); 47 } 48 49 // Computes an absolute reference value for some length. 50 // 51 // E.g. to figure out how many pixels '10vh' is, do length_ref('10vh'). 52 function length_ref(value, refnode = ref) { 53 try { 54 // The reference property 'min-height' is chosen arbitrarily, but 55 // avoid properties with "resolved value is used value"-behavior 56 // [1], as it may affect rounding, and custom properties do not 57 // have this behavior. 58 // 59 // [1] https://drafts.csswg.org/cssom/#resolved-values 60 const ref_property = 'min-height'; 61 refnode.style = `${ref_property}: ${value}`; 62 return getComputedStyle(refnode).getPropertyValue(ref_property); 63 } finally { 64 refnode.style = ''; 65 } 66 } 67 68 function test_computed_value(syntax, value, expected) { 73 69 test(function() { 74 assert_equals(computedStyle.getPropertyValue('--length-1'), '12px'); 75 assert_equals(computedStyle.getPropertyValue('--length-2'), '104px'); 76 assert_equals(computedStyle.getPropertyValue('--length-3'), '140px'); 77 assert_equals(computedStyle.getPropertyValue('--length-4'), '90px'); 78 assert_equals(computedStyle.getPropertyValue('--length-5'), '6px'); 79 assert_equals(computedStyle.getPropertyValue('--length-6'), '140px'); 80 }, "<length> values are computed correctly for " + id); 70 assert_computed_value(divWithFontSizeSet, syntax, value, expected); 71 }, `${syntax} values are computed correctly [${value}]`); 72 } 81 73 82 test(function() { 83 assert_equals(computedStyle.getPropertyValue('--length-percentage-1'), '170px'); 84 assert_equals(computedStyle.getPropertyValue('--length-percentage-2'), '18%'); 85 assert_equals(computedStyle.getPropertyValue('--length-percentage-3'), 'calc(190px + -2%)'); 86 }, "<length-percentage> values are computed correctly for " + id); 74 test(function(){ 75 const element = divWithFontSizeSet; 76 with_custom_property(element, '<length>', '14em', (name) => { 77 assert_computed_value(element, '<length>', `var(${name})`, '140px'); 78 }); 79 }, '<length> values computed are correctly via var()-reference'); 87 80 88 test(function() { 89 assert_equals(computedStyle.getPropertyValue('--csv-1'), '10px, 30px'); 90 assert_equals(computedStyle.getPropertyValue('--csv-2'), '40px, 9px'); 91 assert_equals(computedStyle.getPropertyValue('--csv-3'), '80px'); 92 }, "<length># values are computed correctly for " + id); 81 test(function(){ 82 const element = divWithFontSizeInherited; 83 with_custom_property(element, '<length>', '14em', (name) => { 84 assert_computed_value(element, '<length>', `var(${name})`, '140px'); 85 }); 86 }, '<length> values computed are correctly via var()-reference when font-size is inherited'); 93 87 94 test(function() { 95 assert_equals(computedStyle.getPropertyValue('--csv-4'), '3%, 80px, 22px'); 96 assert_equals(computedStyle.getPropertyValue('--csv-5'), 'calc(10px + 50%), 4px'); 97 assert_equals(computedStyle.getPropertyValue('--csv-6'), 'calc(37px + 13%)'); 98 }, "<length-percentage># values are computed correctly for " + id); 88 test(function(){ 89 const element = divWithFontSizeInherited; 90 assert_computed_value(element, '<length>', '14em', '140px'); 91 }, '<length> values are computed correctly when font-size is inherited [14em]'); 99 92 100 test(function(){101 assert_equals(computedStyle.getPropertyValue('--list-1'), '10px 30px');102 assert_equals(computedStyle.getPropertyValue('--list-2'), '40px 9px');103 }, "<length>+ values are computed correctly for " + id);93 test(function(){ 94 const element = divWithFontSizeInherited; 95 assert_computed_value(element, '<length>', 'calc(14em + 10px)', '150px'); 96 }, '<length> values are computed correctly when font-size is inherited [calc(14em + 10px)]'); 104 97 105 test(function() { 106 assert_equals(computedStyle.getPropertyValue('--list-3'), '3% 80px 22px'); 107 assert_equals(computedStyle.getPropertyValue('--list-4'), 'calc(10px + 50%) 4px'); 108 }, "<length-percentage>+ values are computed correctly for " + id); 98 test_computed_value('<length>', '12px', '12px'); 99 test_computed_value('<length>', '13vw', length_ref('13vw')); 100 test_computed_value('<length>', '14em', '140px'); 101 test_computed_value('<length>', '15vmin', length_ref('15vmin')); 102 test_computed_value('<length>', 'calc(16px - 7em + 10vh)', length_ref('calc(10vh - 54px)')); 109 103 110 test(function() { 111 assert_equals(computedStyle.getPropertyValue('--transform-function-1'), 'translateX(2px)'); 112 assert_equals(computedStyle.getPropertyValue('--transform-function-2'), 'translateX(100px)'); 113 assert_equals(computedStyle.getPropertyValue('--transform-function-3'), 'translateX(calc(110px + 10%))'); 114 assert_equals(computedStyle.getPropertyValue('--transform-function-4'), 'translateX(10%) scale(2)'); 115 }, "<transform-function> values are computed correctly for " + id); 116 } 104 test_computed_value('<length-percentage>', '17em', '170px'); 105 test_computed_value('<length-percentage>', '18%', '18%'); 106 test_computed_value('<length-percentage>', 'calc(19em - 2%)', 'calc(-2% + 190px)'); 107 108 test_computed_value('<length>#', '10px, 3em', '10px, 30px'); 109 test_computed_value('<length>#', '4em ,9px', '40px, 9px'); 110 test_computed_value('<length>#', '8em', '80px'); 111 112 test_computed_value('<length-percentage>#', '3% , 10vmax , 22px', ['3%', length_ref('10vmax'), '22px'].join(', ')); 113 test_computed_value('<length-percentage>#', 'calc(50% + 1em), 4px', 'calc(50% + 10px), 4px'); 114 test_computed_value('<length-percentage>#', 'calc(13% + 37px)', 'calc(13% + 37px)'); 115 116 test_computed_value('<length>+', '10px 3em', '10px 30px'); 117 test_computed_value('<length>+', '4em 9px', '40px 9px'); 118 119 test_computed_value('<length-percentage>+', '3% 10vmax 22px', ['3%', length_ref('10vmax'), '22px'].join(' ')); 120 test_computed_value('<length-percentage>+', 'calc(50% + 1em) 4px', 'calc(50% + 10px) 4px'); 121 122 test_computed_value('<transform-function>', 'translateX(2px)', 'translateX(2px)'); 123 test_computed_value('<transform-function>', 'translateX(10em)', 'translateX(100px)'); 124 test_computed_value('<transform-function>', 'translateX(calc(11em + 10%))', 'translateX(calc(10% + 110px))'); 125 test_computed_value('<transform-function>+', 'translateX(10%) scale(2)', 'translateX(10%) scale(2)'); 126 127 test_computed_value('<integer>', '15', '15'); 128 test_computed_value('<integer>', 'calc(15 + 15)', '30'); 129 test_computed_value('<integer>', 'calc(2.4)', '2'); 130 test_computed_value('<integer>', 'calc(2.6)', '3'); 131 test_computed_value('<integer>', 'calc(2.6 + 3.1)', '6'); 132 133 test_computed_value('<integer>+', '15 calc(2.4) calc(2.6)', '15 2 3'); 134 135 test_computed_value('<color>', '#ff0000', 'rgb(255, 0, 0)'); 136 test_computed_value('<color>', '#000f00', 'rgb(0, 15, 0)'); 137 test_computed_value('<color>', '#00000a', 'rgb(0, 0, 10)'); 138 test_computed_value('<color>', '#badbee', 'rgb(186, 219, 238)'); 139 test_computed_value('<color>', '#badbee33', 'rgba(186, 219, 238, 0.2)'); 140 test_computed_value('<color>', 'tomato', 'rgb(255, 99, 71)'); 141 test_computed_value('<color>', 'plum', 'rgb(221, 160, 221)'); 142 test_computed_value('<color>', 'currentcolor', 'currentcolor'); 143 144 // Custom ident values that look like color keywords should not be converted. 145 test_computed_value('*', 'tomato', 'tomato'); 146 test_computed_value('tomato | plum', 'plum', 'plum'); 147 test_computed_value('tomato | plum | <color>', 'plum', 'plum'); 148 149 test_computed_value('*', '-50grad', '-50grad'); 150 test_computed_value('<angle>', '180deg', '180deg'); 151 test_computed_value('<angle>', '400grad', '360deg'); 152 test_computed_value('<angle>', 'calc(360deg + 400grad)', '720deg'); 153 154 test_computed_value('*', '50s', '50s'); 155 test_computed_value('<time>', '1s', '1s'); 156 test_computed_value('<time>', '1000ms', '1s'); 157 test_computed_value('<time>', 'calc(1000ms + 1s)', '2s'); 158 159 test_computed_value('*', '50dpi', '50dpi'); 160 test_computed_value('<resolution>', '1dppx', '1dppx'); 161 test_computed_value('<resolution>', '96dpi', '1dppx'); 162 test_computed_value('<resolution>', 'calc(1dppx + 96dpi)', '2dppx'); 163 117 164 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt
r237697 r239365 2 2 PASS CSSOM setters function as expected for unregistered properties 3 3 FAIL CSS.registerProperty The given initial value does not parse for the given syntax. 4 FAIL Formerly valid values are still readable from inline styles but are computed as the unset value assert_equals: expected " blue" but got "hello"4 FAIL Formerly valid values are still readable from inline styles but are computed as the unset value assert_equals: expected "rgb(0, 0, 255)" but got "hello" 5 5 FAIL Values not matching the registered type can't be set assert_equals: expected "hello" but got "20" 6 FAIL Values can be removed from inline styles assert_equals: expected "r ed" but got " red"6 FAIL Values can be removed from inline styles assert_equals: expected "rgb(255, 0, 0)" but got " red" 7 7 PASS Stylesheets can be modified by CSSOM 8 FAIL Valid values can be set on inline styles assert_equals: expected " blue" but got " blue"8 FAIL Valid values can be set on inline styles assert_equals: expected "rgb(255, 192, 203)" but got "pink" 9 9 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-cssom.html
r236444 r239365 47 47 assert_equals(inlineStyle.getPropertyValue('--color'), 'hello'); 48 48 assert_equals(computedStyle.getPropertyValue('--length'), '0px'); 49 assert_equals(computedStyle.getPropertyValue('--color'), ' blue');49 assert_equals(computedStyle.getPropertyValue('--color'), 'rgb(0, 0, 255)'); 50 50 }, "Formerly valid values are still readable from inline styles but are computed as the unset value"); 51 51 … … 63 63 assert_equals(inlineStyle.getPropertyValue('--color'), ''); 64 64 assert_equals(computedStyle.getPropertyValue('--length'), '10px'); 65 assert_equals(computedStyle.getPropertyValue('--color'), 'r ed');65 assert_equals(computedStyle.getPropertyValue('--color'), 'rgb(255, 0, 0)'); 66 66 }, "Values can be removed from inline styles"); 67 67 … … 81 81 assert_equals(inlineStyle.getPropertyValue('--color'), 'pink'); 82 82 assert_equals(computedStyle.getPropertyValue('--length'), '30px'); 83 assert_equals(computedStyle.getPropertyValue('--color'), ' pink');83 assert_equals(computedStyle.getPropertyValue('--color'), 'rgb(255, 192, 203)'); 84 84 inlineStyle.setProperty('--color', 'inherit'); 85 85 assert_equals(inlineStyle.getPropertyValue('--color'), 'inherit'); 86 assert_equals(computedStyle.getPropertyValue('--color'), ' blue');86 assert_equals(computedStyle.getPropertyValue('--color'), 'rgb(0, 0, 255)'); 87 87 }, "Valid values can be set on inline styles"); 88 88 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-initial-expected.txt
r236828 r239365 1 1 2 FAIL Initial values of registered properties can be referenced when no custom properties are explicitly set. The given initial value does not parse for the given syntax. 2 PASS Initial value for <length> correctly computed [calc(10px + 15px)] 3 FAIL Initial value for <length-percentage> correctly computed [calc(1in + 10% + 4px)] The given initial value does not parse for the given syntax. 4 FAIL Initial value for <color> correctly computed [pink, inherits] The given initial value does not parse for the given syntax. 5 FAIL Initial value for <color> correctly computed [purple] The given initial value does not parse for the given syntax. 6 FAIL Initial value for <transform-function> correctly computed [rotate(42deg)] The given initial value does not parse for the given syntax. 7 FAIL Initial value for <transform-list> correctly computed [scale(calc(2 + 2))] The given initial value does not parse for the given syntax. 8 FAIL Initial value for <transform-list> correctly computed [scale(calc(2 + 1)) translateX(calc(3px + 1px))] The given initial value does not parse for the given syntax. 9 FAIL Initial inherited value can be substituted [purple, color] The given initial value does not parse for the given syntax. 10 FAIL Initial non-inherited value can be substituted [pink, background-color] The given initial value does not parse for the given syntax. 3 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-initial.html
r236444 r239365 1 <!DOCTYPE HTML>1 <!DOCTYPE html> 2 2 <link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-propertydescriptor-initialvalue" /> 3 3 <link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#register-a-custom-property" /> 4 4 <script src="/resources/testharness.js"></script> 5 5 <script src="/resources/testharnessreport.js"></script> 6 <style> 7 #target { 8 background: var(--inherited-color); 9 color: var(--non-inherited-color); 10 } 11 </style> 6 <script src="./resources/utils.js"></script> 12 7 <div id=target></div> 13 8 <script> 14 test(function() {15 CSS.registerProperty({name: '--length', syntax: '<length>', initialValue: 'calc(10px + 15px)', inherits: false});16 CSS.registerProperty({name: '--length-percentage', syntax: '<length-percentage>', initialValue: 'calc(1in + 10% + 4px)', inherits: false});17 CSS.registerProperty({name: '--inherited-color', syntax: '<color>', initialValue: 'pink', inherits: true});18 CSS.registerProperty({name: '--non-inherited-color', syntax: '<color>', initialValue: 'purple', inherits: false});19 CSS.registerProperty({name: '--transform-function', syntax: '<transform-function>', initialValue: 'rotate(42deg)', inherits: false});20 CSS.registerProperty({name: '--single-transform-list', syntax: '<transform-list>', initialValue: 'scale(calc(2 + 2))', inherits: false});21 CSS.registerProperty({name: '--multiple-transform-list', syntax: '<transform-list>', initialValue: 'scale(calc(2 + 1)) translateX(calc(3px + 1px))', inherits: false});22 9 23 computedStyle = getComputedStyle(target); 24 assert_equals(computedStyle.getPropertyValue('--length'), '25px');25 assert_equals(computedStyle.getPropertyValue('--length-percentage'), 'calc(100px + 10%)');26 assert_equals(computedStyle.getPropertyValue('--inherited-color'), 'pink');27 assert_equals(computedStyle.getPropertyValue('--non-inherited-color'), 'purple');28 assert_equals(computedStyle.getPropertyValue('--transform-function'), 'rotate(42deg)');29 assert_equals(computedStyle.getPropertyValue('--single-transform-list'), 'scale(4)');30 assert_equals(computedStyle.getPropertyValue('--multiple-transform-list'), 'scale(3) translateX(4px)'); 10 function test_initial_value(reg, expected) { 11 let suffix = reg.inherits === true ? ', inherits' : ''; 12 test(function(){ 13 let name = generate_property(reg); 14 let actual = getComputedStyle(target).getPropertyValue(name); 15 assert_equals(actual, expected); 16 }, `Initial value for ${reg.syntax} correctly computed [${reg.initialValue}${suffix}]`); 17 } 31 18 32 assert_equals(computedStyle.backgroundColor, 'rgb(255, 192, 203)'); 33 assert_equals(computedStyle.color, 'rgb(128, 0, 128)'); 34 }, "Initial values of registered properties can be referenced when no custom properties are explicitly set."); 19 test_initial_value({ syntax: '<length>', initialValue: 'calc(10px + 15px)' }, '25px'); 20 test_initial_value({ syntax: '<length-percentage>', initialValue: 'calc(1in + 10% + 4px)' }, 'calc(10% + 100px)'); 21 test_initial_value({ syntax: '<color>', initialValue: 'pink', inherits: true }, 'rgb(255, 192, 203)'); 22 test_initial_value({ syntax: '<color>', initialValue: 'purple' }, 'rgb(128, 0, 128)'); 23 test_initial_value({ syntax: '<transform-function>', initialValue: 'rotate(42deg)' }, 'rotate(42deg)'); 24 test_initial_value({ syntax: '<transform-list>', initialValue: 'scale(calc(2 + 2))' }, 'scale(4)'); 25 test_initial_value({ syntax: '<transform-list>', initialValue: 'scale(calc(2 + 1)) translateX(calc(3px + 1px))' }, 'scale(3) translateX(4px)'); 26 27 // Test that the initial value of the custom property 'reg' is successfully 28 // substituted into 'property'. 29 function test_substituted_value(reg, property, expected) { 30 let inherits_text = reg.inherits === true ? 'inherited' : 'non-inherited'; 31 test(function(){ 32 try { 33 let name = generate_property(reg); 34 target.style = `${property}:var(${name});`; 35 assert_equals(getComputedStyle(target).getPropertyValue(property), expected); 36 } finally { 37 target.style = ''; 38 } 39 }, `Initial ${inherits_text} value can be substituted [${reg.initialValue}, ${property}]`); 40 } 41 42 test_substituted_value({ syntax: '<color>', initialValue: 'purple', inherits: true }, 'color', 'rgb(128, 0, 128)'); 43 test_substituted_value({ syntax: '<color>', initialValue: 'pink' }, 'background-color', 'rgb(255, 192, 203)'); 44 35 45 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt
r239341 r239365 1 CONSOLE MESSAGE: line 3 49: TypeError: CSS.px is not a function. (In 'CSS.px(15)', 'CSS.px' is undefined)1 CONSOLE MESSAGE: line 38: TypeError: target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined) 2 2 3 Harness Error (FAIL), message = TypeError: CSS.px is not a function. (In 'CSS.px(15)', 'CSS.px' is undefined)3 Harness Error (FAIL), message = TypeError: target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined) 4 4 5 5 FAIL Computed * is reified as CSSUnparsedValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined) 6 FAIL Computed <angle> is reified as CSSUnitValue The given initial value does not parse for the given syntax.7 FAIL Computed <color> is reified as CSSStyleValue The given initial value does not parse for the given syntax.8 FAIL Computed <custom-ident> is reified as CSSKeywordValue The given initial value does not parse for the given syntax.9 FAIL Computed <image> [url] is reified as CSSImageValue The given initial value does not parse for the given syntax.10 FAIL Computed <integer> is reified as CSSUnitValue The given initial value does not parse for the given syntax.11 FAIL Computed <length-percentage> [%] is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)12 FAIL Computed <length-percentage> [px] is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)13 FAIL Computed <length-percentage> [px + %] is reified as CSSMathSum Can't find variable: CSSMathSum14 FAIL Computed <length> is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)15 FAIL Computed <number> is reified as CSSUnitValue The given initial value does not parse for the given syntax.16 FAIL Computed <percentage> is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)17 FAIL Computed <resolution> is reified as CSSUnitValue The given initial value does not parse for the given syntax.18 FAIL Computed <time> is reified as CSSUnitValue The given initial value does not parse for the given syntax.19 FAIL Computed <url> is reified as CSSStyleValue The given initial value does not parse for the given syntax.20 FAIL Computed ident is reified as CSSKeywordValue The given initial value does not parse for the given syntax.21 FAIL First computed value correctly reified in space-separated list The given initial value does not parse for the given syntax.22 FAIL First computed value correctly reified in comma-separated list The given initial value does not parse for the given syntax.23 FAIL All computed values correctly reified in space-separated list The given initial value does not parse for the given syntax.24 FAIL All computed values correctly reified in comma-separated list The given initial value does not parse for the given syntax.25 FAIL attributeStyleMap.get returns CSSUnparsedValue for value with var references target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)26 FAIL styleMap.get returns CSSUnparsedValue for value with var references undefined is not an object (evaluating 'rule.styleMap.clear')27 FAIL attributeStyleMap.get returns CSSUnparsedValue for value with var references in list target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)28 FAIL styleMap.get returns CSSUnparsedValue for value with var references in list undefined is not an object (evaluating 'rule.styleMap.clear')29 FAIL attributeStyleMap.get returns CSSUnparsedValue for * target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)30 FAIL styleMap.get returns CSSUnparsedValue for * undefined is not an object (evaluating 'rule.styleMap.clear')31 FAIL attributeStyleMap.get returns CSSUnitValue for <angle> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)32 FAIL styleMap.get returns CSSUnitValue for <angle> undefined is not an object (evaluating 'rule.styleMap.clear')33 FAIL attributeStyleMap.get returns CSSStyleValue for <color> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)34 FAIL styleMap.get returns CSSStyleValue for <color> undefined is not an object (evaluating 'rule.styleMap.clear')35 FAIL attributeStyleMap.get returns CSSKeywordValue for <custom-ident> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)36 FAIL styleMap.get returns CSSKeywordValue for <custom-ident> undefined is not an object (evaluating 'rule.styleMap.clear')37 FAIL attributeStyleMap.get returns CSSImageValue for <image> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)38 FAIL styleMap.get returns CSSImageValue for <image> undefined is not an object (evaluating 'rule.styleMap.clear')39 FAIL attributeStyleMap.get returns CSSUnitValue for <integer> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)40 FAIL styleMap.get returns CSSUnitValue for <integer> undefined is not an object (evaluating 'rule.styleMap.clear')41 FAIL attributeStyleMap.get returns CSSUnitValue for <length-percentage> [10%] target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)42 FAIL styleMap.get returns CSSUnitValue for <length-percentage> [10%] undefined is not an object (evaluating 'rule.styleMap.clear')43 FAIL attributeStyleMap.get returns CSSUnitValue for <length-percentage> [10px] target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)44 FAIL styleMap.get returns CSSUnitValue for <length-percentage> [10px] undefined is not an object (evaluating 'rule.styleMap.clear')45 FAIL attributeStyleMap.get returns CSSMathSum for <length-percentage> [calc(10px + 10%)] target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)46 FAIL styleMap.get returns CSSMathSum for <length-percentage> [calc(10px + 10%)] undefined is not an object (evaluating 'rule.styleMap.clear')47 FAIL attributeStyleMap.get returns CSSUnitValue for <length> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)48 FAIL styleMap.get returns CSSUnitValue for <length> undefined is not an object (evaluating 'rule.styleMap.clear')49 FAIL attributeStyleMap.get returns CSSUnitValue for <number> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)50 FAIL styleMap.get returns CSSUnitValue for <number> undefined is not an object (evaluating 'rule.styleMap.clear')51 FAIL attributeStyleMap.get returns CSSUnitValue for <percentage> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)52 FAIL styleMap.get returns CSSUnitValue for <percentage> undefined is not an object (evaluating 'rule.styleMap.clear')53 FAIL attributeStyleMap.get returns CSSUnitValue for <resolution> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)54 FAIL styleMap.get returns CSSUnitValue for <resolution> undefined is not an object (evaluating 'rule.styleMap.clear')55 FAIL attributeStyleMap.get returns CSSUnitValue for <time> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)56 FAIL styleMap.get returns CSSUnitValue for <time> undefined is not an object (evaluating 'rule.styleMap.clear')57 FAIL attributeStyleMap.get returns CSSStyleValue for <url> target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)58 FAIL styleMap.get returns CSSStyleValue for <url> undefined is not an object (evaluating 'rule.styleMap.clear')59 FAIL attributeStyleMap.get returns CSSKeywordValue for thing1 | THING2 target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)60 FAIL styleMap.get returns CSSKeywordValue for thing1 | THING2 undefined is not an object (evaluating 'rule.styleMap.clear')61 FAIL attributeStyleMap.get returns CSSUnitValue for <length>+ target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)62 FAIL styleMap.get returns CSSUnitValue for <length>+ undefined is not an object (evaluating 'rule.styleMap.clear')63 FAIL attributeStyleMap.get returns CSSUnitValue for <length># target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)64 FAIL styleMap.get returns CSSUnitValue for <length># undefined is not an object (evaluating 'rule.styleMap.clear')65 FAIL attributeStyleMap.getAll returns a list of CSSUnitValues for <length>+ target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)66 FAIL styleMap.getAll returns a list of CSSUnitValues for <length>+ undefined is not an object (evaluating 'rule.styleMap.clear')67 FAIL attributeStyleMap.getAll returns a list of CSSUnitValues for <length># target.attributeStyleMap.clear is not a function. (In 'target.attributeStyleMap.clear()', 'target.attributeStyleMap.clear' is undefined)68 FAIL styleMap.getAll returns a list of CSSUnitValues for <length># undefined is not an object (evaluating 'rule.styleMap.clear')69 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative.html
r236444 r239365 34 34 } 35 35 36 // Cleans style rules used for testing between every test. 37 add_result_callback(function(){ 38 target.attributeStyleMap.clear(); 39 // Clears 'div' rule in #style: 40 style.sheet.rules[0].styleMap.clear(); 41 }); 42 36 43 // On the target element, verify that computed value of 'name' is an instance 37 44 // of 'expected' and not an instance of CSSUnparsedValue. … … 215 222 styleDecl.setProperty(name2, `var(${name1})`); 216 223 assert_true(propertyMap.get(name2) instanceof CSSUnparsedValue); 217 }, name => ` ${name}.get returns CSSUnparsedValue for value with var references`);224 }, name => `StylePropertyMap.get returns CSSUnparsedValue for value with var references (${name})`); 218 225 219 226 test_style_property_map_get(function(styleDecl, propertyMap){ … … 222 229 styleDecl.setProperty(name2, `1px, var(${name1}), 3px`); 223 230 assert_true(propertyMap.get(name2) instanceof CSSUnparsedValue); 224 }, name => ` ${name}.get returns CSSUnparsedValue for value with var references in list`);231 }, name => `StylePropertyMap.get returns CSSUnparsedValue for value with var references in list (${name})`); 225 232 226 233 test_style_property_map_get(function(styleDecl, propertyMap){ 227 234 assert_attribute_get_type(styleDecl, propertyMap, '*', 'if(){}', CSSUnparsedValue); 228 }, name => ` ${name}.get returns CSSUnparsedValue for *`);235 }, name => `StylePropertyMap.get returns CSSUnparsedValue for * (${name})`); 229 236 230 237 test_style_property_map_get(function(styleDecl, propertyMap){ 231 238 assert_attribute_get_type(styleDecl, propertyMap, '<angle>', '42deg', CSSUnitValue); 232 }, name => ` ${name}.get returns CSSUnitValue for <angle>`);239 }, name => `StylePropertyMap.get returns CSSUnitValue for <angle> (${name})`); 233 240 234 241 test_style_property_map_get(function(styleDecl, propertyMap){ 235 242 assert_attribute_get_type(styleDecl, propertyMap, '<color>', '#fefefe', CSSStyleValue); 236 }, name => ` ${name}.get returns CSSStyleValue for <color>`);243 }, name => `StylePropertyMap.get returns CSSStyleValue for <color> (${name})`); 237 244 238 245 test_style_property_map_get(function(styleDecl, propertyMap){ 239 246 assert_attribute_get_type(styleDecl, propertyMap, '<custom-ident>', 'none', CSSKeywordValue); 240 }, name => ` ${name}.get returns CSSKeywordValue for <custom-ident>`);247 }, name => `StylePropertyMap.get returns CSSKeywordValue for <custom-ident> (${name})`); 241 248 242 249 test_style_property_map_get(function(styleDecl, propertyMap){ 243 250 assert_attribute_get_type(styleDecl, propertyMap, '<image>', 'url(thing.png)', CSSImageValue); 244 }, name => ` ${name}.get returns CSSImageValue for <image>`);251 }, name => `StylePropertyMap.get returns CSSImageValue for <image> (${name})`); 245 252 246 253 test_style_property_map_get(function(styleDecl, propertyMap){ 247 254 assert_attribute_get_type(styleDecl, propertyMap, '<integer>', '100', CSSUnitValue); 248 }, name => ` ${name}.get returns CSSUnitValue for <integer>`);255 }, name => `StylePropertyMap.get returns CSSUnitValue for <integer> (${name})`); 249 256 250 257 test_style_property_map_get(function(styleDecl, propertyMap){ 251 258 assert_attribute_get_type(styleDecl, propertyMap, '<length-percentage>', '10%', CSSUnitValue); 252 }, name => ` ${name}.get returns CSSUnitValue for <length-percentage> [10%]`);259 }, name => `StylePropertyMap.get returns CSSUnitValue for <length-percentage> [10%] (${name})`); 253 260 254 261 test_style_property_map_get(function(styleDecl, propertyMap){ 255 262 assert_attribute_get_type(styleDecl, propertyMap, '<length-percentage>', '10px', CSSUnitValue); 256 }, name => ` ${name}.get returns CSSUnitValue for <length-percentage> [10px]`);263 }, name => `StylePropertyMap.get returns CSSUnitValue for <length-percentage> [10px] (${name})`); 257 264 258 265 test_style_property_map_get(function(styleDecl, propertyMap){ 259 266 assert_attribute_get_type(styleDecl, propertyMap, '<length-percentage>', 'calc(10px + 10%)', CSSMathSum); 260 }, name => ` ${name}.get returns CSSMathSum for <length-percentage> [calc(10px + 10%)]`);267 }, name => `StylePropertyMap.get returns CSSMathSum for <length-percentage> [calc(10px + 10%)] (${name})`); 261 268 262 269 test_style_property_map_get(function(styleDecl, propertyMap){ 263 270 assert_attribute_get_type(styleDecl, propertyMap, '<length>', '10px', CSSUnitValue); 264 }, name => ` ${name}.get returns CSSUnitValue for <length>`);271 }, name => `StylePropertyMap.get returns CSSUnitValue for <length> (${name})`); 265 272 266 273 test_style_property_map_get(function(styleDecl, propertyMap){ 267 274 assert_attribute_get_type(styleDecl, propertyMap, '<number>', '42', CSSUnitValue); 268 }, name => ` ${name}.get returns CSSUnitValue for <number>`);275 }, name => `StylePropertyMap.get returns CSSUnitValue for <number> (${name})`); 269 276 270 277 test_style_property_map_get(function(styleDecl, propertyMap){ 271 278 assert_attribute_get_type(styleDecl, propertyMap, '<percentage>', '10%', CSSUnitValue); 272 }, name => ` ${name}.get returns CSSUnitValue for <percentage>`);279 }, name => `StylePropertyMap.get returns CSSUnitValue for <percentage> (${name})`); 273 280 274 281 test_style_property_map_get(function(styleDecl, propertyMap){ 275 282 assert_attribute_get_type(styleDecl, propertyMap, '<resolution>', '300dpi', CSSUnitValue); 276 }, name => ` ${name}.get returns CSSUnitValue for <resolution>`);283 }, name => `StylePropertyMap.get returns CSSUnitValue for <resolution> (${name})`); 277 284 278 285 test_style_property_map_get(function(styleDecl, propertyMap){ 279 286 assert_attribute_get_type(styleDecl, propertyMap, '<time>', '42s', CSSUnitValue); 280 }, name => ` ${name}.get returns CSSUnitValue for <time>`);287 }, name => `StylePropertyMap.get returns CSSUnitValue for <time> (${name})`); 281 288 282 289 test_style_property_map_get(function(styleDecl, propertyMap){ 283 290 assert_attribute_get_type(styleDecl, propertyMap, '<url>', 'url(a)', CSSStyleValue); 284 }, name => ` ${name}.get returns CSSStyleValue for <url>`);291 }, name => `StylePropertyMap.get returns CSSStyleValue for <url> (${name})`); 285 292 286 293 test_style_property_map_get(function(styleDecl, propertyMap){ 287 294 assert_attribute_get_type(styleDecl, propertyMap, 'thing1 | THING2', 'thing1', CSSKeywordValue); 288 }, name => ` ${name}.get returns CSSKeywordValue for thing1 | THING2`);295 }, name => `StylePropertyMap.get returns CSSKeywordValue for thing1 | THING2 (${name})`); 289 296 290 297 test_style_property_map_get(function(styleDecl, propertyMap){ 291 298 assert_attribute_get_type(styleDecl, propertyMap, '<length>+', '10px 20px', CSSUnitValue); 292 }, name => ` ${name}.get returns CSSUnitValue for <length>+`);299 }, name => `StylePropertyMap.get returns CSSUnitValue for <length>+ (${name})`); 293 300 294 301 test_style_property_map_get(function(styleDecl, propertyMap){ 295 302 assert_attribute_get_type(styleDecl, propertyMap, '<length>#', '10px 20px', CSSUnitValue); 296 }, name => ` ${name}.get returns CSSUnitValue for <length>#`);303 }, name => `StylePropertyMap.get returns CSSUnitValue for <length># (${name})`); 297 304 298 305 // attributeStyleMap.getAll … … 303 310 assert_equals(propertyMap.getAll(name).length, 3); 304 311 assert_true(propertyMap.getAll(name).every(x => x instanceof CSSUnitValue)); 305 }, name => ` ${name}.getAll returns a list of CSSUnitValues for <length>+`);312 }, name => `StylePropertyMap.getAll returns a list of CSSUnitValues for <length>+ (${name})`); 306 313 307 314 test_style_property_map_get(function(styleDecl, propertyMap){ … … 310 317 assert_equals(propertyMap.getAll(name).length, 3); 311 318 assert_true(propertyMap.getAll(name).every(x => x instanceof CSSUnitValue)); 312 }, name => ` ${name}.getAll returns a list of CSSUnitValues for <length>#`);319 }, name => `StylePropertyMap.getAll returns a list of CSSUnitValues for <length># (${name})`); 313 320 314 321 // StylePropertyMap.set … … 319 326 propertyMap.clear(); 320 327 328 let ensureArray = v => v.constructor === Array ? v : [v]; 329 321 330 for (let value of options.shouldAccept) 322 propertyMap.set(name, value);331 propertyMap.set(name, ...ensureArray(value)); 323 332 324 333 for (let value of options.shouldReject) { 325 assert_throws(new TypeError(), () => propertyMap.set(name, value));334 assert_throws(new TypeError(), () => propertyMap.set(name, ...ensureArray(value))); 326 335 } 327 }, ` ${propertyMapName}.set accepts correct CSSUnitValues for ${options.syntax}`);336 }, `StylePropertyMap.set accepts correct CSSStyleValues for ${options.syntax} (${propertyMapName})`); 328 337 } 329 338 … … 354 363 initialValue: '0deg', 355 364 shouldAccept: [CSS.deg(42), CSS.turn(2), '42deg'], 356 shouldReject: [unparsed('42deg'), CSS.px(15), '50px' ],365 shouldReject: [unparsed('42deg'), CSS.px(15), '50px', [CSS.deg(15), '10deg']], 357 366 }); 358 367 … … 361 370 initialValue: 'none', 362 371 shouldAccept: [keyword('foo'), 'foo'], 363 shouldReject: [unparsed('foo'), CSS.px(15), '15px' ],372 shouldReject: [unparsed('foo'), CSS.px(15), '15px', [keyword('foo'), 'foo']], 364 373 }); 365 374 … … 368 377 initialValue: 'url(a)', 369 378 shouldAccept: [url_image('url(b)'), 'url(b)'], 370 shouldReject: [unparsed('url(b)'), CSS.px(100), '50px' ],379 shouldReject: [unparsed('url(b)'), CSS.px(100), '50px', [url_image('url(1)'), 'url(2)']], 371 380 }); 372 381 … … 374 383 syntax: '<integer>', 375 384 initialValue: '0', 376 shouldAccept: [CSS.number(1), CSS.number(-42), '1', '-42' ],377 shouldReject: [unparsed('42'), CSS.px(100), '50px' ],385 shouldAccept: [CSS.number(1), CSS.number(-42), '1', '-42', 'calc(2.4)'], 386 shouldReject: [unparsed('42'), CSS.px(100), '50px', [CSS.number(42), '42'], 'calc(2px + 1px)'], 378 387 }); 379 388 … … 382 391 initialValue: '0px', 383 392 shouldAccept: [CSS.percent(10), CSS.px(1), CSS.em(1), '10px', '10%'], 384 shouldReject: [unparsed('10%'), unparsed('10px'), CSS.dpi(1), 'url(b)' ],393 shouldReject: [unparsed('10%'), unparsed('10px'), CSS.dpi(1), 'url(b)', [CSS.percent(10), '10%']], 385 394 }); 386 395 … … 389 398 initialValue: '0px', 390 399 shouldAccept: [CSS.px(10), CSS.em(10), CSS.vh(200), sum(CSS.px(10), CSS.em(20)), '10em', 'calc(10px + 10em)'], 391 shouldReject: [unparsed('10px'), CSS.percent(1), 'url(b)' ],400 shouldReject: [unparsed('10px'), CSS.percent(1), 'url(b)', [CSS.em(10), '10px']], 392 401 }); 393 402 … … 396 405 initialValue: '0', 397 406 shouldAccept: [CSS.number(1337), CSS.number(-42.5), '1337', '-42.5'], 398 shouldReject: [unparsed('42'), CSS.px(15), '#fef' ],407 shouldReject: [unparsed('42'), CSS.px(15), '#fef', [CSS.number(-42.5), '42.5']], 399 408 }); 400 409 … … 403 412 initialValue: '0%', 404 413 shouldAccept: [CSS.percent(10), '10%'], 405 shouldReject: [unparsed('10%'), CSS.px(1), '#fef' ],414 shouldReject: [unparsed('10%'), CSS.px(1), '#fef', [CSS.percent(10), '1%']], 406 415 }); 407 416 … … 410 419 initialValue: '0dpi', 411 420 shouldAccept: [CSS.dpi(100), CSS.dpcm(10), CSS.dppx(50), '100dpi'], 412 shouldReject: [unparsed('42'), CSS.px(15), '#fef' ],421 shouldReject: [unparsed('42'), CSS.px(15), '#fef', [CSS.dpi(1), '2dpi']], 413 422 }); 414 423 … … 417 426 initialValue: '0s', 418 427 shouldAccept: [CSS.s(42), CSS.ms(16), '16ms'], 419 shouldReject: [unparsed('42s'), CSS.px(15), '#fef' ],428 shouldReject: [unparsed('42s'), CSS.px(15), '#fef', [CSS.s(5), '6s']], 420 429 }); 421 430 … … 424 433 initialValue: 'url(a)', 425 434 shouldAccept: [url_image('url(b)')], 426 shouldReject: [unparsed('url(b)'), CSS.px(100), '#fef' ],435 shouldReject: [unparsed('url(b)'), CSS.px(100), '#fef', [url_image('url(1)'), 'url(2)']], 427 436 }); 428 437 … … 438 447 initialValue: 'none', 439 448 shouldAccept: [keyword('thing'), keyword('THING'), 'thing'], 440 shouldReject: [unparsed('thing'), CSS.px(15), keyword('notathing'), 'notathing' ],449 shouldReject: [unparsed('thing'), CSS.px(15), keyword('notathing'), 'notathing', [keyword('thing'), keyword('thing')]], 441 450 }); 442 451 … … 445 454 initialValue: '0deg', 446 455 shouldAccept: [CSS.deg(42), CSS.turn(2), CSS.px(10), CSS.em(10), '10deg', '10px'], 447 shouldReject: [unparsed('42deg'), unparsed('20px'), CSS.s(1), '#fef'], 456 shouldReject: [unparsed('42deg'), unparsed('20px'), CSS.s(1), '#fef', [CSS.deg(42), '21deg']], 457 }); 458 459 // StylePropertyMap.set for list-valued properties: 460 461 test_style_property_map_set({ 462 syntax: '<angle>+', 463 initialValue: '0deg', 464 shouldAccept: [CSS.deg(15), [CSS.deg(15), '10deg'], '15deg 10deg'], 465 shouldReject: [[CSS.deg(15), CSS.px(10)], '15deg 10px'], 466 }); 467 468 test_style_property_map_set({ 469 syntax: '<custom-ident>+', 470 initialValue: 'none', 471 shouldAccept: [keyword('foo'), [keyword('foo'), 'bar'], 'foo bar'], 472 shouldReject: [[keyword('foo'), CSS.px(10)], 'foo 10px'], 473 }); 474 475 test_style_property_map_set({ 476 syntax: '<image>+', 477 initialValue: 'url(a)', 478 shouldAccept: [url_image('url(1)'), [url_image('url(1)'), 'url(2)'], 'url(1) url(2)'], 479 shouldReject: [[url_image('url(1)'), CSS.px(10)], 'url(1) 10px'], 480 }); 481 482 test_style_property_map_set({ 483 syntax: '<integer>+', 484 initialValue: '0', 485 shouldAccept: [CSS.number(42), [CSS.number(42), '42'], '42 42', 'calc(2.4) calc(2.6)'], 486 shouldReject: [[CSS.number(42), keyword('noint')], '42 noint', 'calc(2px + 2px)'], 487 }); 488 489 test_style_property_map_set({ 490 syntax: '<length-percentage>+', 491 initialValue: '0px', 492 shouldAccept: [CSS.percent(10), [CSS.percent(10), '10%']], 493 shouldReject: [[CSS.percent(10), keyword('nolength')], '10% nolength'], 494 }); 495 496 test_style_property_map_set({ 497 syntax: '<length>+', 498 initialValue: '0px', 499 shouldAccept: [CSS.em(10), [CSS.em(10), '10px']], 500 shouldReject: [[CSS.em(10), keyword('nolength'), '10em nolength']], 501 }); 502 503 test_style_property_map_set({ 504 syntax: '<number>+', 505 initialValue: '0', 506 shouldAccept: [CSS.number(-42.5), [CSS.number(-42.5), '42.5'], '-42.5 42.5'], 507 shouldReject: [[CSS.number(-42.5), CSS.px(10)], '-42.5 10px'], 508 }); 509 510 test_style_property_map_set({ 511 syntax: '<percentage>+', 512 initialValue: '0%', 513 shouldAccept: [CSS.percent(10), [CSS.percent(10), '1%'], '10% 1%'], 514 shouldReject: [[CSS.percent(10), keyword('foo')], '10% foo'], 515 }); 516 517 test_style_property_map_set({ 518 syntax: '<resolution>+', 519 initialValue: '0dpi', 520 shouldAccept: [CSS.dpi(1), [CSS.dpi(1), '2dpi'], '1dpi 2dpi'], 521 shouldReject: [[CSS.dpi(1), keyword('foo')], '1dpi foo'], 522 }); 523 524 test_style_property_map_set({ 525 syntax: '<time>+', 526 initialValue: '0s', 527 shouldAccept: [CSS.s(5), [CSS.s(5), '6s'], '5s 6s'], 528 shouldReject: [[CSS.s(5), keyword('foo')], '5s foo'], 529 }); 530 531 test_style_property_map_set({ 532 syntax: '<url>+', 533 initialValue: 'url(a)', 534 shouldAccept: [url_image('url(1)'), [url_image('url(1)'), 'url(2)'], 'url(1) url(2)'], 535 shouldReject: [[url_image('url(1)'), CSS.px(10)], 'url(1) 10px'], 536 }); 537 538 test_style_property_map_set({ 539 syntax: 'thing+', 540 initialValue: 'thing', 541 shouldAccept: [keyword('thing'), [keyword('thing'), 'thing'], 'thing thing'], 542 shouldReject: [[keyword('thing'), CSS.px(10)], 'thing 10px'], 543 }); 544 545 test_style_property_map_set({ 546 syntax: '<length>#', 547 initialValue: '0px', 548 shouldAccept: [CSS.em(10), [CSS.em(10), '10px']], 549 shouldReject: [[CSS.em(10), keyword('nolength'), '10em nolength']], 550 }); 551 552 function test_append_for_property_map(propertyMapName, propertyMap, options) { 553 test(function(){ 554 let name = gen_prop(options.syntax, options.initialValue); 555 556 let ensureArray = v => v.constructor === Array ? v : [v]; 557 558 for (let value of options.values) { 559 propertyMap.clear(); 560 561 if (value.base !== null) 562 propertyMap.set(name, ...ensureArray(value.base)); 563 564 // If 'null' is expected, it means we expect the append to fail. 565 if (value.expect !== null) { 566 propertyMap.append(name, ...ensureArray(value.append)); 567 let actual = Array.from(propertyMap.getAll(name)).join(' '); 568 assert_equals(actual, value.expect); 569 } else { 570 assert_throws(new TypeError(), () => propertyMap.append(name, ...ensureArray(value.append))); 571 } 572 } 573 }, `StylePropertyMap.append accepts correct CSSStyleValues for ${options.syntax} (${propertyMapName})`); 574 } 575 576 // Verify that the correct CSSStyleValues are accepted/rejected when 577 // appending values to list-valued properties. 578 // 579 // The same test is performed twice: once for attributeStyleMap, and once 580 // for styleMap. 581 function test_append(options) { 582 test_append_for_property_map('attributeStyleMap', target.attributeStyleMap, options); 583 test_append_for_property_map('styleMap', style.sheet.rules[0].styleMap, options); 584 } 585 586 test_append({ 587 syntax: '<angle>+', 588 initialValue: '0deg', 589 values: [ 590 { base: [CSS.deg(1)], append: [CSS.px(1)], expect: null }, 591 { base: [CSS.deg(1)], append: [CSS.deg(2), CSS.px(1)], expect: null }, 592 { base: [CSS.deg(1)], append: [CSS.deg(2), '1px'], expect: null }, 593 { base: [CSS.deg(1)], append: [CSS.turn(2), CSS.deg(3)], expect: '1deg 2turn 3deg' }, 594 { base: [CSS.deg(1), CSS.deg(2)], append: [CSS.deg(3)], expect: '1deg 2deg 3deg' }, 595 { base: [CSS.deg(1)], append: [CSS.deg(2), '3deg'], expect: '1deg 2deg 3deg' }, 596 { base: [CSS.deg(1)], append: [CSS.deg(2), '3turn 4deg'], expect: '1deg 2deg 3turn 4deg' }, 597 { base: null, append: [CSS.deg(1), '2deg'], expect: '1deg 2deg' }, 598 ], 599 }); 600 601 test_append({ 602 syntax: '<custom-ident>+', 603 initialValue: 'none', 604 values: [ 605 { base: [keyword('foo')], append: [CSS.px(1)], expect: null }, 606 { base: [keyword('foo')], append: [keyword('bar'), CSS.px(1)], expect: null }, 607 { base: [keyword('foo')], append: [keyword('bar'), '1px'], expect: null }, 608 { base: [keyword('foo')], append: [keyword('bar'), keyword('baz')], expect: 'foo bar baz' }, 609 { base: [keyword('foo'), keyword('bar')], append: [keyword('baz')], expect: 'foo bar baz' }, 610 { base: [keyword('foo')], append: [keyword('bar'), 'baz'], expect: 'foo bar baz' }, 611 { base: [keyword('foo')], append: [keyword('bar'), 'baz zim'], expect: 'foo bar baz zim' }, 612 { base: null, append: [keyword('foo'), 'bar'], expect: 'foo bar' }, 613 ], 614 }); 615 616 ['<image>+', '<url>+'].forEach((syntax) => { 617 test_append({ 618 syntax: syntax, 619 initialValue: 'url(0)', 620 values: [ 621 { base: [url_image('url("1")')], append: [CSS.px(1)], expect: null }, 622 { base: [url_image('url("1")')], append: [url_image('url("2")'), CSS.px(1)], expect: null }, 623 { base: [url_image('url("1")')], append: [url_image('url("2")'), '1px'], expect: null }, 624 { base: [url_image('url("1")')], append: [url_image('url("2")'), url_image('url("3")')], expect: 'url("1") url("2") url("3")' }, 625 { base: [url_image('url("1")'), url_image('url("2")')], append: [url_image('url("3")')], expect: 'url("1") url("2") url("3")' }, 626 { base: [url_image('url("1")')], append: [url_image('url("2")'), 'url("3")'], expect: 'url("1") url("2") url("3")' }, 627 { base: [url_image('url("1")')], append: [url_image('url("2")'), 'url("3") url("4")'], expect: 'url("1") url("2") url("3") url("4")' }, 628 { base: null, append: [url_image('url("1")'), 'url("2")'], expect: 'url("1") url("2")' }, 629 ], 630 }); 631 }); 632 633 test_append({ 634 syntax: '<integer>+', 635 initialValue: '0', 636 values: [ 637 { base: [CSS.number(1)], append: [CSS.px(1)], expect: null }, 638 { base: [CSS.number(1)], append: [CSS.number(2), CSS.px(1)], expect: null }, 639 { base: [CSS.number(1)], append: [CSS.number(2), 'noint'], expect: null }, 640 { base: [CSS.number(1)], append: [CSS.number(2), CSS.number(3)], expect: '1 2 3' }, 641 { base: [CSS.number(1), CSS.number(2)], append: [CSS.number(3)], expect: '1 2 3' }, 642 { base: [CSS.number(1)], append: [CSS.number(2), '3'], expect: '1 2 3' }, 643 { base: [CSS.number(1)], append: [CSS.number(2), '3 4'], expect: '1 2 3 4' }, 644 { base: null, append: [CSS.number(1), '2'], expect: '1 2' }, 645 ], 646 }); 647 648 test_append({ 649 syntax: '<length-percentage>+', 650 initialValue: '0px', 651 values: [ 652 { base: [CSS.px(1)], append: [keyword('nolength')], expect: null }, 653 { base: [CSS.px(1)], append: [CSS.px(2), keyword('nolength')], expect: null }, 654 { base: [CSS.px(1)], append: [CSS.px(2), 'nolength'], expect: null }, 655 { base: [CSS.px(1)], append: [CSS.px(2), CSS.percent(3)], expect: '1px 2px 3%' }, 656 { base: [CSS.px(1), CSS.px(2)], append: [CSS.percent(3)], expect: '1px 2px 3%' }, 657 { base: [CSS.px(1)], append: [CSS.percent(2), '3px'], expect: '1px 2% 3px' }, 658 { base: [CSS.px(1)], append: [CSS.px(2), '3% 4px'], expect: '1px 2px 3% 4px' }, 659 { base: null, append: [CSS.px(1), '2%'], expect: '1px 2%' }, 660 ], 661 }); 662 663 test_append({ 664 syntax: '<length>+', 665 initialValue: '0', 666 values: [ 667 { base: [CSS.px(1)], append: [keyword('nolength')], expect: null }, 668 { base: [CSS.px(1)], append: [CSS.px(2), keyword('nolength')], expect: null }, 669 { base: [CSS.px(1)], append: [CSS.px(2), 'nolength'], expect: null }, 670 { base: [CSS.px(1)], append: [CSS.em(2), CSS.px(3)], expect: '1px 2em 3px' }, 671 { base: [CSS.px(1), CSS.em(2)], append: [CSS.vh(3)], expect: '1px 2em 3vh' }, 672 { base: [CSS.px(1)], append: [CSS.em(2), '3px'], expect: '1px 2em 3px' }, 673 { base: [CSS.px(1)], append: [CSS.px(2), '3em 4cm'], expect: '1px 2px 3em 4cm' }, 674 { base: null, append: [CSS.vh(1), '2px'], expect: '1vh 2px' }, 675 ], 676 }); 677 678 test_append({ 679 syntax: '<number>+', 680 initialValue: '0', 681 values: [ 682 { base: [CSS.number(-1)], append: [keyword('NaN')], expect: null }, 683 { base: [CSS.number(-1)], append: [CSS.number(2.5), keyword('NaN')], expect: null }, 684 { base: [CSS.number(-1)], append: [CSS.number(2.5), '1px'], expect: null }, 685 { base: [CSS.number(-1)], append: [CSS.number(2.5), CSS.number(3.2)], expect: '-1 2.5 3.2' }, 686 { base: [CSS.number(-1), CSS.number(2.5)], append: [CSS.number(3.2)], expect: '-1 2.5 3.2' }, 687 { base: [CSS.number(-1)], append: [CSS.number(2.5), '3.2'], expect: '-1 2.5 3.2' }, 688 { base: [CSS.number(-1)], append: [CSS.number(2.5), '3.2 4'], expect: '-1 2.5 3.2 4' }, 689 { base: null, append: [CSS.number(-1), '2.5'], expect: '-1 2.5' }, 690 ], 691 }); 692 693 test_append({ 694 syntax: '<percentage>+', 695 initialValue: '0%', 696 values: [ 697 { base: [CSS.percent(1)], append: [CSS.px(1)], expect: null }, 698 { base: [CSS.percent(1)], append: [CSS.percent(2), CSS.px(1)], expect: null }, 699 { base: [CSS.percent(1)], append: [CSS.percent(2), '1px'], expect: null }, 700 { base: [CSS.percent(1)], append: [CSS.percent(2), CSS.percent(3)], expect: '1% 2% 3%' }, 701 { base: [CSS.percent(1), CSS.percent(2)], append: [CSS.percent(3)], expect: '1% 2% 3%' }, 702 { base: [CSS.percent(1)], append: [CSS.percent(2), '3%'], expect: '1% 2% 3%' }, 703 { base: [CSS.percent(1)], append: [CSS.percent(2), '3% 4%'], expect: '1% 2% 3% 4%' }, 704 { base: null, append: [CSS.percent(1), '2%'], expect: '1% 2%' }, 705 ], 706 }); 707 708 test_append({ 709 syntax: '<resolution>+', 710 initialValue: '0dpi', 711 values: [ 712 { base: [CSS.dpi(1)], append: [CSS.px(1)], expect: null }, 713 { base: [CSS.dpi(1)], append: [CSS.dpi(2), CSS.px(1)], expect: null }, 714 { base: [CSS.dpi(1)], append: [CSS.dpi(2), '1px'], expect: null }, 715 { base: [CSS.dpi(1)], append: [CSS.dpi(2), CSS.dpi(3)], expect: '1dpi 2dpi 3dpi' }, 716 { base: [CSS.dpi(1), CSS.dpi(2)], append: [CSS.dpi(3)], expect: '1dpi 2dpi 3dpi' }, 717 { base: [CSS.dpi(1)], append: [CSS.dpi(2), '3dpi'], expect: '1dpi 2dpi 3dpi' }, 718 { base: [CSS.dpi(1)], append: [CSS.dpi(2), '3dpi 4dpi'], expect: '1dpi 2dpi 3dpi 4dpi' }, 719 { base: null, append: [CSS.dpi(1), '2dpi'], expect: '1dpi 2dpi' }, 720 ], 721 }); 722 723 test_append({ 724 syntax: '<time>+', 725 initialValue: '0s', 726 values: [ 727 { base: [CSS.s(1)], append: [CSS.px(1)], expect: null }, 728 { base: [CSS.s(1)], append: [CSS.s(2), CSS.px(1)], expect: null }, 729 { base: [CSS.s(1)], append: [CSS.ms(2), '1px'], expect: null }, 730 { base: [CSS.s(1)], append: [CSS.ms(2), CSS.s(3)], expect: '1s 2ms 3s' }, 731 { base: [CSS.s(1), CSS.s(2)], append: [CSS.s(3)], expect: '1s 2s 3s' }, 732 { base: [CSS.s(1)], append: [CSS.s(2), '3s'], expect: '1s 2s 3s' }, 733 { base: [CSS.s(1)], append: [CSS.s(2), '3ms 4s'], expect: '1s 2s 3ms 4s' }, 734 { base: null, append: [CSS.s(1), '2s'], expect: '1s 2s' }, 735 ], 736 }); 737 738 test_append({ 739 syntax: 'foo+', 740 initialValue: 'foo', 741 values: [ 742 { base: [keyword('foo')], append: [CSS.px(1)], expect: null }, 743 { base: [keyword('foo')], append: [keyword('foo'), CSS.px(1)], expect: null }, 744 { base: [keyword('foo')], append: [keyword('foo'), '1px'], expect: null }, 745 { base: [keyword('foo')], append: [keyword('foo'), keyword('foo')], expect: 'foo foo foo' }, 746 { base: [keyword('foo'), keyword('foo')], append: [keyword('foo')], expect: 'foo foo foo' }, 747 { base: [keyword('foo')], append: [keyword('foo'), 'foo'], expect: 'foo foo foo' }, 748 { base: [keyword('foo')], append: [keyword('foo'), 'foo foo'], expect: 'foo foo foo foo' }, 749 { base: null, append: [keyword('foo'), keyword('foo')], expect: 'foo foo' }, 750 ], 448 751 }); 449 752 … … 538 841 }, 'CSSStyleValue.parse[All] returns list of CSSUnitValues for <length>#'); 539 842 843 // Direct CSSStyleValue objects: 844 845 function gen_all_props() { 846 return [ 847 gen_prop('*', 'foo'), 848 gen_prop('foo', 'foo'), 849 gen_prop('<angle>', '0deg'), 850 gen_prop('<color>', 'rgb(1, 2, 3)'), 851 gen_prop('<custom-ident>', 'thing'), 852 gen_prop('<image>', 'url(a)'), 853 gen_prop('<integer>', '0'), 854 gen_prop('<length-percentage>', 'calc(10px + 10%)'), 855 gen_prop('<length>', '0px'), 856 gen_prop('<number>', '0.5'), 857 gen_prop('<percentage>', '0%'), 858 gen_prop('<resolution>', '0dpi'), 859 gen_prop('<time>', '0s'), 860 gen_prop('<transform-function>', 'rotateX(0deg)'), 861 gen_prop('<transform-list>', 'rotateX(0deg)'), 862 gen_prop('<url>', 'url(a)') 863 ]; 864 } 865 866 test(function(){ 867 let props0 = gen_all_props(); 868 let props1 = gen_all_props(); 869 870 for (let i = 0; i < props0.length; i++) { 871 let prop0 = props0[i]; 872 let prop1 = props1[i]; 873 874 // Abuse computedStyleMap to get the initialValue (just to get some 875 // value that will parse for prop0/1's syntax). 876 let initialValue = target.computedStyleMap().get(prop0); 877 878 // We only care about direct CSSStyleValue instances in this test. 879 // Ultimately, in some future version of CSS TypedOM, we may have no 880 // direct CSSStyleValue instances at all, which is fine. 881 if (initialValue.constructor !== CSSStyleValue) { 882 continue; 883 } 884 885 let value = CSSStyleValue.parse(prop0, initialValue.toString()); 886 887 // A value parsed for prop0 must be assignable to prop0. 888 target.attributeStyleMap.clear(); 889 target.attributeStyleMap.set(prop0, value); // Don't throw. 890 891 // A value parsed for prop0 must not be assignable to prop1, even if 892 // the properties have compatible syntaxes. 893 assert_throws(new TypeError(), () => { 894 target.attributeStyleMap.clear(); 895 target.attributeStyleMap.set(prop1, value); 896 }); 897 } 898 }, 'Direct CSSStyleValue instances are tied to their associated property'); 899 900 // StylePropertyMapReadOnly iteration 901 902 test(function(){ 903 let name = gen_prop('<length>', '10px'); 904 let result = Array.from(target.computedStyleMap()).filter(e => e[0] == name)[0]; 905 assert_true(typeof(result) !== 'undefined'); 906 }, 'Registered property with initial value show up on iteration of computedStyleMap'); 907 908 // Verifies that iterating a StylePropertyMap[ReadOnly] yields correctly 909 // typed objects for a given syntax/value. 910 function test_iteration_type_for_property_map(propertyMapName, propertyMap, options) { 911 test(function(){ 912 let name = gen_prop(options.syntax, options.initialValue); 913 if (propertyMap instanceof StylePropertyMap) { 914 // Only set the value if the propertyMap is mutable. 915 propertyMap.set(name, options.value); 916 } 917 let result = Array.from(propertyMap).filter(e => e[0] == name)[0]; 918 let value = result[1]; 919 assert_true(options.expect(value)); 920 }, `Iteration on ${propertyMapName} produces correct type for ${options.syntax}`); 921 } 922 923 function test_iteration_type(options) { 924 test_iteration_type_for_property_map('computedStyleMap', target.computedStyleMap(), options); 925 test_iteration_type_for_property_map('attributeStyleMap', target.attributeStyleMap, options); 926 test_iteration_type_for_property_map('styleMap', style.sheet.rules[0].styleMap, options); 927 } 928 929 test_iteration_type({ 930 syntax: '*', 931 initialValue: 'none', 932 value: 'thing', 933 expect: v => v.length == 1 && v[0] instanceof CSSUnparsedValue, 934 }); 935 936 test_iteration_type({ 937 syntax: '<angle>', 938 initialValue: '0deg', 939 value: '42deg', 940 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 941 }); 942 943 test_iteration_type({ 944 syntax: '<custom-ident>', 945 initialValue: 'none', 946 value: 'thing', 947 expect: v => v.length == 1 && v[0] instanceof CSSKeywordValue, 948 }); 949 950 test_iteration_type({ 951 syntax: '<image>', 952 initialValue: 'url(a)', 953 value: 'url(b)', 954 expect: v => v.length == 1 && v[0] instanceof CSSImageValue, 955 }); 956 957 test_iteration_type({ 958 syntax: '<integer>', 959 initialValue: '0', 960 value: '100', 961 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 962 }); 963 964 test_iteration_type({ 965 syntax: '<length>', 966 initialValue: '0px', 967 value: '10px', 968 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 969 }); 970 971 test_iteration_type({ 972 syntax: '<number>', 973 initialValue: '0', 974 value: '42', 975 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 976 }); 977 978 test_iteration_type({ 979 syntax: '<percentage>', 980 initialValue: '0%', 981 value: '10%', 982 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 983 }); 984 985 test_iteration_type({ 986 syntax: '<resolution>', 987 initialValue: '0dpi', 988 value: '300dpi', 989 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 990 }); 991 992 test_iteration_type({ 993 syntax: '<time>', 994 initialValue: '0s', 995 value: '10s', 996 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 997 }); 998 999 test_iteration_type({ 1000 syntax: '<url>', 1001 initialValue: 'url(a)', 1002 value: 'url(b)', 1003 expect: v => v.length == 1 && v[0].constructor === CSSStyleValue, 1004 }); 1005 1006 test_iteration_type({ 1007 syntax: 'none | thing | THING', 1008 initialValue: 'none', 1009 value: 'THING', 1010 expect: v => v.length == 1 && v[0] instanceof CSSKeywordValue, 1011 }); 1012 1013 test_iteration_type({ 1014 syntax: '<angle> | <length>', 1015 initialValue: '0deg', 1016 value: '10px', 1017 expect: v => v.length == 1 && v[0] instanceof CSSUnitValue, 1018 }); 1019 540 1020 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/unit-cycles-expected.txt
r239341 r239365 1 CONSOLE MESSAGE: line 63: TypeError: element.attributeStyleMap.clear is not a function. (In 'element.attributeStyleMap.clear()', 'element.attributeStyleMap.clear' is undefined)1 CONSOLE MESSAGE: line 74: TypeError: element.attributeStyleMap.clear is not a function. (In 'element.attributeStyleMap.clear()', 'element.attributeStyleMap.clear' is undefined) 2 2 3 3 FAIL Untitled TypeError: element.attributeStyleMap.clear is not a function. (In 'element.attributeStyleMap.clear()', 'element.attributeStyleMap.clear' is undefined) -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/unit-cycles.html
r236444 r239365 5 5 <script src="/resources/testharnessreport.js"></script> 6 6 <script> 7 function register_length(name ) {7 function register_length(name, inherits=true) { 8 8 CSS.registerProperty({ 9 9 name: name, 10 10 syntax: '<length>', 11 11 initialValue: '0px', 12 inherits: false12 inherits: inherits 13 13 }); 14 14 } … … 23 23 register_length('--font-size-ex-via-var'); 24 24 register_length('--font-size-ch-via-var'); 25 register_length('--font-size-em-inherited', true); 26 register_length('--font-size-ex-inherited', true); 27 register_length('--font-size-ch-inherited', true); 25 28 </script> 26 29 <style> … … 44 47 } 45 48 49 #parent { 50 --font-size-em-inherited: 4em; 51 --font-size-ex-inherited: 4ex; 52 --font-size-ch-inherited: 4ch; 53 } 54 46 55 #target { 47 56 font-size: 11px; … … 49 58 </style> 50 59 51 <div id=target></div> 60 <div id=parent> 61 <div id=target></div> 62 </div> 52 63 <div id=ref></div> 53 64 … … 171 182 }, 'Lengths with rem units are detected via var references'); 172 183 184 test(function() { 185 let expected4em = compute_dimension('4em', 'unset'); 186 target.style = 'font-size: var(--font-size-em-inherited);'; 187 assert_property_equals('font-size', expected4em); 188 assert_property_equals('--font-size-em-inherited', expected4em); 189 }, 'Inherited lengths with em units may be used'); 190 191 test(function() { 192 let expected4ex = compute_dimension('4ex', 'unset'); 193 target.style = 'font-size: var(--font-size-ex-inherited);'; 194 assert_property_equals('font-size', expected4ex); 195 assert_property_equals('--font-size-ex-inherited', expected4ex); 196 }, 'Inherited lengths with ex units may be used'); 197 198 test(function() { 199 let expected4ch = compute_dimension('4ch', 'unset'); 200 target.style = 'font-size: var(--font-size-ch-inherited);'; 201 assert_property_equals('font-size', expected4ch); 202 assert_property_equals('--font-size-ch-inherited', expected4ch); 203 }, 'Inherited lengths with ch units may be used'); 204 173 205 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles.html
r236444 r239365 26 26 27 27 computedStyle = getComputedStyle(test1); 28 assert_equals(computedStyle.getPropertyValue('--registered-1-a'), '1px'); 29 assert_equals(computedStyle.getPropertyValue('--registered-1-b'), '2px'); 30 31 assert_equals(computedStyle.getPropertyValue('--registered-1-c'), '2px'); 32 assert_equals(computedStyle.getPropertyValue('--registered-1-d'), '2px'); 33 assert_equals(computedStyle.getPropertyValue('--unregistered-1-a'), '1px'); 34 assert_equals(computedStyle.left, '1px'); 35 assert_equals(computedStyle.top, '2px'); 28 assert_equals(computedStyle.getPropertyValue('--registered-1-a'), ''); 29 assert_equals(computedStyle.getPropertyValue('--registered-1-b'), ''); 30 assert_equals(computedStyle.getPropertyValue('--registered-1-c'), '30px'); 31 assert_equals(computedStyle.getPropertyValue('--registered-1-d'), '4px'); 32 assert_equals(computedStyle.getPropertyValue('--unregistered-1-a'), ''); 33 assert_equals(computedStyle.left, '50px'); 34 assert_equals(computedStyle.top, '60px'); 36 35 }, "A var() cycle between two registered properties is handled correctly."); 37 36 </script> … … 64 63 65 64 computedStyle = getComputedStyle(test2); 66 assert_equals(computedStyle.getPropertyValue('--registered-2-a'), ' 1px');65 assert_equals(computedStyle.getPropertyValue('--registered-2-a'), ''); 67 66 assert_equals(computedStyle.getPropertyValue('--unregistered-2-a'), ''); 68 67 69 assert_equals(computedStyle.getPropertyValue('--registered-2-b'), ' 1px');70 assert_equals(computedStyle.getPropertyValue('--registered-2-c'), ' 1px');68 assert_equals(computedStyle.getPropertyValue('--registered-2-b'), '30px'); 69 assert_equals(computedStyle.getPropertyValue('--registered-2-c'), '3px'); 71 70 assert_equals(computedStyle.getPropertyValue('--registered-2-d'), '40px'); 72 71 assert_equals(computedStyle.getPropertyValue('--registered-2-e'), '5px'); 73 assert_equals(computedStyle.getPropertyValue('--unregistered-2-b'), ' 1px');74 assert_equals(computedStyle.getPropertyValue('--unregistered-2-c'), ' 1px');72 assert_equals(computedStyle.getPropertyValue('--unregistered-2-b'), '50px'); 73 assert_equals(computedStyle.getPropertyValue('--unregistered-2-c'), ''); 75 74 assert_equals(computedStyle.getPropertyValue('--unregistered-2-d'), '60px'); 76 75 assert_equals(computedStyle.getPropertyValue('--unregistered-2-e'), ''); 77 assert_equals(computedStyle.left, ' 1px');76 assert_equals(computedStyle.left, '70px'); 78 77 assert_equals(computedStyle.top, '80px'); 79 78 }, "A var() cycle between a registered properties and an unregistered property is handled correctly."); -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt
r237697 r239365 1 1 2 FAIL var() references work with registered properties assert_equals: expected " 10px" but got " 10px" 2 PASS var() references work with registered properties 3 3 FAIL References to registered var()-properties work in registered lists assert_equals: expected "1px, 10px, 2px" but got "0px" 4 4 FAIL References to mixed registered and unregistered var()-properties work in registered lists assert_equals: expected "1px, 20px, 10px, 2px" but got "0px" 5 5 FAIL Registered lists may be concatenated assert_equals: expected "1px, 10px, 2px, 1px, 20px, 10px, 2px" but got "0px" 6 PASS Font-relative units are absolutized when substituting 7 PASS Calc expressions are resolved when substituting 8 FAIL Lists with relative units are absolutized when substituting assert_equals: expected "110px, 120px" but got "0px" 9 PASS Valid fallback does not invalidate var()-reference [<length>, 10px] 10 PASS Valid fallback does not invalidate var()-reference [<length> | <color>, red] 11 PASS Valid fallback does not invalidate var()-reference [<length> | none, none] 12 FAIL Invalid fallback invalidates var()-reference [<length>, red] assert_equals: expected "" but got "40px" 13 FAIL Invalid fallback invalidates var()-reference [<length> | none, nolength] assert_equals: expected "" but got "40px" 14 FAIL Invalid fallback invalidates var()-reference [<length>, var(--novar)] assert_equals: expected "" but got "40px" 6 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties.html
r236444 r239365 3 3 <script src="/resources/testharness.js"></script> 4 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="./resources/utils.js"></script> 5 6 <style> 6 7 div { … … 55 56 assert_equals(computedStyle.getPropertyValue('--registered-length-7'), '123px'); 56 57 assert_equals(computedStyle.getPropertyValue('--length-1'), ' 20px'); 57 assert_equals(computedStyle.getPropertyValue('--length-2'), ' 58 assert_equals(computedStyle.getPropertyValue('--length-2'), ' 10px'); 58 59 assert_equals(computedStyle.getPropertyValue('--length-3'), ' calc(123px + 123px)'); 59 60 assert_equals(computedStyle.getPropertyValue('--registered-length-invalid'), '15px'); … … 97 98 }, 'Registered lists may be concatenated'); 98 99 100 test(function(){ 101 CSS.registerProperty({ 102 name: '--length-em', 103 syntax: '<length>', 104 initialValue: '0px', 105 inherits: false 106 }); 107 element.style = 'font-size: 11px; --length-em: 10em; --unregistered:var(--length-em);'; 108 let computedStyle = getComputedStyle(element); 109 assert_equals(computedStyle.getPropertyValue('--unregistered'), '110px'); 110 element.style = ''; 111 }, 'Font-relative units are absolutized when substituting'); 112 113 test(function(){ 114 CSS.registerProperty({ 115 name: '--length-calc', 116 syntax: '<length>', 117 initialValue: '0px', 118 inherits: false 119 }); 120 element.style = 'font-size: 11px; --length-calc: calc(10em + 10px); --unregistered:var(--length-calc);'; 121 let computedStyle = getComputedStyle(element); 122 assert_equals(computedStyle.getPropertyValue('--unregistered'), '120px'); 123 element.style = ''; 124 }, 'Calc expressions are resolved when substituting'); 125 126 test(function(){ 127 CSS.registerProperty({ 128 name: '--length-calc-list', 129 syntax: '<length>#', 130 initialValue: '0px', 131 inherits: false 132 }); 133 element.style = 'font-size: 11px; --length-calc-list: 10em, calc(10em + 10px); --unregistered:var(--length-calc-list);'; 134 let computedStyle = getComputedStyle(element); 135 assert_equals(computedStyle.getPropertyValue('--unregistered'), '110px, 120px'); 136 element.style = ''; 137 }, 'Lists with relative units are absolutized when substituting'); 138 139 function test_valid_fallback(syntax, value, fallback) { 140 test(function(){ 141 let name = generate_property(syntax); 142 try { 143 element.style = `${name}: ${value}; --x:var(${name},${fallback})`; 144 let computedStyle = getComputedStyle(element); 145 assert_equals(computedStyle.getPropertyValue('--x'), value); 146 } finally { 147 element.style = ''; 148 } 149 }, `Valid fallback does not invalidate var()-reference [${syntax}, ${fallback}]`); 150 } 151 152 function test_invalid_fallback(syntax, value, fallback) { 153 test(function(){ 154 let name = generate_property(syntax); 155 try { 156 element.style = `${name}: ${value}; --x:var(${name},${fallback})`; 157 let computedStyle = getComputedStyle(element); 158 assert_equals(computedStyle.getPropertyValue('--x'), ''); 159 } finally { 160 element.style = ''; 161 } 162 }, `Invalid fallback invalidates var()-reference [${syntax}, ${fallback}]`); 163 } 164 165 test_valid_fallback('<length>', '40px', '10px'); 166 test_valid_fallback('<length> | <color>', '40px', 'red'); 167 test_valid_fallback('<length> | none', '40px', 'none'); 168 169 test_invalid_fallback('<length>', '40px', 'red'); 170 test_invalid_fallback('<length> | none', '40px', 'nolength'); 171 test_invalid_fallback('<length>', '40px', 'var(--novar)'); 99 172 100 173 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/w3c-import.log
r236444 r239365 24 24 /LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-cssom.html 25 25 /LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-initial.html 26 /LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/self-utils.html 26 27 /LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative.html 27 28 /LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/unit-cycles.html -
trunk/Source/WebCore/ChangeLog
r239361 r239365 1 2018-12-18 Justin Michaud <justin_michaud@apple.com> 2 3 Update CSS Properties and Values API to use new cycle fallback behaviour 4 https://bugs.webkit.org/show_bug.cgi?id=192800 5 6 Reviewed by Antti Koivisto. 7 8 Make CSS variables that are registered and involved in a cycle be treated as invalid. This also fixes a crash in the 9 wpt tests where relative units and calc() in a registered property's initial value would break things instead of failing. 10 11 * css/CSSCustomPropertyValue.h: 12 * css/CSSVariableReferenceValue.cpp: 13 (WebCore::resolveVariableReference): 14 * css/DOMCSSRegisterCustomProperty.cpp: 15 (WebCore::DOMCSSRegisterCustomProperty::registerProperty): 16 * css/StyleResolver.cpp: 17 (WebCore::StyleResolver::applyCascadedCustomProperty): 18 * css/parser/CSSPropertyParser.cpp: 19 (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): 20 1 21 2018-12-18 Daniel Bates <dabates@apple.com> 2 22 -
trunk/Source/WebCore/css/CSSCustomPropertyValue.h
r238872 r239365 68 68 static Ref<CSSCustomPropertyValue> createSyntaxLength(const AtomicString& name, Length value) 69 69 { 70 ASSERT(!value.isUndefined()); 71 ASSERT(!value.isCalculated()); 70 72 return adoptRef(*new CSSCustomPropertyValue(name, { WTFMove(value) })); 71 73 } -
trunk/Source/WebCore/css/CSSVariableReferenceValue.cpp
r237697 r239365 71 71 // Apply fallback to detect cycles 72 72 Vector<CSSParserToken> fallbackResult; 73 resolveVariableFallback(CSSParserTokenRange(range), fallbackResult, state);73 bool fallbackReturn = resolveVariableFallback(CSSParserTokenRange(range), fallbackResult, state); 74 74 75 75 auto* property = style.getCustomProperty(variableName); 76 76 77 if (!property || property->isUnset() || property->isInvalid()) {77 if (!property || property->isUnset()) { 78 78 auto* registered = registeredProperties.get(variableName); 79 79 if (registered && registered->initialValue()) 80 80 property = registered->initialValue(); 81 else 82 return resolveVariableFallback(range, result, state); 81 } 82 83 if (!property || property->isInvalid()) { 84 if (fallbackReturn) 85 result.appendVector(fallbackResult); 86 return fallbackReturn; 83 87 } 84 88 -
trunk/Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
r237697 r239365 41 41 ExceptionOr<void> DOMCSSRegisterCustomProperty::registerProperty(Document& document, const DOMCSSCustomPropertyDescriptor& descriptor) 42 42 { 43 if (!isCustomPropertyName(descriptor.name)) 44 return Exception { SyntaxError, "The name of this property is not a custom property name." }; 45 43 46 RefPtr<CSSCustomPropertyValue> initialValue; 44 47 if (!descriptor.initialValue.isEmpty()) { … … 51 54 styleResolver.updateFont(); 52 55 56 HashSet<CSSPropertyID> dependencies; 57 CSSPropertyParser::collectParsedCustomPropertyValueDependencies(descriptor.syntax, false, dependencies, tokenizer.tokenRange(), strictCSSParserContext()); 58 59 if (!dependencies.isEmpty()) 60 return Exception { SyntaxError, "The given initial value must be computationally independent." }; 61 53 62 initialValue = CSSPropertyParser::parseTypedCustomPropertyValue(descriptor.name, descriptor.syntax, tokenizer.tokenRange(), styleResolver, strictCSSParserContext()); 54 63 … … 56 65 return Exception { SyntaxError, "The given initial value does not parse for the given syntax." }; 57 66 58 HashSet<CSSPropertyID> dependencies;59 67 initialValue->collectDirectComputationalDependencies(dependencies); 60 68 initialValue->collectDirectRootComputationalDependencies(dependencies); -
trunk/Source/WebCore/css/StyleResolver.cpp
r239173 r239365 2320 2320 2321 2321 auto property = state.cascade->customProperties().get(name); 2322 bool inCycle = state.inProgressPropertiesCustom.contains(name); 2322 2323 2323 2324 for (auto index : { SelectorChecker::MatchDefault, SelectorChecker::MatchLink, SelectorChecker::MatchVisited }) { … … 2329 2330 Ref<CSSCustomPropertyValue> valueToApply = CSSCustomPropertyValue::create(downcast<CSSCustomPropertyValue>(*property.cssValue[index])); 2330 2331 2331 if (state.inProgressPropertiesCustom.contains(name)) { 2332 // We are in a cycle, so reset the value. 2333 state.appliedCustomProperties.add(name); 2334 // Resolve this value so that we reset its dependencies 2335 if (WTF::holds_alternative<Ref<CSSVariableReferenceValue>>(valueToApply->value())) 2336 resolvedVariableValue(CSSPropertyCustom, valueToApply.get(), state); 2337 valueToApply = CSSCustomPropertyValue::createWithID(name, CSSValueUnset); 2332 if (inCycle) { 2333 state.appliedCustomProperties.add(name); // Make sure we do not try to apply this property again while resolving it. 2334 valueToApply = CSSCustomPropertyValue::createWithID(name, CSSValueInvalid); 2338 2335 } 2339 2336 … … 2342 2339 if (WTF::holds_alternative<Ref<CSSVariableReferenceValue>>(valueToApply->value())) { 2343 2340 RefPtr<CSSValue> parsedValue = resolvedVariableValue(CSSPropertyCustom, valueToApply.get(), state); 2341 2342 if (state.appliedCustomProperties.contains(name)) 2343 return; // There was a cycle and the value was reset, so bail. 2344 2344 2345 2345 if (!parsedValue) … … 2366 2366 applyProperty(CSSPropertyCustom, valueToApply.ptr(), state, index); 2367 2367 } 2368 state.inProgressPropertiesCustom.remove(name); 2369 state.appliedCustomProperties.add(name); 2368 } 2369 2370 state.inProgressPropertiesCustom.remove(name); 2371 state.appliedCustomProperties.add(name); 2372 2373 for (auto index : { SelectorChecker::MatchDefault, SelectorChecker::MatchLink, SelectorChecker::MatchVisited }) { 2374 if (!property.cssValue[index]) 2375 continue; 2376 if (index != SelectorChecker::MatchDefault && this->state().style()->insideLink() == InsideLink::NotInside) 2377 continue; 2378 2379 Ref<CSSCustomPropertyValue> valueToApply = CSSCustomPropertyValue::create(downcast<CSSCustomPropertyValue>(*property.cssValue[index])); 2380 2381 if (inCycle && WTF::holds_alternative<Ref<CSSVariableReferenceValue>>(valueToApply->value())) { 2382 // Resolve this value so that we reset its dependencies. 2383 resolvedVariableValue(CSSPropertyCustom, valueToApply.get(), state); 2384 } 2370 2385 } 2371 2386 } -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r238698 r239365 4394 4394 m_range.consumeWhitespace(); 4395 4395 auto primitiveVal = consumeWidthOrHeight(m_range, m_context); 4396 if (primitiveVal && primitiveVal->isPrimitiveValue()) 4397 return CSSCustomPropertyValue::createSyntaxLength(name, StyleBuilderConverter::convertLength(styleResolver, *primitiveVal)); 4396 if (primitiveVal && primitiveVal->isPrimitiveValue() && downcast<CSSPrimitiveValue>(*primitiveVal).isLength()) { 4397 auto length = StyleBuilderConverter::convertLength(styleResolver, *primitiveVal); 4398 if (!length.isCalculated() && !length.isUndefined()) 4399 return CSSCustomPropertyValue::createSyntaxLength(name, WTFMove(length)); 4400 } 4398 4401 } else { 4399 4402 auto propertyValue = CSSCustomPropertyValue::createSyntaxAll(name, CSSVariableData::create(m_range));
Note: See TracChangeset
for help on using the changeset viewer.