Bug 30286

Summary: SVG Gradients can't handle percentage values in userSpaceOnUse mode
Product: WebKit Reporter: Dirk Schulze <krit>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric, zimmermann
Priority: P2    
Version: 525.x (Safari 3.1)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
Gradient in userspaceOnUse and percentage values
none
linearGradient userSpaceOnUse with percentage
eric: review-
gradient userSpaceOnUse with values in percentage none

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.