Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3d1a81f05a45ba46e924c411cfe06f510109054b
https://github.com/WebKit/WebKit/commit/3d1a81f05a45ba46e924c411cfe06f510109054b
Author: Sam Weinig <[email protected]>
Date: 2024-04-20 (Sat, 20 Apr 2024)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-computed-relative-color-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-valid-relative-color-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/fill-and-stroke-styles/2d.fillStyle.toStringFunctionCallback-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/fill-and-stroke-styles/2d.fillStyle.toStringFunctionCallback.worker-expected.txt
M Source/WebCore/css/parser/CSSPropertyParserConsumer+Color.cpp
M Source/WebCore/css/parser/CSSPropertyParserConsumer+Color.h
M Source/WebCore/css/parser/CSSPropertyParserConsumer+Number.cpp
M Source/WebCore/css/parser/CSSPropertyParserConsumer+Number.h
M Source/WebCore/css/parser/CSSPropertyParserConsumer+Percent.cpp
M Source/WebCore/css/parser/CSSPropertyParserConsumer+Percent.h
M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp
M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h
M Source/WebCore/html/CanvasBase.h
M Source/WebCore/html/CustomPaintCanvas.cpp
M Source/WebCore/html/CustomPaintCanvas.h
M Source/WebCore/html/HTMLCanvasElement.cpp
M Source/WebCore/html/HTMLCanvasElement.h
M Source/WebCore/html/OffscreenCanvas.cpp
M Source/WebCore/html/OffscreenCanvas.h
M Source/WebCore/html/canvas/CanvasStyle.cpp
Log Message:
-----------
Create clear entry points for color parsing to allow uniformly passing
options/tracking nesting
https://bugs.webkit.org/show_bug.cgi?id=273019
Reviewed by Darin Adler.
In preparation for additional changes to color parsing, this change
creates a consistent interface for the color parsing/consuming functions,
extracting out the color specific options into a new CSSColorParsingOptions
struct and utilizing the clear entry points to track nesting levels.
(For an example of nesting, parsing `color-mix()` is itself a color,
but as part of its parse, it recursively requires an additional 'origin'
color to be parsed).
The nesting level will be useful in the near future to allow changes
in parsing when not at the top level.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-computed-relative-color-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color/parsing/color-valid-relative-color-expected.txt:
In clarify the recursion, I fixed a bug where we were unnecessarily
restrictive and were preventing nested `color-mix()` from working.
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Color.h:
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Color.cpp:
(WebCore::CSSPropertyParserHelpers::ColorParserState::ColorParserState):
Mutable state used only in the cpp file to track options and nesting level.
(WebCore::CSSPropertyParserHelpers::ColorParserStateNester::ColorParserStateNester):
(WebCore::CSSPropertyParserHelpers::ColorParserStateNester::~ColorParserStateNester):
Helper to increment/decrement nesting level using RAII.
(WebCore::CSSPropertyParserHelpers::consumeOriginColorRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeRGBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRGBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeHSLParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeHSLParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseHSLParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeHWBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeHWBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseHWBParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeLabParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseLabParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeLCHParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseNonRelativeLCHParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseLCHParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseRelativeColorFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseColorContrastFunctionParametersRaw):
(WebCore::CSSPropertyParserHelpers::consumeColorMixComponentRaw):
(WebCore::CSSPropertyParserHelpers::consumeColorMixComponent):
(WebCore::CSSPropertyParserHelpers::parseColorMixFunctionParametersRaw):
(WebCore::CSSPropertyParserHelpers::parseColorMixFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseLightDarkFunctionParameters):
(WebCore::CSSPropertyParserHelpers::parseHexColor):
(WebCore::CSSPropertyParserHelpers::parseColorFunctionRaw):
(WebCore::CSSPropertyParserHelpers::parseColorFunction):
(WebCore::CSSPropertyParserHelpers::consumeColor):
(WebCore::CSSPropertyParserHelpers::consumeColorRaw):
(WebCore::CSSPropertyParserHelpers::parseColorRawWorkerSafe):
(WebCore::CSSPropertyParserHelpers::parseColorRaw):
Pass ColorParserState down the stack.
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Number.cpp:
(WebCore::CSSPropertyParserHelpers::validatedNumberRaw):
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Number.h:
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Percent.cpp:
(WebCore::CSSPropertyParserHelpers::validatedPercentRaw):
* Source/WebCore/css/parser/CSSPropertyParserConsumer+Percent.h:
Add validate function forward declarations into the headers. This
was only compiling due to the unified build happening to group
things just right.
* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp:
(WebCore::CSSPropertyParserWorkerSafe::parseColor): Deleted.
* Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h:
Move to CSSPropertyParserConsumer+Color.h.
* Source/WebCore/html/CanvasBase.h:
* Source/WebCore/html/CustomPaintCanvas.h:
(WebCore::CustomPaintCanvas::cssParserContext const):
* Source/WebCore/html/HTMLCanvasElement.h:
(WebCore::HTMLCanvasElement::cssParserContext const):
(WebCore::HTMLCanvasElement::cssParserContext): Deleted.
* Source/WebCore/html/OffscreenCanvas.h:
(WebCore::OffscreenCanvas::cssParserContext const):
Since a CSSParserContext is needed for all canvases, move the
existing HTMLCanvasElement function to be a virtual function
on CanvasBase and implement for OffscreenCanvas and CustomPaintCanvas.
* Source/WebCore/html/canvas/CanvasStyle.cpp:
(WebCore::parseColor):
(WebCore::currentColor):
Call the new CSSPropertyParserConsumer+Color.h parse functions. In
a subsequent change, these will need to pass additional options for
overriding hsl()/hsla() parsing behavior.
Canonical link: https://commits.webkit.org/277783@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes