1/*
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * Copyright (C) 2015 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#pragma once
23
24#include "SVGPathConsumer.h"
25
26namespace WebCore {
27
28class FloatPoint;
29class PathTraversalState;
30
31class SVGPathTraversalStateBuilder final : public SVGPathConsumer {
32public:
33 SVGPathTraversalStateBuilder(PathTraversalState&, float desiredLength = 0);
34
35 unsigned pathSegmentIndex() const { return m_segmentIndex; }
36 float totalLength() const;
37 FloatPoint currentPoint() const;
38
39 void incrementPathSegmentCount() final { ++m_segmentIndex; }
40 bool continueConsuming() final;
41
42private:
43 // Used in UnalteredParsing/NormalizedParsing modes.
44 void moveTo(const FloatPoint&, bool closed, PathCoordinateMode) final;
45 void lineTo(const FloatPoint&, PathCoordinateMode) final;
46 void curveToCubic(const FloatPoint&, const FloatPoint&, const FloatPoint&, PathCoordinateMode) final;
47 void closePath() final;
48
49private:
50 // Not used for PathTraversalState.
51 void lineToHorizontal(float, PathCoordinateMode) final { ASSERT_NOT_REACHED(); }
52 void lineToVertical(float, PathCoordinateMode) final { ASSERT_NOT_REACHED(); }
53 void curveToCubicSmooth(const FloatPoint&, const FloatPoint&, PathCoordinateMode) final { ASSERT_NOT_REACHED(); }
54 void curveToQuadratic(const FloatPoint&, const FloatPoint&, PathCoordinateMode) final { ASSERT_NOT_REACHED(); }
55 void curveToQuadraticSmooth(const FloatPoint&, PathCoordinateMode) final { ASSERT_NOT_REACHED(); }
56 void arcTo(float, float, float, bool, bool, const FloatPoint&, PathCoordinateMode) final { ASSERT_NOT_REACHED(); }
57
58 PathTraversalState& m_traversalState;
59 unsigned m_segmentIndex { 0 };
60};
61
62} // namespace WebCore
63