Skip to content

Commit b32b11e

Browse files
committed
[css-values-4] Make the type-changing math functions also carry the percent hint of their inputs. #10017
1 parent d0e0f40 commit b32b11e

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

css-values-4/Overview.bs

+33-5
Original file line numberDiff line numberDiff line change
@@ -3483,7 +3483,9 @@ Trigonometric Functions: ''sin()'', ''cos()'', ''tan()'', ''asin()'', ''acos()''
34833483
(That is, ''sin(45deg)'', ''sin(.125turn)'', and ''sin(3.14159 / 4)''
34843484
all represent the same value,
34853485
approximately ''.707''.)
3486-
They all represent a <<number>>;
3486+
They all represent a <<number>>,
3487+
with the return type [=made consistent=]
3488+
with the input [=calculation’s=] type.
34873489
''sin()'' and ''cos()'' will always return a number between −1 and 1,
34883490
while ''tan()'' can return any number between −∞ and +∞.
34893491
(See [[#calc-type-checking]] for details on how [=math functions=] handle ∞.)
@@ -3495,7 +3497,9 @@ Trigonometric Functions: ''sin()'', ''cos()'', ''tan()'', ''asin()'', ''acos()''
34953497
which must resolve to a <<number>>,
34963498
and compute their corresponding function,
34973499
interpreting their result as a number of radians,
3498-
representing an <<angle>>.
3500+
representing an <<angle>>
3501+
with the return type [=made consistent=]
3502+
with the input [=calculation’s=] type.
34993503
The angle returned by ''asin()'' must be normalized to the range [''-90deg'', ''90deg''];
35003504
the angle returned by ''acos()'' to the range [''0deg'', ''180deg''];
35013505
and the angle returned by ''atan()'' to the range [''-90deg'', ''90deg''].
@@ -3506,7 +3510,9 @@ Trigonometric Functions: ''sin()'', ''cos()'', ''tan()'', ''asin()'', ''acos()''
35063510
but must have a [=consistent type=]
35073511
or else the function is invalid.
35083512
The function returns the <<angle>>
3509-
between the positive X-axis and the point (B,A).
3513+
between the positive X-axis and the point (B,A),
3514+
with the return type [=made consistent=]
3515+
with the input [=calculation’s=] type.
35103516
The returned angle must be normalized to the interval (''-180deg'', ''180deg'']
35113517
(that is, greater than ''-180deg'', and less than or equal to ''180deg'').
35123518

@@ -3688,12 +3694,18 @@ Exponential Functions: ''pow()'', ''sqrt()'', ''hypot()'', ''log()'', ''exp()''
36883694
both of which must resolve to <<number>>s,
36893695
and returns the result of raising A to the power of B,
36903696
returning the value as a <<number>>.
3697+
The input [=calculations=]
3698+
must have a [=consistent type=]
3699+
or else the function is invalid;
3700+
the result's type will be the [=consistent type=].
36913701

36923702
The <dfn lt="sqrt()">sqrt(A)</dfn> function
36933703
contains a single [=calculation=]
36943704
which must resolve to a <<number>>,
36953705
and returns the square root of the value
3696-
as a <<number>>.
3706+
as a <<number>>,
3707+
with the return type [=made consistent=]
3708+
with the input [=calculation’s=] type.
36973709
(''sqrt(X)'' and ''pow(X, .5)'' are basically equivalent,
36983710
differing only in some error-handling;
36993711
''sqrt()'' is a common enough function
@@ -4023,6 +4035,9 @@ Sign-Related Functions: ''abs()'', ''sign()''</h3>
40234035
+1 if A's numeric value is positive,
40244036
0⁺ if A's numeric value is 0⁺,
40254037
and 0⁻ if A's numeric value is 0⁻.
4038+
The return type is a <<number>>,
4039+
[=made consistent=]
4040+
with the input [=calculation’s=] type.
40264041

40274042
Note: Both of these functions operate on the fully simplified/resolved form of their arguments,
40284043
which may give unintuitive results at first glance.
@@ -4322,11 +4337,24 @@ Type Checking</h3>
43224337
</div>
43234338

43244339
<div algorithm>
4325-
Two or more calculations have a <dfn export local-lt="consistent">consistent type</dfn>
4340+
Two or more calculations have a <dfn export for=CSS local-lt="consistent">consistent type</dfn>
43264341
if [=add two types/adding the types=] doesn't result in failure.
43274342
The [=consistent type=] is the result of the type addition.
43284343
</div>
43294344

4345+
<div algorithm>
4346+
To <dfn export for=CSS lt="make a type consistent|make consistent|made consistent">make a type |base| consistent</dfn>
4347+
with another type |input|:
4348+
4349+
1. If both |base| and |input| have different non-null [=percent hints=],
4350+
they can't be made consistent.
4351+
Return failure.
4352+
4353+
2. Otherwise, set |base|’s [=percent hint=]
4354+
to |input|’s [=percent hint=],
4355+
and return |base|.
4356+
</div>
4357+
43304358
[=Math functions=] themselves have [=CSSNumericValue/types=],
43314359
according to their contained [=calculations=]:
43324360

0 commit comments

Comments
 (0)