Skip to content

[Style] Convert clip-path and offset-path to use strong style types #47005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

weinig
Copy link
Contributor

@weinig weinig commented Jun 21, 2025

2e33f4c

[Style] Convert clip-path and offset-path to use strong style types
https://bugs.webkit.org/show_bug.cgi?id=294754

Reviewed by Darin Adler.

Add strongly typed wrappers for the clip-path and offset-path
properties. These are both "zero-cost" wrappers around the
existing reference counted path operation types.

Converted the PathComputation and WindRuleComputation
interfaces to use the new CPO style invokers to match
the other invokers.

Added support for generic Variant support in TextStream and
made it so that elided tuples can be supported in TextStream
as well.

* Source/WTF/wtf/text/TextStream.h:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/animation/KeyframeEffect.cpp:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/page/InteractionRegion.cpp:
* Source/WebCore/platform/animation/AcceleratedEffectValues.cpp:
* Source/WebCore/platform/graphics/FloatRoundedRect.cpp:
* Source/WebCore/platform/graphics/FloatRoundedRect.h:
* Source/WebCore/rendering/MotionPath.cpp:
* Source/WebCore/rendering/MotionPath.h:
* Source/WebCore/rendering/PathOperation.cpp:
* Source/WebCore/rendering/PathOperation.h:
* Source/WebCore/rendering/ReferencedSVGResources.cpp:
* Source/WebCore/rendering/ReferencedSVGResources.h:
* Source/WebCore/rendering/RenderBox.cpp:
* Source/WebCore/rendering/RenderElementInlines.h:
* Source/WebCore/rendering/RenderLayer.cpp:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
* Source/WebCore/rendering/style/RenderStyle.cpp:
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
* Source/WebCore/rendering/style/RenderStyleSetters.h:
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
* Source/WebCore/rendering/style/StyleRareNonInheritedData.h:
* Source/WebCore/rendering/svg/SVGRenderSupport.cpp:
* Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp:
* Source/WebCore/rendering/svg/SVGRenderingContext.cpp:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceClipper.cpp:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.cpp:
* Source/WebCore/rendering/svg/legacy/SVGResources.cpp:
* Source/WebCore/rendering/svg/legacy/SVGResourcesCache.cpp:
* Source/WebCore/style/StyleAdjuster.cpp:
* Source/WebCore/style/StyleBuilderConverter.h:
* Source/WebCore/style/StyleBuilderCustom.h:
* Source/WebCore/style/StyleExtractorConverter.h:
* Source/WebCore/style/StyleExtractorCustom.h:
* Source/WebCore/style/StyleExtractorSerializer.h:
* Source/WebCore/style/values/StyleValueTypes.h:
* Source/WebCore/style/values/masking/StyleClipPath.cpp: Added.
* Source/WebCore/style/values/masking/StyleClipPath.h: Added.
* Source/WebCore/style/values/motion/StyleOffsetPath.cpp: Added.
* Source/WebCore/style/values/motion/StyleOffsetPath.h: Added.
* Source/WebCore/style/values/shapes/StylePathComputation.h:
* Source/WebCore/style/values/shapes/StylePathFunction.cpp:
* Source/WebCore/style/values/shapes/StylePathFunction.h:
* Source/WebCore/style/values/shapes/StylePathOperationWrappers.cpp: Added.
* Source/WebCore/style/values/shapes/StylePathOperationWrappers.h: Added.
* Source/WebCore/style/values/shapes/StyleWindRuleComputation.h:
* Source/WebCore/svg/SVGClipPathElement.cpp:

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

1ad15b4

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@weinig weinig self-assigned this Jun 21, 2025
@weinig weinig added the CSS Cascading Style Sheets implementation label Jun 21, 2025
@webkit-early-warning-system

This comment was marked as outdated.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 21, 2025
@webkit-ews-buildbot

This comment was marked as outdated.

@weinig weinig removed the merging-blocked Applied to prevent a change from being merged label Jun 21, 2025
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 63a29e3 to a7e1be0 Compare June 21, 2025 16:12
@webkit-early-warning-system

This comment was marked as outdated.

@webkit-ews-buildbot

This comment was marked as outdated.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 21, 2025
@weinig weinig removed the merging-blocked Applied to prevent a change from being merged label Jun 23, 2025
@weinig weinig changed the title [Style] Convert clip-path and offset-path to use strong style types [Style] Jun 23, 2025
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from a7e1be0 to 8237a45 Compare June 23, 2025 00:32
@webkit-early-warning-system

This comment was marked as outdated.

@weinig weinig changed the title [Style] [Style] Convert clip-path and offset-path to use strong style types Jun 23, 2025
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 8237a45 to 25ac024 Compare June 23, 2025 01:00
@webkit-early-warning-system

This comment was marked as outdated.

@webkit-ews-buildbot

