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

Conversation

nainar
Copy link
Contributor

@nainar nainar commented Aug 22, 2017

@shans PTAL? Thanks!

margin
margin-{bottom,left,right,top}
</div>


<div algorithm>
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this doing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo. Removed.

: 'margin'
::
1. Let |values| initially be the empty [=list=].
2. If 'margin-bottom' does not specify ''0'' for it's initial value,
Copy link
Contributor

Choose a reason for hiding this comment

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

its

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

serialize 'margin-top' and append it to |values|.
6. If 'margin' is set to the ''inherit'' keyword, append "inherit" to |values|.
7. Return the result of concatenating all the items in |values|,
separated by " " (U+0020 SPACE).
Copy link
Contributor

Choose a reason for hiding this comment

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

Many of the 4-length properties have collapsed versions when all the lengths (or some of the lengths) are the same. Do we currently serialize collapsed versions? Do other browsers? If there's consensus on collapsed serialization then we should spec that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checked other browsers and fixed it to include collapsing. (Copied the Chrome implementation here)

Copy link
Contributor Author

@nainar nainar left a comment

Choose a reason for hiding this comment

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

@shans PTAL?

</div>


<div algorithm>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo. Removed.

: 'margin'
::
1. Let |values| initially be the empty [=list=].
2. If 'margin-bottom' does not specify ''0'' for it's initial value,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

serialize 'margin-top' and append it to |values|.
6. If 'margin' is set to the ''inherit'' keyword, append "inherit" to |values|.
7. Return the result of concatenating all the items in |values|,
separated by " " (U+0020 SPACE).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checked other browsers and fixed it to include collapsing. (Copied the Chrome implementation here)


: '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.

::
1. If the value specifies ''0'', exit the algorithm.
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.

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
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.

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.

@nainar nainar closed this Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants