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

Unified Diff: Source/core/rendering/svg/RenderSVGRect.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
« no previous file with comments | « Source/core/rendering/svg/RenderSVGRect.h ('k') | Source/core/rendering/svg/RenderSVGShape.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+}
+
}
« no previous file with comments | « Source/core/rendering/svg/RenderSVGRect.h ('k') | Source/core/rendering/svg/RenderSVGShape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698