LibWeb: Support non-fixed <random-value-sharing>

This works by generating random values using XorShift128PlusRNG at
compute time and then caching them on the document using the relevant
random-caching-key
This commit is contained in:
Callum Law 2025-11-05 13:27:48 +13:00 committed by Sam Atkins
parent 86e6aa0291
commit 12e8f503aa
Notes: github-actions[bot] 2025-12-01 11:01:47 +00:00
15 changed files with 226 additions and 54 deletions

View file

@ -2,16 +2,15 @@ Harness status: OK
Found 72 tests
59 Pass
13 Fail
72 Pass
Pass Property scale value 'random(1, 11)'
Fail Property scale value 'random(--foo, 2, 12)'
Fail Property scale value 'random(--foo element-shared, 3, 13)'
Fail Property scale value 'random(element-shared --foo, 4, 14)'
Pass Property scale value 'random(--foo, 2, 12)'
Pass Property scale value 'random(--foo element-shared, 3, 13)'
Pass Property scale value 'random(element-shared --foo, 4, 14)'
Pass Property scale value 'random(0, 10, 5)'
Fail Property scale value 'random(--foo, 10, 20, 5)'
Fail Property scale value 'random(--foo element-shared, 20, 30, 5)'
Fail Property scale value 'random(element-shared --foo, 30, 40, 5)'
Pass Property scale value 'random(--foo, 10, 20, 5)'
Pass Property scale value 'random(--foo element-shared, 20, 30, 5)'
Pass Property scale value 'random(element-shared --foo, 30, 40, 5)'
Pass Property scale value 'random(100, 10)'
Pass Property scale value 'random(-10, -100)'
Pass Property scale value 'random(-100, -10)'
@ -61,18 +60,18 @@ Pass Property scale value 'calc(10 + random(10, 100, infinity))'
Pass Property scale value 'random(10, 100, -infinity)'
Pass Property scale value 'calc(10 + random(10, 100, -infinity))'
Pass Property scale value on pseudo element '::before' 'random(7, 17)'
Fail Property scale value on pseudo element '::before' 'random(--bar, 8, 18)'
Fail Property scale value on pseudo element '::before' 'random(element-shared, 9, 19)'
Fail Property scale value on pseudo element '::before' 'random(element-shared --foo, 10, 20)'
Pass Property scale value on pseudo element '::before' 'random(--bar, 8, 18)'
Pass Property scale value on pseudo element '::before' 'random(element-shared, 9, 19)'
Pass Property scale value on pseudo element '::before' 'random(element-shared --foo, 10, 20)'
Pass Property translate value 'random(10%, 100%)'
Pass Property translate value 'random(fixed random(1, 2), 10%, 100%)'
Pass Property translate value 'random(fixed random(-2, -1), 10%, 100%)'
Fail Maximum random: 'random(a, b)'
Fail Maximum random - shorthand: random(a, b))
Fail Shared by name within an element: 'random(--identifier, a, b)'
Pass Maximum random: 'random(a, b)'
Pass Maximum random - shorthand: random(a, b))
Pass Shared by name within an element: 'random(--identifier, a, b)'
Pass Shared by name within an element - shorthand: random(--identifier, a, b))
Pass Shared between elements within a property: random(element-shared, a, b)
Pass Shared between elements within a property - shorthand: random(element-shared, a, b))
Fail Shared globally: random(--identifier element-shared, a, b)
Pass Shared globally: random(--identifier element-shared, a, b)
Pass Shared globally - shorthand: random(element-shared, a, b))
Pass Fixed: random(fixed <number>, a, b)

View file

