webengine/osswebengine/DerivedSources/WebCore/JSSVGMatrix.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2     This file is part of the WebKit open source project.
       
     3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
       
     4 
       
     5     This library is free software; you can redistribute it and/or
       
     6     modify it under the terms of the GNU Library General Public
       
     7     License as published by the Free Software Foundation; either
       
     8     version 2 of the License, or (at your option) any later version.
       
     9 
       
    10     This library is distributed in the hope that it will be useful,
       
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13     Library General Public License for more details.
       
    14 
       
    15     You should have received a copy of the GNU Library General Public License
       
    16     along with this library; see the file COPYING.LIB.  If not, write to
       
    17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18     Boston, MA 02110-1301, USA.
       
    19 */
       
    20 
       
    21 #include "config.h"
       
    22 
       
    23 
       
    24 #if ENABLE(SVG)
       
    25 
       
    26 #include "Document.h"
       
    27 #include "Frame.h"
       
    28 #include "SVGDocumentExtensions.h"
       
    29 #include "SVGElement.h"
       
    30 #include "SVGAnimatedTemplate.h"
       
    31 #include "JSSVGMatrix.h"
       
    32 
       
    33 #include <wtf/GetPtr.h>
       
    34 
       
    35 #include "JSSVGMatrix.h"
       
    36 
       
    37 using namespace KJS;
       
    38 
       
    39 namespace WebCore {
       
    40 
       
    41 /* Hash table */
       
    42 
       
    43 static const HashEntry JSSVGMatrixTableEntries[] =
       
    44 {
       
    45     { 0, 0, 0, 0, 0 },
       
    46     { "b", JSSVGMatrix::BAttrNum, DontDelete, 0, &JSSVGMatrixTableEntries[7] },
       
    47     { 0, 0, 0, 0, 0 },
       
    48     { "c", JSSVGMatrix::CAttrNum, DontDelete, 0, &JSSVGMatrixTableEntries[6] },
       
    49     { "f", JSSVGMatrix::FAttrNum, DontDelete, 0, 0 },
       
    50     { "a", JSSVGMatrix::AAttrNum, DontDelete, 0, 0 },
       
    51     { "d", JSSVGMatrix::DAttrNum, DontDelete, 0, 0 },
       
    52     { "e", JSSVGMatrix::EAttrNum, DontDelete, 0, 0 }
       
    53 };
       
    54 
       
    55 static const HashTable JSSVGMatrixTable = 
       
    56 {
       
    57     2, 8, JSSVGMatrixTableEntries, 6
       
    58 };
       
    59 
       
    60 /* Hash table for prototype */
       
    61 
       
    62 static const HashEntry JSSVGMatrixPrototypeTableEntries[] =
       
    63 {
       
    64     { "skewX", JSSVGMatrix::SkewXFuncNum, DontDelete|Function, 1, 0 },
       
    65     { 0, 0, 0, 0, 0 },
       
    66     { "rotateFromVector", JSSVGMatrix::RotateFromVectorFuncNum, DontDelete|Function, 2, 0 },
       
    67     { 0, 0, 0, 0, 0 },
       
    68     { "flipX", JSSVGMatrix::FlipXFuncNum, DontDelete|Function, 0, 0 },
       
    69     { "multiply", JSSVGMatrix::MultiplyFuncNum, DontDelete|Function, 1, 0 },
       
    70     { 0, 0, 0, 0, 0 },
       
    71     { "inverse", JSSVGMatrix::InverseFuncNum, DontDelete|Function, 0, &JSSVGMatrixPrototypeTableEntries[11] },
       
    72     { "rotate", JSSVGMatrix::RotateFuncNum, DontDelete|Function, 1, 0 },
       
    73     { "scaleNonUniform", JSSVGMatrix::ScaleNonUniformFuncNum, DontDelete|Function, 2, &JSSVGMatrixPrototypeTableEntries[12] },
       
    74     { "scale", JSSVGMatrix::ScaleFuncNum, DontDelete|Function, 1, &JSSVGMatrixPrototypeTableEntries[13] },
       
    75     { "translate", JSSVGMatrix::TranslateFuncNum, DontDelete|Function, 2, 0 },
       
    76     { "flipY", JSSVGMatrix::FlipYFuncNum, DontDelete|Function, 0, 0 },
       
    77     { "skewY", JSSVGMatrix::SkewYFuncNum, DontDelete|Function, 1, 0 }
       
    78 };
       
    79 
       
    80 static const HashTable JSSVGMatrixPrototypeTable = 
       
    81 {
       
    82     2, 14, JSSVGMatrixPrototypeTableEntries, 11
       
    83 };
       
    84 
       
    85 const ClassInfo JSSVGMatrixPrototype::info = { "SVGMatrixPrototype", 0, &JSSVGMatrixPrototypeTable, 0 };
       
    86 
       
    87 JSObject* JSSVGMatrixPrototype::self(ExecState* exec)
       
    88 {
       
    89     return KJS::cacheGlobalObject<JSSVGMatrixPrototype>(exec, "[[JSSVGMatrix.prototype]]");
       
    90 }
       
    91 
       
    92 bool JSSVGMatrixPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    93 {
       
    94     return getStaticFunctionSlot<JSSVGMatrixPrototypeFunction, JSObject>(exec, &JSSVGMatrixPrototypeTable, this, propertyName, slot);
       
    95 }
       
    96 
       
    97 const ClassInfo JSSVGMatrix::info = { "SVGMatrix", 0, &JSSVGMatrixTable, 0 };
       
    98 
       
    99 JSSVGMatrix::JSSVGMatrix(ExecState* exec, JSSVGPODTypeWrapper<AffineTransform>* impl)
       
   100     : m_impl(impl)
       
   101 {
       
   102     setPrototype(JSSVGMatrixPrototype::self(exec));
       
   103 }
       
   104 
       
   105 JSSVGMatrix::~JSSVGMatrix()
       
   106 {
       
   107     ScriptInterpreter::forgetDOMObject(m_impl.get());
       
   108 }
       
   109 
       
   110 bool JSSVGMatrix::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   111 {
       
   112     return getStaticValueSlot<JSSVGMatrix, KJS::DOMObject>(exec, &JSSVGMatrixTable, this, propertyName, slot);
       
   113 }
       
   114 
       
   115 JSValue* JSSVGMatrix::getValueProperty(ExecState* exec, int token) const
       
   116 {
       
   117     switch (token) {
       
   118     case AAttrNum: {
       
   119         AffineTransform& imp(*impl());
       
   120 
       
   121         return jsNumber(imp.a());
       
   122     }
       
   123     case BAttrNum: {
       
   124         AffineTransform& imp(*impl());
       
   125 
       
   126         return jsNumber(imp.b());
       
   127     }
       
   128     case CAttrNum: {
       
   129         AffineTransform& imp(*impl());
       
   130 
       
   131         return jsNumber(imp.c());
       
   132     }
       
   133     case DAttrNum: {
       
   134         AffineTransform& imp(*impl());
       
   135 
       
   136         return jsNumber(imp.d());
       
   137     }
       
   138     case EAttrNum: {
       
   139         AffineTransform& imp(*impl());
       
   140 
       
   141         return jsNumber(imp.e());
       
   142     }
       
   143     case FAttrNum: {
       
   144         AffineTransform& imp(*impl());
       
   145 
       
   146         return jsNumber(imp.f());
       
   147     }
       
   148     }
       
   149     return 0;
       
   150 }
       
   151 
       
   152 void JSSVGMatrix::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
       
   153 {
       
   154     lookupPut<JSSVGMatrix, KJS::DOMObject>(exec, propertyName, value, attr, &JSSVGMatrixTable, this);
       
   155 }
       
   156 
       
   157 void JSSVGMatrix::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
       
   158 {
       
   159     switch (token) {
       
   160     case AAttrNum: {
       
   161         AffineTransform& imp(*impl());
       
   162 
       
   163         imp.setA(value->toNumber(exec));
       
   164         m_impl->commitChange(exec);
       
   165         break;
       
   166     }
       
   167     case BAttrNum: {
       
   168         AffineTransform& imp(*impl());
       
   169 
       
   170         imp.setB(value->toNumber(exec));
       
   171         m_impl->commitChange(exec);
       
   172         break;
       
   173     }
       
   174     case CAttrNum: {
       
   175         AffineTransform& imp(*impl());
       
   176 
       
   177         imp.setC(value->toNumber(exec));
       
   178         m_impl->commitChange(exec);
       
   179         break;
       
   180     }
       
   181     case DAttrNum: {
       
   182         AffineTransform& imp(*impl());
       
   183 
       
   184         imp.setD(value->toNumber(exec));
       
   185         m_impl->commitChange(exec);
       
   186         break;
       
   187     }
       
   188     case EAttrNum: {
       
   189         AffineTransform& imp(*impl());
       
   190 
       
   191         imp.setE(value->toNumber(exec));
       
   192         m_impl->commitChange(exec);
       
   193         break;
       
   194     }
       
   195     case FAttrNum: {
       
   196         AffineTransform& imp(*impl());
       
   197 
       
   198         imp.setF(value->toNumber(exec));
       
   199         m_impl->commitChange(exec);
       
   200         break;
       
   201     }
       
   202     }
       
   203 }
       
   204 
       
   205 JSValue* JSSVGMatrixPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   206 {
       
   207     if (!thisObj->inherits(&JSSVGMatrix::info))
       
   208       return throwError(exec, TypeError);
       
   209 
       
   210     JSSVGPODTypeWrapper<AffineTransform>* wrapper = static_cast<JSSVGMatrix*>(thisObj)->impl();
       
   211     AffineTransform& imp(*wrapper);
       
   212 
       
   213     switch (id) {
       
   214     case JSSVGMatrix::MultiplyFuncNum: {
       
   215         AffineTransform secondMatrix = toSVGMatrix(args[0]);
       
   216 
       
   217 
       
   218         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.multiply(secondMatrix)));
       
   219         wrapper->commitChange(exec);
       
   220         return result;
       
   221     }
       
   222     case JSSVGMatrix::InverseFuncNum: {
       
   223         return static_cast<JSSVGMatrix*>(thisObj)->inverse(exec, args);
       
   224     }
       
   225     case JSSVGMatrix::TranslateFuncNum: {
       
   226         double x = args[0]->toNumber(exec);
       
   227         double y = args[1]->toNumber(exec);
       
   228 
       
   229 
       
   230         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.translate(x, y)));
       
   231         wrapper->commitChange(exec);
       
   232         return result;
       
   233     }
       
   234     case JSSVGMatrix::ScaleFuncNum: {
       
   235         double scaleFactor = args[0]->toNumber(exec);
       
   236 
       
   237 
       
   238         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.scale(scaleFactor)));
       
   239         wrapper->commitChange(exec);
       
   240         return result;
       
   241     }
       
   242     case JSSVGMatrix::ScaleNonUniformFuncNum: {
       
   243         double scaleFactorX = args[0]->toNumber(exec);
       
   244         double scaleFactorY = args[1]->toNumber(exec);
       
   245 
       
   246 
       
   247         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.scaleNonUniform(scaleFactorX, scaleFactorY)));
       
   248         wrapper->commitChange(exec);
       
   249         return result;
       
   250     }
       
   251     case JSSVGMatrix::RotateFuncNum: {
       
   252         double angle = args[0]->toNumber(exec);
       
   253 
       
   254 
       
   255         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.rotate(angle)));
       
   256         wrapper->commitChange(exec);
       
   257         return result;
       
   258     }
       
   259     case JSSVGMatrix::RotateFromVectorFuncNum: {
       
   260         return static_cast<JSSVGMatrix*>(thisObj)->rotateFromVector(exec, args);
       
   261     }
       
   262     case JSSVGMatrix::FlipXFuncNum: {
       
   263 
       
   264 
       
   265         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.flipX()));
       
   266         wrapper->commitChange(exec);
       
   267         return result;
       
   268     }
       
   269     case JSSVGMatrix::FlipYFuncNum: {
       
   270 
       
   271 
       
   272         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.flipY()));
       
   273         wrapper->commitChange(exec);
       
   274         return result;
       
   275     }
       
   276     case JSSVGMatrix::SkewXFuncNum: {
       
   277         double angle = args[0]->toNumber(exec);
       
   278 
       
   279 
       
   280         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.skewX(angle)));
       
   281         wrapper->commitChange(exec);
       
   282         return result;
       
   283     }
       
   284     case JSSVGMatrix::SkewYFuncNum: {
       
   285         double angle = args[0]->toNumber(exec);
       
   286 
       
   287 
       
   288         KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<AffineTransform>(imp.skewY(angle)));
       
   289         wrapper->commitChange(exec);
       
   290         return result;
       
   291     }
       
   292     }
       
   293     return 0;
       
   294 }
       
   295 KJS::JSValue* toJS(KJS::ExecState* exec, JSSVGPODTypeWrapper<AffineTransform>* obj)
       
   296 {
       
   297     return KJS::cacheDOMObject<JSSVGPODTypeWrapper<AffineTransform>, JSSVGMatrix>(exec, obj);
       
   298 }
       
   299 AffineTransform toSVGMatrix(KJS::JSValue* val)
       
   300 {
       
   301     return val->isObject(&JSSVGMatrix::info) ? (AffineTransform) *static_cast<JSSVGMatrix*>(val)->impl() : AffineTransform();
       
   302 }
       
   303 
       
   304 }
       
   305 
       
   306 #endif // ENABLE(SVG)