Skip to content

Commit d10b537

Browse files
committed
[css-typed-om] Add min/max to 'serialize a CSSUnitValue', and pass it when serializing arg of CSSPerspective. Fixes #1069.
1 parent 53a9d7b commit d10b537

File tree

1 file changed

+55
-15
lines changed

1 file changed

+55
-15
lines changed

css-typed-om/Overview.bs

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,9 +1697,9 @@ rather than on {{CSSNumericValue}} instances.
16971697
and abort this algorithm.
16981698

16991699
3. If |result| is a <<dimension-token>>
1700-
and [=creating a type=] from |result|'s unit returns failure,
1701-
[=throw=] a {{SyntaxError}}
1702-
and abort this algorithm.
1700+
and [=creating a type=] from |result|'s unit returns failure,
1701+
[=throw=] a {{SyntaxError}}
1702+
and abort this algorithm.
17031703

17041704
4. [=Reify a numeric value=] |result|,
17051705
and return the result.
@@ -5762,27 +5762,64 @@ length3.toString(); // "42px";
57625762
</div>
57635763

57645764

5765-
{{CSSUnitValue}} Serialization {#numericvalue-serialization}
5766-
------------------------------------------------------------
5765+
{{CSSNumericValue}} Serialization {#numericvalue-serialization}
5766+
---------------------------------------------------------------
57675767

57685768
<div algorithm>
5769-
To <dfn export>serialize a {{CSSUnitValue}}</dfn> |this|:
5769+
To <dfn export>serialize a {{CSSNumericValue}}</dfn> |this|,
5770+
given
5771+
an optional |minimum|, a numeric value,
5772+
and optional |maximum|, a numeric value:
5773+
5774+
1. If |this| is a {{CSSUnitValue}},
5775+
[=serialize a CSSUnitValue=] from |this|,
5776+
passing |minimum| and |maximum|.
5777+
Return the result.
5778+
5779+
2. Otherwise,
5780+
[=serialize a CSSMathValue=] from |this|,
5781+
and return the result.
5782+
</div>
5783+
5784+
{{CSSUnitValue}} Serialization {#unitvalue-serialization}
5785+
---------------------------------------------------------
5786+
5787+
<div algorithm>
5788+
To <dfn export>serialize a {{CSSUnitValue}}</dfn> |this|,
5789+
with optional arguments
5790+
|minimum|, a numeric value,
5791+
and |maximum|, a numeric value:
57705792

57715793
1. Let |value| and |unit| be
57725794
|this|‘s {{CSSUnitValue/value}} and {{CSSUnitValue/unit}} internal slots.
57735795

57745796
2. Set |s| to the result of serializing a <<number>> from |value|,
57755797
per [[cssom#serializing-css-values]].
57765798

5777-
3. If |unit| is "number",
5778-
return |s|.
5799+
3. If |unit| is:
5800+
5801+
<dl class=switch>
5802+
: "number"
5803+
:: Do nothing.
5804+
5805+
: "percent"
5806+
:: Append "%" to |s|.
5807+
5808+
: anything else
5809+
:: Append |unit| to |s|.
5810+
</dl>
57795811

5780-
4. Otherwise, if |unit| is "percent",
5781-
append "%" to |s|,
5782-
then return |s|.
5812+
4. If |minimum| was passed
5813+
and |this| is less than |minimum|,
5814+
or if |maximum| was passed
5815+
and |this| is greater than |maximum|,
5816+
or either |minimum| and/or |maximum| were passed
5817+
and the relative size of |this| and |minimum|/|maximum|
5818+
can't be determined with the available information at this time,
5819+
prepend "calc(" to |s|,
5820+
then append ")" to |s|.
57835821

5784-
5. Otherwise, append |unit| to |s|,
5785-
then return |s|.
5822+
5. Return |s|.
57865823
</div>
57875824

57885825

@@ -5791,8 +5828,10 @@ length3.toString(); // "42px";
57915828

57925829
<div algorithm>
57935830
To <dfn export>serialize a {{CSSMathValue}}</dfn> |this|,
5794-
with additional flags |nested|, a boolean (defaulting to false if unspecified),
5795-
and |paren-less|, a boolean (defaulting to false if unspecified):
5831+
with optional arguments
5832+
|nested|, a boolean (defaulting to false if unspecified),
5833+
|paren-less|, a boolean (defaulting to false if unspecified),
5834+
perform the following steps.
57965835

57975836
1. Let |s| initially be the empty [=string=].
57985837

@@ -6083,6 +6122,7 @@ length3.toString(); // "42px";
60836122
1. Let |s| initially be "perspective(".
60846123

60856124
2. Serialize |this|’s {{CSSPerspective/length}} internal slot,
6125+
with a <var ignore>minimum</var> of ''0px'',
60866126
and append it to |s|.
60876127

60886128
3. Append ")" to |s|,

0 commit comments

Comments
 (0)