Chromium Code Reviews| Index: Source/core/rendering/svg/RenderSVGRect.cpp |
| diff --git a/Source/core/rendering/svg/RenderSVGRect.cpp b/Source/core/rendering/svg/RenderSVGRect.cpp |
| index a8d37354f857f1a685ad47d61c941fcc3601492a..e9fe5fad7b06592d5acd490a90f9a12a9f355b9b 100644 |
| --- a/Source/core/rendering/svg/RenderSVGRect.cpp |
| +++ b/Source/core/rendering/svg/RenderSVGRect.cpp |
| @@ -62,8 +62,12 @@ void RenderSVGRect::updateShapeFromElement() |
| // Spec: "A value of zero disables rendering of the element." |
| if (!boundingBoxSize.isEmpty()) { |
| - // Fallback to RenderSVGShape if rect has rounded corners or a non-scaling stroke. |
| - if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->currentValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { |
| + // Fallback to RenderSVGShape and path-based hit detection if the rect |
| + // has rounded corners or a non-scaling or non-simple stroke. |
| + if (rect->rx()->currentValue()->value(lengthContext) > 0 |
| + || rect->ry()->currentValue()->value(lengthContext) > 0 |
| + || hasNonScalingStroke() |
| + || !hasSimpleStroke()) { |
| RenderSVGShape::updateShapeFromElement(); |
| m_usePathFallback = true; |
| return; |
| @@ -90,7 +94,7 @@ bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point) |
| { |
| // The optimized contains code below does not support non-smooth strokes so we need |
| // to fall back to RenderSVGShape::shapeDependentStrokeContains in these cases. |
| - if (m_usePathFallback || !hasSmoothStroke()) { |
| + if (m_usePathFallback || !hasSimpleStroke()) { |
| if (!hasPath()) |
| RenderSVGShape::updateShapeFromElement(); |
| return RenderSVGShape::shapeDependentStrokeContains(point); |
| @@ -106,4 +110,12 @@ bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi |
| return m_fillBoundingBox.contains(point.x(), point.y()); |
| } |
| +bool RenderSVGRect::hasSimpleStroke() const |
| +{ |
| + const SVGRenderStyle& svgStyle = style()->svgStyle(); |
| + return svgStyle.strokeDashArray()->isEmpty() |
| + && svgStyle.strokeMiterLimit() == SVGRenderStyle::initialStrokeMiterLimit() |
| + && svgStyle.joinStyle() == SVGRenderStyle::initialJoinStyle(); |
|
Erik Dahlström (inactive)
2014/12/04 14:25:48
Here's an example where this might fail: http://js
|
| +} |
| + |
| } |