Bug 233153 - Implement parsing and animation support for ray() shape accepted by offset-path
Summary: Implement parsing and animation support for ray() shape accepted by offset-path
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kiet Ho
URL:
Keywords: InRadar
Depends on:
Blocks: 203847 233344
  Show dependency treegraph
 
Reported: 2021-11-15 15:57 PST by Kiet Ho
Modified: 2021-11-19 16:56 PST (History)
14 users (show)

See Also:


Attachments
WIP (167.46 KB, patch)
2021-11-17 05:32 PST, Kiet Ho
no flags Details | Formatted Diff | Diff
Patch (168.98 KB, patch)
2021-11-18 10:17 PST, Kiet Ho
no flags Details | Formatted Diff | Diff
Patch (168.97 KB, patch)
2021-11-19 15:02 PST, Kiet Ho
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kiet Ho 2021-11-15 15:57:09 PST
Implement parsing and animation support for ray() shape allowed by offset-path
Comment 1 Kiet Ho 2021-11-17 05:32:42 PST
Created attachment 444511 [details]
WIP
Comment 2 EWS Watchlist 2021-11-17 05:33:36 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 3 Kiet Ho 2021-11-18 10:17:04 PST
Created attachment 444696 [details]
Patch
Comment 4 Radar WebKit Bug Importer 2021-11-19 11:07:28 PST
<rdar://problem/85611929>
Comment 5 Dean Jackson 2021-11-19 14:05:04 PST
Comment on attachment 444696 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=444696&action=review

> Source/WebCore/css/parser/CSSPropertyParser.cpp:2807
> +    RefPtr<CSSPrimitiveValue> isContaining;
> +    while (!args.atEnd()) {
> +        if (!angle && (angle = consumeAngle(args, context.mode, UnitlessQuirk::Forbid, UnitlessZeroQuirk::Forbid)))
> +            continue;
> +
> +        if (!size && (size = consumeIdent<CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide, CSSValueFarthestCorner, CSSValueSides>(args)))
> +            continue;
> +
> +        if (!isContaining && (isContaining = consumeIdent<CSSValueContain>(args)))
> +            continue;
> +
> +        return nullptr;
> +    }
> +
> +    // <angle> and <size> must be present.
> +    if (!angle || !size)
> +        return nullptr;
> +
> +    return CSSRayValue::create(angle.releaseNonNull(), size.releaseNonNull(), isContaining);

Given that you end up passing a bool for the isContaining parameter, I wonder if you ever need the RefPtr<CSSPrimitiveValue> for it. Wouldn't it work to have a bool variable, and simply test that consumeIdent<CSSValueContain> returns a value, then set the bool to true before calling continue?

> Source/WebCore/style/StyleBuilderConverter.h:663
> +        RayPathOperation::Size size = RayPathOperation::Size::ClosestCorner;
> +        switch (rayValue.size()->valueID()) {
> +        case CSSValueClosestCorner:
> +            size = RayPathOperation::Size::ClosestCorner;
> +            break;
> +        case CSSValueClosestSide:
> +            size = RayPathOperation::Size::ClosestSide;
> +            break;
> +        case CSSValueFarthestCorner:
> +            size = RayPathOperation::Size::FarthestCorner;
> +            break;
> +        case CSSValueFarthestSide:
> +            size = RayPathOperation::Size::FarthestSide;
> +            break;
> +        case CSSValueSides:
> +            size = RayPathOperation::Size::Sides;
> +            break;
> +        default:
> +            ASSERT_NOT_REACHED();
> +            return nullptr;
> +        }

Not important, but I see people tend to use immediately called lambdas for initialisation of variables? e.g.

auto size = [] (CSSValueID valueID) -> RayPathOperation::Size {
  switch (valueID) {
  case CSSValueClosestCorner:
     return ClosestCorner;
...


}(rayValue.size()->valueID());

Don't make the change though. This is fine.

> LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-path-computed.html:22
> -test_computed_value("offset-path", "ray(calc(180deg - 45deg) farthest-side)", "ray(calc(135deg) farthest-side)");
> +test_computed_value("offset-path", "ray(calc(180deg - 45deg) farthest-side)", "ray(135deg farthest-side)");

This is making a change to an imported test? Was it intentional? What happens when we update WPT?
Comment 6 Kiet Ho 2021-11-19 14:08:50 PST
Comment on attachment 444696 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=444696&action=review

>> Source/WebCore/css/parser/CSSPropertyParser.cpp:2807
>> +    return CSSRayValue::create(angle.releaseNonNull(), size.releaseNonNull(), isContaining);
> 
> Given that you end up passing a bool for the isContaining parameter, I wonder if you ever need the RefPtr<CSSPrimitiveValue> for it. Wouldn't it work to have a bool variable, and simply test that consumeIdent<CSSValueContain> returns a value, then set the bool to true before calling continue?

You're right, I'll change it to just a simple bool.

>> LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-path-computed.html:22
>> +test_computed_value("offset-path", "ray(calc(180deg - 45deg) farthest-side)", "ray(135deg farthest-side)");
> 
> This is making a change to an imported test? Was it intentional? What happens when we update WPT?

This change is exported here: https://github.com/web-platform-tests/wpt/pull/31658. Once this patch is merged, the bot will automatically merge the WPT pull request.
Comment 7 Kiet Ho 2021-11-19 15:02:58 PST
Created attachment 444859 [details]
Patch
Comment 8 EWS 2021-11-19 16:56:28 PST
Committed r286086 (244473@main): <https://commits.webkit.org/244473@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 444859 [details].