@ -2,37 +2,37 @@ Harness status: OK
Found 32 tests
3 Pass
29 Fail
Fail e.style['width'] = "random(0px, 100px)" should set the property value
Fail e.style['width'] = "random(0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(--foo, 0px, 100px)" should set the property value
Fail e.style['width'] = "random(auto, 0px, 100px)" should set the property value
Fail e.style['width'] = "random(--foo element-shared, 0px, 100px)" should set the property value
Fail e.style['width'] = "random(auto element-shared, 0px, 100px)" should set the property value
Fail e.style['width'] = "random(element-shared --foo, 0px, 100px)" should set the property value
Fail e.style['width'] = "random(element-shared auto, 0px, 100px)" should set the property value
29 Pass
3 Fail
Pass e.style['width'] = "random(0px, 100px)" should set the property value
Pass e.style['width'] = "random(0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(--foo, 0px, 100px)" should set the property value
Pass e.style['width'] = "random(auto, 0px, 100px)" should set the property value
Pass e.style['width'] = "random(--foo element-shared, 0px, 100px)" should set the property value
Pass e.style['width'] = "random(auto element-shared, 0px, 100px)" should set the property value
Pass e.style['width'] = "random(element-shared --foo, 0px, 100px)" should set the property value
Pass e.style['width'] = "random(element-shared auto, 0px, 100px)" should set the property value
Pass e.style['width'] = "random(fixed 0.5, 0px, 100px)" should set the property value
Fail e.style['width'] = "random(--foo, 0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(auto, 0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(--foo element-shared, 0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(auto element-shared, 0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(element-shared --foo, 0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(element-shared auto, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(--foo, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(auto, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(--foo element-shared, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(auto element-shared, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(element-shared --foo, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(element-shared auto, 0px, 100px, 50px)" should set the property value
Pass e.style['width'] = "random(fixed 0.5, 0px, 100px, 50px)" should set the property value
Fail e.style['width'] = "random(10px, 20%)" should set the property value
Fail e.style['width'] = "random(100px, 0px)" should set the property value
Fail e.style['width'] = "random(-100px, -10px)" should set the property value
Fail e.style['width'] = "random(-100px, -10px, -5px)" should set the property value
Fail e.style['width'] = "random(1em, 200rem)" should set the property value
Pass e.style['width'] = "random(10px, 20%)" should set the property value
Pass e.style['width'] = "random(100px, 0px)" should set the property value
Pass e.style['width'] = "random(-100px, -10px)" should set the property value
Pass e.style['width'] = "random(-100px, -10px, -5px)" should set the property value
Pass e.style['width'] = "random(1em, 200rem)" should set the property value
Fail e.style['width'] = "random(10 * 100px, 200em / 2)" should set the property value
Pass e.style['width'] = "random(fixed calc(2 / 4), 0px, 100px)" should set the property value
Fail e.style['width'] = "calc(2 * random(0px, 100px))" should set the property value
Pass e.style['width'] = "calc(2 * random(0px, 100px))" should set the property value
Fail e.style['max-lines'] = "random(25, 50)" should set the property value
Fail e.style['max-lines'] = "random(25, 50, 5)" should set the property value
Fail e.style['scale'] = "random(0.5, 2.5)" should set the property value
Fail e.style['scale'] = "random(0.5, 2.5, 0.1)" should set the property value
Fail e.style['rotate'] = "random(25deg, 1turn)" should set the property value
Fail e.style['rotate'] = "random(25deg, 1turn, 5deg)" should set the property value
Fail e.style['transition-delay'] = "random(25ms, 50s)" should set the property value
Fail e.style['transition-delay'] = "random(25ms, 50s, 5s)" should set the property value
Pass e.style['scale'] = "random(0.5, 2.5)" should set the property value
Pass e.style['scale'] = "random(0.5, 2.5, 0.1)" should set the property value
Pass e.style['rotate'] = "random(25deg, 1turn)" should set the property value
Pass e.style['rotate'] = "random(25deg, 1turn, 5deg)" should set the property value
Pass e.style['transition-delay'] = "random(25ms, 50s)" should set the property value
Pass e.style['transition-delay'] = "random(25ms, 50s, 5s)" should set the property value