This comment was marked as outdated.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 23, 2025
@weinig weinig removed the merging-blocked Applied to prevent a change from being merged label Jun 23, 2025
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 25ac024 to 25afd55 Compare June 23, 2025 15:51
@weinig weinig requested review from anttijk and darinadler June 23, 2025 18:17
@weinig weinig marked this pull request as ready for review June 23, 2025 18:17
@weinig weinig requested review from graouts and cdumez as code owners June 23, 2025 18:17
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 25afd55 to 96a9927 Compare June 23, 2025 18:19
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 96a9927 to 8adb468 Compare June 23, 2025 18:43
@@ -154,6 +156,8 @@ class FloatRoundedRect {

bool intersectionIsRectangular(const FloatRect&) const;

Path path() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure I like the pattern here.

Does FloatRect have a path function in it? What about IntRect? If we want to convert something that can be added to a path into a path with just that single geometric figure in it, wouldn’t we want to do that with a template function rather than adding a member function to each type?

I didn’t necessarily spot all the new code that depends on this, so I’m not sure how much this makes the code more elegant or if it makes a template abstraction possible. At least some of the call sites I found don’t really seem like they need to be the way they are.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having FloatRect and IntRect having path() functions sounds good actually.

The alternative, to make the call sites a bit more weirdly is to give Path() a constructor that takes a FloatRoundedRect (and ones for FloatRect and IntRect), which would also be ok with me.

Its all just to avoid the multiple lines needed to construct and add the one shape you want.

@webkit-ews-buildbot

This comment was marked as outdated.

@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 8adb468 to 1db1449 Compare June 23, 2025 20:36
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 23, 2025
@weinig weinig removed the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 1db1449 to 65716b7 Compare June 24, 2025 00:31
@weinig weinig added the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Jun 24, 2025
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #41339 (65716b7)

❌ Found 1 failing file with 4 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@weinig weinig removed safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks merging-blocked Applied to prevent a change from being merged labels Jun 24, 2025
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from 65716b7 to ce278de Compare June 24, 2025 02:43
@weinig weinig force-pushed the eng/clip-and-offset-path-wrappers branch from ce278de to 1ad15b4 Compare June 24, 2025 13:26
@weinig weinig added the merge-queue Applied to send a pull request to merge-queue label Jun 24, 2025
https://bugs.webkit.org/show_bug.cgi?id=294754

Reviewed by Darin Adler.

Add strongly typed wrappers for the clip-path and offset-path
properties. These are both "zero-cost" wrappers around the
existing reference counted path operation types.

Converted the PathComputation and WindRuleComputation
interfaces to use the new CPO style invokers to match
the other invokers.

Added support for generic Variant support in TextStream and
made it so that elided tuples can be supported in TextStream
as well.

* Source/WTF/wtf/text/TextStream.h:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/animation/KeyframeEffect.cpp:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/page/InteractionRegion.cpp:
* Source/WebCore/platform/animation/AcceleratedEffectValues.cpp:
* Source/WebCore/platform/graphics/FloatRoundedRect.cpp:
* Source/WebCore/platform/graphics/FloatRoundedRect.h:
* Source/WebCore/rendering/MotionPath.cpp:
* Source/WebCore/rendering/MotionPath.h:
* Source/WebCore/rendering/PathOperation.cpp:
* Source/WebCore/rendering/PathOperation.h:
* Source/WebCore/rendering/ReferencedSVGResources.cpp:
* Source/WebCore/rendering/ReferencedSVGResources.h:
* Source/WebCore/rendering/RenderBox.cpp:
* Source/WebCore/rendering/RenderElementInlines.h:
* Source/WebCore/rendering/RenderLayer.cpp:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
* Source/WebCore/rendering/style/RenderStyle.cpp:
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
* Source/WebCore/rendering/style/RenderStyleSetters.h:
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
* Source/WebCore/rendering/style/StyleRareNonInheritedData.h:
* Source/WebCore/rendering/svg/SVGRenderSupport.cpp:
* Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp:
* Source/WebCore/rendering/svg/SVGRenderingContext.cpp:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceClipper.cpp:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.cpp:
* Source/WebCore/rendering/svg/legacy/SVGResources.cpp:
* Source/WebCore/rendering/svg/legacy/SVGResourcesCache.cpp:
* Source/WebCore/style/StyleAdjuster.cpp:
* Source/WebCore/style/StyleBuilderConverter.h:
* Source/WebCore/style/StyleBuilderCustom.h:
* Source/WebCore/style/StyleExtractorConverter.h:
* Source/WebCore/style/StyleExtractorCustom.h:
* Source/WebCore/style/StyleExtractorSerializer.h:
* Source/WebCore/style/values/StyleValueTypes.h:
* Source/WebCore/style/values/masking/StyleClipPath.cpp: Added.
* Source/WebCore/style/values/masking/StyleClipPath.h: Added.
* Source/WebCore/style/values/motion/StyleOffsetPath.cpp: Added.
* Source/WebCore/style/values/motion/StyleOffsetPath.h: Added.
* Source/WebCore/style/values/shapes/StylePathComputation.h:
* Source/WebCore/style/values/shapes/StylePathFunction.cpp:
* Source/WebCore/style/values/shapes/StylePathFunction.h:
* Source/WebCore/style/values/shapes/StylePathOperationWrappers.cpp: Added.
* Source/WebCore/style/values/shapes/StylePathOperationWrappers.h: Added.
* Source/WebCore/style/values/shapes/StyleWindRuleComputation.h:
* Source/WebCore/svg/SVGClipPathElement.cpp:

Canonical link: https://commits.webkit.org/296560@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/clip-and-offset-path-wrappers branch from 1ad15b4 to 2e33f4c Compare June 24, 2025 14:21
@webkit-commit-queue
Copy link
Collaborator

Committed 296560@main (2e33f4c): https://commits.webkit.org/296560@main

Reviewed commits have been landed. Closing PR #47005 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 2e33f4c into WebKit:main Jun 24, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Cascading Style Sheets implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants