Open Bug 981300 Opened 11 years ago Updated 2 years ago

Check that <custom-ident> implementation matches the spec, once the spec is settled

Categories

(Core :: CSS Parsing and Computation, defect, P5)

defect

Tracking

()

People

(Reporter: SimonSapin, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-needed)

The CSS Values & Units spec defines a <custom-ident> type for author-defined identifiers. It excludes some identifiers to make parsing unambiguous. However, as of this writing, the CSS WG is still discussing exactly what set of identifiers should be excluded. http://dev.w3.org/csswg/css-values/#custom-idents http://lists.w3.org/Archives/Public/www-style/2014Mar/0145.html https://bugzilla.mozilla.org/show_bug.cgi?id=976787#c42 Once that discussion is settled at the spec level, we should check/fix or usage of ParseCustomIdent() in layout/style/nsCSSParser.cpp (method introduced in bug 976787.)
Adding dev-doc-needed here as we will need to document <custom-ident> itself.
Keywords: dev-doc-needed
<custom-ident> by itself is mostly useful as a spec concept, I’m not convinced it deserves its own documentation. Rather, the documentation for anything that uses it should give the explicit list of keywords that are excluded (rather than the details of the general rule which this list is derived from.)
Yes, but we list the BNF syntax of a property with an adequate tooltip so that if the list of excluded list change in the future, we don't need to go through all articles; only one need to be modified.
Except that here, the list of excluded keywords may be different every time <custom-ident> is used in a different context, as not the same things will be ambiguous. For example, 'span' is excluded from <custom-ident> in the grid-row-start property, but it doesn’t need to be excluded for eg. counter-increment. http://dev.w3.org/csswg/css-grid/#propdef-grid-row-start > <grid-line> = > auto | > <custom-ident> | > [ <integer> && <custom-ident>? ] | > [ span && [ <integer> || <custom-ident> ] ]
Priority: -- → P5
[marking this as "depends-on" bug 981300 (instead of "see also"), since bug 981300 is adding the code in question here, which means we depend on it.]
[er, I meant to say bug 976787 there, of course]
Simon, do you know if the CSSWG discussions you refer to in comment 0 led to anything that might need adjustments to our code? The Note at https://drafts.csswg.org/css-values-3/#custom-idents "When designing grammars with <custom-ident>, the <custom-ident> should always be "positionally unambiguous", so that it’s impossible to conflict with any keyword values in the property." (I have no clue what "positionally unambiguous" means there. It's not defined in the spec.) We currently reject "span span" as a parse error, and so does Chrome AFAICT.
Flags: needinfo?(simon.sapin)
(In reply to Mats Palmgren (:mats) from comment #7) > The Note at > https://drafts.csswg.org/css-values-3/#custom-idents > "When designing grammars with <custom-ident>, the <custom-ident> should > always be "positionally unambiguous", so that it’s impossible to conflict > with any keyword values in the property." > > (I have no clue what "positionally unambiguous" means there. It's not > defined in the spec.) See https://lists.w3.org/Archives/Public/www-style/2014Mar/0068.html for more info; "positionally unambiguous" refers to where the custom-idents are declared. The phrasing indicates these custom-idents should be obvious/impossible to misinterpret no matter where they are declared. Not sure if that helps... I reached out to Tab Atkins for clarification.

When designing grammars with <custom-ident>, the <custom-ident> should always […]

This is a "should" requirement for CSS specifications, which Grid happens to violate since span in some positions is ambiguous.

The part of https://drafts.csswg.org/css-values-3/#custom-idents relevant to implementations (though it may have changed since previous comments here) is:

When parsing positionally-ambiguous keywords in a property value, a <custom-ident> production can only claim the keyword if no other unfulfilled production can claim it.

For example, the shorthand declaration animation: ease-in ease-out is equivalent to the longhand declarations animation-timing-function: ease-in; animation-name: ease-out;. ease-in is claimed by the <easing-function> production belonging to animation-timing-function, leaving ease-out to be claimed by the <custom-ident> production belonging to animation-name.

This says that span span should not be a parse error. Instead the ambiguity should be resolved by making the first span resolve as a keyword (since that grammar production is at that point unfullfilled), and the second one as a <custom-ident> (since by then that is the only remaining grammar production).

This "priority" is more important in e.g. span 2 where we want to parse the span keyword and not a custom identifier.

Flags: needinfo?(simon.sapin)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.