Skip to content

Commit 88a0736

Browse files
Sam Weinigweinig
authored andcommitted
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@main
1 parent 8cee0c8 commit 88a0736

21 files changed

+1406
-595
lines changed

LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-valid-color-mix-function-expected.txt

Lines changed: 7 additions & 44 deletions
Large diffs are not rendered by default.

LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-valid-color-mix-function.html

Lines changed: 282 additions & 310 deletions
Large diffs are not rendered by default.

Source/WebCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ set(WebCore_PRIVATE_INCLUDE_DIRECTORIES
8989
"${WEBCORE_DIR}/crypto/parameters"
9090
"${WEBCORE_DIR}/css"
9191
"${WEBCORE_DIR}/css/calc"
92+
"${WEBCORE_DIR}/css/color"
9293
"${WEBCORE_DIR}/css/parser"
9394
"${WEBCORE_DIR}/css/query"
9495
"${WEBCORE_DIR}/css/typedom"

Source/WebCore/Sources.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,9 @@ css/calc/CSSCalcOperationNode.cpp
857857
css/calc/CSSCalcPrimitiveValueNode.cpp
858858
css/calc/CSSCalcSymbolTable.cpp
859859
css/calc/CSSCalcValue.cpp
860+
css/color/CSSResolvedColorMix.cpp
861+
css/color/CSSUnresolvedColor.cpp
862+
css/color/CSSUnresolvedColorMix.cpp
860863
css/parser/CSSAtRuleID.cpp
861864
css/parser/CSSCustomPropertySyntax.cpp
862865
css/parser/CSSParser.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15948,6 +15948,10 @@
1594815948
BC024A9C270A789D00FD4C3F /* WebXRSession+AR.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = "WebXRSession+AR.idl"; sourceTree = "<group>"; };
1594915949
BC02A63B0E09A9CF004B6D2B /* CSSFunctionValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFunctionValue.h; sourceTree = "<group>"; };
1595015950
BC02A6450E09AAE9004B6D2B /* CSSFunctionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFunctionValue.cpp; sourceTree = "<group>"; };
15951+
BC04A7C6296E53410003F9DB /* CSSResolvedColorMix.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSResolvedColorMix.cpp; sourceTree = "<group>"; };
15952+
BC04A7C7296E53410003F9DB /* CSSResolvedColorMix.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSResolvedColorMix.h; sourceTree = "<group>"; };
15953+
BC04A7C8296E57810003F9DB /* CSSUnresolvedColorMix.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSUnresolvedColorMix.cpp; sourceTree = "<group>"; };
15954+
BC04A7C9296E57810003F9DB /* CSSUnresolvedColorMix.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSUnresolvedColorMix.h; sourceTree = "<group>"; };
1595115955
BC06ED040BFD5BAE00856E9D /* JSHTMLTableSectionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTableSectionElement.cpp; sourceTree = "<group>"; };
1595215956
BC06ED050BFD5BAE00856E9D /* JSHTMLTableSectionElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLTableSectionElement.h; sourceTree = "<group>"; };
1595315957
BC06ED990BFD660600856E9D /* JSHTMLTableColElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTableColElement.cpp; sourceTree = "<group>"; };
@@ -16288,6 +16292,8 @@
1628816292
BCB1E31628F36B5800FCAF0F /* StyleFilterImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StyleFilterImage.cpp; sourceTree = "<group>"; };
1628916293
BCB1E31728F36B5800FCAF0F /* StyleFilterImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StyleFilterImage.h; sourceTree = "<group>"; };
1629016294
BCB2F88D275BEE57007231BF /* ColorNormalization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorNormalization.h; sourceTree = "<group>"; };
16295+
BCB3536F295D121700298CA3 /* CSSUnresolvedColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSUnresolvedColor.cpp; sourceTree = "<group>"; };
16296+
BCB35370295D121700298CA3 /* CSSUnresolvedColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSUnresolvedColor.h; sourceTree = "<group>"; };
1629116297
BCB4779725D46EFF005EF0C8 /* RenderModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderModel.h; sourceTree = "<group>"; };
1629216298
BCB4779825D46EFF005EF0C8 /* RenderModel.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderModel.cpp; sourceTree = "<group>"; };
1629316299
BCB92D4E1293550B00C8387F /* FontBaseline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontBaseline.h; sourceTree = "<group>"; };
@@ -30797,6 +30803,19 @@
3079730803
path = js;
3079830804
sourceTree = "<group>";
3079930805
};
30806+
BC29861A296B586100E4001F /* color */ = {
30807+
isa = PBXGroup;
30808+
children = (
30809+
BC04A7C6296E53410003F9DB /* CSSResolvedColorMix.cpp */,
30810+
BC04A7C7296E53410003F9DB /* CSSResolvedColorMix.h */,
30811+
BCB3536F295D121700298CA3 /* CSSUnresolvedColor.cpp */,
30812+
BCB35370295D121700298CA3 /* CSSUnresolvedColor.h */,
30813+
BC04A7C8296E57810003F9DB /* CSSUnresolvedColorMix.cpp */,
30814+
BC04A7C9296E57810003F9DB /* CSSUnresolvedColorMix.h */,
30815+
);
30816+
path = color;
30817+
sourceTree = "<group>";
30818+
};
3080030819
BC2B412227335E0C00A2D191 /* dummy */ = {
3080130820
isa = PBXGroup;
3080230821
children = (
@@ -33142,6 +33161,7 @@
3314233161
isa = PBXGroup;
3314333162
children = (
3314433163
BCF1644D26629F9A0002F7EF /* calc */,
33164+
BC29861A296B586100E4001F /* color */,
3314533165
946D37271D6CB2250077084F /* parser */,
3314633166
E4DA5E3E28A2867300849BCF /* query */,
3314733167
4BAFD0DA21921EAD00C0AB64 /* typedom */,

Source/WebCore/css/CSSPrimitiveValue.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "CSSPrimitiveValueMappings.h"
3030
#include "CSSPropertyNames.h"
3131
#include "CSSToLengthConversionData.h"
32+
#include "CSSUnresolvedColor.h"
3233
#include "CSSValueKeywords.h"
3334
#include "CSSValuePool.h"
3435
#include "CalculationCategory.h"
@@ -135,6 +136,7 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSUnitType unitType)
135136
case CSSUnitType::CSS_STRING:
136137
case CSSUnitType::CSS_UNICODE_RANGE:
137138
case CSSUnitType::CSS_UNKNOWN:
139+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
138140
case CSSUnitType::CSS_URI:
139141
case CSSUnitType::CSS_VALUE_ID:
140142
return false;
@@ -221,6 +223,7 @@ static inline bool isStringType(CSSUnitType type)
221223
case CSSUnitType::CSS_TURN:
222224
case CSSUnitType::CSS_UNICODE_RANGE:
223225
case CSSUnitType::CSS_UNKNOWN:
226+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
224227
case CSSUnitType::CSS_VALUE_ID:
225228
case CSSUnitType::CSS_VB:
226229
case CSSUnitType::CSS_VH:
@@ -385,6 +388,13 @@ CSSPrimitiveValue::CSSPrimitiveValue(Ref<CSSCalcValue>&& value)
385388
m_value.calc = &value.leakRef();
386389
}
387390

391+
CSSPrimitiveValue::CSSPrimitiveValue(Ref<CSSUnresolvedColor>&& unresolvedColor)
392+
: CSSValue(PrimitiveClass)
393+
{
394+
setPrimitiveUnitType(CSSUnitType::CSS_UNRESOLVED_COLOR);
395+
m_value.unresolvedColor = &unresolvedColor.leakRef();
396+
}
397+
388398
CSSPrimitiveValue::~CSSPrimitiveValue()
389399
{
390400
cleanup();
@@ -428,6 +438,9 @@ void CSSPrimitiveValue::cleanup()
428438
case CSSUnitType::CSS_RGBCOLOR:
429439
std::destroy_at(reinterpret_cast<Color*>(&m_value.colorAsInteger));
430440
break;
441+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
442+
m_value.unresolvedColor->deref();
443+
break;
431444
case CSSUnitType::CSS_DIMENSION:
432445
case CSSUnitType::CSS_NUMBER:
433446
case CSSUnitType::CSS_INTEGER:
@@ -629,6 +642,11 @@ Ref<CSSPrimitiveValue> CSSPrimitiveValue::create(Ref<Rect>&& value)
629642
return adoptRef(*new CSSPrimitiveValue(WTFMove(value)));
630643
}
631644

645+
Ref<CSSPrimitiveValue> CSSPrimitiveValue::create(Ref<CSSUnresolvedColor>&& value)
646+
{
647+
return adoptRef(*new CSSPrimitiveValue(WTFMove(value)));
648+
}
649+
632650
double CSSPrimitiveValue::computeDegrees() const
633651
{
634652
return computeDegrees(primitiveType(), doubleValue());
@@ -1318,6 +1336,7 @@ ASCIILiteral CSSPrimitiveValue::unitTypeString(CSSUnitType unitType)
13181336
case CSSUnitType::CSS_CALC:
13191337
case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_NUMBER:
13201338
case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_LENGTH:
1339+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
13211340
case CSSUnitType::CSS_FONT_FAMILY:
13221341
case CSSUnitType::CSS_PROPERTY_ID:
13231342
case CSSUnitType::CSS_VALUE_ID:
@@ -1420,6 +1439,8 @@ ALWAYS_INLINE String CSSPrimitiveValue::formatNumberForCustomCSSText() const
14201439
return serializeFontFamily(m_value.string);
14211440
case CSSUnitType::CSS_URI:
14221441
return serializeURL(m_value.string);
1442+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
1443+
return m_value.unresolvedColor->serializationForCSS();
14231444
case CSSUnitType::CSS_VALUE_ID:
14241445
// Per the specification, we should lowercase keywords during serialization:
14251446
// https://www.w3.org/TR/cssom-1/#serialize-a-css-component-value
@@ -1629,6 +1650,8 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
16291650
return m_value.calc && other.m_value.calc && m_value.calc->equals(*other.m_value.calc);
16301651
case CSSUnitType::CSS_SHAPE:
16311652
return m_value.shape && other.m_value.shape && m_value.shape->equals(*other.m_value.shape);
1653+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
1654+
return m_value.unresolvedColor && other.m_value.unresolvedColor && m_value.unresolvedColor->equals(*other.m_value.unresolvedColor);
16321655
case CSSUnitType::CSS_IDENT:
16331656
case CSSUnitType::CSS_UNICODE_RANGE:
16341657
case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_NUMBER:

Source/WebCore/css/CSSPrimitiveValue.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace WebCore {
3636
class CSSBasicShape;
3737
class CSSCalcValue;
3838
class CSSToLengthConversionData;
39+
class CSSUnresolvedColor;
3940
class Color;
4041
class Counter;
4142
class DeprecatedCSSOMPrimitiveValue;
@@ -112,6 +113,7 @@ class CSSPrimitiveValue final : public CSSValue {
112113
bool isDotsPerCentimeter() const { return primitiveType() == CSSUnitType::CSS_DPCM; }
113114
bool isX() const { return primitiveType() == CSSUnitType::CSS_X; }
114115
bool isResolution() const { return unitCategory(primitiveType()) == CSSUnitCategory::Resolution; }
116+
bool isUnresolvedColor() const { return primitiveUnitType() == CSSUnitType::CSS_UNRESOLVED_COLOR; }
115117
bool isViewportPercentageLength() const { return isViewportPercentageLength(primitiveUnitType()); }
116118
bool isValueID() const { return primitiveUnitType() == CSSUnitType::CSS_VALUE_ID; }
117119
bool isFlex() const { return primitiveType() == CSSUnitType::CSS_FR; }
@@ -130,6 +132,7 @@ class CSSPrimitiveValue final : public CSSValue {
130132
static Ref<CSSPrimitiveValue> create(Ref<Pair>&&);
131133
static Ref<CSSPrimitiveValue> create(Ref<Quad>&&);
132134
static Ref<CSSPrimitiveValue> create(Ref<Rect>&&);
135+
static Ref<CSSPrimitiveValue> create(Ref<CSSUnresolvedColor>&&);
133136

134137
template<typename T> static Ref<CSSPrimitiveValue> create(const T&); // Specializations are in CSSPrimitiveValueMappings.h.
135138

@@ -179,6 +182,7 @@ class CSSPrimitiveValue final : public CSSValue {
179182
WEBCORE_EXPORT String stringValue() const;
180183

181184
const Color& color() const { ASSERT(primitiveUnitType() == CSSUnitType::CSS_RGBCOLOR); return *reinterpret_cast<const Color*>(&m_value.colorAsInteger); }
185+
const CSSUnresolvedColor& unresolvedColor() const { ASSERT(primitiveUnitType() == CSSUnitType::CSS_UNRESOLVED_COLOR); return *m_value.unresolvedColor; }
182186
Counter* counterValue() const { return primitiveUnitType() != CSSUnitType::CSS_COUNTER ? nullptr : m_value.counter; }
183187
CSSCalcValue* cssCalcValue() const { return primitiveUnitType() != CSSUnitType::CSS_CALC ? nullptr : m_value.calc; }
184188
Pair* pairValue() const { return primitiveUnitType() != CSSUnitType::CSS_PAIR ? nullptr : m_value.pair; }
@@ -229,6 +233,7 @@ class CSSPrimitiveValue final : public CSSValue {
229233
explicit CSSPrimitiveValue(Ref<Pair>&&);
230234
explicit CSSPrimitiveValue(Ref<Quad>&&);
231235
explicit CSSPrimitiveValue(Ref<Rect>&&);
236+
explicit CSSPrimitiveValue(Ref<CSSUnresolvedColor>&&);
232237

233238
CSSPrimitiveValue(StaticCSSValueTag, CSSValueID);
234239
CSSPrimitiveValue(StaticCSSValueTag, const Color&);
@@ -260,6 +265,7 @@ class CSSPrimitiveValue final : public CSSValue {
260265
Rect* rect;
261266
Quad* quad;
262267
uint64_t colorAsInteger;
268+
CSSUnresolvedColor* unresolvedColor;
263269
Pair* pair;
264270
CSSBasicShape* shape;
265271
CSSCalcValue* calc;
@@ -382,6 +388,16 @@ inline bool isValueID(const CSSPrimitiveValue* value, CSSValueID id)
382388
return valueID(value) == id;
383389
}
384390

391+
inline bool isValueID(const RefPtr<CSSPrimitiveValue>& value, CSSValueID id)
392+
{
393+
return valueID(value.get()) == id;
394+
}
395+
396+
inline bool isValueID(const Ref<CSSPrimitiveValue>& value, CSSValueID id)
397+
{
398+
return valueID(value.get()) == id;
399+
}
400+
385401
inline bool isValueID(const CSSValue& value, CSSValueID id)
386402
{
387403
return valueID(value) == id;

Source/WebCore/css/CSSUnits.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ CSSUnitCategory unitCategory(CSSUnitType type)
124124
case CSSUnitType::CSS_STRING:
125125
case CSSUnitType::CSS_UNICODE_RANGE:
126126
case CSSUnitType::CSS_UNKNOWN:
127+
case CSSUnitType::CSS_UNRESOLVED_COLOR:
127128
case CSSUnitType::CSS_URI:
128129
case CSSUnitType::CSS_VALUE_ID:
129130
case CSSUnitType::CustomIdent:
@@ -265,6 +266,7 @@ TextStream& operator<<(TextStream& ts, CSSUnitType unitType)
265266
case CSSUnitType::CSS_CALC: ts << "calc"; break;
266267
case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_NUMBER: ts << "calc_percentage_with_number"; break;
267268
case CSSUnitType::CSS_CALC_PERCENTAGE_WITH_LENGTH: ts << "calc_percentage_with_length"; break;
269+
case CSSUnitType::CSS_UNRESOLVED_COLOR: ts << "unresolved_color"; break;
268270
case CSSUnitType::CSS_FONT_FAMILY: ts << "font_family"; break;
269271
case CSSUnitType::CSS_PROPERTY_ID: ts << "property_id"; break;
270272
case CSSUnitType::CSS_VALUE_ID: ts << "value_id"; break;

Source/WebCore/css/CSSUnits.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ enum class CSSUnitType : uint8_t {
121121

122122
CSS_FONT_FAMILY,
123123

124+
CSS_UNRESOLVED_COLOR,
125+
124126
CSS_PROPERTY_ID,
125127
CSS_VALUE_ID,
126128

0 commit comments

Comments
 (0)