NEW 267401
Explore the 'serialization' issue in getAttribute('transform')
https://bugs.webkit.org/show_bug.cgi?id=267401
Summary Explore the 'serialization' issue in getAttribute('transform')
Ahmad Saleem
Reported 2024-01-11 01:55:53 PST
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'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 'negative' issue but now this is to understand whether we need to do anything for 'comma' serialization. Thanks!
Attachments
Radar WebKit Bug Importer
Comment 2 2024-01-18 01:56:14 PST
Brent Fulgham
Comment 3 2024-01-29 09:42:06 PST
@Karl: Are you saying there is no bug here?
Karl Dubost
Comment 4 2024-01-29 19:12:40 PST
@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('http://www.w3.org/2000/svg', 'svg'); var g = document.createElementNS('http://www.w3.org/2000/svg', 'g'); var transform = svg.createSVGTransform(); transform.setScale(-2, -4); g.transform.baseVal.appendItem(transform) g.getAttribute('transform') 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's modification, Safari returns like Chrome. The spec says: https://drafts.csswg.org/css-transforms/#funcdef-transform-scale scale() = scale( <number> , <number>? ) 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('transform').
Karl Dubost
Comment 5 2024-01-29 21:35:29 PST
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 "scale(" 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. ")" here in https://searchfox.org/wubkat/rev/e65977cbea63da31c3c8c9644d8384bb27fe46d0/Source/WebCore/svg/SVGTransformValue.h#246-254 It adds a space instead of a comma.
Karl Dubost
Comment 6 2024-01-29 22:02:16 PST
Note You need to log in before you can comment on or make changes to this bug.