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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGMarkerData.h

Issue 2539763002: Use the right point for marker orientation when closing a subpath (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/markers/marker-orientation-close-path-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 inAngle += 360; 99 inAngle += 360;
100 return clampTo<float>((inAngle + outAngle) / 2); 100 return clampTo<float>((inAngle + outAngle) / 2);
101 case EndMarker: 101 case EndMarker:
102 return clampTo<float>(inAngle); 102 return clampTo<float>(inAngle);
103 } 103 }
104 104
105 ASSERT_NOT_REACHED(); 105 ASSERT_NOT_REACHED();
106 return 0; 106 return 0;
107 } 107 }
108 108
109 void updateOutslope(const FloatPoint& point) { 109 void updateOutslope(const PathElement& element) {
110 m_outslopePoints[0] = m_origin; 110 m_outslopePoints[0] = m_origin;
111 FloatPoint point = element.type == PathElementCloseSubpath
112 ? m_subpathStart
113 : element.points[0];
111 m_outslopePoints[1] = point; 114 m_outslopePoints[1] = point;
112 } 115 }
113 116
114 void updateFromPathElement(const PathElement& element) { 117 void updateFromPathElement(const PathElement& element) {
115 // First update the outslope for the previous element. 118 // First update the outslope for the previous element.
116 updateOutslope(element.points[0]); 119 updateOutslope(element);
117 120
118 // Record the marker for the previous element. 121 // Record the marker for the previous element.
119 if (m_elementIndex > 0) { 122 if (m_elementIndex > 0) {
120 SVGMarkerType markerType = m_elementIndex == 1 ? StartMarker : MidMarker; 123 SVGMarkerType markerType = m_elementIndex == 1 ? StartMarker : MidMarker;
121 m_positions.append( 124 m_positions.append(
122 MarkerPosition(markerType, m_origin, currentAngle(markerType))); 125 MarkerPosition(markerType, m_origin, currentAngle(markerType)));
123 } 126 }
124 127
125 // Update our marker data for this element. 128 // Update our marker data for this element.
126 updateMarkerDataForPathElement(element); 129 updateMarkerDataForPathElement(element);
(...skipping 14 matching lines...) Expand all
141 m_inslopePoints[1] = points[2]; 144 m_inslopePoints[1] = points[2];
142 m_origin = points[2]; 145 m_origin = points[2];
143 break; 146 break;
144 case PathElementMoveToPoint: 147 case PathElementMoveToPoint:
145 m_subpathStart = points[0]; 148 m_subpathStart = points[0];
146 case PathElementAddLineToPoint: 149 case PathElementAddLineToPoint:
147 updateInslope(points[0]); 150 updateInslope(points[0]);
148 m_origin = points[0]; 151 m_origin = points[0];
149 break; 152 break;
150 case PathElementCloseSubpath: 153 case PathElementCloseSubpath:
151 updateInslope(points[0]); 154 updateInslope(m_subpathStart);
152 m_origin = m_subpathStart; 155 m_origin = m_subpathStart;
153 m_subpathStart = FloatPoint(); 156 m_subpathStart = FloatPoint();
154 } 157 }
155 } 158 }
156 159
157 void updateInslope(const FloatPoint& point) { 160 void updateInslope(const FloatPoint& point) {
158 m_inslopePoints[0] = m_origin; 161 m_inslopePoints[0] = m_origin;
159 m_inslopePoints[1] = point; 162 m_inslopePoints[1] = point;
160 } 163 }
161 164
162 Vector<MarkerPosition>& m_positions; 165 Vector<MarkerPosition>& m_positions;
163 unsigned m_elementIndex; 166 unsigned m_elementIndex;
164 FloatPoint m_origin; 167 FloatPoint m_origin;
165 FloatPoint m_subpathStart; 168 FloatPoint m_subpathStart;
166 FloatPoint m_inslopePoints[2]; 169 FloatPoint m_inslopePoints[2];
167 FloatPoint m_outslopePoints[2]; 170 FloatPoint m_outslopePoints[2];
168 bool m_autoStartReverse; 171 bool m_autoStartReverse;
169 }; 172 };
170 173
171 } // namespace blink 174 } // namespace blink
172 175
173 #endif // SVGMarkerData_h 176 #endif // SVGMarkerData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/markers/marker-orientation-close-path-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698