bool RenderSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke) { if (!strokeBoundingBox().contains(point)) return false; Color fallbackColor; if (requiresStroke && !RenderSVGResource::strokePaintingResource(this, style(), fallbackColor)) return false; const SVGRenderStyle* svgStyle = style()->svgStyle(); for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { ASSERT(style()->svgStyle()->hasStroke()); float strokeWidth = this->strokeWidth(); if (style()->svgStyle()->capStyle() == SquareCap) { if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth).contains(point)) return true; } else { ASSERT(style()->svgStyle()->capStyle() == RoundCap); FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i].x(), point.y() - m_zeroLengthLinecapLocations[i].y()); if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f) return true; } } if (!svgStyle->strokeDashArray().isEmpty() || svgStyle->strokeMiterLimit() != svgStyle->initialStrokeMiterLimit() || svgStyle->joinStyle() != svgStyle->initialJoinStyle() || svgStyle->capStyle() != svgStyle->initialCapStyle()) { if (!m_path) RenderSVGShape::createShape(); return RenderSVGShape::shapeDependentStrokeContains(point); } return shapeDependentStrokeContains(point); }
FloatRect RenderSVGPath::calculateUpdatedStrokeBoundingBox() const { FloatRect strokeBoundingBox = m_strokeBoundingBox; if (style().svgStyle().hasStroke()) { // FIXME: zero-length subpaths do not respect vector-effect = non-scaling-stroke. float strokeWidth = this->strokeWidth(); for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) strokeBoundingBox.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth)); } return strokeBoundingBox; }
bool RenderSVGPath::shapeDependentStrokeContains(const FloatPoint& point) { if (RenderSVGShape::shapeDependentStrokeContains(point)) return true; const SVGRenderStyle& svgStyle = style().svgStyle(); for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { ASSERT(svgStyle.hasStroke()); float strokeWidth = this->strokeWidth(); if (svgStyle.capStyle() == SquareCap) { if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth).contains(point)) return true; } else { ASSERT(svgStyle.capStyle() == RoundCap); FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i].x(), point.y() - m_zeroLengthLinecapLocations[i].y()); if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f) return true; } } return false; }