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.
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.
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.
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.
27
#include "SVGPathSegListBuilder.h"
29
#include "ExceptionCode.h"
30
#include "SVGPathElement.h"
31
#include "SVGPathSegArc.h"
32
#include "SVGPathSegClosePath.h"
33
#include "SVGPathSegCurvetoCubic.h"
34
#include "SVGPathSegCurvetoCubicSmooth.h"
35
#include "SVGPathSegCurvetoQuadratic.h"
36
#include "SVGPathSegCurvetoQuadraticSmooth.h"
37
#include "SVGPathSegLineto.h"
38
#include "SVGPathSegLinetoHorizontal.h"
39
#include "SVGPathSegLinetoVertical.h"
40
#include "SVGPathSegList.h"
41
#include "SVGPathSegMoveto.h"
45
SVGPathSegListBuilder::SVGPathSegListBuilder()
48
, m_pathSegRole(PathSegUndefinedRole)
52
void SVGPathSegListBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode mode)
54
ASSERT(m_pathElement);
55
ASSERT(m_pathSegList);
56
if (mode == AbsoluteCoordinates)
57
m_pathSegList->append(m_pathElement->createSVGPathSegMovetoAbs(targetPoint.x(), targetPoint.y(), m_pathSegRole));
59
m_pathSegList->append(m_pathElement->createSVGPathSegMovetoRel(targetPoint.x(), targetPoint.y(), m_pathSegRole));
62
void SVGPathSegListBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode)
64
ASSERT(m_pathElement);
65
ASSERT(m_pathSegList);
66
if (mode == AbsoluteCoordinates)
67
m_pathSegList->append(m_pathElement->createSVGPathSegLinetoAbs(targetPoint.x(), targetPoint.y(), m_pathSegRole));
69
m_pathSegList->append(m_pathElement->createSVGPathSegLinetoRel(targetPoint.x(), targetPoint.y(), m_pathSegRole));
72
void SVGPathSegListBuilder::lineToHorizontal(float x, PathCoordinateMode mode)
74
ASSERT(m_pathElement);
75
ASSERT(m_pathSegList);
76
if (mode == AbsoluteCoordinates)
77
m_pathSegList->append(m_pathElement->createSVGPathSegLinetoHorizontalAbs(x, m_pathSegRole));
79
m_pathSegList->append(m_pathElement->createSVGPathSegLinetoHorizontalRel(x, m_pathSegRole));
82
void SVGPathSegListBuilder::lineToVertical(float y, PathCoordinateMode mode)
84
ASSERT(m_pathElement);
85
ASSERT(m_pathSegList);
86
if (mode == AbsoluteCoordinates)
87
m_pathSegList->append(m_pathElement->createSVGPathSegLinetoVerticalAbs(y, m_pathSegRole));
89
m_pathSegList->append(m_pathElement->createSVGPathSegLinetoVerticalRel(y, m_pathSegRole));
92
void SVGPathSegListBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
94
ASSERT(m_pathElement);
95
ASSERT(m_pathSegList);
96
if (mode == AbsoluteCoordinates)
97
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicAbs(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), point2.x(), point2.y(), m_pathSegRole));
99
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicRel(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), point2.x(), point2.y(), m_pathSegRole));
102
void SVGPathSegListBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode)
104
ASSERT(m_pathElement);
105
ASSERT(m_pathSegList);
106
if (mode == AbsoluteCoordinates)
107
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicSmoothAbs(targetPoint.x(), targetPoint.y(), point2.x(), point2.y(), m_pathSegRole));
109
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicSmoothRel(targetPoint.x(), targetPoint.y(), point2.x(), point2.y(), m_pathSegRole));
112
void SVGPathSegListBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode)
114
ASSERT(m_pathElement);
115
ASSERT(m_pathSegList);
116
if (mode == AbsoluteCoordinates)
117
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticAbs(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), m_pathSegRole));
119
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticRel(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), m_pathSegRole));
122
void SVGPathSegListBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode)
124
ASSERT(m_pathElement);
125
ASSERT(m_pathSegList);
126
if (mode == AbsoluteCoordinates)
127
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticSmoothAbs(targetPoint.x(), targetPoint.y(), m_pathSegRole));
129
m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticSmoothRel(targetPoint.x(), targetPoint.y(), m_pathSegRole));
132
void SVGPathSegListBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode)
134
ASSERT(m_pathElement);
135
ASSERT(m_pathSegList);
136
if (mode == AbsoluteCoordinates)
137
m_pathSegList->append(m_pathElement->createSVGPathSegArcAbs(targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepFlag, m_pathSegRole));
139
m_pathSegList->append(m_pathElement->createSVGPathSegArcRel(targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepFlag, m_pathSegRole));
142
void SVGPathSegListBuilder::closePath()
144
ASSERT(m_pathElement);
145
ASSERT(m_pathSegList);
146
m_pathSegList->append(m_pathElement->createSVGPathSegClosePath(m_pathSegRole));
151
#endif // ENABLE(SVG)