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

Enhance <input type=color> with alpha and colorspace=display-p3 #10456

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

annevk
Copy link
Member

@annevk annevk commented Jul 3, 2024

The new alpha and colorspace attributes give it parity with the 2D canvas API.

As part of this change we do away with the "simple color" concept as that has been replaced by CSS colors now.

Fixes #3400.


WebKit can contribute tests as part of implementing this feature.

It would be great to get some help from @svgeesus @tabatkins and @LeaVerou on resolving #8917 so HTML can clearly link a way to serialize CSS color values (for the Hexadecimal state we can continue to maintain that ourselves). I think we have a plan there, but let me know if there's anything still unclear (prolly best in that issue).

(See WHATWG Working Mode: Changes for more details.)


/common-microsyntaxes.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/input.html ( diff )

@annevk annevk added addition/proposal New features or enhancements topic: forms impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation agenda+ To be discussed at a triage meeting labels Jul 3, 2024
@annevk annevk force-pushed the annevk/color-input-improvements branch from a48f1e6 to 1ea2ca0 Compare July 3, 2024 14:55
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
@past past removed the agenda+ To be discussed at a triage meeting label Jul 11, 2024
@annevk
Copy link
Member Author

annevk commented Jul 11, 2024

@domenic observed that for <input type=color alpha> we do not have to set the proposed "HTMLCompatible" serialization parameter to true and could instead use the modern serialization. Which would mean instead of rgba(...) (that 2D canvas requires as discussed in #8917) you would get color(srgb ...) presumably. It would still be limited to 8-bits per color component, but it seems reasonable to me.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editorially looking pretty good, although some questions in #3400 (comment) seem interesting as an uninformed-about-color person.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@josepharhar
Copy link
Contributor

I think it would take us some time to upgrade the color picker popup in chromium (thanks @lukewarlow for mentioning that DevTools has a better one), but if we can just support serialization etc. in IDLs based on these new attributes in the meantime based on WPTs then that sounds good to me.

@lukewarlow
Copy link
Member

I think it would be unfortunate to support the alpha attribute but not actually allow the user to select an alpha value? But not fully supporting picking display P3 but supporting the serialisation seems like it could be more acceptable?

@josepharhar
Copy link
Contributor

Yeah I suppose we could easily and quickly add alpha, then hopefully follow up with display p3 later

The new alpha and colorspace attributes give it parity with the 2D
canvas API.

As part of this change we do away with the "simple color" concept as
that has been replaced by CSS colors now.

Fixes #3400.
@annevk annevk force-pushed the annevk/color-input-improvements branch from 4da70fc to 327b2ae Compare September 19, 2024 08:36
@annevk annevk added the agenda+ To be discussed at a triage meeting label Sep 19, 2024
@annevk
Copy link
Member Author

annevk commented Sep 19, 2024

I believe I have addressed the questions in #3400 and this is now rebased on top of #8917 so it's using all the latest terms. Marking agenda+ to double check on implementer interest, but if that can be provided out-of-band that would be swell as we've already discussed this a number of times.

Copy link

@svgeesus svgeesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link

@svgeesus svgeesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall

<span data-x="named color">named colors</span>, then return the <span>simple color</span>
corresponding to that keyword. <ref>CSSCOLOR</ref></p>
<p>If <var>input</var> is an <span>ASCII case-insensitive</span> match for one of the <span
data-x="named color">named colors</span>, then return the CSS color corresponding to that

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@annevk annevk Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that matches how we talk about "CSS color" in HTML. What we mean here is the parsed representation, the internal object if you will, not the syntax.

<tr>
<td><dfn attr-value for="input/colorspace"><code
data-x="attr-input-colorspace-limited-srgb">limited-srgb</code></dfn>
<td><dfn data-x="attr-input-colorspace-limited-srgb-state">Limited sRGB</dfn>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to infer that limited-srgb is also limited to (0 .. 1) ie 0 .. 255 range, as well as being limited to 8 bits?

While display-p3 uses the extended range, so negative values and values greater than 1 (greater than the component value for white) are allowed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements agenda+ To be discussed at a triage meeting impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation topic: forms
Development

Successfully merging this pull request may close these issues.

Allow <input type="color"> to give an alpha channel and/or colors beyond sRGB?
6 participants