RESOLVED FIXED 172901
Percentages are calculated wrong in SVG transform CSS property
https://bugs.webkit.org/show_bug.cgi?id=172901
Summary Percentages are calculated wrong in SVG transform CSS property
kari.pihkala
Reported 2017-06-04 00:47:12 PDT
Created attachment 311955 [details] CSS Transform Test Case The transform CSS property calculates percentages wrong in SVG. They should be relative to the parent viewport, but they seem to be relative to the element’s size. This can be seen by changing the blue rectangle’s width in the test case. In the test case, the blue rectangles should be close to the middle line. The blue one on the right side of the line, the aqua colored at the center. The rectangles should follow the line if the browser window is resized. Firefox can display the test case correctly.
Attachments
CSS Transform Test Case (655 bytes, image/svg+xml)
2017-06-04 00:47 PDT, kari.pihkala
no flags
Patch (10.76 KB, patch)
2017-06-04 22:07 PDT, Simon Fraser (smfr)
no flags
Symbol Test Case (882 bytes, image/svg+xml)
2017-06-04 22:47 PDT, kari.pihkala
no flags
kari.pihkala
Comment 1 2017-06-04 00:53:20 PDT
Simon Fraser (smfr)
Comment 2 2017-06-04 19:21:11 PDT
In a recent Safari Tech Preview, we now support transform-box and fix the behavior of percentages. However, this seems to be broken if the <svg> has no explicit viewBox.
Simon Fraser (smfr)
Comment 3 2017-06-04 22:07:51 PDT
kari.pihkala
Comment 4 2017-06-04 22:47:14 PDT
Created attachment 311983 [details] Symbol Test Case Also <symbol> elements are affected. I've attached Symbol Test Case for it. I think your patch will fix them as well.
Simon Fraser (smfr)
Comment 5 2017-06-04 22:57:03 PDT
Yeah, that testcase looks fine with the fix.
WebKit Commit Bot
Comment 6 2017-06-04 23:09:04 PDT
Comment on attachment 311981 [details] Patch Clearing flags on attachment: 311981 Committed r217776: <http://trac.webkit.org/changeset/217776>
WebKit Commit Bot
Comment 7 2017-06-04 23:09:06 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 8 2017-06-06 09:40:20 PDT
Comment on attachment 311981 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=311981&action=review > Source/WebCore/svg/SVGGraphicsElement.cpp:94 > + FloatSize viewportSize; > + SVGLengthContext(this).determineViewport(viewportSize); > + boundingBox.setSize(viewportSize); What if determineViewport returns false? I ask because I want to do a bit of refactoring to use std::optional and I am wondering whether this code is asserting that determineViewport always returns true or if it is taking advantage of the fact that size will be 0x0 if it returns false.
Simon Fraser (smfr)
Comment 9 2017-06-06 10:44:50 PDT
(In reply to Darin Adler from comment #8) > Comment on attachment 311981 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=311981&action=review > > > Source/WebCore/svg/SVGGraphicsElement.cpp:94 > > + FloatSize viewportSize; > > + SVGLengthContext(this).determineViewport(viewportSize); > > + boundingBox.setSize(viewportSize); > > What if determineViewport returns false? I ask because I want to do a bit of > refactoring to use std::optional and I am wondering whether this code is > asserting that determineViewport always returns true or if it is taking > advantage of the fact that size will be 0x0 if it returns false. The latter.
Note You need to log in before you can comment on or make changes to this bug.