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

Proposal: the data attribute of an event of inputType "formatFontColor" should be in RGB/RGBA format #67

Closed
whsieh opened this issue Aug 18, 2017 · 8 comments

Comments

@whsieh
Copy link

whsieh commented Aug 18, 2017

Currently, the spec (at https://w3c.github.io/input-events/) states that the data attribute of an input event of type "formatFontColor" is "the simple color value...of the proposed color". According to the linked spec (https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#colours), "A simple color consists of three 8-bit numbers in the range 0..255, representing the red, green, and blue components of the color respectively, in the sRGB color space."

It seems like this would preclude the possibility of setting transparent colors, or colors in an extended color space. Would it be reasonable to tweak the spec so that the data attribute would take on value that match CSS text when using, say, getComputedStyle(element).color?

@whsieh
Copy link
Author

whsieh commented Aug 18, 2017

@whsieh whsieh changed the title Proposal: the data attribute of an event of inputType "formatForeColor" should be in the same format as CSS text Proposal: the data attribute of an event of inputType "formatFontColor" should be in the same format as CSS text Aug 18, 2017
@johanneswilm
Copy link
Contributor

johanneswilm commented Aug 18, 2017

This is absolutely possible. Safari is the only browser with such a color menu. The term "simple color" came out of the TAG review:

While we understand that this comes from a underlying infrastructural issue (HTML) - colors are just mentioned as "hex digit value", which could be a bit more specific. I believe the concept you are looking for is simple color (defined in HTML), but this has the downside of not having alpha channel support.
https://html.spec.whatwg.org/multipage/infrastructure.html#colours [1]

For JS editors to be able to deal with this event effectively, it would be a good idea to not give colors in many different formats. @whsieh would it be OK if we limited the colors to RGB and RGBA [2]?

[1] w3ctag/design-reviews#160 (comment)

[2] https://www.w3.org/TR/css3-color/#rgba-color

@whsieh
Copy link
Author

whsieh commented Aug 18, 2017

I see! If JavaScript compatibility is the big concern here, I think limiting to rgb() and rgba() is a reasonable compromise for the time being.

Hopefully, this doesn't lock us into only being able to specify rgb/rgba in the future though? While there's currently no UI affordance in Safari to specify deep colors for text/backgrounds, it doesn't seem unreasonable to add such options.

@johanneswilm
Copy link
Contributor

johanneswilm commented Aug 18, 2017

No, future specs could expand on the list of allowed values, so this will not create a lock-in.

The values may have to be read by JavaScript, so allowing any type of color values would mean that the JS color parser would have to be much more complex than if we only allow RGBA/RGB.

A parser could be as simple as this if only rgb/rgba was allowed:

data.replace(/[^0-9,.]/g,'').split(',').map(str => parseFloat(str))

So the current proposal is to exchange the term "simple colors" with "RGB/RGBA colors" (linking to the CSS color spec instead of the infrastructure document).

@whsieh
Copy link
Author

whsieh commented Aug 18, 2017

Got it — changing the "simple colors" requirement to "RGB/RGBA colors" sounds good to me. Thanks for the explanation!

@whsieh whsieh changed the title Proposal: the data attribute of an event of inputType "formatFontColor" should be in the same format as CSS text Proposal: the data attribute of an event of inputType "formatFontColor" should be in RGB/RGBA format Aug 18, 2017
@johanneswilm
Copy link
Contributor

approved by today's editing taskforce call

@johanneswilm
Copy link
Contributor

fixed in 95b1b48

@johanneswilm
Copy link
Contributor

level 1 fix in 88bb8ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants