Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 88a0736c2c2d79064ae781e6ef99e4e5abbf692f
      
https://github.com/WebKit/WebKit/commit/88a0736c2c2d79064ae781e6ef99e4e5abbf692f
  Author: Sam Weinig <wei...@apple.com>
  Date:   2023-01-20 (Fri, 20 Jan 2023)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-valid-color-mix-function-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-valid-color-mix-function.html
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSPrimitiveValue.cpp
    M Source/WebCore/css/CSSPrimitiveValue.h
    M Source/WebCore/css/CSSUnits.cpp
    M Source/WebCore/css/CSSUnits.h
    M Source/WebCore/css/StyleColor.cpp
    M Source/WebCore/css/StyleColor.h
    M Source/WebCore/css/calc/CSSCalcCategoryMapping.cpp
    A Source/WebCore/css/color/CSSResolvedColorMix.cpp
    A Source/WebCore/css/color/CSSResolvedColorMix.h
    A Source/WebCore/css/color/CSSUnresolvedColor.cpp
    A Source/WebCore/css/color/CSSUnresolvedColor.h
    A Source/WebCore/css/color/CSSUnresolvedColorMix.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/platform/graphics/ColorInterpolationMethod.cpp
    M Source/WebCore/platform/graphics/ColorInterpolationMethod.h
    M Source/WebCore/style/ColorFromPrimitiveValue.cpp

  Log Message:
  -----------
  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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to