Need function for manual style-resolution for things like gradient stops
Vector<SVGGradientStop> SVGGradientElement::buildStops() const
// FIXME: Manual style resolution is a hack
RenderStyle* gradientStyle = const_cast<SVGGradientElement*>(this)->styleForRenderer(parent()->renderer());
Gradient stops must inherit style via CSS. The WebCore render tree is optimized not to bother computing styles for any node which does not have a renderer. Furthermore, if anynode does not have a renderer, none of its ancestors do either. Thus nodes like <defs> cause style resolution trouble.
In these cases, there should be a special function styleForResolution() (or better named), which can be used by SVG element which need to resolve style across "holes" in the render tree (as are to be expected by things such as <defs> <*Gradient> and possibly eventually <pattern>.
Right now the current solution for gradients breaks when gradients are inside <defs> (I think).
We should chat about this at some point. I don't think you need a new function necessarily.
I'm not sure I'm able to come up with a test case to demonstrate this. This one seems to work fine in TOT:
<svg xmlns="http://www.w3.org/2000/svg" style='color: green'>
<linearGradient id='gradient' x2='5'>
<stop offset='0' stop-color='currentColor' />
<stop offset='1' stop-color='red' />
<rect fill="url(#gradient)" width='100px' height='100px' />
I still think a function do use to do this more cleanly would be nice.
An alternative way to fix all this is to actually make gradient stops have real renderers with real styles, such as suggested in:
This would also require <defs> to have a renderer, as mentioned in:
*** Bug 12545 has been marked as a duplicate of this bug. ***
Landed in r25175.