EncodedJSValue JSC_HOST_CALL jsSVGPointPrototypeFunctionMatrixTransform(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSSVGPoint* castedThis = jsDynamicCast<JSSVGPoint*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSSVGPoint::info()); SVGPropertyTearOff<SVGPoint> & impl = castedThis->impl(); if (impl.isReadOnly()) { setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR); return JSValue::encode(jsUndefined()); } SVGPoint& podImpl = impl.propertyReference(); if (exec->argumentCount() < 1) return throwVMError(exec, createNotEnoughArgumentsError(exec)); if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSSVGMatrix::info())) return throwVMTypeError(exec); SVGPropertyTearOff<SVGMatrix>* matrix(toSVGMatrix(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); if (!matrix) { setDOMException(exec, TYPE_MISMATCH_ERR); return JSValue::encode(jsUndefined()); } JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(podImpl.matrixTransform(matrix->propertyReference())))); return JSValue::encode(result); }
EncodedJSValue JSC_HOST_CALL jsSVGTransformPrototypeFunctionSetMatrix(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSSVGTransform* castedThis = jsDynamicCast<JSSVGTransform*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSSVGTransform::info()); SVGPropertyTearOff<SVGTransform> & impl = castedThis->impl(); if (impl.isReadOnly()) { setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR); return JSValue::encode(jsUndefined()); } SVGTransform& podImpl = impl.propertyReference(); if (exec->argumentCount() < 1) return throwVMError(exec, createNotEnoughArgumentsError(exec)); if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSSVGMatrix::info())) return throwVMTypeError(exec); SVGPropertyTearOff<SVGMatrix>* matrix(toSVGMatrix(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); if (!matrix) { setDOMException(exec, TYPE_MISMATCH_ERR); return JSValue::encode(jsUndefined()); } podImpl.setMatrix(matrix->propertyReference()); impl.commitChange(); return JSValue::encode(jsUndefined()); }
JSValue* JSSVGMatrix::multiply(ExecState* exec, const ArgList& args) { AffineTransform imp(*impl()); AffineTransform secondMatrix = toSVGMatrix(args[0]); return toJS(exec, JSSVGPODTypeWrapperCreatorReadOnly<AffineTransform>::create(imp.multiply(secondMatrix)).get(), m_context.get()); }
JSValue* JSSVGTransformListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSSVGTransformList::info)) return throwError(exec, TypeError); SVGTransformList* imp = static_cast<SVGTransformList*>(static_cast<JSSVGTransformList*>(thisObj)->impl()); switch (id) { case JSSVGTransformList::ClearFuncNum: { ExceptionCode ec = 0; imp->clear(ec); setDOMException(exec, ec); return jsUndefined(); } case JSSVGTransformList::InitializeFuncNum: { ExceptionCode ec = 0; SVGTransform item = toSVGTransform(args[0]); KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->initialize(item, ec))); setDOMException(exec, ec); return result; } case JSSVGTransformList::GetItemFuncNum: { ExceptionCode ec = 0; bool indexOk; unsigned index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->getItem(index, ec))); setDOMException(exec, ec); return result; } case JSSVGTransformList::InsertItemBeforeFuncNum: { ExceptionCode ec = 0; SVGTransform item = toSVGTransform(args[0]); bool indexOk; unsigned index = args[1]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->insertItemBefore(item, index, ec))); setDOMException(exec, ec); return result; } case JSSVGTransformList::ReplaceItemFuncNum: { ExceptionCode ec = 0; SVGTransform item = toSVGTransform(args[0]); bool indexOk; unsigned index = args[1]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->replaceItem(item, index, ec))); setDOMException(exec, ec); return result; } case JSSVGTransformList::RemoveItemFuncNum: { ExceptionCode ec = 0; bool indexOk; unsigned index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->removeItem(index, ec))); setDOMException(exec, ec); return result; } case JSSVGTransformList::AppendItemFuncNum: { ExceptionCode ec = 0; SVGTransform item = toSVGTransform(args[0]); KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->appendItem(item, ec))); setDOMException(exec, ec); return result; } case JSSVGTransformList::CreateSVGTransformFromMatrixFuncNum: { AffineTransform matrix = toSVGMatrix(args[0]); KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->createSVGTransformFromMatrix(matrix))); return result; } case JSSVGTransformList::ConsolidateFuncNum: { KJS::JSValue* result = toJS(exec, new JSSVGPODTypeWrapper<SVGTransform>(imp->consolidate())); return result; } } return 0; }