OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2002, 2003 The Karbon Developers | |
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | |
4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> | |
5 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
7 * | |
8 * This library is free software; you can redistribute it and/or | |
9 * modify it under the terms of the GNU Library General Public | |
10 * License as published by the Free Software Foundation; either | |
11 * version 2 of the License, or (at your option) any later version. | |
12 * | |
13 * This library is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Library General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Library General Public License | |
19 * along with this library; see the file COPYING.LIB. If not, write to | |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
21 * Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #include "config.h" | |
25 #include "core/svg/SVGPathSegListBuilder.h" | |
26 | |
27 #include "core/dom/ExceptionCode.h" | |
28 #include "core/svg/SVGPathElement.h" | |
29 #include "core/svg/SVGPathSegArcAbs.h" | |
30 #include "core/svg/SVGPathSegArcRel.h" | |
31 #include "core/svg/SVGPathSegClosePath.h" | |
32 #include "core/svg/SVGPathSegCurvetoCubicAbs.h" | |
33 #include "core/svg/SVGPathSegCurvetoCubicRel.h" | |
34 #include "core/svg/SVGPathSegCurvetoCubicSmoothAbs.h" | |
35 #include "core/svg/SVGPathSegCurvetoCubicSmoothRel.h" | |
36 #include "core/svg/SVGPathSegCurvetoQuadraticAbs.h" | |
37 #include "core/svg/SVGPathSegCurvetoQuadraticRel.h" | |
38 #include "core/svg/SVGPathSegCurvetoQuadraticSmoothAbs.h" | |
39 #include "core/svg/SVGPathSegCurvetoQuadraticSmoothRel.h" | |
40 #include "core/svg/SVGPathSegLinetoAbs.h" | |
41 #include "core/svg/SVGPathSegLinetoHorizontalAbs.h" | |
42 #include "core/svg/SVGPathSegLinetoHorizontalRel.h" | |
43 #include "core/svg/SVGPathSegLinetoRel.h" | |
44 #include "core/svg/SVGPathSegLinetoVerticalAbs.h" | |
45 #include "core/svg/SVGPathSegLinetoVerticalRel.h" | |
46 #include "core/svg/SVGPathSegMovetoAbs.h" | |
47 #include "core/svg/SVGPathSegMovetoRel.h" | |
48 | |
49 namespace blink { | |
50 | |
51 SVGPathSegListBuilder::SVGPathSegListBuilder(SVGPathElement* pathElement, PassRe
fPtrWillBeRawPtr<SVGPathSegList> pathSegList) | |
52 : m_pathElement(pathElement) | |
53 , m_pathSegList(pathSegList) | |
54 { | |
55 ASSERT(m_pathElement); | |
56 ASSERT(m_pathSegList); | |
57 } | |
58 | |
59 void SVGPathSegListBuilder::emitSegment(const PathSegmentData& segment) | |
60 { | |
61 RefPtrWillBeRawPtr<SVGPathSeg> newPathSegment; | |
62 switch (segment.command) { | |
63 case PathSegMoveToRel: | |
64 newPathSegment = SVGPathSegMovetoRel::create(m_pathElement, segment.targ
etPoint.x(), segment.targetPoint.y()); | |
65 break; | |
66 case PathSegMoveToAbs: | |
67 newPathSegment = SVGPathSegMovetoAbs::create(m_pathElement, segment.targ
etPoint.x(), segment.targetPoint.y()); | |
68 break; | |
69 case PathSegLineToRel: | |
70 newPathSegment = SVGPathSegLinetoRel::create(m_pathElement, segment.targ
etPoint.x(), segment.targetPoint.y()); | |
71 break; | |
72 case PathSegLineToAbs: | |
73 newPathSegment = SVGPathSegLinetoAbs::create(m_pathElement, segment.targ
etPoint.x(), segment.targetPoint.y()); | |
74 break; | |
75 case PathSegLineToHorizontalRel: | |
76 newPathSegment = SVGPathSegLinetoHorizontalRel::create(m_pathElement, se
gment.targetPoint.x()); | |
77 break; | |
78 case PathSegLineToHorizontalAbs: | |
79 newPathSegment = SVGPathSegLinetoHorizontalAbs::create(m_pathElement, se
gment.targetPoint.x()); | |
80 break; | |
81 case PathSegLineToVerticalRel: | |
82 newPathSegment = SVGPathSegLinetoVerticalRel::create(m_pathElement, segm
ent.targetPoint.y()); | |
83 break; | |
84 case PathSegLineToVerticalAbs: | |
85 newPathSegment = SVGPathSegLinetoVerticalAbs::create(m_pathElement, segm
ent.targetPoint.y()); | |
86 break; | |
87 case PathSegClosePath: | |
88 newPathSegment = SVGPathSegClosePath::create(m_pathElement); | |
89 break; | |
90 case PathSegCurveToCubicRel: | |
91 newPathSegment = SVGPathSegCurvetoCubicRel::create(m_pathElement, segmen
t.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.point1.y
(), segment.point2.x(), segment.point2.y()); | |
92 break; | |
93 case PathSegCurveToCubicAbs: | |
94 newPathSegment = SVGPathSegCurvetoCubicAbs::create(m_pathElement, segmen
t.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.point1.y
(), segment.point2.x(), segment.point2.y()); | |
95 break; | |
96 case PathSegCurveToCubicSmoothRel: | |
97 newPathSegment = SVGPathSegCurvetoCubicSmoothRel::create(m_pathElement,
segment.targetPoint.x(), segment.targetPoint.y(), segment.point2.x(), segment.po
int2.y()); | |
98 break; | |
99 case PathSegCurveToCubicSmoothAbs: | |
100 newPathSegment = SVGPathSegCurvetoCubicSmoothAbs::create(m_pathElement,
segment.targetPoint.x(), segment.targetPoint.y(), segment.point2.x(), segment.po
int2.y()); | |
101 break; | |
102 case PathSegCurveToQuadraticRel: | |
103 newPathSegment = SVGPathSegCurvetoQuadraticRel::create(m_pathElement, se
gment.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.poin
t1.y()); | |
104 break; | |
105 case PathSegCurveToQuadraticAbs: | |
106 newPathSegment = SVGPathSegCurvetoQuadraticAbs::create(m_pathElement, se
gment.targetPoint.x(), segment.targetPoint.y(), segment.point1.x(), segment.poin
t1.y()); | |
107 break; | |
108 case PathSegCurveToQuadraticSmoothRel: | |
109 newPathSegment = SVGPathSegCurvetoQuadraticSmoothRel::create(m_pathEleme
nt, segment.targetPoint.x(), segment.targetPoint.y()); | |
110 break; | |
111 case PathSegCurveToQuadraticSmoothAbs: | |
112 newPathSegment = SVGPathSegCurvetoQuadraticSmoothAbs::create(m_pathEleme
nt, segment.targetPoint.x(), segment.targetPoint.y()); | |
113 break; | |
114 case PathSegArcRel: | |
115 newPathSegment = SVGPathSegArcRel::create(m_pathElement, segment.targetP
oint.x(), segment.targetPoint.y(), segment.arcRadii().x(), segment.arcRadii().y(
), segment.arcAngle(), segment.arcLarge, segment.arcSweep); | |
116 break; | |
117 case PathSegArcAbs: | |
118 newPathSegment = SVGPathSegArcAbs::create(m_pathElement, segment.targetP
oint.x(), segment.targetPoint.y(), segment.arcRadii().x(), segment.arcRadii().y(
), segment.arcAngle(), segment.arcLarge, segment.arcSweep); | |
119 break; | |
120 default: | |
121 ASSERT_NOT_REACHED(); | |
122 } | |
123 m_pathSegList->appendWithoutByteStreamSync(newPathSegment); | |
124 } | |
125 | |
126 } | |
OLD | NEW |