1/*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2015 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 "SVGPathTraversalStateBuilder.h"
26
27#include "PathTraversalState.h"
28
29namespace WebCore {
30
31SVGPathTraversalStateBuilder::SVGPathTraversalStateBuilder(PathTraversalState& state, float desiredLength)
32 : m_traversalState(state)
33{
34 m_traversalState.setDesiredLength(desiredLength);
35}
36
37void SVGPathTraversalStateBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode)
38{
39 m_traversalState.processPathElement(PathElementMoveToPoint, &targetPoint);
40}
41
42void SVGPathTraversalStateBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode)
43{
44 m_traversalState.processPathElement(PathElementAddLineToPoint, &targetPoint);
45}
46
47void SVGPathTraversalStateBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode)
48{
49 FloatPoint points[] = { point1, point2, targetPoint };
50
51 m_traversalState.processPathElement(PathElementAddCurveToPoint, points);
52}
53
54void SVGPathTraversalStateBuilder::closePath()
55{
56 m_traversalState.processPathElement(PathElementCloseSubpath, nullptr);
57}
58
59bool SVGPathTraversalStateBuilder::continueConsuming()
60{
61 return !m_traversalState.success();
62}
63
64float SVGPathTraversalStateBuilder::totalLength() const
65{
66 return m_traversalState.totalLength();
67}
68
69FloatPoint SVGPathTraversalStateBuilder::currentPoint() const
70{
71 return m_traversalState.current();
72}
73
74}
75