| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
| 3 * | |
| 4 * This library is free software; you can redistribute it and/or | |
| 5 * modify it under the terms of the GNU Library General Public | |
| 6 * License as published by the Free Software Foundation; either | |
| 7 * version 2 of the License, or (at your option) any later version. | |
| 8 * | |
| 9 * This library is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 * Library General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU Library General Public License | |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 17 * Boston, MA 02110-1301, USA. | |
| 18 */ | |
| 19 | |
| 20 #include "config.h" | |
| 21 #include "core/svg/SVGPathSegListSource.h" | |
| 22 | |
| 23 #include "core/svg/SVGPathElement.h" | |
| 24 #include "core/svg/SVGPathSegArc.h" | |
| 25 #include "core/svg/SVGPathSegCurvetoCubic.h" | |
| 26 #include "core/svg/SVGPathSegCurvetoCubicSmooth.h" | |
| 27 #include "core/svg/SVGPathSegCurvetoQuadratic.h" | |
| 28 #include "core/svg/SVGPathSegLinetoHorizontal.h" | |
| 29 #include "core/svg/SVGPathSegLinetoVertical.h" | |
| 30 | |
| 31 namespace blink { | |
| 32 | |
| 33 SVGPathSegListSource::SVGPathSegListSource(SVGPathSegList::ConstIterator itBegin
, SVGPathSegList::ConstIterator itEnd) | |
| 34 : m_itCurrent(itBegin) | |
| 35 , m_itEnd(itEnd) | |
| 36 { | |
| 37 } | |
| 38 | |
| 39 bool SVGPathSegListSource::hasMoreData() const | |
| 40 { | |
| 41 return m_itCurrent != m_itEnd; | |
| 42 } | |
| 43 | |
| 44 SVGPathSegType SVGPathSegListSource::peekSegmentType() | |
| 45 { | |
| 46 ASSERT(hasMoreData()); | |
| 47 return static_cast<SVGPathSegType>(m_itCurrent->pathSegType()); | |
| 48 } | |
| 49 | |
| 50 PathSegmentData SVGPathSegListSource::parseSegment() | |
| 51 { | |
| 52 ASSERT(hasMoreData()); | |
| 53 PathSegmentData segment; | |
| 54 RefPtrWillBeRawPtr<SVGPathSeg> pathSegment = *m_itCurrent; | |
| 55 segment.command = static_cast<SVGPathSegType>(pathSegment->pathSegType()); | |
| 56 ++m_itCurrent; | |
| 57 | |
| 58 switch (segment.command) { | |
| 59 case PathSegMoveToRel: | |
| 60 case PathSegMoveToAbs: | |
| 61 case PathSegLineToRel: | |
| 62 case PathSegLineToAbs: | |
| 63 case PathSegCurveToQuadraticSmoothRel: | |
| 64 case PathSegCurveToQuadraticSmoothAbs: { | |
| 65 SVGPathSegSingleCoordinate* singleCoordinate = static_cast<SVGPathSegSin
gleCoordinate*>(pathSegment.get()); | |
| 66 segment.targetPoint = FloatPoint(singleCoordinate->x(), singleCoordinate
->y()); | |
| 67 break; | |
| 68 } | |
| 69 case PathSegLineToHorizontalRel: | |
| 70 case PathSegLineToHorizontalAbs: { | |
| 71 SVGPathSegLinetoHorizontal* horizontal = static_cast<SVGPathSegLinetoHor
izontal*>(pathSegment.get()); | |
| 72 segment.targetPoint.setX(horizontal->x()); | |
| 73 break; | |
| 74 } | |
| 75 case PathSegLineToVerticalRel: | |
| 76 case PathSegLineToVerticalAbs: { | |
| 77 SVGPathSegLinetoVertical* vertical = static_cast<SVGPathSegLinetoVertica
l*>(pathSegment.get()); | |
| 78 segment.targetPoint.setY(vertical->y()); | |
| 79 break; | |
| 80 } | |
| 81 case PathSegClosePath: | |
| 82 break; | |
| 83 case PathSegCurveToCubicRel: | |
| 84 case PathSegCurveToCubicAbs: { | |
| 85 SVGPathSegCurvetoCubic* cubic = static_cast<SVGPathSegCurvetoCubic*>(pat
hSegment.get()); | |
| 86 segment.point1 = FloatPoint(cubic->x1(), cubic->y1()); | |
| 87 segment.point2 = FloatPoint(cubic->x2(), cubic->y2()); | |
| 88 segment.targetPoint = FloatPoint(cubic->x(), cubic->y()); | |
| 89 break; | |
| 90 } | |
| 91 case PathSegCurveToCubicSmoothRel: | |
| 92 case PathSegCurveToCubicSmoothAbs: { | |
| 93 SVGPathSegCurvetoCubicSmooth* cubicSmooth = static_cast<SVGPathSegCurvet
oCubicSmooth*>(pathSegment.get()); | |
| 94 segment.point2 = FloatPoint(cubicSmooth->x2(), cubicSmooth->y2()); | |
| 95 segment.targetPoint = FloatPoint(cubicSmooth->x(), cubicSmooth->y()); | |
| 96 break; | |
| 97 } | |
| 98 case PathSegCurveToQuadraticRel: | |
| 99 case PathSegCurveToQuadraticAbs: { | |
| 100 SVGPathSegCurvetoQuadratic* quadratic = static_cast<SVGPathSegCurvetoQua
dratic*>(pathSegment.get()); | |
| 101 segment.point1 = FloatPoint(quadratic->x1(), quadratic->y1()); | |
| 102 segment.targetPoint = FloatPoint(quadratic->x(), quadratic->y()); | |
| 103 break; | |
| 104 } | |
| 105 case PathSegArcRel: | |
| 106 case PathSegArcAbs: { | |
| 107 SVGPathSegArc* arcTo = static_cast<SVGPathSegArc*>(pathSegment.get()); | |
| 108 segment.point1 = FloatPoint(arcTo->r1(), arcTo->r2()); | |
| 109 segment.point2.setX(arcTo->angle()); | |
| 110 segment.arcLarge = arcTo->largeArcFlag(); | |
| 111 segment.arcSweep = arcTo->sweepFlag(); | |
| 112 segment.targetPoint = FloatPoint(arcTo->x(), arcTo->y()); | |
| 113 break; | |
| 114 } | |
| 115 default: | |
| 116 ASSERT_NOT_REACHED(); | |
| 117 } | |
| 118 return segment; | |
| 119 } | |
| 120 | |
| 121 } | |
| OLD | NEW |