Bug 30286 - SVG Gradients can't handle percentage values in userSpaceOnUse mode
Summary: SVG Gradients can't handle percentage values in userSpaceOnUse mode
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-11 14:59 PDT by Dirk Schulze
Modified: 2009-10-12 16:05 PDT (History)
3 users (show)

See Also:


Attachments
Gradient in userspaceOnUse and percentage values (1.28 KB, image/svg+xml)
2009-10-11 14:59 PDT, Dirk Schulze
no flags Details
linearGradient userSpaceOnUse with percentage (11.61 KB, patch)
2009-10-12 05:30 PDT, Dirk Schulze
eric: review-
Details | Formatted Diff | Diff
gradient userSpaceOnUse with values in percentage (169.90 KB, patch)
2009-10-12 15:38 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Schulze 2009-10-11 14:59:02 PDT
Created attachment 41004 [details]
Gradient in userspaceOnUse and percentage values

On using gradientSpace="userSpaceOnUse" we can't handle x,y,width,height values in percentage correct. The percentage should use the Userspace as refernce. The example in the attachement shows the problem. The above 3 rects schould look like the 3 rects on the bottom.
Comment 1 Dirk Schulze 2009-10-12 05:30:48 PDT
Created attachment 41033 [details]
linearGradient userSpaceOnUse with percentage

Some clean up.
The problem was, that we transformed the values x1, ... y2 to doubles, saved them in LinearGradientAttributes and didn't differ between objectBoundingBox and userSpaceOnUse later.
I removed LinearGradientAttributes and take the values of SVGLinearGradientElement directly. We needed LinearGradientAttributes to draw the gradients on the old platform dependent code of SVGPaintServer. We don't need it anymore and calculate the box in the element itself.

The same has to be done on radialGradient too. I'll work on it once this code is landed.

I'll create the test results at home.
Comment 2 Eric Seidel (no email) 2009-10-12 07:11:34 PDT
Comment on attachment 41033 [details]
linearGradient userSpaceOnUse with percentage

This needs a ChangeLog and a test.  Otherwise I think this is a good change, but can't really tell.
Comment 3 Nikolas Zimmermann 2009-10-12 09:24:23 PDT
Hm, on first sight the change looks wrong to me. The whole idea behind LinearGradientAttributes is to correctly handle deep-nested gradients (aka. gradient referencing another gradient using xlink:href). We need to be careful to take the _right_ x1/y1/.. values from the correct origin.

Are you sure this doesn't break existing tests? If it doesn't, something is wrong :-)
Comment 4 Dirk Schulze 2009-10-12 15:38:33 PDT
Created attachment 41064 [details]
gradient userSpaceOnUse with values in percentage

This patch fixes both radial as well as linear gradients. It gives GradientAttributes SVGLength values instead of double. This makes it possible to calculate the correct result on userSpaceOnUse mode with values in percentage.
Comment 5 Nikolas Zimmermann 2009-10-12 15:45:16 PDT
Comment on attachment 41064 [details]
gradient userSpaceOnUse with values in percentage

Excellent job, r=me.
Comment 6 WebKit Commit Bot 2009-10-12 16:05:30 PDT
Comment on attachment 41064 [details]
gradient userSpaceOnUse with values in percentage

Clearing flags on attachment: 41064

Committed r49481: <http://trac.webkit.org/changeset/49481>
Comment 7 WebKit Commit Bot 2009-10-12 16:05:34 PDT
All reviewed patches have been landed.  Closing bug.