• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "config.h"
21 
22 #if ENABLE(SVG)
23 #include "JSSVGMatrix.h"
24 
25 #include "TransformationMatrix.h"
26 #include "SVGException.h"
27 
28 using namespace JSC;
29 
30 namespace WebCore {
31 
inverse(ExecState * exec,const ArgList &)32 JSValue JSSVGMatrix::inverse(ExecState* exec, const ArgList&)
33 {
34     TransformationMatrix imp(*impl());
35     JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.inverse()).get(), m_context.get());
36 
37     if (!imp.isInvertible())
38         setDOMException(exec, SVGException::SVG_MATRIX_NOT_INVERTABLE);
39 
40     return result;
41 }
42 
rotateFromVector(ExecState * exec,const ArgList & args)43 JSValue JSSVGMatrix::rotateFromVector(ExecState* exec, const ArgList& args)
44 {
45     TransformationMatrix imp(*impl());
46 
47     float x = args.at(0).toFloat(exec);
48     float y = args.at(1).toFloat(exec);
49 
50     JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.rotateFromVector(x, y)).get(), m_context.get());
51 
52     if (x == 0.0 || y == 0.0)
53         setDOMException(exec, SVGException::SVG_INVALID_VALUE_ERR);
54 
55     return result;
56 }
57 
58 }
59 
60 #endif // ENABLE(SVG)
61