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

Color processing steps are incorrect #760

Open
marcoscaceres opened this issue Apr 18, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@marcoscaceres
Copy link
Member

commented Apr 18, 2019

We currently rely on [[CSS-SYNTAX-3]] "parse a component value", but that's an internal algorithm that's participating in a larger parser... it also skips of preconditions that the parser requires.

We've asked the CSS working group for guidance.

@marcoscaceres marcoscaceres added the bug label Apr 18, 2019

@SimonSapin

This comment has been minimized.

Copy link

commented Apr 18, 2019

Assuming the input is Unicode (with bytes you’d first decode to Unicode), parsing should go something like:

Perhaps css-syntax should have better “glue” algorithms for putting these three steps together. https://drafts.csswg.org/css-syntax/#parse-grammar says it can take a string as input, but when following steps we then get to “from the list of tokens produced by the tokenizer” without further links or info about how to make a tokenizer.

CC @tabatkins

@tabatkins

This comment has been minimized.

Copy link
Member

commented Apr 22, 2019

The first three steps are all covered by just calling CSS/parse with a string. The end result is a <color> value, which you can then manipulate in prose, excluding things aren't convertible to RGBA (like currentcolor or device-cmyk()) and possibly excluding more difficult things (like color() with a non-builtin profile). Step 4 is all past CSS Syntax tho, and into CSS Color.

(Like, if this kind of thing might be done elsewhere, it might be useful for CSS Color to go ahead and define a grammar nonterminal just for "canonicalizable to RGBA without outside information" colors, so you can just parse to that.)


but when following steps we then get to “from the list of tokens produced by the tokenizer” without further links or info about how to make a tokenizer.

You might be missing this introductory text from 5.3, which applies to all of the algorithms:

They assume that they are invoked on a token stream, but they may also be invoked on a string; if so, first perform input preprocessing to produce a code point stream, then perform tokenization to produce a token stream.

Does that answer your question? If not, what exactly do you think is missing?

@SimonSapin

This comment has been minimized.

Copy link

commented Apr 23, 2019

Ah indeed, 5.3 intro is what I missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.