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 #include "V8SVGPathSeg.h" 33 34 #include "V8DOMWindow.h" 35 #include "V8DOMWrapper.h" 36 #include "V8SVGPathSegArcAbs.h" 37 #include "V8SVGPathSegArcRel.h" 38 #include "V8SVGPathSegClosePath.h" 39 #include "V8SVGPathSegCurvetoCubicAbs.h" 40 #include "V8SVGPathSegCurvetoCubicRel.h" 41 #include "V8SVGPathSegCurvetoCubicSmoothAbs.h" 42 #include "V8SVGPathSegCurvetoCubicSmoothRel.h" 43 #include "V8SVGPathSegCurvetoQuadraticAbs.h" 44 #include "V8SVGPathSegCurvetoQuadraticRel.h" 45 #include "V8SVGPathSegCurvetoQuadraticSmoothAbs.h" 46 #include "V8SVGPathSegCurvetoQuadraticSmoothRel.h" 47 #include "V8SVGPathSegLinetoAbs.h" 48 #include "V8SVGPathSegLinetoHorizontalAbs.h" 49 #include "V8SVGPathSegLinetoHorizontalRel.h" 50 #include "V8SVGPathSegLinetoRel.h" 51 #include "V8SVGPathSegLinetoVerticalAbs.h" 52 #include "V8SVGPathSegLinetoVerticalRel.h" 53 #include "V8SVGPathSegMovetoAbs.h" 54 #include "V8SVGPathSegMovetoRel.h" 55 56 namespace WebCore { 57 58 v8::Handle<v8::Value> toV8(SVGPathSeg* impl) 59 { 60 if (!impl) 61 return v8::Null(); 62 switch (impl->pathSegType()) { 63 case SVGPathSeg::PATHSEG_CLOSEPATH: 64 return toV8(static_cast<SVGPathSegClosePath*>(impl)); 65 case SVGPathSeg::PATHSEG_MOVETO_ABS: 66 return toV8(static_cast<SVGPathSegMovetoAbs*>(impl)); 67 case SVGPathSeg::PATHSEG_MOVETO_REL: 68 return toV8(static_cast<SVGPathSegMovetoRel*>(impl)); 69 case SVGPathSeg::PATHSEG_LINETO_ABS: 70 return toV8(static_cast<SVGPathSegLinetoAbs*>(impl)); 71 case SVGPathSeg::PATHSEG_LINETO_REL: 72 return toV8(static_cast<SVGPathSegLinetoRel*>(impl)); 73 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: 74 return toV8(static_cast<SVGPathSegCurvetoCubicAbs*>(impl)); 75 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: 76 return toV8(static_cast<SVGPathSegCurvetoCubicRel*>(impl)); 77 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: 78 return toV8(static_cast<SVGPathSegCurvetoQuadraticAbs*>(impl)); 79 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: 80 return toV8(static_cast<SVGPathSegCurvetoQuadraticRel*>(impl)); 81 case SVGPathSeg::PATHSEG_ARC_ABS: 82 return toV8(static_cast<SVGPathSegArcAbs*>(impl)); 83 case SVGPathSeg::PATHSEG_ARC_REL: 84 return toV8(static_cast<SVGPathSegArcRel*>(impl)); 85 case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: 86 return toV8(static_cast<SVGPathSegLinetoHorizontalAbs*>(impl)); 87 case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: 88 return toV8(static_cast<SVGPathSegLinetoHorizontalRel*>(impl)); 89 case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: 90 return toV8(static_cast<SVGPathSegLinetoVerticalAbs*>(impl)); 91 case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: 92 return toV8(static_cast<SVGPathSegLinetoVerticalRel*>(impl)); 93 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: 94 return toV8(static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(impl)); 95 case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: 96 return toV8(static_cast<SVGPathSegCurvetoCubicSmoothRel*>(impl)); 97 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: 98 return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(impl)); 99 case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: 100 return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(impl)); 101 } 102 ASSERT_NOT_REACHED(); 103 return V8SVGPathSeg::wrap(impl); 104 } 105 106 } // namespace WebCore 107