Home | History | Annotate | Download | only in custom
      1 /*
      2  * Copyright (C) 2010 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #include "config.h"
     32 
     33 #if ENABLE(SVG)
     34 #include "V8SVGPathSeg.h"
     35 
     36 #include "V8DOMWindow.h"
     37 #include "V8DOMWrapper.h"
     38 #include "V8SVGPathSegArcAbs.h"
     39 #include "V8SVGPathSegArcRel.h"
     40 #include "V8SVGPathSegClosePath.h"
     41 #include "V8SVGPathSegCurvetoCubicAbs.h"
     42 #include "V8SVGPathSegCurvetoCubicRel.h"
     43 #include "V8SVGPathSegCurvetoCubicSmoothAbs.h"
     44 #include "V8SVGPathSegCurvetoCubicSmoothRel.h"
     45 #include "V8SVGPathSegCurvetoQuadraticAbs.h"
     46 #include "V8SVGPathSegCurvetoQuadraticRel.h"
     47 #include "V8SVGPathSegCurvetoQuadraticSmoothAbs.h"
     48 #include "V8SVGPathSegCurvetoQuadraticSmoothRel.h"
     49 #include "V8SVGPathSegLinetoAbs.h"
     50 #include "V8SVGPathSegLinetoHorizontalAbs.h"
     51 #include "V8SVGPathSegLinetoHorizontalRel.h"
     52 #include "V8SVGPathSegLinetoRel.h"
     53 #include "V8SVGPathSegLinetoVerticalAbs.h"
     54 #include "V8SVGPathSegLinetoVerticalRel.h"
     55 #include "V8SVGPathSegMovetoAbs.h"
     56 #include "V8SVGPathSegMovetoRel.h"
     57 
     58 namespace WebCore {
     59 
     60 v8::Handle<v8::Value> toV8(SVGPathSeg* impl)
     61 {
     62     if (!impl)
     63         return v8::Null();
     64     switch (impl->pathSegType()) {
     65     case SVGPathSeg::PATHSEG_CLOSEPATH:
     66         return toV8(static_cast<SVGPathSegClosePath*>(impl));
     67     case SVGPathSeg::PATHSEG_MOVETO_ABS:
     68         return toV8(static_cast<SVGPathSegMovetoAbs*>(impl));
     69     case SVGPathSeg::PATHSEG_MOVETO_REL:
     70         return toV8(static_cast<SVGPathSegMovetoRel*>(impl));
     71     case SVGPathSeg::PATHSEG_LINETO_ABS:
     72         return toV8(static_cast<SVGPathSegLinetoAbs*>(impl));
     73     case SVGPathSeg::PATHSEG_LINETO_REL:
     74         return toV8(static_cast<SVGPathSegLinetoRel*>(impl));
     75     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
     76         return toV8(static_cast<SVGPathSegCurvetoCubicAbs*>(impl));
     77     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
     78         return toV8(static_cast<SVGPathSegCurvetoCubicRel*>(impl));
     79     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
     80         return toV8(static_cast<SVGPathSegCurvetoQuadraticAbs*>(impl));
     81     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
     82         return toV8(static_cast<SVGPathSegCurvetoQuadraticRel*>(impl));
     83     case SVGPathSeg::PATHSEG_ARC_ABS:
     84         return toV8(static_cast<SVGPathSegArcAbs*>(impl));
     85     case SVGPathSeg::PATHSEG_ARC_REL:
     86         return toV8(static_cast<SVGPathSegArcRel*>(impl));
     87     case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
     88         return toV8(static_cast<SVGPathSegLinetoHorizontalAbs*>(impl));
     89     case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
     90         return toV8(static_cast<SVGPathSegLinetoHorizontalRel*>(impl));
     91     case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
     92         return toV8(static_cast<SVGPathSegLinetoVerticalAbs*>(impl));
     93     case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
     94         return toV8(static_cast<SVGPathSegLinetoVerticalRel*>(impl));
     95     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
     96         return toV8(static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(impl));
     97     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
     98         return toV8(static_cast<SVGPathSegCurvetoCubicSmoothRel*>(impl));
     99     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
    100         return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(impl));
    101     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
    102         return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(impl));
    103     }
    104     ASSERT_NOT_REACHED();
    105     return V8SVGPathSeg::wrap(impl);
    106 }
    107 
    108 } // namespace WebCore
    109 
    110 #endif
    111