RenderSVGResource* RenderSVGResource::strokePaintingResource(const RenderObject* object, const RenderStyle* style) { ASSERT(object); ASSERT(style); const SVGRenderStyle* svgStyle = style->svgStyle(); if (!svgStyle || !svgStyle->hasStroke()) return 0; SVGPaint* strokePaint = svgStyle->strokePaint(); ASSERT(strokePaint); RenderSVGResource* strokePaintingResource = 0; FloatRect objectBoundingBox = object->objectBoundingBox(); SVGPaint::SVGPaintType paintType = strokePaint->paintType(); if (!objectBoundingBox.isEmpty() && (paintType == SVGPaint::SVG_PAINTTYPE_URI || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR)) { AtomicString id(SVGURIReference::getTarget(strokePaint->uri())); strokePaintingResource = getRenderSVGResourceContainerById(object->document(), id); if (!strokePaintingResource) registerPendingResource(id, paintType, object); } if (paintType != SVGPaint::SVG_PAINTTYPE_URI && !strokePaintingResource) { RenderSVGResourceSolidColor* solidResource = sharedSolidPaintingResource(); strokePaintingResource = solidResource; Color strokeColor; if (strokePaint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) strokeColor = style->visitedDependentColor(CSSPropertyColor); else strokeColor = strokePaint->color(); adjustColorForPseudoRules(style, false /* useFillPaint */, strokeColor); // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT if (strokeColor.isValid()) solidResource->setColor(strokeColor); else strokePaintingResource = 0; } if (!strokePaintingResource) { // default value (black), see bug 11017 RenderSVGResourceSolidColor* solidResource = sharedSolidPaintingResource(); solidResource->setColor(Color::black); strokePaintingResource = solidResource; } return strokePaintingResource; }
bool SVGResources::buildCachedResources(const RenderElement& renderer, const RenderStyle& style) { ASSERT(renderer.element()); ASSERT_WITH_SECURITY_IMPLICATION(renderer.element()->isSVGElement()); if (!renderer.element()) return false; auto& element = downcast<SVGElement>(*renderer.element()); Document& document = element.document(); SVGDocumentExtensions& extensions = document.accessSVGExtensions(); const AtomicString& tagName = element.localName(); if (tagName.isNull()) return false; const SVGRenderStyle& svgStyle = style.svgStyle(); bool foundResources = false; if (clipperFilterMaskerTags().contains(tagName)) { if (svgStyle.hasClipper()) { AtomicString id(svgStyle.clipperResource()); if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(document, id))) foundResources = true; else registerPendingResource(extensions, id, element); } if (style.hasFilter()) { const FilterOperations& filterOperations = style.filter(); if (filterOperations.size() == 1) { const FilterOperation& filterOperation = *filterOperations.at(0); if (filterOperation.type() == FilterOperation::REFERENCE) { const auto& referenceFilterOperation = downcast<ReferenceFilterOperation>(filterOperation); AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString(referenceFilterOperation.url(), element.document()); if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(document, id))) foundResources = true; else registerPendingResource(extensions, id, element); } } } if (svgStyle.hasMasker()) { AtomicString id(svgStyle.maskerResource()); if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(document, id))) foundResources = true; else registerPendingResource(extensions, id, element); } } if (markerTags().contains(tagName) && svgStyle.hasMarkers()) { AtomicString markerStartId(svgStyle.markerStartResource()); if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerStartId))) foundResources = true; else registerPendingResource(extensions, markerStartId, element); AtomicString markerMidId(svgStyle.markerMidResource()); if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerMidId))) foundResources = true; else registerPendingResource(extensions, markerMidId, element); AtomicString markerEndId(svgStyle.markerEndResource()); if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerEndId))) foundResources = true; else registerPendingResource(extensions, markerEndId, element); } if (fillAndStrokeTags().contains(tagName)) { if (svgStyle.hasFill()) { bool hasPendingResource = false; AtomicString id; if (setFill(paintingResourceFromSVGPaint(document, svgStyle.fillPaintType(), svgStyle.fillPaintUri(), id, hasPendingResource))) foundResources = true; else if (hasPendingResource) registerPendingResource(extensions, id, element); } if (svgStyle.hasStroke()) { bool hasPendingResource = false; AtomicString id; if (setStroke(paintingResourceFromSVGPaint(document, svgStyle.strokePaintType(), svgStyle.strokePaintUri(), id, hasPendingResource))) foundResources = true; else if (hasPendingResource) registerPendingResource(extensions, id, element); } } if (chainableResourceTags().contains(tagName)) { AtomicString id(targetReferenceFromResource(element)); if (setLinkedResource(getRenderSVGResourceContainerById(document, id))) foundResources = true; else registerPendingResource(extensions, id, element); } return foundResources; }