<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>267401</bug_id>
          
          <creation_ts>2024-01-11 01:55:53 -0800</creation_ts>
          <short_desc>Explore the &apos;serialization&apos; issue in getAttribute(&apos;transform&apos;)</short_desc>
          <delta_ts>2024-01-29 22:02:16 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=264752</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>karlcow</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2004378</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-11 01:55:53 -0800</bug_when>
    <thetext>Hi Team,

This is separate bug from bug 264752 to explore following identified by Karl:

There are potentially two different issues 
* negative to positive number
* serialization with/without comma
as the 3 browsers return something different. 



         IN             OUT
Safari:  scale(-2, -4)  scale(2 4).   No comma, positive numbers
Firefox: scale(-2, -4)  scale(-2, -4) Comma, negative numbers
Chrome:  scale(-2, -4)  scale(-2 -4)  No comma, negative numbers

I have the feeling that Firefox is right here for the comma.
https://drafts.csswg.org/css-transforms/#funcdef-transform-scale
I didn&apos;t find a reference why it should be serialize differently, aka without the comma. 


But WebKit definitely needs to return negative numbers.

__

We have fixed &apos;negative&apos; issue but now this is to understand whether we need to do anything for &apos;comma&apos; serialization.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004593</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-11 18:35:20 -0800</bug_when>
    <thetext>The parsing is correct in 
https://searchfox.org/wubkat/rev/889804f28206ffa2dd7930e2e52df50dc4260049/Source/WebCore/svg/SVGTransformable.cpp#127-131</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005797</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-01-18 01:56:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/121178816&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2008530</commentid>
    <comment_count>3</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2024-01-29 09:42:06 -0800</bug_when>
    <thetext>@Karl: Are you saying there is no bug here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2008782</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-29 19:12:40 -0800</bug_when>
    <thetext>@Brent
in Bug 264752, Ahmad fixed part of the serialization.
The changes are in 
https://github.com/WebKit/WebKit/pull/22475/files
The test code though should be a WPT test, instead of something Apple only.

The test is this:
var svg = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;svg&apos;);
var g = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;g&apos;);
var transform = svg.createSVGTransform();
transform.setScale(-2, -4);
g.transform.baseVal.appendItem(transform)
g.getAttribute(&apos;transform&apos;)


Before Bug 264752:
         IN             OUT
Safari:  scale(-2, -4)  scale(2 4).   No comma, positive numbers
Firefox: scale(-2, -4)  scale(-2, -4) Comma, negative numbers
Chrome:  scale(-2, -4)  scale(-2 -4)  No comma, negative numbers

After Bug 264752 (Tested in minibrowser ToT of today):
         IN             OUT
Safari:  scale(-2, -4)  scale(-2 -4).   No comma, negative numbers

So Ahmad fixed the part, where the values were transformed as positive numbers!

Now there is the difference in between Firefox and Chrome.
With Ahmad&apos;s modification, Safari returns like Chrome.


The spec says:
https://drafts.csswg.org/css-transforms/#funcdef-transform-scale

scale() = scale( &lt;number&gt; , &lt;number&gt;? )
specifies a 2D scale operation by the [sx,sy] scaling vector described by the 2 parameters. If the second parameter is not provided, it takes a value equal to the first. For example, scale(1, 1) would leave an element unchanged, while scale(2, 2) would cause it to appear twice as long in both the X and Y axes, or four times its typical geometric size.

Note the comma, there is nothing which says it should be serialized without a comma.
So I think there is a bug in both Chrome and Safari, that needs to be fixed.


And fwiw, 

setTranslate() has the same issue


So my initial comment is the parsing is correct, but the serialization is wrong when doing getAttribute(&apos;transform&apos;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2008816</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-29 21:35:29 -0800</bug_when>
    <thetext>https://searchfox.org/wubkat/rev/e65977cbea63da31c3c8c9644d8384bb27fe46d0/Source/WebCore/svg/SVGTransformValue.h#189-216

SVGTransformList::valueAsString() calls the list of items in the transform and make a loop and add the serialized values separated by spaces.

1. append a prefix, for example &quot;scale(&quot;
2. call an appendSomething function depending on type, for example appendScale(builder)
3. This is calling appendFixedPrecisionNumbers
4. which in the end will add the closing parenthesis. &quot;)&quot;

here in https://searchfox.org/wubkat/rev/e65977cbea63da31c3c8c9644d8384bb27fe46d0/Source/WebCore/svg/SVGTransformValue.h#246-254

It adds a space instead of a comma.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2008820</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-01-29 22:02:16 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/23492</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>