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

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

Issue 810343003: Fix pointer-events:all when stroke="none" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove line uniting m_hitTestStrokeBoundingBox with markerRect Created 5 years, 11 months 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 e50f50ce7d0fda9d7534a13b88f32932aa233be5..0c38186f08d0d2fc1d8ea331f4e331d7bf3aeffd 100644
--- a/Source/core/rendering/svg/RenderSVGRect.cpp
+++ b/Source/core/rendering/svg/RenderSVGRect.cpp
@@ -30,6 +30,8 @@
#include "core/rendering/svg/RenderSVGRect.h"
#include "core/svg/SVGRectElement.h"
+#include <cmath>
+
namespace blink {
RenderSVGRect::RenderSVGRect(SVGRectElement* node)
@@ -47,8 +49,8 @@ void RenderSVGRect::updateShapeFromElement()
// Before creating a new object we need to clear the cached bounding box
// to avoid using garbage.
m_fillBoundingBox = FloatRect();
- m_innerStrokeRect = FloatRect();
- m_outerStrokeRect = FloatRect();
+ m_strokeBoundingBox = FloatRect();
+ m_hitTestStrokeBoundingBox = FloatRect();
m_usePathFallback = false;
SVGRectElement* rect = toSVGRectElement(element());
ASSERT(rect);
@@ -75,19 +77,9 @@ void RenderSVGRect::updateShapeFromElement()
}
m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(lengthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize);
-
- // To decide if the stroke contains a point we create two rects which represent the inner and
- // the outer stroke borders. A stroke contains the point, if the point is between them.
- m_innerStrokeRect = m_fillBoundingBox;
- m_outerStrokeRect = m_fillBoundingBox;
-
- if (style()->svgStyle().hasStroke()) {
- float strokeWidth = this->strokeWidth();
- m_innerStrokeRect.inflate(-strokeWidth / 2);
- m_outerStrokeRect.inflate(strokeWidth / 2);
- }
-
- m_strokeBoundingBox = m_outerStrokeRect;
+ m_hitTestStrokeBoundingBox = m_fillBoundingBox;
+ m_hitTestStrokeBoundingBox.inflate(strokeWidth() / 2);
+ m_strokeBoundingBox = style()->svgStyle().hasStroke() ? m_hitTestStrokeBoundingBox : m_fillBoundingBox;
}
bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point)
@@ -100,7 +92,19 @@ bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point)
return RenderSVGShape::shapeDependentStrokeContains(point);
}
- return m_outerStrokeRect.contains(point, FloatRect::InsideOrOnStroke) && !m_innerStrokeRect.contains(point, FloatRect::InsideButNotOnStroke);
+ const float halfStrokeWidth = strokeWidth() / 2;
+ const float halfWidth = m_fillBoundingBox.width() / 2;
+ const float halfHeight = m_fillBoundingBox.height() / 2;
+
+ const FloatPoint fillBoundingBoxCenter = FloatPoint(m_fillBoundingBox.x() + halfWidth, m_fillBoundingBox.y() + halfHeight);
+ const float absDeltaX = std::abs(point.x() - fillBoundingBoxCenter.x());
+ const float absDeltaY = std::abs(point.y() - fillBoundingBoxCenter.y());
+
+ if (!(absDeltaX <= halfWidth + halfStrokeWidth && absDeltaY <= halfHeight + halfStrokeWidth))
+ return false;
+
+ return (halfWidth - halfStrokeWidth <= absDeltaX)
+ || (halfHeight - halfStrokeWidth <= absDeltaY);
}
bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const WindRule fillRule) const
« 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