Bug 233382

Summary: Support rendering url(), CSS basic shapes other than path(), and coord-box for offset-path
Product: WebKit Reporter: Kiet Ho <tho22>
Component: CSSAssignee: Nikos Mouchtaris <nmouchtaris>
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, clopez, dino, esprehn+autocc, ews-watchlist, fred.wang, glenn, kondapallykalyan, nmouchtaris, ntim, pdr, simon.fraser, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 203847    
Attachments:
Description Flags
WIP
none
WIP
none
WIP
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
simon.fraser: review+, ews-feeder: commit-queue-
Patch
ntim: commit-queue-
Patch for landing
none
Patch for landing none

Description Kiet Ho 2021-11-19 13:55:10 PST
Support rendering url(), CSS basic shapes other than path(), and coord-box for offset-path. Right now offset-path will parse them just fine, but will ignore any shapes other than path().
Comment 1 Radar WebKit Bug Importer 2021-11-26 13:56:18 PST
<rdar://problem/85772826>
Comment 2 Nikos Mouchtaris 2022-02-17 22:28:32 PST
Created attachment 452482 [details]
WIP
Comment 3 Nikos Mouchtaris 2022-02-18 01:20:57 PST
Created attachment 452496 [details]
WIP
Comment 4 Dean Jackson 2022-02-18 08:45:32 PST
Comment on attachment 452496 [details]
WIP

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

> Source/WebCore/rendering/style/RenderStyle.cpp:1474
> +            // how to get current render box- want something like computeRoundedRectForBoxShape
> +            // marginBoxRect();pathForReferenceRect
> +            // return downcast<BoxPathOperation>(operation).pathForReferenceRect(box);

Did you intend to leave this comment in?
Comment 5 Nikos Mouchtaris 2022-02-18 16:58:21 PST
Created attachment 452611 [details]
WIP
Comment 6 Nikos Mouchtaris 2022-02-21 22:52:18 PST
Created attachment 452827 [details]
Patch
Comment 7 Nikos Mouchtaris 2022-03-24 17:04:59 PDT
Created attachment 455706 [details]
Patch
Comment 8 EWS Watchlist 2022-03-24 17:06:30 PDT
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 9 Nikos Mouchtaris 2022-03-24 17:07:36 PDT
Created attachment 455707 [details]
Patch
Comment 10 Dean Jackson 2022-03-25 16:57:31 PDT
Comment on attachment 455707 [details]
Patch

would like to see more tests - shame WPT doesn't have them.
Comment 11 Nikos Mouchtaris 2022-03-25 17:13:38 PDT
Created attachment 455812 [details]
Patch
Comment 12 Simon Fraser (smfr) 2022-03-25 19:05:34 PDT
Comment on attachment 455707 [details]
Patch

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

> Source/WebCore/rendering/PathOperation.h:71
> +    static Ref<ReferencePathOperation> create(const String&, const String&, const RefPtr<SVGElement>);

You need to name the string parameters in the header so the reader knows what they are.

> Source/WebCore/rendering/PathOperation.h:85
> +    ReferencePathOperation(const String&, const String&, const RefPtr<SVGElement>);

Ditto

> Source/WebCore/rendering/RenderLayer.cpp:1345
> +        if (is<RenderBox>(renderer())) {
> +            auto cssBox = transformBoxToCSSBoxType(renderer().style().transformBox());
> +            if (auto pathOperation = renderer().style().offsetPath()) {
> +                if (pathOperation->type() == PathOperation::Box)
> +                    cssBox = downcast<BoxPathOperation>(pathOperation)->referenceBox();
> +            }
> +
> +            referenceBox = snapRectToDevicePixels(downcast<RenderBox>(renderer()).referenceBox(cssBox), renderer().document().deviceScaleFactor());
> +        }

This doesn't seem right. The presence of an offset path shouldn't affect transform rendering. This needs a testcase.

> Source/WebCore/rendering/style/RenderStyle.cpp:1528
> +    switch (operation.type())
> +    {

Brace on the previous line.

> Source/WebCore/rendering/style/RenderStyle.cpp:1532
> +        case PathOperation::Reference:
> +        {

Ditto

> Source/WebCore/rendering/style/RenderStyle.cpp:1538
> +        case PathOperation::Box:
> +        {

Ditto

> Source/WebCore/rendering/style/RenderStyle.cpp:1542
> +        case PathOperation::Ray:
> +        {

Ditto
Comment 13 Nikos Mouchtaris 2022-04-01 17:49:00 PDT
Created attachment 456422 [details]
Patch
Comment 14 Tim Nguyen (:ntim) 2022-04-04 14:46:07 PDT
Comment on attachment 456422 [details]
Patch

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

Looks like there are some trivial style errors.

> Source/WebCore/ChangeLog:16
> +        Tests: imported/w3c/web-platform-tests/css/motion/offset-path-shape.html
> +               imported/w3c/web-platform-tests/css/motion/offset-path-url.html

Can you please export these tests? They're not upstream
Comment 15 Simon Fraser (smfr) 2022-04-04 14:53:36 PDT
Comment on attachment 456422 [details]
Patch

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

> Source/WebCore/rendering/PathOperation.cpp:2
> + * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.

Doesn't seem right for a new file.

> Source/WebCore/rendering/PathOperation.h:74
> +    const RefPtr<SVGElement> element() const;

This can return a SVGElement*

> Source/WebCore/rendering/PathOperation.h:85
> +    ReferencePathOperation(const String& url, const String& fragment, const RefPtr<SVGElement> element);

The argument can be a SVGElement*

> Source/WebCore/rendering/RenderLayer.cpp:1340
> +                if (pathOperation->type() == PathOperation::Box) {

This should use is<BoxPathOperation>()

> Source/WebCore/rendering/style/RenderStyle.cpp:1537
> +        case PathOperation::Box: {
> +            return downcast<BoxPathOperation>(operation).getPath();
> +        }

You only need braces in case statements if you declare local variables. None of these cases do.
Comment 16 Nikos Mouchtaris 2022-04-04 16:37:24 PDT
Created attachment 456649 [details]
Patch
Comment 17 Tim Nguyen (:ntim) 2022-04-04 23:21:17 PDT
Comment on attachment 456649 [details]
Patch

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

> LayoutTests/imported/w3c/web-platform-tests/css/motion/offset-path-geometry-box.html:6
> +    <link rel="match" href="offset-path-shape-ref.html">

The ref is wrong here. I'll fix it upstream in the WPT PR, but please fix it in this patch.
Comment 18 Tim Nguyen (:ntim) 2022-04-04 23:23:29 PDT
Comment on attachment 456649 [details]
Patch

Please also fix the webkit-style errors on EWS, I think it's complaining specifically about `const RefPtr<SVGElement> element` in each constructor, I think it's sensible to remove the parameter names in those cases.
Comment 19 Tim Nguyen (:ntim) 2022-04-04 23:29:15 PDT
Created attachment 456674 [details]
Patch for landing

Addressed my 2 own comments (I copy pasted the previous attachment then did manual edits)
Comment 20 Tim Nguyen (:ntim) 2022-04-04 23:43:27 PDT
Comment on attachment 456674 [details]
Patch for landing

oh looks like you can't just copy an attachment and edit it
Comment 21 Tim Nguyen (:ntim) 2022-04-04 23:44:04 PDT
Created attachment 456675 [details]
Patch for landing
Comment 22 EWS 2022-04-05 01:04:47 PDT
Committed r292382 (249247@main): <https://commits.webkit.org/249247@main>

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