Skip to content
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

[css-values-4] Define generic serialization for functional notations.… #9721

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions css-values-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2928,6 +2928,57 @@ Functional Notations</h2>
Other [=functional notations=] are defined in their own modules;
for example the <<absolute-color-function>>s are defined in [[CSS-COLOR-5]].

<h3 id="fuctional-serialization">
Serialization of Functional Notations</h3>

<div algorithm="serialize a functional notation">
Unless otherwise specified,
to <dfn export>serialize a functional notation</dfn>:

1. Let |s| be a string containing
the function's name in lowercase,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
the function's name in lowercase,
the function's name in <a href="https://infra.spec.whatwg.org/#ascii-lowercase">ASCII lowercase</a>,

followed by “(” (U+0028 LEFT PARENTHESIS).

2. Append to |s|
the serializations of the arguments of the [=functional notation=]
per their individual grammars,
in the order the grammars are written in,
joining space-separated tokens with a single space,
and following each serialized comma with a single space (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.

Is it possible to describe here that other tokens like ;, / and so on are also followed by a single space? Or is there no consistency in what we have now?

When serializing [=computed values=] or its derivatives
(not [=specified values|specified=] or [=declared values|declared=] values),
omit components when possible without changing the meaning.

3. Append “)” (U+0029 RIGHT PARENTHESIS) to |s|.
</div>

ISSUE(9720): We are inconsistent in how we handled [=specified values=].

<div class=example>
For example, given a function like
''LINEAR-GRADIENT( to bottom , red calc( 1em + 5% ) , green calc(130px / 2) , blue 100% )'':

: as a [=specified value=]
:: it will serialize as ''linear-gradient(to bottom, red calc(5% + 1em), green calc(65px), blue 100%)''
* Function names and [=keywords=] become lowercase.
* Whitespace is normalized:
one space between most tokens, but no space
after left parentheses/brackets,
before right parentheses/brackets,
or before commas
* ''calc()'' arguments are simplified and sorted per [[#calc-serialize]]

: as a [=computed value=]
:: it will serialize as ''linear-gradient(red calc(5% + 16px), green calc(65px), blue)''

* In addition to any [=specified value=] simplifications,
any additional value [=computed value|computations=] are also applied,
such as converting [=specified lengths=] to [=computed lengths=].
* Values that match the default
(e.g. ''to bottom'', the ''100%'' stop position on the final stop)
are omitted entirely.
</div>

<!--
██████ ███ ██ ██████ ███ ███
██ ██ ██ ██ ██ ██ ██ ██ ██
Expand Down