LibWeb: Implement basic CSS random() function

At the moment this is limited to only fixed value sharing and does not
support step values
This commit is contained in:
Callum Law
2025-11-04 13:35:17 +13:00
committed by Sam Atkins
parent 8944130fde
commit 2a5e389f63
Notes: github-actions[bot] 2025-12-01 11:02:05 +00:00
17 changed files with 380 additions and 31 deletions

View File

@@ -2,9 +2,9 @@ Harness status: OK
Found 72 tests
4 Pass
68 Fail
Fail Property scale value 'random(1, 11)'
27 Pass
45 Fail
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)'
@@ -12,15 +12,15 @@ Fail 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)'
Fail Property scale value 'random(100, 10)'
Fail Property scale value 'random(-10, -100)'
Fail Property scale value 'random(-100, -10)'
Pass Property scale value 'random(100, 10)'
Pass Property scale value 'random(-10, -100)'
Pass Property scale value 'random(-100, -10)'
Fail Property scale value 'random(40, 50, -5)'
Fail Property scale value 'random(5 * 1, 30 / 2)'
Fail Property scale value 'calc(2 * random(6, 16))'
Fail Property scale value 'random(NaN, 100)'
Fail Property scale value 'random(10, NaN)'
Fail Property scale value 'random(NaN, NaN)'
Pass Property scale value 'random(5 * 1, 30 / 2)'
Pass Property scale value 'calc(2 * random(6, 16))'
Pass Property scale value 'random(NaN, 100)'
Pass Property scale value 'random(10, NaN)'
Pass Property scale value 'random(NaN, NaN)'
Fail Property scale value 'random(NaN, 100, 10)'
Fail Property scale value 'random(10, NaN, 10)'
Fail Property scale value 'random(NaN, NaN, 10)'
@@ -28,9 +28,9 @@ Fail Property scale value 'random(NaN, 100, NaN)'
Fail Property scale value 'random(10, NaN, NaN)'
Fail Property scale value 'random(NaN, NaN, NaN)'
Fail Property scale value 'random(10, 100, NaN)'
Fail Property scale value 'calc(10 + random(NaN, 100))'
Fail Property scale value 'calc(10 + random(10, NaN))'
Fail Property scale value 'calc(10 + random(NaN, NaN))'
Pass Property scale value 'calc(10 + random(NaN, 100))'
Pass Property scale value 'calc(10 + random(10, NaN))'
Pass Property scale value 'calc(10 + random(NaN, NaN))'
Fail Property scale value 'calc(10 + random(NaN, 100, 10))'
Fail Property scale value 'calc(10 + random(10, NaN, 10))'
Fail Property scale value 'calc(10 + random(NaN, NaN, 10))'
@@ -38,35 +38,35 @@ Fail Property scale value 'calc(10 + random(NaN, 100, NaN))'
Fail Property scale value 'calc(10 + random(10, NaN, NaN))'
Fail Property scale value 'calc(10 + random(NaN, NaN, NaN))'
Fail Property scale value 'calc(10 + random(10, 100, NaN))'
Fail Property scale value 'random(infinity, 100)'
Fail Property scale value 'random(infinity, infinity)'
Pass Property scale value 'random(infinity, 100)'
Pass Property scale value 'random(infinity, infinity)'
Fail Property scale value 'random(infinity, 100, 10)'
Fail Property scale value 'random(infinity, infinity, 10)'
Fail Property scale value 'random(infinity, 100, infinity)'
Fail Property scale value 'random(infinity, infinity, infinity)'
Fail Property scale value 'calc(10 + random(infinity, 100))'
Fail Property scale value 'calc(10 + random(infinity, infinity))'
Pass Property scale value 'calc(10 + random(infinity, 100))'
Pass Property scale value 'calc(10 + random(infinity, infinity))'
Fail Property scale value 'calc(10 + random(infinity, infinity, 10))'
Fail Property scale value 'calc(10 + random(infinity, 100, infinity))'
Fail Property scale value 'calc(10 + random(infinity, infinity, infinity))'
Fail Property scale value 'calc(10 + random(infinity, 100, 10))'
Fail Property scale value 'random(10, infinity)'
Pass Property scale value 'random(10, infinity)'
Fail Property scale value 'random(10, infinity, 10)'
Fail Property scale value 'random(10, infinity, infinity)'
Fail Property scale value 'calc(10 + random(10, infinity))'
Pass Property scale value 'calc(10 + random(10, infinity))'
Fail Property scale value 'calc(10 + random(10, infinity, 10))'
Fail Property scale value 'calc(10 + random(10, infinity, infinity))'
Fail Property scale value 'random(10, 100, infinity)'
Fail Property scale value 'calc(10 + random(10, 100, infinity))'
Fail Property scale value 'random(10, 100, -infinity)'
Fail Property scale value 'calc(10 + random(10, 100, -infinity))'
Fail Property scale value on pseudo element '::before' 'random(7, 17)'
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)'
Fail Property translate value 'random(10%, 100%)'
Fail Property translate value 'random(fixed random(1, 2), 10%, 100%)'
Fail Property translate value 'random(fixed random(-2, -1), 10%, 100%)'
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)'
@@ -75,4 +75,4 @@ 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 - shorthand: random(element-shared, a, b))
Fail Fixed: random(fixed <number>, a, b)
Pass Fixed: random(fixed <number>, a, b)