whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.12k stars 2.67k forks source link

Use CSSOMString where appropriate #2570

Open zcorpan opened 7 years ago

zcorpan commented 7 years ago

See https://github.com/w3c/csswg-drafts/pull/1266

I think all media attributes as well as img/source sizes should be CSSOMStrings since they use CSS syntax.

cc @SimonSapin

SimonSapin commented 7 years ago

Probably anything that goes trough https://drafts.csswg.org/css-syntax/#tokenization … except I suppose text nodes that happen to be in a <style> element. Stylo also does replacement (of surrogates to U+FFFD) there when parsing a stylesheet, but I don’t think that case can be as neatly expressed though use of CSSOMString.

annevk commented 7 years ago

Does the CSS parser have entry points yet for code points or scalar values?

SimonSapin commented 7 years ago

https://drafts.csswg.org/css-syntax/#input-byte-stream

When parsing a stylesheet, the stream of Unicode code points that comprises the input to the tokenization stage might be initially seen by the user agent as a stream of bytes

Might, not necessarily.

To decode the stream of bytes into a stream of code points, UAs must use the decode algorithm defined in [ENCODING], with the fallback encoding determined as follows.

Code points, even though decode emits scalar values. I think this implicit “upcasting” is fine.

https://drafts.csswg.org/css-syntax/#input-preprocessing

The input stream consists of the code points pushed into it as the input byte stream is decoded.

This is the other entry point. The wording should be tweaked so that it doesn’t imply that these code point necessarily come directly from decoding a byte stream. CC @tabatkins

annevk commented 7 years ago

"Might" seems rather bad. Can't we just have an explicit entry point for bytes and one for code points? (And yes, as defined a scalar value is a code point: https://infra.spec.whatwg.org/#scalar-value.)