Commit 88a0736
Add support for using 'currentcolor' with color-mix()
https://bugs.webkit.org/show_bug.cgi?id=250459
Reviewed by Darin Adler.
To support 'currentcolor' as the origin color in a color-mix()
value, this change adds a new CSSPrimitiveValue type called
CSSUnresolvedColor as a peer to the existing color value, that
represents, as the name suggests, unresolved color values.
In this change, CSSUnresolvedColor is only used for color-mix(),
but it is implemented in a way so that we can add support for
other unresolved colors like relative colors.
In addition to CSSUnresolvedColor, to fully support 'currentcolor'
StyleColor was updated to add a third kind in addition to Color
and CurrentColor, for color-mix(). This allows for us to do late
evaluation of the color-mix() in the case of a 'currentcolor'
(or even in more interesting cases like an origin which is another
color-mix that itself has 'currentcolor' as the origin).
CSSUnresolvedColor also fixes an issue where we were not preserving
calc() values for the percentages in color-mix() in the specified
value serialization.
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
Add new files.
* Source/WebCore/css/CSSPrimitiveValue.cpp:
(WebCore::isValidCSSUnitTypeForDoubleConversion):
(WebCore::isStringType):
(WebCore::CSSPrimitiveValue::init):
(WebCore::CSSPrimitiveValue::cleanup):
(WebCore::CSSPrimitiveValue::unitTypeString):
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
(WebCore::CSSPrimitiveValue::equals const):
* Source/WebCore/css/CSSPrimitiveValue.h:
(WebCore::isValueID):
* Source/WebCore/css/CSSUnits.cpp:
(WebCore::unitCategory):
(WebCore::operator<<):
* Source/WebCore/css/CSSUnits.h:
* Source/WebCore/css/calc/CSSCalcCategoryMapping.cpp:
(WebCore::hasDoubleValue):
Add new CSS_UNRESOLVED_COLOR kind.
* Source/WebCore/css/StyleColor.cpp:
(WebCore::StyleColor::copy):
(WebCore::StyleColor::resolveColor const):
(WebCore::StyleColor::isCurrentColor const):
(WebCore::StyleColor::isColorMix const):
(WebCore::StyleColor::resolveAbsoluteComponents):
(WebCore::resolveAbsoluteComponents):
(WebCore::resolveColor):
(WebCore::serializationForCSS):
(WebCore::operator<<):
* Source/WebCore/css/StyleColor.h:
(WebCore::StyleColor::StyleColor):
(WebCore::StyleColor::operator=):
(WebCore::StyleColor::currentColor):
(WebCore::operator==):
(WebCore::operator!=):
(WebCore::StyleColor::operator== const):
(WebCore::StyleColor::operator!= const):
(WebCore::CurrentColor::operator== const): Deleted.
(WebCore::CurrentColor::operator!= const): Deleted.
Support a new StyleColorMix kind. Rename CurrentColor to StyleCurrentColor
for consistency.
* Source/WebCore/css/color/CSSResolvedColorMix.cpp: Added.
(WebCore::normalizedMixPercentages):
(WebCore::mixColorComponentsUsingColorInterpolationMethod):
(WebCore::mix):
* Source/WebCore/css/color/CSSResolvedColorMix.h: Added.
CSSResolvedColorMix serves as the implementation of the final
resolved color-mix(), and is used for eager mixing (in the case
of the Raw variant currently used on workers) and in StyleColor
when doing the final resolution.
* Source/WebCore/css/color/CSSUnresolvedColor.cpp: Added.
(WebCore::CSSUnresolvedColor::cssText const):
(WebCore::CSSUnresolvedColor::equals const):
(WebCore::CSSUnresolvedColor::createStyleColor const):
* Source/WebCore/css/color/CSSUnresolvedColor.h: Added.
CSSUnresolvedColor serves a container for unresolved colors
in CSSPrimitiveValue. For now it only supports color-mix(),
but is setup to support other kinds going future.
* Source/WebCore/css/color/CSSUnresolvedColorMix.cpp: Added.
(WebCore::serializationForCSS):
(WebCore::operator==):
(WebCore::operator!=):
(WebCore::createStyleColor):
* Source/WebCore/css/color/CSSUnresolvedColorMix.h: Added.
Value type for unresolved color-mix(), used as the "specified
value" for color-mix() to correctly serialize per-spec and
correctly resolve to a structured StyleColor at style building
time.
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeOriginColorRaw):
(WebCore::CSSPropertyParserHelpers::consumeOptionalAlphaRaw):
(WebCore::CSSPropertyParserHelpers::consumeOptionalAlphaRawAllowingSymbolTableIdent):
(WebCore::CSSPropertyParserHelpers::parseRelativeRGBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeRGBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRGBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeHSLParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeHSLParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseHSLParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseHWBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeHWBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeHWBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseLabParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeLabParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeLabParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseLCHParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeLCHParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeLCHParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForRGBTypesRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionForRGBTypes):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForXYZTypesRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionForXYZTypes):
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeColorFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseColorContrastFunctionParametersRaw):
(WebCore::CSSPropertyParserHelpers::consumeColorMixComponentRaw):
(WebCore::CSSPropertyParserHelpers::consumeColorMixComponent):
(WebCore::CSSPropertyParserHelpers::parseColorMixFunctionParametersRaw):
(WebCore::CSSPropertyParserHelpers::hasNonCalculatedZeroPercentage):
(WebCore::CSSPropertyParserHelpers::parseColorMixFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionRaw):
(WebCore::CSSPropertyParserHelpers::parseColorFunction):
(WebCore::CSSPropertyParserHelpers::consumeColorWorkerSafe):
(WebCore::CSSPropertyParserHelpers::consumeColor):
(WebCore::CSSPropertyParserHelpers::consumeOriginColor): Deleted.
(WebCore::CSSPropertyParserHelpers::consumeOptionalAlpha): Deleted.
(WebCore::CSSPropertyParserHelpers::consumeOptionalAlphaAllowingSymbolTableIdent): Deleted.
(WebCore::CSSPropertyParserHelpers::parseRelativeRGBParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseNonRelativeRGBParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseRGBParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseRelativeHSLParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseNonRelativeHSLParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseHSLParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseHWBParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseRelativeHWBParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseNonRelativeHWBParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseLabParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseRelativeLabParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseNonRelativeLabParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseLCHParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseRelativeLCHParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseNonRelativeLCHParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForRGBTypes): Deleted.
(WebCore::CSSPropertyParserHelpers::parseColorFunctionForXYZTypes): Deleted.
(WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::parseColorContrastFunctionParameters): Deleted.
(WebCore::CSSPropertyParserHelpers::normalizedMixPercentages): Deleted.
(WebCore::CSSPropertyParserHelpers::mixColorComponentsUsingColorInterpolationMethod): Deleted.
(WebCore::CSSPropertyParserHelpers::mixColorComponents): Deleted.
Renames color parsing functions to use the Raw suffix to match convention and
make it clear that the new color-mix parsing function is sufficiently different
in that it is not eagerly resolving.
* Source/WebCore/platform/graphics/ColorInterpolationMethod.cpp:
(WebCore::serializationForCSS):
* Source/WebCore/platform/graphics/ColorInterpolationMethod.h:
Add CSS serialization support and fix HasHueInterpolationMethod to actually
match the right structs.
* Source/WebCore/style/ColorFromPrimitiveValue.cpp:
(WebCore::Style::colorFromPrimitiveValue):
Support CSSUnresolvedColor CSSPrimitiveValues when building StyleColors.
Canonical link: https://commits.webkit.org/259145@main1 parent 8cee0c8 commit 88a0736
File tree
21 files changed
+1406
-595
lines changed- LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing
- Source/WebCore
- WebCore.xcodeproj
- css
- calc
- color
- parser
- platform/graphics
- style
21 files changed
+1406
-595
lines changedLines changed: 7 additions & 44 deletions
Large diffs are not rendered by default.
Lines changed: 282 additions & 310 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
860 | 863 | | |
861 | 864 | | |
862 | 865 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15948 | 15948 | | |
15949 | 15949 | | |
15950 | 15950 | | |
| 15951 | + | |
| 15952 | + | |
| 15953 | + | |
| 15954 | + | |
15951 | 15955 | | |
15952 | 15956 | | |
15953 | 15957 | | |
| |||
16288 | 16292 | | |
16289 | 16293 | | |
16290 | 16294 | | |
| 16295 | + | |
| 16296 | + | |
16291 | 16297 | | |
16292 | 16298 | | |
16293 | 16299 | | |
| |||
30797 | 30803 | | |
30798 | 30804 | | |
30799 | 30805 | | |
| 30806 | + | |
| 30807 | + | |
| 30808 | + | |
| 30809 | + | |
| 30810 | + | |
| 30811 | + | |
| 30812 | + | |
| 30813 | + | |
| 30814 | + | |
| 30815 | + | |
| 30816 | + | |
| 30817 | + | |
| 30818 | + | |
30800 | 30819 | | |
30801 | 30820 | | |
30802 | 30821 | | |
| |||
33142 | 33161 | | |
33143 | 33162 | | |
33144 | 33163 | | |
| 33164 | + | |
33145 | 33165 | | |
33146 | 33166 | | |
33147 | 33167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
| |||
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| 226 | + | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
| |||
385 | 388 | | |
386 | 389 | | |
387 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
388 | 398 | | |
389 | 399 | | |
390 | 400 | | |
| |||
428 | 438 | | |
429 | 439 | | |
430 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
431 | 444 | | |
432 | 445 | | |
433 | 446 | | |
| |||
629 | 642 | | |
630 | 643 | | |
631 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
632 | 650 | | |
633 | 651 | | |
634 | 652 | | |
| |||
1318 | 1336 | | |
1319 | 1337 | | |
1320 | 1338 | | |
| 1339 | + | |
1321 | 1340 | | |
1322 | 1341 | | |
1323 | 1342 | | |
| |||
1420 | 1439 | | |
1421 | 1440 | | |
1422 | 1441 | | |
| 1442 | + | |
| 1443 | + | |
1423 | 1444 | | |
1424 | 1445 | | |
1425 | 1446 | | |
| |||
1629 | 1650 | | |
1630 | 1651 | | |
1631 | 1652 | | |
| 1653 | + | |
| 1654 | + | |
1632 | 1655 | | |
1633 | 1656 | | |
1634 | 1657 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| |||
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
| 236 | + | |
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
| |||
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
| 268 | + | |
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
| |||
382 | 388 | | |
383 | 389 | | |
384 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
385 | 401 | | |
386 | 402 | | |
387 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| 269 | + | |
268 | 270 | | |
269 | 271 | | |
270 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
0 commit comments