Skip to content

Commit f63d90e

Browse files
committed
[css-values-4] Add round(line-width, ...). #3720
1 parent 05005de commit f63d90e

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

css-values-4/Overview.bs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,7 +3323,7 @@ Stepped Value Functions: ''round()'', ''mod()'', and ''rem()''</h3>
33233323

33243324
If A is exactly equal to an integer multiple of B,
33253325
''round()'' resolves to A exactly
3326-
(preserving whether A is 0⁻ or 0⁺, if relevant).
3326+
(preserving whether A is 0⁻ or 0⁺, if relevant).
33273327
Otherwise, there are two integer multiples of B that are potentially "closest" to A,
33283328
|lower B| which is closer to −∞
33293329
and |upper B| which is closer to +∞.
@@ -3343,6 +3343,15 @@ Stepped Value Functions: ''round()'', ''mod()'', and ''rem()''</h3>
33433343
: <dfn>to-zero</dfn>
33443344
:: Choose whichever of |lower B| and |upper B|
33453345
that has the smallest absolute difference from 0.
3346+
: <dfn>line-width</dfn>
3347+
:: If A is non-negative and B is omitted,
3348+
A is [=snapped as a border width=].
3349+
3350+
Otherwise, identical to ''<rounding-strategy>/nearest'',
3351+
except that if A is positive (non-zero)
3352+
and one of |lower B| or |upper B| is zero,
3353+
choose the non-zero one,
3354+
then [=snap as a border width=].
33463355
</dl>
33473356

33483357
If |lower B| would be zero,
@@ -3353,11 +3362,28 @@ Stepped Value Functions: ''round()'', ''mod()'', and ''rem()''</h3>
33533362
If <<rounding-strategy>> is omitted,
33543363
it defaults to ''nearest''.
33553364
(Aka [=rounding to the nearest integer=].)
3365+
If <<rounding-strategy>> is ''<rounding-strategy>/line-width'',
3366+
the [=CSSNumericValue/type=] of A
3367+
must match <<length>>.
3368+
33563369
If the [=CSSNumericValue/type=] of A
33573370
matches <<number>>,
33583371
then B may be omitted,
3359-
and defaults to ''1'';
3360-
omitting B is otherwise invalid.
3372+
and defaults to ''1''.
3373+
If <<rounding-strategy>> is ''<rounding-strategy>/line-width'',
3374+
B may also be omitted
3375+
and has special behavior (defined above)
3376+
essentially defaulting it to one device pixel.
3377+
In all other cases,
3378+
omitting B is invalid.
3379+
3380+
Advisement: While ''round(line-width, ...)''
3381+
attempts to ensure that non-zero values never round to zero,
3382+
passing a sufficiently small A value
3383+
might cause it to be represented as 0 internally anyway.
3384+
Use caution when writing very small values;
3385+
''round(line-width, 0.1px)'' is safer than ''round(line-width, 0.0001px)'',
3386+
and the difference between the two is almost certainly nil in practice.
33613387

33623388
Issue(5689): CSSOM needs to specify how it rounds,
33633389
and it's probably good for CSS functions to round the same way by default.

0 commit comments

Comments
 (0)