Title: [284853] trunk
Revision
284853
Author
[email protected]
Date
2021-10-25 18:44:38 -0700 (Mon, 25 Oct 2021)

Log Message

Fix issue for transform-origin in SVG
https://bugs.webkit.org/show_bug.cgi?id=232189

Patch by Nikolaos Mouchtaris <[email protected]> on 2021-10-25
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-ref.svg: Added.
* web-platform-tests/svg/styling/render/transform-origin-not-explicit-style.svg: Added.

Source/WebCore:

Add temp fix to use previously ignored transform-origin in SVGGraphicsElement::animatedLocalTransform
if not explicitly set in style. Proper fix to come: https://bugs.webkit.org/show_bug.cgi?id=232128.

Tests: imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-ref.svg
       imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style.svg

* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::animatedLocalTransform const):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (284852 => 284853)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-26 00:34:53 UTC (rev 284852)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-26 01:44:38 UTC (rev 284853)
@@ -1,3 +1,13 @@
+2021-10-25  Nikolaos Mouchtaris  <[email protected]>
+
+        Fix issue for transform-origin in SVG
+        https://bugs.webkit.org/show_bug.cgi?id=232189
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-ref.svg: Added.
+        * web-platform-tests/svg/styling/render/transform-origin-not-explicit-style.svg: Added.
+
 2021-10-25  Chris Dumez  <[email protected]>
 
         Form navigations with target=_blank should not have an opener

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-visual-expected.svg (0 => 284853)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-visual-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-visual-expected.svg	2021-10-26 01:44:38 UTC (rev 284853)
@@ -0,0 +1,13 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:h="http://www.w3.org/1999/xhtml"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     width="300" height="200" viewBox="0 0 300 200">
+  <style>
+    rect {
+      fill: green;
+    }
+  </style>
+  <g transform="translate(140, 130)">
+    <rect x="-30" y="-20" width="80" height="30"/>
+  </g>
+</svg>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-visual.svg (0 => 284853)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-visual.svg	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-visual.svg	2021-10-26 01:44:38 UTC (rev 284853)
@@ -0,0 +1,18 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:h="http://www.w3.org/1999/xhtml"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     width="300" height="200" viewBox="0 0 300 200">
+  <metadata>
+    <h:link rel="help" href=""
+    <link rel="match" href=""
+    <h:meta name="assert" content="The transform-origin attribute impacts SVG rendering."/>
+  </metadata>
+  <style>
+    rect {
+      fill: green;
+    }
+  </style>
+  <g transform="translate(140, 130)">
+    <rect x="0" y="0" width="40" height="10" transform="scale(2, 3)" transform-origin="30 10"/>
+  </g>
+</svg>

Modified: trunk/Source/WebCore/ChangeLog (284852 => 284853)


--- trunk/Source/WebCore/ChangeLog	2021-10-26 00:34:53 UTC (rev 284852)
+++ trunk/Source/WebCore/ChangeLog	2021-10-26 01:44:38 UTC (rev 284853)
@@ -1,3 +1,19 @@
+2021-10-25  Nikolaos Mouchtaris  <[email protected]>
+
+        Fix issue for transform-origin in SVG
+        https://bugs.webkit.org/show_bug.cgi?id=232189
+
+        Reviewed by Simon Fraser.
+
+        Add temp fix to use previously ignored transform-origin in SVGGraphicsElement::animatedLocalTransform 
+        if not explicitly set in style. Proper fix to come: https://bugs.webkit.org/show_bug.cgi?id=232128.
+
+        Tests: imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style-ref.svg
+               imported/w3c/web-platform-tests/svg/styling/render/transform-origin-not-explicit-style.svg
+
+        * svg/SVGGraphicsElement.cpp:
+        (WebCore::SVGGraphicsElement::animatedLocalTransform const):
+
 2021-10-25  Chris Fleizach  <[email protected]>
 
         WebKit should use img@title as label even if img@alt is exlicitly empty

Modified: trunk/Source/WebCore/svg/SVGGraphicsElement.cpp (284852 => 284853)


--- trunk/Source/WebCore/svg/SVGGraphicsElement.cpp	2021-10-26 00:34:53 UTC (rev 284852)
+++ trunk/Source/WebCore/svg/SVGGraphicsElement.cpp	2021-10-26 01:44:38 UTC (rev 284853)
@@ -99,8 +99,13 @@
     }
 
     // If we didn't have the CSS "transform" property set, we must account for the "transform" attribute.
-    if (!hasSpecifiedTransform)
+    if (!hasSpecifiedTransform && style) {
+        auto boundingBox = SVGRenderSupport::transformReferenceBox(*renderer(), *this, *style);
+        auto t = floatPointForLengthPoint(style->transformOriginXY(), boundingBox.size());
+        matrix.translate(t);
         matrix *= transform().concatenate();
+        matrix.translate(-t.x(), -t.y());
+    }
 
     if (m_supplementalTransform)
         return *m_supplementalTransform * matrix;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to