Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1363)

Unified Diff: Source/core/rendering/svg/RenderSVGEllipse.cpp

Issue 745383007: Fix an issue where hit detection could fail on rect and ellipse shapes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/svg/RenderSVGEllipse.cpp
diff --git a/Source/core/rendering/svg/RenderSVGEllipse.cpp b/Source/core/rendering/svg/RenderSVGEllipse.cpp
index 47ad9b9822549fd0d983ba4cdde7284bd636a0d0..66ac961ce5bc8885d869b849c4e6d79ccfb7e394 100644
--- a/Source/core/rendering/svg/RenderSVGEllipse.cpp
+++ b/Source/core/rendering/svg/RenderSVGEllipse.cpp
@@ -60,8 +60,9 @@ void RenderSVGEllipse::updateShapeFromElement()
return;
if (!m_radii.isEmpty()) {
- // Fallback to RenderSVGShape if shape has a non-scaling stroke.
- if (hasNonScalingStroke()) {
+ // Fallback to RenderSVGShape and path-based hit detection if the ellipse
+ // has a non-scaling or discontinuous stroke.
+ if (hasNonScalingStroke() || !hasContinuousStroke()) {
RenderSVGShape::updateShapeFromElement();
m_usePathFallback = true;
return;
@@ -96,9 +97,9 @@ void RenderSVGEllipse::calculateRadiiAndCenter()
bool RenderSVGEllipse::shapeDependentStrokeContains(const FloatPoint& point)
{
- // The optimized contains code below does not support non-smooth strokes so we need
+ // The optimized code below does not support discontinuous strokes so we need
// to fall back to RenderSVGShape::shapeDependentStrokeContains in these cases.
- if (m_usePathFallback || !hasSmoothStroke()) {
+ if (m_usePathFallback || !hasContinuousStroke()) {
if (!hasPath())
RenderSVGShape::updateShapeFromElement();
return RenderSVGShape::shapeDependentStrokeContains(point);
@@ -133,4 +134,10 @@ bool RenderSVGEllipse::shapeDependentFillContains(const FloatPoint& point, const
return xrX * xrX + yrY * yrY <= 1.0;
}
+bool RenderSVGEllipse::hasContinuousStroke() const
+{
+ const SVGRenderStyle& svgStyle = style()->svgStyle();
+ return svgStyle.strokeDashArray()->isEmpty();
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698