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

Unified Diff: Source/core/layout/svg/LayoutSVGPath.cpp

Issue 1048043002: Fix pointer-events:all when stroke="none" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 8 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/layout/svg/LayoutSVGPath.h ('k') | Source/core/layout/svg/LayoutSVGRect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/svg/LayoutSVGPath.cpp
diff --git a/Source/core/layout/svg/LayoutSVGPath.cpp b/Source/core/layout/svg/LayoutSVGPath.cpp
index 0e811c0ad2cfabffcdec05730d315aebbf0f411a..c8e5d6bd4f0f1832253f7c08e6c06adf4f578632 100644
--- a/Source/core/layout/svg/LayoutSVGPath.cpp
+++ b/Source/core/layout/svg/LayoutSVGPath.cpp
@@ -34,6 +34,7 @@
#include "core/layout/svg/SVGResourcesCache.h"
#include "core/layout/svg/SVGSubpathData.h"
#include "core/svg/SVGGraphicsElement.h"
+#include "wtf/MathExtras.h"
namespace blink {
@@ -55,6 +56,41 @@ void LayoutSVGPath::updateShapeFromElement()
m_strokeBoundingBox = calculateUpdatedStrokeBoundingBox();
}
+FloatRect LayoutSVGPath::hitTestStrokeBoundingBox() const
+{
+ const SVGComputedStyle& svgStyle = style()->svgStyle();
+ if (svgStyle.hasStroke())
+ return m_strokeBoundingBox;
+
+ // Implementation of http://dev.w3.org/fxtf/css-masking-1/#compute-stroke-bounding-box
+ // except that we ignore whether the stroke is none.
+
+ FloatRect box = m_fillBoundingBox;
+
+ const float strokeWidth = this->strokeWidth();
+ if (strokeWidth <= 0)
+ return box;
+
+ float delta = strokeWidth / 2;
+
+ if (svgStyle.hasMiterJoinStyle()) {
+ const float miter = svgStyle.strokeMiterLimit();
+ if (miter < M_SQRT2 && svgStyle.hasSquareCapStyle())
+ delta *= M_SQRT2;
+ else
+ delta *= miter;
+ } else if (svgStyle.hasSquareCapStyle()) {
+ delta *= M_SQRT2;
+ }
+
+ box.inflate(delta);
+
+ for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i)
+ box.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth));
+
+ return box;
+}
+
FloatRect LayoutSVGPath::calculateUpdatedStrokeBoundingBox() const
{
FloatRect strokeBoundingBox = m_strokeBoundingBox;
@@ -78,9 +114,9 @@ bool LayoutSVGPath::shapeDependentStrokeContains(const FloatPoint& point)
return true;
const SVGComputedStyle& svgStyle = style()->svgStyle();
+ const float strokeWidth = this->strokeWidth();
for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) {
ASSERT(svgStyle.hasStroke());
- float strokeWidth = this->strokeWidth();
if (svgStyle.capStyle() == SquareCap) {
if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth).contains(point))
return true;
« no previous file with comments | « Source/core/layout/svg/LayoutSVGPath.h ('k') | Source/core/layout/svg/LayoutSVGRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698