From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/svg/SVGPoint.h | 99 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 8 deletions(-) (limited to 'Source/WebCore/svg/SVGPoint.h') 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 { +public: + static Ref create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatPoint& value) + { + return adoptRef(*new SVGPoint(animatedProperty, role, value)); + } -} // namespace WebCore + static Ref create(const FloatPoint& initialValue = { }) + { + return adoptRef(*new SVGPoint(initialValue)); + } + + static Ref create(const FloatPoint* initialValue) + { + return adoptRef(*new SVGPoint(initialValue)); + } + + template static ExceptionOr> create(ExceptionOr&& initialValue) + { + if (initialValue.hasException()) + return initialValue.releaseException(); + return create(initialValue.releaseReturnValue()); + } + + float x() + { + return propertyReference().x(); + } + + ExceptionOr setX(float xValue) + { + if (isReadOnly()) + return Exception { NO_MODIFICATION_ALLOWED_ERR }; + + propertyReference().setX(xValue); + commitChange(); + + return { }; + } + + float y() + { + return propertyReference().y(); + } + + ExceptionOr setY(float xValue) + { + if (isReadOnly()) + return Exception { NO_MODIFICATION_ALLOWED_ERR }; -#endif // ENABLE(SVG) + propertyReference().setY(xValue); + commitChange(); -#endif // SVGPoint_h + return { }; + } + + ExceptionOr> 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(&animatedProperty, role, value) + { + } + + SVGPoint(SVGPropertyRole role, FloatPoint& value) + : SVGPropertyTearOff(nullptr, role, value) + { + } + + explicit SVGPoint(const FloatPoint& initialValue) + : SVGPropertyTearOff(initialValue) + { + } + + explicit SVGPoint(const FloatPoint* initialValue) + : SVGPropertyTearOff(initialValue) + { + } +}; + +} // namespace WebCore -- cgit v1.2.1