Bug 99984

Summary: [SVG] SVGPreserveAspectRatio::transformRect is done incorrectly in 'slice' mode
Product: WebKit Reporter: Branimir Lambov <blambov>
Component: SVGAssignee: Philip Rogers <pdr>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, d-r, eric, fmalita, gyuyoung.kim, krit, pdr, rakuco, schenney, webkit.review.bot, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 98403    
Attachments:
Description Flags
Patch
none
Current rendering
none
Expected rendering as done by Firefox (ignore the color differences)
none
Post-patch rendering
none
Patch
none
Testcase
none
Patch
none
Failing <image> testcase
none
Patch
none
Patch
zimmermann: review+, buildbot: commit-queue-
Rebased patch
webkit.review.bot: commit-queue-
Rebased patch (2)
webkit.review.bot: commit-queue-
Rebased patch (3) krit: review+

Branimir Lambov
Reported 2012-10-22 05:31:54 PDT
It uses destRect location in calculating positioning within the src rect. These two files in the test suite are rendered wrong as a result: svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html
Attachments
Patch (7.71 KB, patch)
2012-10-22 05:39 PDT, Branimir Lambov
no flags
Current rendering (74.79 KB, image/png)
2012-10-22 06:46 PDT, Branimir Lambov
no flags
Expected rendering as done by Firefox (ignore the color differences) (91.09 KB, image/png)
2012-10-22 06:47 PDT, Branimir Lambov
no flags
Post-patch rendering (74.33 KB, image/png)
2012-10-22 06:49 PDT, Branimir Lambov
no flags
Patch (8.07 KB, patch)
2012-11-06 08:12 PST, Branimir Lambov
no flags
Testcase (4.14 KB, image/svg+xml)
2012-11-07 09:05 PST, Branimir Lambov
no flags
Patch (12.66 KB, patch)
2012-11-07 09:17 PST, Branimir Lambov
no flags
Failing <image> testcase (3.33 KB, image/svg+xml)
2012-11-07 10:04 PST, Branimir Lambov
no flags
Patch (144.63 KB, patch)
2012-12-04 05:13 PST, Branimir Lambov
no flags
Patch (144.74 KB, patch)
2012-12-05 07:46 PST, Branimir Lambov
zimmermann: review+
buildbot: commit-queue-
Rebased patch (166.82 KB, patch)
2013-02-18 20:15 PST, Philip Rogers
webkit.review.bot: commit-queue-
Rebased patch (2) (166.65 KB, patch)
2013-02-18 21:37 PST, Philip Rogers
webkit.review.bot: commit-queue-
Rebased patch (3) (167.82 KB, patch)
2013-02-19 12:07 PST, Philip Rogers
krit: review+
Branimir Lambov
Comment 1 2012-10-22 05:39:23 PDT
Dirk Schulze
Comment 2 2012-10-22 06:16:03 PDT
(In reply to comment #0) > It uses destRect location in calculating positioning within the src rect. > > These two files in the test suite are rendered wrong as a result: > svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html > svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html You want a review for something that makes the rendering wrong? :P Can you be more explicit please? How is it different? How does it differ in comparison to other UAs? Can you share pictures please?
Branimir Lambov
Comment 3 2012-10-22 06:46:27 PDT
Created attachment 169896 [details] Current rendering
Branimir Lambov
Comment 4 2012-10-22 06:47:14 PDT
Created attachment 169897 [details] Expected rendering as done by Firefox (ignore the color differences)
Branimir Lambov
Comment 5 2012-10-22 06:49:54 PDT
Created attachment 169898 [details] Post-patch rendering
Branimir Lambov
Comment 6 2012-10-22 06:56:28 PDT
Before the patch, the girl's head was being drawn lower than it should be because the location of the wrong rect was used in the code. Moreover, the crop changes with the positioning of the target rectangle (try adding a 'y=100' attribute to the filtered rect: the position of the image with respect to the rectangle will remain the same in Firefox and Opera (correct), but will change in WebKit (wrong)).
Branimir Lambov
Comment 7 2012-11-05 03:17:47 PST
I'm still waiting for a review.
Dirk Schulze
Comment 8 2012-11-05 06:29:41 PST
Comment on attachment 169886 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169886&action=review Sorry, was traveling. The fix sounds good then. But have some comments. > Source/WebCore/ChangeLog:8 > + Corrects SVG aspect ratio calculations in 'slice' mode. Can you add more detail please? What is the problem? What have you done in order to fix the problem? What causes the problem and so on. > Source/WebCore/ChangeLog:13 > + * svg/SVGPreserveAspectRatio.cpp: > + (WebCore::SVGPreserveAspectRatio::transformRect): Inline comments behind functions can be very helpful as well. > LayoutTests/ChangeLog:8 > + [SVG] SVGPreserveAspectRatio::transformRect is done incorrectly in 'slice' mode > + https://bugs.webkit.org/show_bug.cgi?id=99984 > + > + Reviewed by NOBODY (OOPS!). > + > + Corrects SVG aspect ratio calculations in 'slice' mode. I would like to have more tests. It is not good if it is just triggered by SVGFEImage. Can you add a test for <svg> and preserve aspect ratio (hopefully a ref test)? A test with <image> would be preferred as well.
Branimir Lambov
Comment 9 2012-11-06 08:12:20 PST
Dirk Schulze
Comment 10 2012-11-06 08:14:21 PST
Comment on attachment 172593 [details] Patch I am unsure if you didn't read my last comment. I would like to have some new tests for <svg> and <image>, since they use SVGPreserveAspectRatio as well.
Branimir Lambov
Comment 11 2012-11-06 08:16:52 PST
View in context: https://bugs.webkit.org/attachment.cgi?id=169886&action=review >> Source/WebCore/ChangeLog:8 >> + Corrects SVG aspect ratio calculations in 'slice' mode. > > Can you add more detail please? What is the problem? What have you done in order to fix the problem? What causes the problem and so on. Done. >> Source/WebCore/ChangeLog:13 >> + (WebCore::SVGPreserveAspectRatio::transformRect): > > Inline comments behind functions can be very helpful as well. Done. >> LayoutTests/ChangeLog:8 >> + Corrects SVG aspect ratio calculations in 'slice' mode. > > I would like to have more tests. It is not good if it is just triggered by SVGFEImage. Can you add a test for <svg> and preserve aspect ratio (hopefully a ref test)? A test with <image> would be preferred as well. The offending code is currently only used by SVGFEImage (see http://code.google.com/p/chromium/source/search?q=transformrect). There already exist multiple aspect ratio tests of <img>, css backgroundImage etc., but they do not currently hit this particular method. There's a battery of tests of the functionality as part of the patch for bug 98403, which applies transformRect to a wider range of situations.
Dirk Schulze
Comment 12 2012-11-06 08:21:13 PST
(In reply to comment #11) > The offending code is currently only used by SVGFEImage (see http://code.google.com/p/chromium/source/search?q=transformrect). There already exist multiple aspect ratio tests of <img>, css backgroundImage etc., but they do not currently hit this particular method. Obviously none of the tests failed, since you didn't need to rebaseline. Therefore, these tests don't test your functional change. > > There's a battery of tests of the functionality as part of the patch for bug 98403, which applies transformRect to a wider range of situations. If there are tests in bug 98403 that run into this issue, please add them into this patch. Again, I would like to see tests where you run into this issue for the elements <svg> and <image> (not <img>).
Branimir Lambov
Comment 13 2012-11-07 09:05:20 PST
Created attachment 172818 [details] Testcase
Branimir Lambov
Comment 14 2012-11-07 09:17:52 PST
Branimir Lambov
Comment 15 2012-11-07 09:20:25 PST
<img> and <svg> use SVGPreserveAspectRatio::getCTM and are not affected by this bug. I added an exhaustive test for <feImage>, which tests all aspect ratio choices that can hit SVGPreserveAspectRatio::transformRect.
Dirk Schulze
Comment 16 2012-11-07 09:21:46 PST
Comment on attachment 172820 [details] Patch This is the same test as LayoutTests/svg/W3C-SVG-1.1-SE/filters-image-05-f.svg You don't need to upload it again. I wonder why we don't have the same problem in other cases like LayoutTests/svg/W3C-SVG-1.1/coords-viewattr-02-b.svg Which does exactly the same on <image> and does not fail. I would like to know why it doesn't fail before approving this patch. Maybe it is a bug in FEImage instead, maybe SVGImageElement has hacks that need to be removed. Maybe the test is slightly different, in which case we need tests for <image> as well.
Branimir Lambov
Comment 17 2012-11-07 09:22:23 PST
Sorry, <img> should have been <image> above.
Branimir Lambov
Comment 18 2012-11-07 09:26:33 PST
You do not have this problem in W3C-SVG-1.1-SE/filters-image-05-f.svg because it uses translation to bring the source and destination locations to 0, 0. In that case the old code does not fail. The new tests specifies non-zero destination location and fails.
Dirk Schulze
Comment 19 2012-11-07 09:32:20 PST
(In reply to comment #15) > <img> and <svg> use SVGPreserveAspectRatio::getCTM and are not affected by this bug. > > I added an exhaustive test for <feImage>, which tests all aspect ratio choices that can hit SVGPreserveAspectRatio::transformRect. RenderSVGImage uses: SVGImageElement* imageElement = static_cast<SVGImageElement*>(node()); imageElement->preserveAspectRatio().transformRect(destRect, srcRect); So it might be affected as well, no?
Dirk Schulze
Comment 20 2012-11-07 09:53:39 PST
(In reply to comment #18) > You do not have this problem in W3C-SVG-1.1-SE/filters-image-05-f.svg because it uses translation to bring the source and destination locations to 0, 0. In that case the old code does not fail. > > The new tests specifies non-zero destination location and fails. This makes sense to me.
Dirk Schulze
Comment 21 2012-11-07 09:55:20 PST
Comment on attachment 172820 [details] Patch The new file has no expectation. Can you add one please? Then I can r+ it.
Branimir Lambov
Comment 22 2012-11-07 10:04:34 PST
Created attachment 172827 [details] Failing <image> testcase You were right, <image> can fail as well. I could swear chromium code search couldn't find the RenderSVGImage reference a couple of days ago. My mistake. Adding a new test case for <image> and the expected results.
Branimir Lambov
Comment 23 2012-12-04 05:13:29 PST
Stephen Chenney
Comment 24 2012-12-05 07:31:18 PST
Comment on attachment 177468 [details] Patch LayoutTests/svg/image-preserveAspectRatio-all.svg should appear in svg/as-image Otherwise this is right. But I'm not an approved reviewer, so someone else will have to do the final R+.
Branimir Lambov
Comment 25 2012-12-05 07:46:28 PST
Build Bot
Comment 26 2012-12-05 09:26:59 PST
Comment on attachment 177747 [details] Patch Attachment 177747 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/15148543 New failing tests: svg/as-image/image-preserveAspectRatio-all.svg svg/filters/feImage-preserveAspectRatio-all.svg
Nikolas Zimmermann
Comment 27 2012-12-20 05:30:38 PST
Comment on attachment 177747 [details] Patch I agree with Dirk that the ChangeLog could be more descriptive, you're telling us what was done but not why. Ideally you'd reference the SVG spec formulas here, or some other source proving our implementation is wrong. That would have sped-up the review process :-) Anyhow, please be careful with not breaking mac EWS, it's red. I'll r+ this, but Dirk or others can feel free to r- it again, if the ChangeLog should be updated for instance.
Philip Rogers
Comment 28 2013-02-18 20:15:55 PST
Created attachment 188976 [details] Rebased patch Yikes! We let a good patch go stale. Branimir is no longer working on this stuff. I've rebased his patch and updated the ChangeLog as was requested by the reviewers.
WebKit Review Bot
Comment 29 2013-02-18 20:17:40 PST
Attachment 188976 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/platform/chromium/TestExpectations', u'LayoutTests/platform/chromium/svg/as-image/image-preserveAspectRatio-all-expected.png', u'LayoutTests/platform/chromium/svg/as-image/image-preserveAspectRatio-all-expected.txt', u'LayoutTests/platform/chromium/svg/filters/feImage-preserveAspectRatio-all-expected.png', u'LayoutTests/platform/chromium/svg/filters/feImage-preserveAspectRatio-all-expected.txt', u'LayoutTests/platform/efl/TestExpectations', u'LayoutTests/platform/mac/TestExpectations', u'LayoutTests/platform/qt/TestExpectations', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg', u'Source/WebCore/ChangeLog', u'Source/WebCore/svg/SVGPreserveAspectRatio.cpp']" exit_code: 1 LayoutTests/platform/chromium/svg/filters/feImage-preserveAspectRatio-all-expected.png:0: Have to enable auto props in the subversion config file (/home/alancutter/.subversion/config "enable-auto-props = yes"). Have to set the svn:mime-type in the subversion config file (/home/alancutter/.subversion/config "*.png = svn:mime-type=image/png"). [image/png] [5] Total errors found: 1 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 30 2013-02-18 21:06:38 PST
Comment on attachment 188976 [details] Rebased patch Attachment 188976 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16629206 New failing tests: svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html
Philip Rogers
Comment 31 2013-02-18 21:37:38 PST
Created attachment 188983 [details] Rebased patch (2) SVN1.7 vs SVN1.6 compatibility issues :/ Lets try this again.
WebKit Review Bot
Comment 32 2013-02-18 21:41:25 PST
Attachment 188983 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/platform/chromium/TestExpectations', u'LayoutTests/platform/efl/TestExpectations', u'LayoutTests/platform/gtk/TestExpectations', u'LayoutTests/platform/mac/TestExpectations', u'LayoutTests/platform/qt/TestExpectations', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg', u'Source/WebCore/ChangeLog', u'Source/WebCore/svg/SVGPreserveAspectRatio.cpp']" exit_code: 1 LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png:0: Have to enable auto props in the subversion config file (/home/alancutter/.subversion/config "enable-auto-props = yes"). Have to set the svn:mime-type in the subversion config file (/home/alancutter/.subversion/config "*.png = svn:mime-type=image/png"). [image/png] [5] Total errors found: 1 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 33 2013-02-18 22:26:27 PST
Comment on attachment 188983 [details] Rebased patch (2) Attachment 188983 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16613513 New failing tests: svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html
Philip Rogers
Comment 34 2013-02-19 12:07:44 PST
Created attachment 189134 [details] Rebased patch (3)
WebKit Review Bot
Comment 35 2013-02-19 12:10:22 PST
Attachment 189134 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/platform/chromium/TestExpectations', u'LayoutTests/platform/efl/TestExpectations', u'LayoutTests/platform/gtk/TestExpectations', u'LayoutTests/platform/mac/TestExpectations', u'LayoutTests/platform/qt/TestExpectations', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt', u'LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt', u'LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg', u'Source/WebCore/ChangeLog', u'Source/WebCore/svg/SVGPreserveAspectRatio.cpp']" exit_code: 1 LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png:0: Have to enable auto props in the subversion config file (/home/alancutter/.subversion/config "enable-auto-props = yes"). Have to set the svn:mime-type in the subversion config file (/home/alancutter/.subversion/config "*.png = svn:mime-type=image/png"). [image/png] [5] Total errors found: 1 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Philip Rogers
Comment 36 2013-02-19 12:14:09 PST
Comment on attachment 189134 [details] Rebased patch (3) Marking for review. I think the style checker is wrong to flag this patch (the mimetype property is properly set). I'll file a separate bug for that.
Philip Rogers
Comment 37 2013-02-19 12:22:58 PST
(In reply to comment #36) > (From update of attachment 189134 [details]) > Marking for review. I think the style checker is wrong to flag this patch (the mimetype property is properly set). I'll file a separate bug for that. As promised, bug for the style checker warning: https://bugs.webkit.org/show_bug.cgi?id=110249
Dirk Schulze
Comment 38 2013-02-19 14:22:34 PST
Comment on attachment 189134 [details] Rebased patch (3) r=me
Philip Rogers
Comment 39 2013-02-19 15:06:25 PST
Note You need to log in before you can comment on or make changes to this bug.