Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005 Rob Buis <buis (at) kde.org>
      4  * Copyright (C) 2007 Eric Seidel <eric (at) 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 
     25 #if ENABLE(SVG)
     26 #include "SVGPathTraversalStateBuilder.h"
     27 
     28 namespace WebCore {
     29 
     30 SVGPathTraversalStateBuilder::SVGPathTraversalStateBuilder()
     31     : m_traversalState(0)
     32     , m_desiredLength(0)
     33 {
     34 }
     35 
     36 void SVGPathTraversalStateBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode)
     37 {
     38     ASSERT(m_traversalState);
     39     m_traversalState->m_totalLength += m_traversalState->moveTo(targetPoint);
     40 }
     41 
     42 void SVGPathTraversalStateBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode)
     43 {
     44     ASSERT(m_traversalState);
     45     m_traversalState->m_totalLength += m_traversalState->lineTo(targetPoint);
     46 }
     47 
     48 void SVGPathTraversalStateBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode)
     49 {
     50     ASSERT(m_traversalState);
     51     m_traversalState->m_totalLength += m_traversalState->cubicBezierTo(point1, point2, targetPoint);
     52 }
     53 
     54 void SVGPathTraversalStateBuilder::closePath()
     55 {
     56     ASSERT(m_traversalState);
     57     m_traversalState->m_totalLength += m_traversalState->closeSubpath();
     58 }
     59 
     60 void SVGPathTraversalStateBuilder::setDesiredLength(float desiredLength)
     61 {
     62     ASSERT(m_traversalState);
     63     m_traversalState->m_desiredLength = desiredLength;
     64 }
     65 
     66 bool SVGPathTraversalStateBuilder::continueConsuming()
     67 {
     68     ASSERT(m_traversalState);
     69     ASSERT(m_traversalState->m_action == PathTraversalState::TraversalSegmentAtLength);
     70     return m_traversalState->m_totalLength < m_traversalState->m_desiredLength;
     71 }
     72 
     73 void SVGPathTraversalStateBuilder::incrementPathSegmentCount()
     74 {
     75     ASSERT(m_traversalState);
     76     ++m_traversalState->m_segmentIndex;
     77 }
     78 
     79 unsigned long SVGPathTraversalStateBuilder::pathSegmentIndex()
     80 {
     81     ASSERT(m_traversalState);
     82     return m_traversalState->m_segmentIndex;
     83 }
     84 
     85 }
     86 
     87 #endif // ENABLE(SVG)
     88