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

Side by Side Diff: Source/core/svg/SVGPathParser.cpp

Issue 1017703002: Normalize targetPoint first in parseArcToSegment (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2002, 2003 The Karbon Developers 2 * Copyright (C) 2002, 2003 The Karbon Developers
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org>
5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. 5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 m_consumer->arcTo(rx, ry, angle, largeArc, sweep, targetPoint, m_mode); 250 m_consumer->arcTo(rx, ry, angle, largeArc, sweep, targetPoint, m_mode);
251 return true; 251 return true;
252 } 252 }
253 253
254 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment ( a "lineto") joining the endpoints. 254 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment ( a "lineto") joining the endpoints.
255 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters 255 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
256 // If the current point and target point for the arc are identical, it shoul d be treated as a zero length 256 // If the current point and target point for the arc are identical, it shoul d be treated as a zero length
257 // path. This ensures continuity in animations. 257 // path. This ensures continuity in animations.
258 rx = fabsf(rx); 258 rx = fabsf(rx);
259 ry = fabsf(ry); 259 ry = fabsf(ry);
260 bool arcIsZeroLength = false; 260
261 if (m_mode == RelativeCoordinates) 261 if (m_mode == RelativeCoordinates)
262 arcIsZeroLength = targetPoint == FloatPoint::zero(); 262 targetPoint += m_currentPoint;
263 else 263
264 arcIsZeroLength = targetPoint == m_currentPoint; 264 if (!rx || !ry || targetPoint == m_currentPoint) {
265 if (!rx || !ry || arcIsZeroLength) { 265 m_consumer->lineTo(targetPoint, AbsoluteCoordinates);
266 if (m_mode == RelativeCoordinates) 266 m_currentPoint = targetPoint;
267 m_currentPoint += targetPoint;
268 else
269 m_currentPoint = targetPoint;
270 m_consumer->lineTo(m_currentPoint, AbsoluteCoordinates);
271 return true; 267 return true;
272 } 268 }
273 269
274 FloatPoint point1 = m_currentPoint; 270 FloatPoint point1 = m_currentPoint;
275 if (m_mode == RelativeCoordinates)
276 targetPoint += m_currentPoint;
277 m_currentPoint = targetPoint; 271 m_currentPoint = targetPoint;
278 return decomposeArcToCubic(angle, rx, ry, point1, targetPoint, largeArc, swe ep); 272 return decomposeArcToCubic(angle, rx, ry, point1, targetPoint, largeArc, swe ep);
279 } 273 }
280 274
281 bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, boo l checkForInitialMoveTo) 275 bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, boo l checkForInitialMoveTo)
282 { 276 {
283 ASSERT(m_source); 277 ASSERT(m_source);
284 ASSERT(m_consumer); 278 ASSERT(m_consumer);
285 279
286 m_pathParsingMode = pathParsingMode; 280 m_pathParsingMode = pathParsingMode;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 point2 = targetPoint; 467 point2 = targetPoint;
474 point2.move(t * sinEndTheta, -t * cosEndTheta); 468 point2.move(t * sinEndTheta, -t * cosEndTheta);
475 469
476 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform .mapPoint(point2), 470 m_consumer->curveToCubic(pointTransform.mapPoint(point1), pointTransform .mapPoint(point2),
477 pointTransform.mapPoint(targetPoint), AbsoluteC oordinates); 471 pointTransform.mapPoint(targetPoint), AbsoluteC oordinates);
478 } 472 }
479 return true; 473 return true;
480 } 474 }
481 475
482 } 476 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698