[webkit-changes] [WebKit/WebKit] 46519e: Unify aggregates used by CSS and Style value repre...

Sam Weinig noreply at github.com
Mon Dec 2 20:40:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 46519ef9b5f8c807600f11114d37eae8bde159e8
      https://github.com/WebKit/WebKit/commit/46519ef9b5f8c807600f11114d37eae8bde159e8
  Author: Sam Weinig <sam at webkit.org>
  Date:   2024-12-02 (Mon, 02 Dec 2024)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSGradientValue.cpp
    M Source/WebCore/css/parser/CSSPropertyParserConsumer+ColorAdjust.cpp
    M Source/WebCore/css/parser/CSSPropertyParserConsumer+Image.cpp
    M Source/WebCore/css/parser/CSSPropertyParserConsumer+Shapes.cpp
    A Source/WebCore/css/values/CSSValueAggregates.cpp
    A Source/WebCore/css/values/CSSValueAggregates.h
    M Source/WebCore/css/values/CSSValueTypes.cpp
    M Source/WebCore/css/values/CSSValueTypes.h
    M Source/WebCore/css/values/backgrounds/CSSBorderRadius.h
    R Source/WebCore/css/values/backgrounds/CSSMinimallySerializingRectEdges.h
    M Source/WebCore/css/values/color/CSSColorLayers.h
    M Source/WebCore/css/values/images/CSSGradient.h
    M Source/WebCore/css/values/primitives/CSSPosition.h
    M Source/WebCore/css/values/primitives/CSSPrimitiveNumericTypes+CSSValueCreation.h
    M Source/WebCore/css/values/shapes/CSSInsetFunction.h
    M Source/WebCore/css/values/shapes/CSSPolygonFunction.h
    M Source/WebCore/css/values/shapes/CSSRectFunction.h
    M Source/WebCore/css/values/shapes/CSSShapeFunction.h
    M Source/WebCore/css/values/shapes/CSSXywhFunction.h
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/style/values/StyleValueTypes.h
    M Source/WebCore/style/values/backgrounds/StyleBorderRadius.h
    R Source/WebCore/style/values/backgrounds/StyleMinimallySerializingRectEdges.h
    M Source/WebCore/style/values/color-adjust/StyleColorScheme.h
    M Source/WebCore/style/values/color/StyleColorLayers.cpp
    M Source/WebCore/style/values/color/StyleColorLayers.h
    M Source/WebCore/style/values/images/StyleGradient.h
    M Source/WebCore/style/values/motion/StyleRayFunction.h
    M Source/WebCore/style/values/primitives/StylePosition.h
    M Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Evaluation.h
    M Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes.h
    M Source/WebCore/style/values/shapes/StyleCircleFunction.h
    M Source/WebCore/style/values/shapes/StyleEllipseFunction.h
    M Source/WebCore/style/values/shapes/StyleInsetFunction.h
    M Source/WebCore/style/values/shapes/StylePolygonFunction.h
    M Source/WebCore/style/values/shapes/StyleShapeFunction.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in

  Log Message:
  -----------
  Unify aggregates used by CSS and Style value representations
https://bugs.webkit.org/show_bug.cgi?id=283854

Reviewed by Darin Adler.

There is a bunch of duplication between CSSValueTypes and StyleValueTypes
that can be removed now by extracting the common types into their own file.

Unifies:
    Constant
    CustomIdentifier
    FunctionNotation<C, T>
    SpaceSeparatedVector<T, N>
    CommaSeparatedVector<T, N>
    SpaceSeparatedArray<T, N>
    CommaSeparatedArray<T, N>
    SpaceSeparatedTuple<Ts...>
    CommaSeparatedTuple<Ts...>
    Point<T>
    Size<T>

Renames:
    Point<T> -> SpaceSeparatedPoint<T>
    Size<T> -> SpaceSeparatedSize<T>

Adds:
    SpaceSeparatedRectEdges<T> (replaces raw use of WebCore::RectEdges<T>).

Additionally, all types now fall into one of the following categories:
    - Leaf (must be specialized)
    - OptionalLike (std::optional/WTF::Markable)
    - TupleLike (std::tuple/SpaceSeparatedTuple/CommaSeparatedTuple/SpaceSeparatedArray/CommaSeparatedArray)
    - RangeLike (SpaceSeparatedVector/CommaSeparatedVector)
    - VariantLike (std::variant)

To conform to a particular category, a TreatAs<category>Like template variable
must be specialized.

By conforming to a category, most algorithms will have default behaviors. For
TupleLike and RangeLike, an additional conformance, SerializationSeparator<>
is required to obtain defaulted serialization.

Algorithms can implement default behaviors for entire categories by constraining
a specialization using the TreadAs<category>Like template variable. For instance,
Gradient code requires a specialized algorithm called `StyleImageIsUncacheable`.
It can now use:

template<typename CSSType> requires (TreatAsRangeLike<CSSType>) struct StyleImageIsUncacheable<CSSType> {
    bool operator()(const auto& value) { return std::ranges::any_of(value, [](auto& element) { return styleImageIsUncacheable(element); }); }
};

to implement a proper default implementation for all Range-Like types. (It can
do similarly for Optional-Like, Tuple-Like and Variant-Like). This significantly
cuts down on the amount of code needed.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSGradientValue.cpp:
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Image.cpp:
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Shapes.cpp:
* Source/WebCore/css/values/CSSValueAggregates.cpp: Copied from Source/WebCore/css/values/CSSValueTypes.cpp.
* Source/WebCore/css/values/CSSValueAggregates.h: Added.
* Source/WebCore/css/values/CSSValueTypes.cpp:
* Source/WebCore/css/values/CSSValueTypes.h:
* Source/WebCore/css/values/backgrounds/CSSBorderRadius.h:
* Source/WebCore/css/values/backgrounds/CSSMinimallySerializingRectEdges.h:
* Source/WebCore/css/values/primitives/CSSPosition.h:
* Source/WebCore/css/values/primitives/CSSPrimitiveNumericTypes+CSSValueCreation.h:
* Source/WebCore/css/values/shapes/CSSPolygonFunction.h:
* Source/WebCore/css/values/shapes/CSSRectFunction.h:
* Source/WebCore/css/values/shapes/CSSShapeFunction.h:
* Source/WebCore/css/values/shapes/CSSXywhFunction.h:
* Source/WebCore/html/HTMLInputElement.cpp:
* Source/WebCore/style/values/StyleValueTypes.h:
* Source/WebCore/style/values/backgrounds/StyleBorderRadius.h:
* Source/WebCore/style/values/backgrounds/StyleMinimallySerializingRectEdges.h:
* Source/WebCore/style/values/color-adjust/StyleColorScheme.h:
* Source/WebCore/style/values/images/StyleGradient.h:
* Source/WebCore/style/values/motion/StyleRayFunction.h:
* Source/WebCore/style/values/primitives/StylePosition.h:
* Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Evaluation.h:
* Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes.h:
* Source/WebCore/style/values/shapes/StyleCircleFunction.h:
* Source/WebCore/style/values/shapes/StyleEllipseFunction.h:
* Source/WebCore/style/values/shapes/StyleInsetFunction.h:
* Source/WebCore/style/values/shapes/StylePolygonFunction.h:
* Source/WebCore/style/values/shapes/StyleShapeFunction.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/287255@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list