Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPathTraversalStateBuilder.cpp

Issue 1471943003: Introduce SVGPathQuery to hold SVG path query methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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) Research In Motion Limited 2010. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23 #include "config.h"
24 #include "core/svg/SVGPathTraversalStateBuilder.h"
25
26 #include "core/svg/SVGPathData.h"
27 #include "platform/graphics/PathTraversalState.h"
28
29 namespace blink {
30
31 SVGPathTraversalStateBuilder::SVGPathTraversalStateBuilder(PathTraversalState::P athTraversalAction traversalAction, float desiredLength)
32 : m_traversalState(traversalAction)
33 , m_segmentIndex(0)
34 {
35 m_traversalState.m_desiredLength = desiredLength;
36 }
37
38 void SVGPathTraversalStateBuilder::emitSegment(const PathSegmentData& segment)
39 {
40 switch (segment.command) {
41 case PathSegMoveToAbs:
42 m_traversalState.m_totalLength += m_traversalState.moveTo(segment.target Point);
43 break;
44 case PathSegLineToAbs:
45 m_traversalState.m_totalLength += m_traversalState.lineTo(segment.target Point);
46 break;
47 case PathSegClosePath:
48 m_traversalState.m_totalLength += m_traversalState.closeSubpath();
49 break;
50 case PathSegCurveToCubicAbs:
51 m_traversalState.m_totalLength += m_traversalState.cubicBezierTo(segment .point1, segment.point2, segment.targetPoint);
52 break;
53 default:
54 ASSERT_NOT_REACHED();
55 }
56 }
57
58 bool SVGPathTraversalStateBuilder::continueConsuming()
59 {
60 m_traversalState.processSegment();
61 return !m_traversalState.m_success;
62 }
63
64 void SVGPathTraversalStateBuilder::incrementPathSegmentCount()
65 {
66 ++m_segmentIndex;
67 }
68
69 float SVGPathTraversalStateBuilder::totalLength()
70 {
71 return m_traversalState.m_totalLength;
72 }
73
74 FloatPoint SVGPathTraversalStateBuilder::currentPoint()
75 {
76 return m_traversalState.m_current;
77 }
78
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698