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

Side by Side Diff: Source/core/rendering/svg/RenderSVGPath.cpp

Issue 810343003: Fix pointer-events:all when stroke="none" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove braces from single-line if statement 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
10 * Copyright (C) 2011 University of Szeged 10 * Copyright (C) 2011 University of Szeged
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 { 42 {
43 } 43 }
44 44
45 RenderSVGPath::~RenderSVGPath() 45 RenderSVGPath::~RenderSVGPath()
46 { 46 {
47 } 47 }
48 48
49 void RenderSVGPath::updateShapeFromElement() 49 void RenderSVGPath::updateShapeFromElement()
50 { 50 {
51 RenderSVGShape::updateShapeFromElement(); 51 RenderSVGShape::updateShapeFromElement();
52
53 if (m_markerPositions.isEmpty()) {
54 m_markerRect = FloatRect();
55 } else {
56 m_markerRect = markerRect(strokeWidth());
57 m_strokeBoundingBox.unite(m_markerRect);
58 }
59
52 updateZeroLengthSubpaths(); 60 updateZeroLengthSubpaths();
53
54 m_strokeBoundingBox = calculateUpdatedStrokeBoundingBox(); 61 m_strokeBoundingBox = calculateUpdatedStrokeBoundingBox();
55 } 62 }
56 63
57 FloatRect RenderSVGPath::calculateUpdatedStrokeBoundingBox() const 64 FloatRect RenderSVGPath::calculateUpdatedStrokeBoundingBox() const
58 { 65 {
59 FloatRect strokeBoundingBox = m_strokeBoundingBox; 66 FloatRect strokeBoundingBox = m_strokeBoundingBox;
60 67
61 if (!m_markerPositions.isEmpty()) 68 // FIXME: zero-length subpaths do not respect vector-effect = non-scaling-st roke.
62 strokeBoundingBox.unite(markerRect(strokeWidth())); 69 const float strokeWidth = this->strokeWidth();
63 70 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i)
64 if (style()->svgStyle().hasStroke()) { 71 strokeBoundingBox.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLocatio ns[i], strokeWidth));
65 // FIXME: zero-length subpaths do not respect vector-effect = non-scalin g-stroke.
66 float strokeWidth = this->strokeWidth();
67 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i)
68 strokeBoundingBox.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLoc ations[i], strokeWidth));
69 }
70 72
71 return strokeBoundingBox; 73 return strokeBoundingBox;
72 } 74 }
73 75
74 bool RenderSVGPath::shapeDependentStrokeContains(const FloatPoint& point) 76 bool RenderSVGPath::shapeDependentStrokeContains(const FloatPoint& point)
75 { 77 {
76 if (RenderSVGShape::shapeDependentStrokeContains(point)) 78 if (RenderSVGShape::shapeDependentStrokeContains(point))
77 return true; 79 return true;
78 80
79 const SVGRenderStyle& svgStyle = style()->svgStyle(); 81 const SVGRenderStyle& svgStyle = style()->svgStyle();
82 const float strokeWidth = this->strokeWidth();
80 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { 83 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) {
81 ASSERT(svgStyle.hasStroke()); 84 ASSERT(svgStyle.hasStroke());
82 float strokeWidth = this->strokeWidth();
83 if (svgStyle.capStyle() == SquareCap) { 85 if (svgStyle.capStyle() == SquareCap) {
84 if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWid th).contains(point)) 86 if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWid th).contains(point))
85 return true; 87 return true;
86 } else { 88 } else {
87 ASSERT(svgStyle.capStyle() == RoundCap); 89 ASSERT(svgStyle.capStyle() == RoundCap);
88 FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i]. x(), point.y() - m_zeroLengthLinecapLocations[i].y()); 90 FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i]. x(), point.y() - m_zeroLengthLinecapLocations[i].y());
89 if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f) 91 if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f)
90 return true; 92 return true;
91 } 93 }
92 } 94 }
93 return false; 95 return false;
94 } 96 }
95 97
98 FloatRect RenderSVGPath::actualStrokeBoundingBox() const
99 {
100 if (style()->svgStyle().hasStroke())
101 return m_strokeBoundingBox;
102
103 FloatRect actualStrokeBoundingBox = m_fillBoundingBox;
104 actualStrokeBoundingBox.unite(m_markerRect);
105 return actualStrokeBoundingBox;
106 }
107
96 bool RenderSVGPath::shouldStrokeZeroLengthSubpath() const 108 bool RenderSVGPath::shouldStrokeZeroLengthSubpath() const
97 { 109 {
98 // Spec(11.4): Any zero length subpath shall not be stroked if the "stroke-l inecap" property has a value of butt 110 // Spec(11.4): Any zero length subpath shall not be stroked if the "stroke-l inecap" property has a value of butt
99 // but shall be stroked if the "stroke-linecap" property has a value of roun d or square 111 // but shall be stroked if the "stroke-linecap" property has a value of roun d or square
100 return style()->svgStyle().hasStroke() && style()->svgStyle().capStyle() != ButtCap; 112 return style()->svgStyle().hasStroke() && style()->svgStyle().capStyle() != ButtCap;
101 } 113 }
102 114
103 FloatRect RenderSVGPath::zeroLengthSubpathRect(const FloatPoint& linecapPosition , float strokeWidth) 115 FloatRect RenderSVGPath::zeroLengthSubpathRect(const FloatPoint& linecapPosition , float strokeWidth)
104 { 116 {
105 return FloatRect(linecapPosition.x() - strokeWidth / 2, linecapPosition.y() - strokeWidth / 2, strokeWidth, strokeWidth); 117 return FloatRect(linecapPosition.x() - strokeWidth / 2, linecapPosition.y() - strokeWidth / 2, strokeWidth, strokeWidth);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ASSERT(resources); 176 ASSERT(resources);
165 177
166 RenderSVGResourceMarker* markerStart = resources->markerStart(); 178 RenderSVGResourceMarker* markerStart = resources->markerStart();
167 179
168 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien tType() == SVGMarkerOrientAutoStartReverse : false); 180 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien tType() == SVGMarkerOrientAutoStartReverse : false);
169 path().apply(&markerData, SVGMarkerData::updateFromPathElement); 181 path().apply(&markerData, SVGMarkerData::updateFromPathElement);
170 markerData.pathIsDone(); 182 markerData.pathIsDone();
171 } 183 }
172 184
173 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698