Index: Source/core/layout/svg/LayoutSVGShape.cpp |
diff --git a/Source/core/layout/svg/LayoutSVGShape.cpp b/Source/core/layout/svg/LayoutSVGShape.cpp |
index 1b11b2e6e9ca6fde8a8952357f5d7d916e3a06f1..a6fbe09b903bd51414996ef4e0b9543b44599122 100644 |
--- a/Source/core/layout/svg/LayoutSVGShape.cpp |
+++ b/Source/core/layout/svg/LayoutSVGShape.cpp |
@@ -73,6 +73,21 @@ void LayoutSVGShape::updateShapeFromElement() |
m_strokeBoundingBox = calculateStrokeBoundingBox(); |
} |
+FloatRect LayoutSVGShape::hitTestStrokeBoundingBox() const |
+{ |
+ if (style()->svgStyle().hasStroke()) |
+ return m_strokeBoundingBox; |
+ |
+ // Implementation of http://dev.w3.org/fxtf/css-masking-1/#compute-stroke-bounding-box |
+ // for the <rect> / <ellipse> / <circle> case except that we ignore whether |
+ // the stroke is none. |
+ |
+ FloatRect box = m_fillBoundingBox; |
+ const float strokeWidth = this->strokeWidth(); |
+ box.inflate(strokeWidth / 2); |
+ return box; |
+} |
+ |
bool LayoutSVGShape::shapeDependentStrokeContains(const FloatPoint& point) |
{ |
ASSERT(m_path); |
@@ -107,11 +122,16 @@ bool LayoutSVGShape::fillContains(const FloatPoint& point, bool requiresFill, co |
bool LayoutSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke) |
{ |
- if (!strokeBoundingBox().contains(point)) |
- return false; |
+ if (requiresStroke) { |
+ if (!strokeBoundingBox().contains(point)) |
+ return false; |
- if (requiresStroke && !SVGPaintServer::existsForLayoutObject(*this, styleRef(), ApplyToStrokeMode)) |
- return false; |
+ if (!SVGPaintServer::existsForLayoutObject(*this, styleRef(), ApplyToStrokeMode)) |
+ return false; |
+ } else { |
+ if (!hitTestStrokeBoundingBox().contains(point)) |
+ return false; |
+ } |
return shapeDependentStrokeContains(point); |
} |