Skip to content

Add serialization for the margin and margin-{bottom,left,right,top} #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions css-typed-om/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,60 @@ depending on the property they came from:
return "currentcolor".
2. Otherwise, return the result of serializing the <<color>> value.

: 'margin'
::
1. Let |values| initially be the empty [=list=].
2. If 'margin-top' does not specify ''0'' for its value,
consider 'margin-top' to be |topValue| and append it to |values|.
3. If 'margin-right' does not specify ''0'' for its value,
consider 'margin-right' to be |rightValue|.
4. If 'margin-bottom' does not specify ''0'' for its value,
consider 'margin-bottom' to be |bottomValue|.
5. If 'margin-left' does not specify ''0'' for its value,
consider 'margin-left' to be |leftValue|.
6. Append |rightValue| to |values| if one of the following conditions is true:
1. |rightValue| and |topValue| are not equivalent,
2. |topValue| and |bottomValue| are not equivalent
3. Or |rightValue| and |leftValue| are not equivalent.
7. Append |bottomValue| to |values| if one of the following conditions is true:
1. |topValue| and |bottomValue| are not equivalent
2. Or |rightValue| and |leftValue| are not equivalent.
8. If |rightValue| and |leftValue| are not equivalent append |leftValue| to |values|.
9. If 'margin' is set to the ''inherit'' keyword, append "inherit" to |values|.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the sub-properties, cut this line. We'll deal with the global keywords generically.

10. Return the result of concatenating all the items in |values|,
separated by " " (U+0020 SPACE).

: 'margin-bottom'
::
1. If the value specifies ''0'', exit the algorithm.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exit and do what? When serializing 'margin-bottom', ''0px'' is still a valid value that needs to be serialized. The algorithm always needs to output a value.

(Also, in general, lengths need to be talked about in slightly more generic terms. It's not about specifying ''0'', it's about the <<length>> value being equivalent to ''0px''.)

Same applies to all the 'margin-*' properties.

2. If the value is the ''inherit'' keyword,
return "inherit".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we should address this at a higher level. This doesn't address any of the other global keywords, and every property allows the global keywords. Go ahead and cut this line entirely; we need to intervene for these keywords before getting to any specific property.

3. If the value is of type <<margin-width>> return the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<<margin-width>> isn't a type. It's either a <<length>> or auto; serialize these two branches.

result of serializing the <<margin-width>> value.

: 'margin-left'
::
1. If the value specifies ''0'', exit the algorithm.
2. If the value is the ''inherit'' keyword,
return "inherit".
3. If the value is of type <<margin-width>> return the
result of serializing the <<margin-width>> value.

: 'margin-right'
::
1. If the value specifies ''0'', exit the algorithm.
2. If the value is the ''inherit'' keyword,
return "inherit".
3. If the value is of type <<margin-width>> return the
result of serializing the <<margin-width>> value.

: 'margin-top'
::
1. If the value specifies ''0'', exit the algorithm.
2. If the value is the ''inherit'' keyword,
return "inherit".
3. If the value is of type <<margin-width>> return the
result of serializing the <<margin-width>> value.


Security Considerations {#security-considerations}
Expand Down