Bug 138439 - Revert a change in SVGRenderSupport::mapLocalToContainer committed for fixing <https://bugs.webkit.org/show_bug.cgi?id=119626>
Summary: Revert a change in SVGRenderSupport::mapLocalToContainer committed for fixing...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords:
: 119626 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-11-05 14:40 PST by Said Abou-Hallawa
Modified: 2015-02-16 15:19 PST (History)
16 users (show)

See Also:


Attachments
Patch (4.33 KB, patch)
2014-11-06 18:17 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (4.37 KB, patch)
2014-11-13 19:26 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (6.18 KB, patch)
2015-02-13 21:13 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Example (347 bytes, text/html)
2015-02-15 14:55 PST, Said Abou-Hallawa
no flags Details
Example (410 bytes, text/html)
2015-02-15 14:58 PST, Said Abou-Hallawa
no flags Details
Patch (6.20 KB, patch)
2015-02-16 14:33 PST, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2014-11-05 14:40:26 PST
The original fix <https://bugs.webkit.org/show_bug.cgi?id=119626> was just porting the Blink fix <https://codereview.chromium.org/143363004>.  This change causes the WebKit search in SVG to be broken.  And it was also reverted from Blink because it broke their SVG rendering.
Comment 1 Said Abou-Hallawa 2014-11-06 18:17:05 PST
Created attachment 241153 [details]
Patch
Comment 2 Said Abou-Hallawa 2014-11-06 18:23:03 PST
*** Bug 119626 has been marked as a duplicate of this bug. ***
Comment 3 Simon Fraser (smfr) 2014-11-06 18:27:20 PST
Comment on attachment 241153 [details]
Patch

This patch needs a layout test (or two).
Comment 4 Said Abou-Hallawa 2014-11-13 19:26:00 PST
Created attachment 241530 [details]
Patch
Comment 5 Said Abou-Hallawa 2014-11-13 19:31:15 PST
After talking to Simon, he agreed on not submitting more layout tests. The original fix submitted the test svg/transforms/svg-geometry-crash.html which was firing an assertion. To revert the fix and keep the test, I had to come with the right fix which fixes the assertion and does not break the layout.
Comment 6 Said Abou-Hallawa 2015-02-13 21:13:45 PST
Created attachment 246575 [details]
Patch
Comment 7 Simon Fraser (smfr) 2015-02-13 22:17:52 PST
Comment on attachment 246575 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=246575&action=review

> Source/WebCore/rendering/svg/SVGRenderSupport.cpp:94
> +        transform = downcast<RenderSVGRoot>(parent).localToBorderBoxTransform() * renderer.localToParentTransform();

What is renderer.localToParentTransform() for the SVG root? I'm confused that you need both this and localToBorderBoxTransform.
Comment 8 Said Abou-Hallawa 2015-02-15 14:55:53 PST
Created attachment 246623 [details]
Example
Comment 9 Said Abou-Hallawa 2015-02-15 14:56:52 PST
(In reply to comment #7)
> Comment on attachment 246575 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=246575&action=review
> 
> > Source/WebCore/rendering/svg/SVGRenderSupport.cpp:94
> > +        transform = downcast<RenderSVGRoot>(parent).localToBorderBoxTransform() * renderer.localToParentTransform();
> 
> What is renderer.localToParentTransform() for the SVG root? I'm confused
> that you need both this and localToBorderBoxTransform.

Consider the following example (attached):

<html>
<head>
  <style>
  svg {
    width: 200px;
    height: 200px;
    background-color: lime;
  }
  </style>
</head>
<body>
  <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewbox="-100 -100 200 200">
    <rect x="0" y="0" width="100" height="100" fill="orange"/>
	<rect x="0" y="0" width="100" height="100" transform="translate(50,50) scale(0.5, 0.5)" fill="red"/>
  </svg>
</body>
</html>

To get the localToParentTransform for a point in the red rectangle you need to do the following:
-- Get localToParentTransform in SVG coordinate which is:
   = translate(50,50) * scale(0.5, 0.5)
-- Since the parent is the SVG root, we need to map from SVG coordinates to the css coordinates. And since the viewbox="-100 -100 200 200", the localToBorderBoxTransform of the SVG root is:
   = translate(100, 100).
-- So the localToParentTransform of a point in the red rectangle is css coordinate is:
   = translate(100, 100) * translate(50, 50) * scale(0.5, 0.5)
   = translate(150, 150) * scale(0.5, 0.5)

As a concrete example, let's map the center of the red rectangle from local coordinate (which is in SVG coordinates) to parent css coordinates.

-- The center of the red rectangle in local SVG coordinates is:
   p1 = (50,50)
-- Map p1 from local SVG coordinates to parent SVG coordinates:
   p2 = translate(50, 50) * scale(0.5, 0.5) * p1 = (75,75)
-- Map p2 from parent SVG coordinates to CSS coordinates:
   p3 = translate(100, 100) * p2 = (175,175)

which is the correct mapping.

Also notice that SVGRenderSupport::mapLocalToContainer() and SVGRenderSupport::pushMappingToContainer() handle the children SVG elements only. 
RenderSVGRoot does not call these methods and implements its own ones which expect local css box coordinates.
Comment 10 Said Abou-Hallawa 2015-02-15 14:58:00 PST
Created attachment 246624 [details]
Example
Comment 11 WebKit Commit Bot 2015-02-16 14:28:26 PST
Comment on attachment 246575 [details]
Patch

Rejecting attachment 246575 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-02', 'validate-changelog', '--check-oops', '--non-interactive', 246575, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

/Volumes/Data/EWS/WebKit/Source/WebCore/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).

Full output: http://webkit-queues.appspot.com/results/6731636418805760
Comment 12 Said Abou-Hallawa 2015-02-16 14:33:39 PST
Created attachment 246684 [details]
Patch
Comment 13 WebKit Commit Bot 2015-02-16 15:19:33 PST
Comment on attachment 246684 [details]
Patch

Clearing flags on attachment: 246684

Committed r180179: <http://trac.webkit.org/changeset/180179>
Comment 14 WebKit Commit Bot 2015-02-16 15:19:40 PST
All reviewed patches have been landed.  Closing bug.