Skip to content

Conversation

@smfr
Copy link
Contributor

@smfr smfr commented Jul 27, 2024

5b3fbae

Add CSSValue types for the shape() function
https://bugs.webkit.org/show_bug.cgi?id=277211
rdar://132644760

Reviewed by Tim Nguyen.

To support the CSS shape() function[1] we need two new CSSValue subclasses.

CSSShapeValue subclasses CSSValueContainingVector, since the segments form a list.
Those segments are represented by CSSShapeSegmentValue. The spec calls these "commands",
but I chose to use "segment" to match terminology in Path and SVG code.

Internally CSSShapeSegmentValue uses one of several data types to store the segment
data, based on how many lengths or points need to be stored.

These classes are not yet instantiated.

Based on code by Noam Rosenthal.

[1] https://drafts.csswg.org/css-shapes-2/#shape-function

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSBasicShapes.cpp:
(WebCore::CSSPolygonValue::CSSPolygonValue): Use r-value reference for the CSSValueListBuilder argument.
(WebCore::CSSPolygonValue::create):
(WebCore::CSSShapeValue::create):
(WebCore::CSSShapeValue::CSSShapeValue):
(WebCore::CSSShapeValue::customCSSText const):
(WebCore::CSSShapeValue::equals const):
* Source/WebCore/css/CSSBasicShapes.h:
* Source/WebCore/css/CSSShapeSegmentValue.cpp: Added.
(WebCore::CSSShapeSegmentValue::createMove):
(WebCore::CSSShapeSegmentValue::createLine):
(WebCore::CSSShapeSegmentValue::createHorizontalLine):
(WebCore::CSSShapeSegmentValue::createVerticalLine):
(WebCore::CSSShapeSegmentValue::createCubicCurve):
(WebCore::CSSShapeSegmentValue::createQuadraticCurve):
(WebCore::CSSShapeSegmentValue::createSmoothCubicCurve):
(WebCore::CSSShapeSegmentValue::createSmoothQuadraticCurve):
(WebCore::CSSShapeSegmentValue::createArc):
(WebCore::CSSShapeSegmentValue::createClose):
(WebCore::CSSShapeSegmentValue::equals const):
(WebCore::CSSShapeSegmentValue::customCSSText const):
* Source/WebCore/css/CSSShapeSegmentValue.h: Added.
(WebCore::CSSShapeSegmentValue::type const):
(WebCore::CSSShapeSegmentValue::ShapeSegmentData::ShapeSegmentData):
(WebCore::CSSShapeSegmentValue::ShapeSegmentData::operator== const):
(WebCore::CSSShapeSegmentValue::OnePointData::OnePointData):
(WebCore::CSSShapeSegmentValue::TwoPointData::TwoPointData):
(WebCore::CSSShapeSegmentValue::ArcData::ArcData):
(WebCore::CSSShapeSegmentValue::create):
(WebCore::CSSShapeSegmentValue::CSSShapeSegmentValue):
* Source/WebCore/css/CSSValue.cpp:
(WebCore::CSSValue::visitDerived):
* Source/WebCore/css/CSSValue.h:
(WebCore::CSSValue::isShape const):
(WebCore::CSSValue::isShapeSegment const):
* Source/WebCore/css/CSSValueKeywords.in: Add shape-related keywords.
* Source/WebCore/rendering/style/BasicShapes.h:

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

047f258

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ❌ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2
✅ 🛠 tv
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@smfr smfr self-assigned this Jul 27, 2024
@smfr smfr added the CSS Cascading Style Sheets implementation label Jul 27, 2024
@smfr smfr force-pushed the eng/Add-CSSValue-types-for-the-shape-function branch from 6a3f105 to 4fc1a7f Compare July 27, 2024 19:12
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 27, 2024
@smfr smfr removed the merging-blocked Applied to prevent a change from being merged label Jul 27, 2024
@smfr smfr force-pushed the eng/Add-CSSValue-types-for-the-shape-function branch from 4fc1a7f to 047f258 Compare July 27, 2024 20:07
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 27, 2024
@smfr smfr added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Jul 28, 2024
https://bugs.webkit.org/show_bug.cgi?id=277211
rdar://132644760

