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 <