Title: [264622] trunk
- Revision
- 264622
- Author
- [email protected]
- Date
- 2020-07-20 15:12:21 -0700 (Mon, 20 Jul 2020)
Log Message
CSS clip-path is applied to the <svg> root element in the view-box coordinates
https://bugs.webkit.org/show_bug.cgi?id=214418
Patch by Said Abou-Hallawa <[email protected]> on 2020-07-20
Reviewed by Darin Adler.
Source/WebCore:
We need to transfer the bounding box of the SVG element renderer from the
SVG coordinates system to the CSS coordinates before calculating the clip
path. Then we need to transfer the clip path back to the SVG coordinates
before applying it to the GraphicsContext. The GraphicsContext is already
transformed by the localToPrentTransform.
Test: svg/in-html/svg-view-box-css-clip-path.html
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::clipContextToCSSClippingArea):
LayoutTests:
* svg/in-html/svg-view-box-css-clip-path-expected.html: Added.
* svg/in-html/svg-view-box-css-clip-path.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (264621 => 264622)
--- trunk/LayoutTests/ChangeLog 2020-07-20 22:01:37 UTC (rev 264621)
+++ trunk/LayoutTests/ChangeLog 2020-07-20 22:12:21 UTC (rev 264622)
@@ -1,3 +1,13 @@
+2020-07-20 Said Abou-Hallawa <[email protected]>
+
+ CSS clip-path is applied to the <svg> root element in the view-box coordinates
+ https://bugs.webkit.org/show_bug.cgi?id=214418
+
+ Reviewed by Darin Adler.
+
+ * svg/in-html/svg-view-box-css-clip-path-expected.html: Added.
+ * svg/in-html/svg-view-box-css-clip-path.html: Added.
+
2020-07-20 Clark Wang <[email protected]>
Fixes to match BaseAudioContext.idl to spec
Added: trunk/LayoutTests/svg/in-html/svg-view-box-css-clip-path-expected.html (0 => 264622)
--- trunk/LayoutTests/svg/in-html/svg-view-box-css-clip-path-expected.html (rev 0)
+++ trunk/LayoutTests/svg/in-html/svg-view-box-css-clip-path-expected.html 2020-07-20 22:12:21 UTC (rev 264622)
@@ -0,0 +1,10 @@
+<style>
+ .green-box {
+ height: 200px;
+ width: 200px;
+ background-color: green;
+ }
+</style>
+<body>
+ <div class="green-box"></div>
+</body>
Added: trunk/LayoutTests/svg/in-html/svg-view-box-css-clip-path.html (0 => 264622)
--- trunk/LayoutTests/svg/in-html/svg-view-box-css-clip-path.html (rev 0)
+++ trunk/LayoutTests/svg/in-html/svg-view-box-css-clip-path.html 2020-07-20 22:12:21 UTC (rev 264622)
@@ -0,0 +1,14 @@
+<style>
+ .green-box {
+ height: 400px;
+ width: 400px;
+ clip-path: inset(0 200px 200px 0);
+ }
+</style>
+<body>
+ <div>
+ <svg class="green-box" viewBox="0 0 200 200">
+ <rect width="100%" height="100%" fill="green"/>
+ </svg>
+ </div>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (264621 => 264622)
--- trunk/Source/WebCore/ChangeLog 2020-07-20 22:01:37 UTC (rev 264621)
+++ trunk/Source/WebCore/ChangeLog 2020-07-20 22:12:21 UTC (rev 264622)
@@ -1,3 +1,21 @@
+2020-07-20 Said Abou-Hallawa <[email protected]>
+
+ CSS clip-path is applied to the <svg> root element in the view-box coordinates
+ https://bugs.webkit.org/show_bug.cgi?id=214418
+
+ Reviewed by Darin Adler.
+
+ We need to transfer the bounding box of the SVG element renderer from the
+ SVG coordinates system to the CSS coordinates before calculating the clip
+ path. Then we need to transfer the clip path back to the SVG coordinates
+ before applying it to the GraphicsContext. The GraphicsContext is already
+ transformed by the localToPrentTransform.
+
+ Test: svg/in-html/svg-view-box-css-clip-path.html
+
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::clipContextToCSSClippingArea):
+
2020-07-20 Clark Wang <[email protected]>
Fixes to match BaseAudioContext.idl to spec
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (264621 => 264622)
--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp 2020-07-20 22:01:37 UTC (rev 264621)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp 2020-07-20 22:12:21 UTC (rev 264622)
@@ -395,8 +395,15 @@
ClipPathOperation* clipPathOperation = renderer.style().clipPath();
if (is<ShapeClipPathOperation>(clipPathOperation)) {
auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation);
- FloatRect referenceBox = clipPathReferenceBox(renderer, clipPath.referenceBox());
- context.clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
+ auto localToParentTransform = renderer.localToParentTransform();
+
+ auto referenceBox = clipPathReferenceBox(renderer, clipPath.referenceBox());
+ referenceBox = localToParentTransform.mapRect(referenceBox);
+
+ auto path = clipPath.pathForReferenceRect(referenceBox);
+ path.transform(localToParentTransform.inverse().valueOr(AffineTransform()));
+
+ context.clipPath(path, clipPath.windRule());
}
if (is<BoxClipPathOperation>(clipPathOperation)) {
auto& clipPath = downcast<BoxClipPathOperation>(*clipPathOperation);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes