Bug 267401
| Summary: | Explore the 'serialization' issue in getAttribute('transform') | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
| Component: | SVG | Assignee: | Karl Dubost <karlcow> |
| Status: | NEW | ||
| Severity: | Normal | CC: | bfulgham, karlcow, sabouhallawa, webkit-bug-importer, zimmermann |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=264752 | ||
Ahmad Saleem
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Karl Dubost
The parsing is correct in
https://searchfox.org/wubkat/rev/889804f28206ffa2dd7930e2e52df50dc4260049/Source/WebCore/svg/SVGTransformable.cpp#127-131
Radar WebKit Bug Importer
<rdar://problem/121178816>
Brent Fulgham
@Karl: Are you saying there is no bug here?
Karl Dubost
@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
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
Pull request: https://github.com/WebKit/WebKit/pull/23492