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'> <defs> <linearGradient id='gradient' x2='5'> <stop offset='0' stop-color='currentColor' /> <stop offset='1' stop-color='red' /> </linearGradient> </defs> <rect fill="url(#gradient)" width='100px' height='100px' /> </svg> 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: http://bugs.webkit.org/show_bug.cgi?id=12193 This would also require <defs> to have a renderer, as mentioned in: http://bugs.webkit.org/show_bug.cgi?id=12207
*** Bug 12545 has been marked as a duplicate of this bug. ***
Landed in r25175.