Bug 51843

Summary: Implement repeating CSS3 gradients
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: CSSAssignee: Simon Fraser (smfr) <simon.fraser>
Status: RESOLVED FIXED    
Severity: Normal CC: krit, peter, simon.fraser, webmaster
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
URL: http://dev.w3.org/csswg/css3-images/#gradients
Attachments:
Description Flags
Patch hyatt: review+

Description Simon Fraser (smfr) 2011-01-03 12:01:56 PST
CSS3 has repeating gradients, which need to be implemented.
Comment 1 Simon Fraser (smfr) 2011-01-05 12:39:27 PST
Created attachment 78028 [details]
Patch
Comment 2 Dave Hyatt 2011-01-05 12:44:17 PST
Comment on attachment 78028 [details]
Patch

The 60 lines of code in addStops might be better off in a separate function.

r=me though whatever you decide to do.
Comment 3 Simon Fraser (smfr) 2011-01-05 13:07:46 PST
http://trac.webkit.org/changeset/75097
Comment 4 Dirk Schulze 2011-01-07 08:36:15 PST
(In reply to comment #3)
> http://trac.webkit.org/changeset/75097

Is it possible to pull this down to Gradient? This way platforms could benefit of their own implementations and we could reuse the code for SVG.
Comment 5 Simon Fraser (smfr) 2011-01-07 08:51:26 PST
(In reply to comment #4)
> (In reply to comment #3)
> > http://trac.webkit.org/changeset/75097
> 
> Is it possible to pull this down to Gradient? This way platforms could benefit of their own implementations and we could reuse the code for SVG.

No, because you have to know the size of the box being rendered into to know how many repeats you add.

This cannot be in Gradient, because a single Gradient may be re-used to render to different places.
Comment 6 Dirk Schulze 2011-01-07 11:17:25 PST
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > http://trac.webkit.org/changeset/75097
> > 
> > Is it possible to pull this down to Gradient? This way platforms could benefit of their own implementations and we could reuse the code for SVG.
> 
> No, because you have to know the size of the box being rendered into to know how many repeats you add.
> 
> This cannot be in Gradient, because a single Gradient may be re-used to render to different places.

Hm. You're right, gradient should be as independent of the drawing area as possible to reuse it :-/ But you'Re adding the color stops manually, so reusing it might cause the gradient to be not-reusable as well.

And what about adding supportsSpreadMethods() to Gradient and add a check CSSGradientValue::addStops? Platforms could decide for their own if they return true or false. setSpreadMethod is also able to handle more than just repeating and pad (default). Doesn't CSS support reflection as well (http://doc.trolltech.com/4.7/qradialgradient.html)?
Comment 7 Simon Fraser (smfr) 2011-01-07 11:26:28 PST
> Hm. You're right, gradient should be as independent of the drawing area as possible to reuse it :-/ But you're adding the color stops manually, so reusing it might cause the gradient to be not-reusable as well.

In CSSGradientValue I know that this Gradient is only used to render into boxes of a given size.

> And what about adding supportsSpreadMethods() to Gradient and add a check CSSGradientValue::addStops? Platforms could decide for their own if they return true or false. setSpreadMethod is also able to handle more than just repeating and pad (default). Doesn't CSS support reflection as well (http://doc.trolltech.com/4.7/qradialgradient.html)?

That sounds OK.