Reviewed by Tim Nguyen.

To support the CSS shape() function[1] we need two new CSSValue subclasses.

CSSShapeValue subclasses CSSValueContainingVector, since the segments form a list.
Those segments are represented by CSSShapeSegmentValue. The spec calls these "commands",
but I chose to use "segment" to match terminology in Path and SVG code.

Internally CSSShapeSegmentValue uses one of several data types to store the segment
data, based on how many lengths or points need to be stored.

These classes are not yet instantiated.

Based on code by Noam Rosenthal.

[1] https://drafts.csswg.org/css-shapes-2/#shape-function

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSBasicShapes.cpp:
(WebCore::CSSPolygonValue::CSSPolygonValue): Use r-value reference for the CSSValueListBuilder argument.
(WebCore::CSSPolygonValue::create):
(WebCore::CSSShapeValue::create):
(WebCore::CSSShapeValue::CSSShapeValue):
(WebCore::CSSShapeValue::customCSSText const):
(WebCore::CSSShapeValue::equals const):
* Source/WebCore/css/CSSBasicShapes.h:
* Source/WebCore/css/CSSShapeSegmentValue.cpp: Added.
(WebCore::CSSShapeSegmentValue::createMove):
(WebCore::CSSShapeSegmentValue::createLine):
(WebCore::CSSShapeSegmentValue::createHorizontalLine):
(WebCore::CSSShapeSegmentValue::createVerticalLine):
(WebCore::CSSShapeSegmentValue::createCubicCurve):
(WebCore::CSSShapeSegmentValue::createQuadraticCurve):
(WebCore::CSSShapeSegmentValue::createSmoothCubicCurve):
(WebCore::CSSShapeSegmentValue::createSmoothQuadraticCurve):
(WebCore::CSSShapeSegmentValue::createArc):
(WebCore::CSSShapeSegmentValue::createClose):
(WebCore::CSSShapeSegmentValue::equals const):
(WebCore::CSSShapeSegmentValue::customCSSText const):
* Source/WebCore/css/CSSShapeSegmentValue.h: Added.
(WebCore::CSSShapeSegmentValue::type const):
(WebCore::CSSShapeSegmentValue::ShapeSegmentData::ShapeSegmentData):
(WebCore::CSSShapeSegmentValue::ShapeSegmentData::operator== const):
(WebCore::CSSShapeSegmentValue::OnePointData::OnePointData):
(WebCore::CSSShapeSegmentValue::TwoPointData::TwoPointData):
(WebCore::CSSShapeSegmentValue::ArcData::ArcData):
(WebCore::CSSShapeSegmentValue::create):
(WebCore::CSSShapeSegmentValue::CSSShapeSegmentValue):
* Source/WebCore/css/CSSValue.cpp:
(WebCore::CSSValue::visitDerived):
* Source/WebCore/css/CSSValue.h:
(WebCore::CSSValue::isShape const):
(WebCore::CSSValue::isShapeSegment const):
* Source/WebCore/css/CSSValueKeywords.in: Add shape-related keywords.
* Source/WebCore/rendering/style/BasicShapes.h:

Canonical link: https://commits.webkit.org/281462@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Add-CSSValue-types-for-the-shape-function branch from 047f258 to 5b3fbae Compare July 28, 2024 01:48
@webkit-commit-queue
Copy link
Collaborator

Committed 281462@main (5b3fbae): https://commits.webkit.org/281462@main

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

@webkit-commit-queue webkit-commit-queue merged commit 5b3fbae into WebKit:main Jul 28, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 28, 2024
@smfr smfr deleted the eng/Add-CSSValue-types-for-the-shape-function branch October 15, 2024 16:07
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