SVGPaintServer* KSVGPainterFactory::strokePaintServer(const RenderStyle* style, const RenderObject* item) { if (!style->svgStyle()->hasStroke()) return 0; SVGPaint* stroke = style->svgStyle()->strokePaint(); SVGPaintServer* strokePaintServer = 0; if (stroke->paintType() == SVGPaint::SVG_PAINTTYPE_URI) { AtomicString id(SVGURIReference::getTarget(stroke->uri())); strokePaintServer = getPaintServerById(item->document(), id); SVGElement* svgElement = static_cast<SVGElement*>(item->element()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); if (item->isRenderPath() && strokePaintServer) strokePaintServer->addClient(static_cast<SVGStyledElement*>(svgElement)); else if (!strokePaintServer) svgElement->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement)); } else { strokePaintServer = sharedSolidPaintServer(); SVGPaintServerSolid* strokePaintServerSolid = static_cast<SVGPaintServerSolid*>(strokePaintServer); if (stroke->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) strokePaintServerSolid->setColor(style->color()); else strokePaintServerSolid->setColor(stroke->color()); // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT if (!strokePaintServerSolid->color().isValid()) strokePaintServer = 0; } return strokePaintServer; }
SVGPaintServer* SVGPaintServer::fillPaintServer(const RenderStyle* style, const RenderObject* item) { if (!style->svgStyle()->hasFill()) return 0; SVGPaint* fill = style->svgStyle()->fillPaint(); SVGPaintServer* fillPaintServer = 0; SVGPaint::SVGPaintType paintType = fill->paintType(); if (paintType == SVGPaint::SVG_PAINTTYPE_URI || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) { AtomicString id(SVGURIReference::getTarget(fill->uri())); fillPaintServer = getPaintServerById(item->document(), id); SVGElement* svgElement = static_cast<SVGElement*>(item->node()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); if (item->isRenderPath() && fillPaintServer) fillPaintServer->addClient(static_cast<SVGStyledElement*>(svgElement)); else if (!fillPaintServer && paintType == SVGPaint::SVG_PAINTTYPE_URI) svgElement->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement)); } if (paintType != SVGPaint::SVG_PAINTTYPE_URI && !fillPaintServer) { fillPaintServer = sharedSolidPaintServer(); SVGPaintServerSolid* fillPaintServerSolid = static_cast<SVGPaintServerSolid*>(fillPaintServer); if (paintType == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) fillPaintServerSolid->setColor(style->color()); else fillPaintServerSolid->setColor(fill->color()); // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT if (!fillPaintServerSolid->color().isValid()) fillPaintServer = 0; } if (!fillPaintServer) { // default value (black), see bug 11017 fillPaintServer = sharedSolidPaintServer(); static_cast<SVGPaintServerSolid*>(fillPaintServer)->setColor(Color::black); } return fillPaintServer; }