OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 LayoutSVGPath::~LayoutSVGPath() | 46 LayoutSVGPath::~LayoutSVGPath() |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 void LayoutSVGPath::updateShapeFromElement() | 50 void LayoutSVGPath::updateShapeFromElement() |
51 { | 51 { |
52 LayoutSVGShape::updateShapeFromElement(); | 52 LayoutSVGShape::updateShapeFromElement(); |
| 53 updateZeroLengthSubpaths(); |
| 54 } |
| 55 |
| 56 void LayoutSVGPath::updateStrokeAndFillBoundingBoxes() |
| 57 { |
| 58 LayoutSVGShape::updateStrokeAndFillBoundingBoxes(); |
| 59 |
| 60 // TODO(pdr): We should only call this in updateShapeFromElement. |
53 processMarkerPositions(); | 61 processMarkerPositions(); |
54 updateZeroLengthSubpaths(); | 62 if (!m_markerPositions.isEmpty()) |
| 63 m_strokeBoundingBox.unite(markerRect(strokeWidth())); |
55 | 64 |
56 m_strokeBoundingBox = calculateUpdatedStrokeBoundingBox(); | 65 if (style()->svgStyle().hasStroke()) { |
| 66 // FIXME: zero-length subpaths do not respect vector-effect = non-scalin
g-stroke. |
| 67 float strokeWidth = this->strokeWidth(); |
| 68 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) |
| 69 m_strokeBoundingBox.unite(zeroLengthSubpathRect(m_zeroLengthLinecapL
ocations[i], strokeWidth)); |
| 70 } |
57 } | 71 } |
58 | 72 |
59 FloatRect LayoutSVGPath::hitTestStrokeBoundingBox() const | 73 FloatRect LayoutSVGPath::hitTestStrokeBoundingBox() const |
60 { | 74 { |
61 const SVGComputedStyle& svgStyle = style()->svgStyle(); | 75 const SVGComputedStyle& svgStyle = style()->svgStyle(); |
62 if (svgStyle.hasStroke()) | 76 if (svgStyle.hasStroke()) |
63 return m_strokeBoundingBox; | 77 return m_strokeBoundingBox; |
64 | 78 |
65 // Implementation of http://dev.w3.org/fxtf/css-masking-1/#compute-stroke-bo
unding-box | 79 // Implementation of http://dev.w3.org/fxtf/css-masking-1/#compute-stroke-bo
unding-box |
66 // except that we ignore whether the stroke is none. | 80 // except that we ignore whether the stroke is none. |
(...skipping 17 matching lines...) Expand all Loading... |
84 } | 98 } |
85 | 99 |
86 box.inflate(delta); | 100 box.inflate(delta); |
87 | 101 |
88 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) | 102 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) |
89 box.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeW
idth)); | 103 box.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeW
idth)); |
90 | 104 |
91 return box; | 105 return box; |
92 } | 106 } |
93 | 107 |
94 FloatRect LayoutSVGPath::calculateUpdatedStrokeBoundingBox() const | |
95 { | |
96 FloatRect strokeBoundingBox = m_strokeBoundingBox; | |
97 | |
98 if (!m_markerPositions.isEmpty()) | |
99 strokeBoundingBox.unite(markerRect(strokeWidth())); | |
100 | |
101 if (style()->svgStyle().hasStroke()) { | |
102 // FIXME: zero-length subpaths do not respect vector-effect = non-scalin
g-stroke. | |
103 float strokeWidth = this->strokeWidth(); | |
104 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) | |
105 strokeBoundingBox.unite(zeroLengthSubpathRect(m_zeroLengthLinecapLoc
ations[i], strokeWidth)); | |
106 } | |
107 | |
108 return strokeBoundingBox; | |
109 } | |
110 | |
111 bool LayoutSVGPath::shapeDependentStrokeContains(const FloatPoint& point) | 108 bool LayoutSVGPath::shapeDependentStrokeContains(const FloatPoint& point) |
112 { | 109 { |
113 if (LayoutSVGShape::shapeDependentStrokeContains(point)) | 110 if (LayoutSVGShape::shapeDependentStrokeContains(point)) |
114 return true; | 111 return true; |
115 | 112 |
116 const SVGComputedStyle& svgStyle = style()->svgStyle(); | 113 const SVGComputedStyle& svgStyle = style()->svgStyle(); |
117 const float strokeWidth = this->strokeWidth(); | 114 const float strokeWidth = this->strokeWidth(); |
118 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { | 115 for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { |
119 ASSERT(svgStyle.hasStroke()); | 116 ASSERT(svgStyle.hasStroke()); |
120 if (svgStyle.capStyle() == SquareCap) { | 117 if (svgStyle.capStyle() == SquareCap) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ASSERT(resources); | 198 ASSERT(resources); |
202 | 199 |
203 LayoutSVGResourceMarker* markerStart = resources->markerStart(); | 200 LayoutSVGResourceMarker* markerStart = resources->markerStart(); |
204 | 201 |
205 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); | 202 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); |
206 path().apply(&markerData, SVGMarkerData::updateFromPathElement); | 203 path().apply(&markerData, SVGMarkerData::updateFromPathElement); |
207 markerData.pathIsDone(); | 204 markerData.pathIsDone(); |
208 } | 205 } |
209 | 206 |
210 } | 207 } |
OLD | NEW |