diff options
Diffstat (limited to 'Source/WebCore/svg/SVGPoint.h')
-rw-r--r-- | Source/WebCore/svg/SVGPoint.h | 99 |
1 files changed, 91 insertions, 8 deletions
diff --git a/Source/WebCore/svg/SVGPoint.h b/Source/WebCore/svg/SVGPoint.h index 32c1537d7..e9c6dc917 100644 --- a/Source/WebCore/svg/SVGPoint.h +++ b/Source/WebCore/svg/SVGPoint.h @@ -23,19 +23,102 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SVGPoint_h -#define SVGPoint_h - -#if ENABLE(SVG) +#pragma once +#include "ExceptionCode.h" #include "FloatPoint.h" +#include "SVGMatrix.h" +#include "SVGPropertyTearOff.h" namespace WebCore { -typedef FloatPoint SVGPoint; +class SVGPoint : public SVGPropertyTearOff<FloatPoint> { +public: + static Ref<SVGPoint> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatPoint& value) + { + return adoptRef(*new SVGPoint(animatedProperty, role, value)); + } -} // namespace WebCore + static Ref<SVGPoint> create(const FloatPoint& initialValue = { }) + { + return adoptRef(*new SVGPoint(initialValue)); + } + + static Ref<SVGPoint> create(const FloatPoint* initialValue) + { + return adoptRef(*new SVGPoint(initialValue)); + } + + template<typename T> static ExceptionOr<Ref<SVGPoint>> create(ExceptionOr<T>&& initialValue) + { + if (initialValue.hasException()) + return initialValue.releaseException(); + return create(initialValue.releaseReturnValue()); + } + + float x() + { + return propertyReference().x(); + } + + ExceptionOr<void> setX(float xValue) + { + if (isReadOnly()) + return Exception { NO_MODIFICATION_ALLOWED_ERR }; + + propertyReference().setX(xValue); + commitChange(); + + return { }; + } + + float y() + { + return propertyReference().y(); + } + + ExceptionOr<void> setY(float xValue) + { + if (isReadOnly()) + return Exception { NO_MODIFICATION_ALLOWED_ERR }; -#endif // ENABLE(SVG) + propertyReference().setY(xValue); + commitChange(); -#endif // SVGPoint_h + return { }; + } + + ExceptionOr<Ref<SVGPoint>> matrixTransform(SVGMatrix& matrix) + { + if (isReadOnly()) + return Exception { NO_MODIFICATION_ALLOWED_ERR }; + + auto newPoint = propertyReference().matrixTransform(matrix.propertyReference()); + commitChange(); + + return SVGPoint::create(newPoint); + } + +protected: + SVGPoint(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatPoint& value) + : SVGPropertyTearOff<FloatPoint>(&animatedProperty, role, value) + { + } + + SVGPoint(SVGPropertyRole role, FloatPoint& value) + : SVGPropertyTearOff<FloatPoint>(nullptr, role, value) + { + } + + explicit SVGPoint(const FloatPoint& initialValue) + : SVGPropertyTearOff<FloatPoint>(initialValue) + { + } + + explicit SVGPoint(const FloatPoint* initialValue) + : SVGPropertyTearOff<FloatPoint>(initialValue) + { + } +}; + +} // namespace WebCore |