-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
a48f1e6
to
1ea2ca0
Compare
@domenic observed that for |
There was a problem hiding this 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.
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. |
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? |
Yeah I suppose we could easily and quickly add alpha, then hopefully follow up with display p3 later |
3c211f0
to
4da70fc
Compare
4da70fc
to
327b2ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall
source
Outdated
<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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest "CSS color" link to https://drafts.csswg.org/css-color-5/#typedef-color
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay. Perhaps the <color> type from CSS Typed OM, then?
Having read through the spec one bit still feels slightly ambiguous to me, but this could just be that I'm missing something. It seems that Is there an obvious reason in the spec that it uses https://drafts.csswg.org/css-color/#serializing-color-function-values instead? |
…ttributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. A future change will adjust the UI accordingly and add the necessary tests. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
…ttributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly and add the necessary tests. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
…ttributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly and add the necessary tests. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
…ttributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly and add the necessary tests. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
…attributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly. Tests are upstreamed here: web-platform-tests/wpt#48630 * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.js: Added. (test): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-expected.txt. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.html. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.js: Added. (const.assert_colors.set_up_fuzzy_color_test): (forEach): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/w3c-import.log: * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/mac-wk1/TestExpectations: * LayoutTests/platform/wpe/TestExpectations: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::attributeChanged): (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
…attributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly. Tests are upstreamed here: web-platform-tests/wpt#48630 * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.js: Added. (test): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-expected.txt. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.html. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.js: Added. (const.assert_colors.set_up_fuzzy_color_test): (forEach): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/w3c-import.log: * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/mac-wk1/TestExpectations: * LayoutTests/platform/wpe/TestExpectations: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::attributeChanged): (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
…attributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by NOBODY (OOPS!). Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly. Tests are upstreamed here: web-platform-tests/wpt#48630 * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.js: Added. (test): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-expected.txt. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.html. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.js: Added. (const.assert_colors.set_up_fuzzy_color_test): (forEach): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/w3c-import.log: * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/mac-wk1/TestExpectations: * LayoutTests/platform/wpe/TestExpectations: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::attributeChanged): (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl:
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.
264ac8e
to
298db78
Compare
Luke's issue has been discussed in w3c/csswg-drafts#11008 and I landed a minor fix for it in this PR. Tests are up as well now. I plan on landing this PR Monday. |
…attributes https://bugs.webkit.org/show_bug.cgi?id=281213 rdar://137663314 Reviewed by Sam Weinig. Add the necessary infrastructure for whatwg/html#10456. In particular: - Support the alpha and colorspace attributes behind a preference. - When the preference is enabled vastly expand the CSS color parsing and serialization capabilities of <input type=color>. Future changes will adjust the UI accordingly. Tests are upstreamed here: web-platform-tests/wpt#48630 * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-attributes.window.js: Added. (test): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color-expected.txt. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.tentative.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.html. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/color.window.js: Added. (const.assert_colors.set_up_fuzzy_color_test): (forEach): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/w3c-import.log: * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/mac-wk1/TestExpectations: * LayoutTests/platform/wpe/TestExpectations: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/ColorInputType.cpp: (WebCore::colorParsingParameters): (WebCore::parseColorValue): (WebCore::serializeColorValue): (WebCore::ColorInputType::fallbackValue const): (WebCore::ColorInputType::sanitizeValue const): (WebCore::ColorInputType::valueAsColor const): (WebCore::ColorInputType::typeMismatchFor const): (WebCore::ColorInputType::didChooseColor): (WebCore::ColorInputType::suggestedColors const): (WebCore::ColorInputType::selectColor): * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::attributeChanged): (WebCore::HTMLInputElement::alpha): (WebCore::HTMLInputElement::colorSpace): (WebCore::HTMLInputElement::setColorSpace): * Source/WebCore/html/HTMLInputElement.h: * Source/WebCore/html/HTMLInputElement.idl: Canonical link: https://commits.webkit.org/285322@main
…testonly Automatic update from web-platform-tests HTML: alpha and colorspace attribute Context: whatwg/html#10456. -- wpt-commits: 05ae498a46fd05d85b867fb1457df94a10dc4bb4 wpt-pr: 48630
…testonly Automatic update from web-platform-tests HTML: alpha and colorspace attribute Context: whatwg/html#10456. -- wpt-commits: 05ae498a46fd05d85b867fb1457df94a10dc4bb4 wpt-pr: 48630
This is a start on whatwg/html#10456 but it turns out that our types don't work in a way that's compatible with this, so I'm leaving it for now.
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 )
/infrastructure.html ( diff )
/input.html ( diff )
/rendering.html ( diff )