Skip to content

Commit

Permalink
Define how CSSMathValue objects serialize. Fixes #489.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Jan 30, 2018
1 parent 4dc7faf commit 42a9ff0
Showing 1 changed file with 79 additions and 2 deletions.
81 changes: 79 additions & 2 deletions css-typed-om/Overview.bs
Expand Up @@ -2992,9 +2992,86 @@ followed by their {{CSSUnitValue/unit}}.
{{CSSMathValue}} Serialization {#calc-serialization}
---------------------------------------------------------

{{CSSMathValue}} objects are serialized into a ''calc()'' expression
{{CSSMathValue}} objects are serialized into a [=math function=] as follows:

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

2. If the object is a {{CSSMathMin}} or {{CSSMathMax}}:
1. Append "min(" or "max(" to |s|, as appropriate.

2. [=list/For each=] |arg| in the object's {{CSSMathMin/values}} internal slot,
serialize |arg| and append the result to |s|,
appending a ", " between successive values.

3. Append ")" to |s|
and return |s|.

3. Otherwise, if the object is a {{CSSMathSum}}:
1. If this object is nested inside of another {{CSSMathValue}} object,
append "(" to |s|;
otherwise, append "calc(" to |s|.

2. Serialize the first [=list/item=] in the object's {{CSSMathSum/values}} internal slot
and append the result to |s|.

3. [=list/For each=] |arg| in the object's {{CSSMathSum/values}} internal slot beyond the first:
1. If |arg| is a {{CSSMathNegate}},
append " - " to |s|,
then serialize |arg|'s {{CSSMathNegate/value}} internal slot
and append the result to |s|.
2. Otherwise, append " + " to |s|,
then serialize |arg|
and append the result to |s|.

4. Append ")" to |s|,
and return |s|.

4. Otherwise, if the object is a {{CSSMathNegate}}:
1. If this object is nested inside of another {{CSSMathValue}} object,
append "(" to |s|;
otherwise, append "calc(" to |s|.

2. Append "-" to |s|.

3. Serialize the object's {{CSSMathNegate/value}} internal slot
and append the result to |s|.

4. Append ")" to |s|,
and return |s|.

5. Otherwise, if the object is a {{CSSMathProduct}}:
1. If this object is nested inside of another {{CSSMathValue}} object,
append "(" to |s|;
otherwise, append "calc(" to |s|.

2. Serialize the first [=list/item=] in the object's {{CSSMathProduct/values}} internal slot
and append the result to |s|.

3. [=list/For each=] |arg| in the object's {{CSSMathProduct/values}} internal slot beyond the first:
1. If |arg| is a {{CSSMathInvert}},
append " / " to |s|,
then serialize |arg|'s {{CSSMathInvert/value}} internal slot
and append the result to |s|.
2. Otherwise, append " * " to |s|,
then serialize |arg|
and append the result to |s|.

4. Append ")" to |s|,
and return |s|.

6. Otherwise, if the object is a {{CSSMathInvert}}:
1. If this object is nested inside of another {{CSSMathValue}} object,
append "(" to |s|;
otherwise, append "calc(" to |s|.

2. Append "1 / " to |s|.

3. Serialize the object's {{CSSMathInvert/value}} internal slot
and append the result to |s|.

4. Append ")" to |s|,
and return |s|.

Issue(489): TODO

{{CSSTransformValue}} Serialization {#transformvalue-serialization}
-------------------------------------------------------------------
Expand Down

0 comments on commit 42a9ff0

Please sign in to comment.