@@ -1697,9 +1697,9 @@ rather than on {{CSSNumericValue}} instances.
1697
1697
and abort this algorithm.
1698
1698
1699
1699
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.
1703
1703
1704
1704
4. [=Reify a numeric value=] |result|,
1705
1705
and return the result.
@@ -5762,27 +5762,64 @@ length3.toString(); // "42px";
5762
5762
</div>
5763
5763
5764
5764
5765
- {{CSSUnitValue }} Serialization {#numericvalue-serialization}
5766
- ------------------------------------------------------------
5765
+ {{CSSNumericValue }} Serialization {#numericvalue-serialization}
5766
+ ---------------------------------------------------------------
5767
5767
5768
5768
<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:
5770
5792
5771
5793
1. Let |value| and |unit| be
5772
5794
|this|‘s {{CSSUnitValue/value}} and {{CSSUnitValue/unit}} internal slots.
5773
5795
5774
5796
2. Set |s| to the result of serializing a <<number>> from |value|,
5775
5797
per [[cssom#serializing-css-values]] .
5776
5798
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>
5779
5811
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|.
5783
5821
5784
- 5. Otherwise, append |unit| to |s|,
5785
- then return |s|.
5822
+ 5. Return |s|.
5786
5823
</div>
5787
5824
5788
5825
@@ -5791,8 +5828,10 @@ length3.toString(); // "42px";
5791
5828
5792
5829
<div algorithm>
5793
5830
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.
5796
5835
5797
5836
1. Let |s| initially be the empty [=string=] .
5798
5837
@@ -6083,6 +6122,7 @@ length3.toString(); // "42px";
6083
6122
1. Let |s| initially be "perspective(".
6084
6123
6085
6124
2. Serialize |this|’s {{CSSPerspective/length}} internal slot,
6125
+ with a <var ignore> minimum</var> of ''0px'' ,
6086
6126
and append it to |s|.
6087
6127
6088
6128
3. Append ")" to |s|,
0 commit comments