From 641be53f3edc14fd1dd48537173e29c9eb81ce3a Mon Sep 17 00:00:00 2001
From: Anders Hartvoll Ruud
Date: Fri, 15 Feb 2019 09:33:19 +0100
Subject: [PATCH 1/2] [css-properties-values-api] Define parsing rules for the
syntax string.
This defines how to parse the syntax strings using some algorithms and
concepts from css-syntax, while leaning as little as possible on its
concept of tokens.
* Whitespace behavior is now defined.
* Escaping is now allowed for ident syntax strings.
Resolves #112.
---
css-properties-values-api/Overview.bs | 427 ++++++++++++++++++--------
1 file changed, 298 insertions(+), 129 deletions(-)
diff --git a/css-properties-values-api/Overview.bs b/css-properties-values-api/Overview.bs
index 67cdd395..b41b5dc9 100644
--- a/css-properties-values-api/Overview.bs
+++ b/css-properties-values-api/Overview.bs
@@ -140,25 +140,11 @@ as arguments of the same names.
throw an {{InvalidModificationError}}
and exit this algorithm.
- 3. If |syntax| is not present,
- or is equal to "*"
(U+002A ASTERISK),
- let |parsed syntax| be undefined,
- and skip to the next step of this algorithm.
-
- Otherwise, attempt to parse |syntax|
- according to the rules in [[#supported-syntax-strings]].
- If it does not parse successfully,
- throw a {{SyntaxError}}.
- Otherwise,
- let |parsed syntax| be the parsed syntax.
-
- Note: For example, a valid syntax string is something like "<length>"
,
- or "<number>+"
;
- the allowed syntax is a subset of [[css-values-3#value-defs]].
- Future levels of this specification are expected to expand the complexity of allowed syntax strings,
- allowing custom properties that more closely resemble the full breadth of what CSS properties allow.
+ 3. Attempt to parse |syntax| according to the rules in [[#parsing-the-syntax-string]].
+ If it does not parse successfully, throw a {{SyntaxError}}.
+ Otherwise, let |syntax descriptor| be the resulting syntax descriptor .
- 4. If |parsed syntax| is undefined,
+ 4. If |syntax descriptor| is the universal syntax descriptor ,
and |initialValue| is not present,
let |parsed initial value| be empty.
This must be treated identically to the "default" initial value of custom properties,
@@ -166,7 +152,7 @@ as arguments of the same names.
Skip to the next step of this algorithm.
Otherwise,
- if |parsed syntax| is undefined,
+ if |syntax descriptor| is the universal syntax descriptor ,
parse |initialValue| as a <>.
If this fails,
throw a {{SyntaxError}}
@@ -181,7 +167,7 @@ as arguments of the same names.
Otherwise,
parse {{PropertyDescriptor/initialValue}}
- according to |parsed syntax|.
+ according to |syntax descriptor|.
If this fails,
throw a {{SyntaxError}}
and exit this algorithm.
@@ -195,7 +181,7 @@ as arguments of the same names.
6. Let |registered property| be a record
with a property name of |parsed name|,
- a syntax of |parsed syntax|,
+ a syntax of |syntax descriptor|,
an initial value of |parsed initial value|,
and an inherit flag of |inherit flag|.
Add |registered property|
@@ -281,111 +267,6 @@ the property becomes [=invalid at computed-value time=]
and becoming ''inherit''.
-Supported syntax strings {#supported-syntax-strings}
-----------------------------------------------------
-
-The following syntax strings are supported:
-
-: Primitive Terms
-:: The following syntax strings are primitive terms that can be
- combined as described below:
-
- : "<length>"
- :: Any valid <> value
- : "<number>"
- :: <> values
- : "<percentage>"
- :: Any valid <> value
- : "<length-percentage>"
- :: Any valid <> or <> value, any valid <>
- expression combining <> and <> components.
- : "<color>"
- :: Any valid <> value
- : "<image>"
- :: Any valid <> value
- : "<url>"
- :: Any valid <> value
- : "<integer>"
- :: Any valid <> value
- : "<angle>"
- :: Any valid <> value
- : "<time>"
- :: Any valid <> value
- : "<resolution>"
- :: Any valid <> value
- : "<transform-function>"
- :: Any valid <> value
- : "<custom-ident>"
- :: Any valid <> value
- : Any sequence consisting of a name-start code point ,
- followed by zero or more name code points ,
- which matches the <> production
- :: That identifier
-
- Note: <>s are compared codepoint-wise with each other;
- this is different than the normal behavior of UA-defined CSS
- which limits itself to ASCII
- and is ASCII case-insensitive .
- So, specifying an ident like Red
- means that the precise value ''Red'' is accepted;
- ''red'', ''RED'', and any other casing variants are not matched by this.
- It is recommended that idents be restricted to ASCII and written in lower-case,
- to match CSS conventions.
-
-
-: "<transform-list>"
-:: A list of valid <> values. This is a convenience
- production which is equivalent to "<transform-function>+"
-
-: Any primitive term followed by '+'
-:: A space-separated list of one or more repetitions of the type specified by the string.
- Note: Since <transform-list> is already a space separated list, <transform-list>+
- is invalid.
-
-: Any primitive term followed by '#'
-:: A comma-separated list of one or more repetitions of the type specified by the string.
-
-: Any combination of terms separated by '|'
-:: Any value that matches one of the items in the combination, matched in specified order.
-
- Note: That is, given the syntax string "red | <color>"
,
- matching the value ''red'' against it will parse as an identifier,
- while matching the value ''blue'' will parse as a <>.
-: "*"
-:: Any valid token stream
-
-Note: [[css3-values]] maintains a distinction between properties that accept
-only a length, and properties that accept both a length and a percentage,
-however the distinction doesn't currently cleanly line up with the productions.
-Accordingly, this specification introduces the length-percentage production
-for the purpose of cleanly specifying this distinction.
-
-Regardless of the syntax specified, all custom properties will accept
-CSS-wide keywords as well as ''revert'', and process these values
-appropriately.
-
-Note: This does not apply to the {{PropertyDescriptor/initialValue}} member
-of the {{PropertyDescriptor}} dictionary.
-
-
- For example, the following are all valid syntax strings.
-
- : "<length>"
- :: accepts length values
- : "<length> | <percentage>"
- :: accepts lengths, percentages, percentage calc expressions, and length calc
- expressions, but not calc expressions containing a combination of length
- and percentage values.
- : "<length-percentage>"
- :: accepts all values that "<length> | <percentage>"
would
- accept, as well as calc expressions containing a combination of both length
- and percentage values.
- : "big | bigger | BIGGER"
- :: accepts the ident "big", or the ident "bigger", or the ident "BIGGER".
- : "<length>+"
- :: accepts a space-separated list of length values.
-
-
Calculation of Computed Values {#calculation-of-computed-values}
----------------------------------------------------------------
@@ -512,6 +393,295 @@ component:
and ''font-size'' will behave as if the value ''unset'' was specified.
+
+Syntax Strings {#syntax-strings}
+================================
+
+A syntax string describes the value types accepted by a registered
+custom property. Syntax strings consists of
+syntax component names , that are
+optionally [[#multipliers|multiplied]] and [[#combinator|combined]].
+
+A syntax string can be parsed into a syntax descriptor , which is either:
+
+ 1. A list of syntax components , each of which accept the value types
+ specified in [[#supported-names]], or
+ 2. The universal syntax descriptor ('*'), which accepts any valid token
+ stream.
+
+Regardless of the syntax specified, all custom properties will accept
+CSS-wide keywords as well as ''revert'', and process these values
+appropriately.
+
+Note: This does not apply to the {{PropertyDescriptor/initialValue}} member
+of the {{PropertyDescriptor}} dictionary.
+
+
+ For example, the following are all valid syntax strings.
+
+ : "<length>"
+ :: accepts length values
+ : "<length> | <percentage>"
+ :: accepts lengths, percentages, percentage calc expressions, and length calc
+ expressions, but not calc expressions containing a combination of length
+ and percentage values.
+ : "<length-percentage>"
+ :: accepts all values that "<length> | <percentage>"
would
+ accept, as well as calc expressions containing a combination of both length
+ and percentage values.
+ : "big | bigger | BIGGER"
+ :: accepts the ident big
, or the ident bigger
, or
+ the ident BIGGER
.
+ : "<length>+"
+ :: accepts a space-separated list of length values.
+ : "*"
+ :: accepts any valid token stream
+
+
+Note: The internal grammar of syntax strings is a subset of
+ [[css-values-3#value-defs]]. Future levels of this specification are expected
+ to expand the complexity of the allowed grammar, allowing custom properties
+ that more closely resemble the full breadth of what CSS properties allow.
+
+The remainder of this chapter describes the internal grammar of the syntax
+strings.
+
+Supported names {#supported-names}
+----------------------------------
+
+This section defines a list of supported syntax component names , and the
+corresponding types accepted by the resulting syntax component .
+
+: "<length>"
+:: Any valid <> value
+: "<number>"
+:: <> values
+: "<percentage>"
+:: Any valid <> value
+: "<length-percentage>"
+:: Any valid <> or <> value, any valid <>
+ expression combining <> and <> components.
+
+ Note: [[css3-values]] maintains a distinction between properties that accept
+ only a length, and properties that accept both a length and a percentage,
+ however the distinction doesn't currently cleanly line up with the productions.
+ Accordingly, this specification introduces the length-percentage production
+ for the purpose of cleanly specifying this distinction.
+
+: "<color>"
+:: Any valid <> value
+: "<image>"
+:: Any valid <> value
+: "<url>"
+:: Any valid <> value
+: "<integer>"
+:: Any valid <> value
+: "<angle>"
+:: Any valid <> value
+: "<time>"
+:: Any valid <> value
+: "<resolution>"
+:: Any valid <> value
+: "<transform-function>"
+:: Any valid <> value
+: "<custom-ident>"
+:: Any valid <> value
+: Any sequence which [[css-syntax-3#would-start-an-identifier|starts an identifier]],
+ [[css-syntax-3#consume-name|can be consumed as a name]], and matches the <> production
+:: That identifier
+
+ Note: <>s are compared codepoint-wise with each other;
+ this is different than the normal behavior of UA-defined CSS
+ which limits itself to ASCII
+ and is ASCII case-insensitive .
+ So, specifying an ident like Red
+ means that the precise value ''Red'' is accepted;
+ ''red'', ''RED'', and any other casing variants are not matched by this.
+ It is recommended that idents be restricted to ASCII and written in lower-case,
+ to match CSS conventions.
+
+: "<transform-list>"
+:: A list of valid <> values. Note that
+ "<transform-list>"
is a non-terminal data type name
+ equivalent to "<transform-function>+"
+
+Note: The that a syntax string of "*"
will produce the
+ universal syntax descriptor , which is not a syntax component .
+ Therefore, "*"
may not be [[#multipliers|multiplied]] or
+ [[#combinator|combined]] with anything else.
+
+The '+' and '#' multipliers {#multipliers}
+------------------------------------------
+
+Any syntax component name except
+non-terminal data type names may be immediately followed by a multiplier:
+
+ : U+002B PLUS SIGN (+)
+ :: Indicates a space-separated list.
+
+ : U+0023 NUMBER SIGN (#)
+ :: Indicates a comma-separated list.
+
+
+ : "<length>+"
+ :: accepts a space-separated list of length values
+ : "<color>#"
+ :: accepts a comma-separated list of color values
+
+
+Note: The multiplier must appear immediately after the syntax component name
+being multiplied.
+
+The '|' combinator {#combinator}
+--------------------------------
+
+Syntax strings may use U+007C VERTICAL LINE (|) to provide multiple
+syntax component names . Such syntax strings will result in a
+syntax descriptor with multiple syntax components .
+
+When a syntax descriptor with multiple syntax components is used
+to parse a CSS value, the syntax components are matched in the order specified.
+
+ Note: That is, given the syntax string "red | <color>"
,
+ matching the value ''red'' against it will parse as an identifier,
+ while matching the value ''blue'' will parse as a <>.
+
+
+ : "<length> | auto"
+ :: accepts a length, or auto
+ : "foo | <color># | <integer>"
+ :: accepts foo, a comma-separated list of color values, or a single integer
+
+
+Parsing the syntax string
+-------------------------
+
+### Definitions ### {#parsing-definitions}
+
+: data type name
+:: A sequence of code points consisting of a U+003C LESS-THAN SIGN (<), followed be zero or more name code points , and terminated by U+003E GREATER-THAN SIGN (>).
+
+: non-terminal data type name
+:: A data type which expands into some expression consisting of terminal data type names .
+
+: syntax component
+:: An object consisting of a syntax component name , and an optional [[#multipliers|multiplier]].
+
+: syntax component name
+:: A sequence of code points which is either a data type name ,
+ or a sequence that can produce a <>.
+
+: syntax descriptor
+:: An object consisting of a list of syntax components .
+
+: universal syntax descriptor
+:: A special descriptor which accepts any valid token stream.
+
+### Consume a syntax descriptor ### {#consume-syntax-descriptor}
+
+
+
+### Consume a syntax component ### {#consume-syntax-component}
+
+
+ To
consume a syntax component from a stream of
code points :
+
+ Consume as much
whitespace as possible.
+
+ Let |component| be a new
syntax component with its |name| initially
+ empty.
+
+ Consume the
next input code point :
+
+ : U+003C LESS-THAN SIGN (<)
+ ::
Consume a data type name , and assign the result to the |component|'s |name|.
+
+ :
name-start code point
+ ::
Reconsume the current input code point .
+ [[css-syntax-3#consume-name|Consume a name]]. If the result matches the
+ <
> production, assign the result to the |component|'s |name|.
+ Otherwise return an error.
+
+ : U+005C REVERSE SOLIDUS (\)
+ :: Reconsume the current input code point .
+ [[css-syntax-3#consume-name|Consume a name]]. If the result matches the
+ <> production, assign the result to the |component|'s |name|.
+ Otherwise return an error.
+
+ : anything else
+ :: Return an error.
+
+ Consume the next input code point :
+
+ : U+002B PLUS SIGN (+)
+ :: If |component| has a non-terminal data type name , or if |component| is
+ already marked as a list of any kind, return an error. Otherwise, mark |component| as a
+ [[css-values-3#value-defs|space-separated list]].
+
+ : U+0023 NUMBER SIGN (#)
+ :: If |component| has a non-terminal data type name , or if |component| is
+ already marked as a list of any kind, return an error. Otherwise, mark |component| as a
+ [[css-values-3#value-defs|comma-separated list]].
+
+ : EOF
+ :: Return |component|.
+
+ : anything else
+ :: Reconsume the current input code point . Return |component|.
+
+
+### Consume a data type name ### {#consume-data-type-name}
+
+
+ To
consume a data type name from a stream of
code points :
+
+ Let |name| initially be a string containing a single
code point :
+ U+003C LESS-THAN SIGN (<).
+
+ Repeatedly consume the
next input code point :
+
+ : U+003E GREATER-THAN SIGN (>)
+ :: Append the
code point to |name|. If |name| matches one of the
+
data type names listed in [[#supported-names]], return |name|.
+ Otherwise return an error.
+
+ :
name code point
+ :: Append the
code point to |name|.
+
+ : anything else
+ :: Return an error.
+
+
Behavior of Custom Properties {#behavior-of-custom-properties}
==============================================================
@@ -595,9 +765,8 @@ Fallbacks in ''var()'' references {#fallbacks-in-var-references}
References to registered custom properties using the ''var()'' function may
provide a fallback. However, the fallback value must match the
-[[#supported-syntax-strings|registered syntax]] of the custom property being
-referenced, otherwise the declaration is
-invalid at computed-value time .
+syntax descriptor of the custom property being referenced, otherwise the
+declaration is invalid at computed-value time .
Note: This applies regardless of whether or not the fallback is being used.
From e106b4ba3289952755dcae43cc77a9c709e6c923 Mon Sep 17 00:00:00 2001
From: Tab Atkins Jr
Date: Fri, 15 Feb 2019 16:50:10 -0800
Subject: [PATCH 2/2] fixups
changes:
* refer directly to algorithms dfns
* use and link to some Infra and Syntax concepts
* strip whitespace from the syntax string
* simplify algorithms a little
* fix a reconsume bug in "consume a syntax component"
---
css-properties-values-api/Overview.bs | 189 +++++++++++++-------------
1 file changed, 92 insertions(+), 97 deletions(-)
diff --git a/css-properties-values-api/Overview.bs b/css-properties-values-api/Overview.bs
index b41b5dc9..8459616e 100644
--- a/css-properties-values-api/Overview.bs
+++ b/css-properties-values-api/Overview.bs
@@ -140,9 +140,9 @@ as arguments of the same names.
throw an {{InvalidModificationError}}
and exit this algorithm.
- 3. Attempt to parse |syntax| according to the rules in [[#parsing-the-syntax-string]].
- If it does not parse successfully, throw a {{SyntaxError}}.
- Otherwise, let |syntax descriptor| be the resulting syntax descriptor .
+ 3. Attempt to [=consume a syntax descriptor=] from |syntax|.
+ If it returns failure, throw a {{SyntaxError}}.
+ Otherwise, let |syntax descriptor| be the returned syntax descriptor .
4. If |syntax descriptor| is the universal syntax descriptor ,
and |initialValue| is not present,
@@ -153,7 +153,7 @@ as arguments of the same names.
Otherwise,
if |syntax descriptor| is the universal syntax descriptor ,
- parse |initialValue| as a <>.
+ [=CSS/parse=] |initialValue| as a <>.
If this fails,
throw a {{SyntaxError}}
and exit this algorithm.
@@ -166,7 +166,7 @@ as arguments of the same names.
and exit this algorithm.
Otherwise,
- parse {{PropertyDescriptor/initialValue}}
+ [=CSS/parse=] {{PropertyDescriptor/initialValue}}
according to |syntax descriptor|.
If this fails,
throw a {{SyntaxError}}
@@ -179,12 +179,12 @@ as arguments of the same names.
5. Set |inherit flag| to the value of |inherits|.
- 6. Let |registered property| be a record
+ 6. Let |registered property| be a [=struct=]
with a property name of |parsed name|,
a syntax of |syntax descriptor|,
an initial value of |parsed initial value|,
and an inherit flag of |inherit flag|.
- Add |registered property|
+ [=set/Append=] |registered property|
to |property set|.
@@ -399,7 +399,7 @@ Syntax Strings {#syntax-strings}
A syntax string describes the value types accepted by a registered
custom property. Syntax strings consists of
-syntax component names , that are
+[=syntax component names=], that are
optionally [[#multipliers|multiplied]] and [[#combinator|combined]].
A syntax string can be parsed into a syntax descriptor , which is either:
@@ -409,13 +409,10 @@ A syntax string can be parsed into a syntax descriptor , which is either:
2. The universal syntax descriptor ('*'), which accepts any valid token
stream.
-Regardless of the syntax specified, all custom properties will accept
-CSS-wide keywords as well as ''revert'', and process these values
+Note: Regardless of the syntax specified, all custom properties accept
+CSS-wide keywords , and process these values
appropriately.
-Note: This does not apply to the {{PropertyDescriptor/initialValue}} member
-of the {{PropertyDescriptor}} dictionary.
-
For example, the following are all valid syntax strings.
@@ -439,9 +436,9 @@ of the {{PropertyDescriptor}} dictionary.
Note: The internal grammar of syntax strings is a subset of
- [[css-values-3#value-defs]]. Future levels of this specification are expected
- to expand the complexity of the allowed grammar, allowing custom properties
- that more closely resemble the full breadth of what CSS properties allow.
+[[css-values-3#value-defs|the CSS Value Definition Syntax]]. Future levels of this specification are expected
+to expand the complexity of the allowed grammar, allowing custom properties
+that more closely resemble the full breadth of what CSS properties allow.
The remainder of this chapter describes the internal grammar of the syntax
strings.
@@ -449,7 +446,7 @@ strings.
Supported names {#supported-names}
----------------------------------
-This section defines a list of supported syntax component names , and the
+This section defines the supported syntax component names , and the
corresponding types accepted by the resulting syntax component .
: "<length>"
@@ -460,14 +457,7 @@ corresponding types accepted by the resulting syntax component .
:: Any valid <> value
: "<length-percentage>"
:: Any valid <> or <> value, any valid <>
- expression combining <> and <> components.
-
- Note: [[css3-values]] maintains a distinction between properties that accept
- only a length, and properties that accept both a length and a percentage,
- however the distinction doesn't currently cleanly line up with the productions.
- Accordingly, this specification introduces the length-percentage production
- for the purpose of cleanly specifying this distinction.
-
+ expression combining <> and <> components.
: "<color>"
:: Any valid <> value
: "<image>"
@@ -502,10 +492,10 @@ corresponding types accepted by the resulting syntax component .
: "<transform-list>"
:: A list of valid <> values. Note that
- "<transform-list>"
is a non-terminal data type name
+ "<transform-list>"
is a pre-multiplied data type name
equivalent to "<transform-function>+"
-Note: The that a syntax string of "*"
will produce the
+Note: A syntax string of "*"
will produce the
universal syntax descriptor , which is not a syntax component .
Therefore, "*"
may not be [[#multipliers|multiplied]] or
[[#combinator|combined]] with anything else.
@@ -514,13 +504,13 @@ The '+' and '#' multipliers {#multipliers}
------------------------------------------
Any syntax component name except
-non-terminal data type names may be immediately followed by a multiplier:
+pre-multiplied data type names may be immediately followed by a multiplier:
- : U+002B PLUS SIGN (+)
- :: Indicates a space-separated list.
+: U+002B PLUS SIGN (+)
+:: Indicates a space-separated list.
- : U+0023 NUMBER SIGN (#)
- :: Indicates a comma-separated list.
+: U+0023 NUMBER SIGN (#)
+:: Indicates a comma-separated list.
:
"<length>+"
@@ -542,9 +532,9 @@ The '|' combinator {#combinator}
When a
syntax descriptor with multiple
syntax components is used
to parse a CSS value, the syntax components are matched in the order specified.
- Note: That is, given the syntax string
"red | <color>"
,
- matching the value ''red'' against it will parse as an identifier,
- while matching the value ''blue'' will parse as a <
>.
+Note: That is, given the syntax string "red | <color>"
,
+matching the value ''red'' against it will parse as an identifier,
+while matching the value ''blue'' will parse as a <>.
: "<length> | auto"
@@ -553,16 +543,16 @@ to parse a CSS value, the syntax components are matched in the order specified.
:: accepts foo, a comma-separated list of color values, or a single integer
-Parsing the syntax string
--------------------------
+Parsing the syntax string {#parsing-syntax}
+-------------------------------------------
### Definitions ### {#parsing-definitions}
: data type name
-:: A sequence of code points consisting of a U+003C LESS-THAN SIGN (<), followed be zero or more name code points , and terminated by U+003E GREATER-THAN SIGN (>).
+:: A sequence of code points consisting of a U+003C LESS-THAN SIGN (<), followed be zero or more name code points , and terminated by U+003E GREATER-THAN SIGN (>).
-: non-terminal data type name
-:: A data type which expands into some expression consisting of terminal data type names .
+: pre-multiplied data type name
+:: A [=data type name=] that represents another [=syntax component=] with a [[#multipliers|multiplier]] already included.
: syntax component
:: An object consisting of a syntax component name , and an optional [[#multipliers|multiplier]].
@@ -580,84 +570,88 @@ Parsing the syntax string
### Consume a syntax descriptor ### {#consume-syntax-descriptor}
- This section describes how to
consume a syntax descriptor from a
- stream of
code points . It either produces a
syntax descriptor
+ This section describes how to
consume a syntax descriptor from a [=string=] |string|.
+ It either produces a
syntax descriptor
with a list of
syntax components , or the
universal syntax descriptor .
- Consume the
next input code point :
+ 1. [=Strip leading and trailing ASCII whitespace=] from |string|.
- : U+002A ASTERISK (*)
- :: If the
next input code point is EOF, return the
-
universal syntax descriptor . Otherwise return an error.
+ 2. If |string|’s [=string/length=] is 0,
+ return failure.
- : anything else
- ::
Reconsume the current input code point .
+ 3. If |string|’s [=string/length=] is 1,
+ and the only [=code point=] in |string| is U+002A ASTERISK (*),
+ return the [=universal syntax descriptor=].
- Let |descriptor| be an initially empty list of
syntax components .
+ 4. Let |stream| be an [=input stream=] created from the [=code points=] of |string|,
+ preprocessed as specified in [[css-syntax-3]].
+ Let |descriptor| be an initially empty [=list=] of
syntax components .
- Repeatedly consume the
next input code point :
+ 5. Repeatedly consume the
next input code point :
- :
whitespace
- :: Do nothing.
+ :
whitespace
+ :: Do nothing.
- : U+007C VERTICAL LINE (|)
- :: If |descriptor| is an empty list, return an error. Otherwise
-
consume a syntax component and append the result to |descriptor|.
+ : EOF
+ :: If |descriptor|’s [=list/length=] is greater than zero,
+ return |descriptor|;
+ otherwise, return failure.
- : EOF
- :: Return |descriptor|.
+ : U+007C VERTICAL LINE (|)
+ ::
Consume a syntax component .
+ If failure was returned,
+ return failure;
+ otherwise,
+ [=list/append=] the returned value to |descriptor|.
- : anything else
- ::
Consume a syntax component , and append the result to |descriptor|.
+ : anything else
+ ::
Reconsume the current input code point .
+
Consume a syntax component .
+ If failure was returned,
+ return failure;
+ otherwise,
+ [=list/append=] the returned value to |descriptor|.
### Consume a syntax component ### {#consume-syntax-component}
- To
consume a syntax component from a stream of
code points :
+ To
consume a syntax component from a stream of
code points |stream|:
- Consume as much
whitespace as possible.
+ Consume as much
whitespace as possible from |stream|.
- Let |component| be a new
syntax component with its |name| initially
+ Let |component| be a new
syntax component with its |name| and |multiplier| initially
empty.
Consume the
next input code point :
: U+003C LESS-THAN SIGN (<)
- ::
Consume a data type name , and assign the result to the |component|'s |name|.
+ ::
Consume a data type name .
+ If it returned a [=string=], set |component|'s |name| to the returned value.
+ Otherwise, return failure.
:
name-start code point
- ::
Reconsume the current input code point .
- [[css-syntax-3#consume-name|Consume a name]]. If the result matches the
- <
> production, assign the result to the |component|'s |name|.
- Otherwise return an error.
-
: U+005C REVERSE SOLIDUS (\)
- :: Reconsume the current input code point .
- [[css-syntax-3#consume-name|Consume a name]]. If the result matches the
- <> production, assign the result to the |component|'s |name|.
- Otherwise return an error.
+ :: If the stream [=starts with an identifier=],
+ reconsume the current input code point
+ then [=consume a name=] from the stream,
+ and set |component|’s |name| to the returned <>’s value.
+ Otherwise return failure.
: anything else
- :: Return an error.
-
- Consume the next input code point :
+ :: Return failure.
- : U+002B PLUS SIGN (+)
- :: If |component| has a non-terminal data type name , or if |component| is
- already marked as a list of any kind, return an error. Otherwise, mark |component| as a
- [[css-values-3#value-defs|space-separated list]].
+ If |component|’s |name| is a [=pre-multiplied data type name=],
+ return |component|.
- : U+0023 NUMBER SIGN (#)
- :: If |component| has a non-terminal data type name , or if |component| is
- already marked as a list of any kind, return an error. Otherwise, mark |component| as a
- [[css-values-3#value-defs|comma-separated list]].
+ If the [=next input code point=]
+ is U+002B PLUS SIGN (+)
+ or U+0023 NUMBER SIGN (#),
+ consume the next input code point ,
+ and set |component|’s |multiplier| to the [=current input code point=].
- : EOF
- :: Return |component|.
+ Return |component|.
- : anything else
- :: Reconsume the current input code point . Return |component|.
### Consume a data type name ### {#consume-data-type-name}
@@ -665,21 +659,22 @@ Parsing the syntax string
To
consume a data type name from a stream of
code points :
- Let |name| initially be a string containing a single
code point :
- U+003C LESS-THAN SIGN (<).
+ Note: This algorithm assumes that a U+003C LESS-THAN SIGN (<)
code point has already been consumed from the stream.
+
+ Let |name| initially be a [=string=] containing a single U+003C LESS-THAN SIGN (<)
code point .
Repeatedly consume the
next input code point :
- : U+003E GREATER-THAN SIGN (>)
+ : U+003E GREATER-THAN SIGN (>)
:: Append the
code point to |name|. If |name| matches one of the
data type names listed in [[#supported-names]], return |name|.
- Otherwise return an error.
+ Otherwise return failure.
:
name code point
:: Append the
code point to |name|.
: anything else
- :: Return an error.
+ :: Return failure.
Behavior of Custom Properties {#behavior-of-custom-properties}
@@ -777,16 +772,16 @@ Example 1: Using custom properties to add animation behavior {#example-1}
-------------------------------------------------------------------------
-<script>
+<script>
CSS.registerProperty({
name: "--stop-color",
- syntax: "<color>",
+ syntax: "<color>",
inherits: false,
initialValue: "rgba(0,0,0,0)"
});
-</script>
+</script>
-<style>
+<style>
.button {
--stop-color: red;
@@ -798,7 +793,7 @@ CSS.registerProperty({
--stop-color: green;
}
-</style>
+</style>