From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- dom/svg/SVGTransformListSMILType.h | 131 +++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 dom/svg/SVGTransformListSMILType.h (limited to 'dom/svg/SVGTransformListSMILType.h') diff --git a/dom/svg/SVGTransformListSMILType.h b/dom/svg/SVGTransformListSMILType.h new file mode 100644 index 000000000..526f9ba50 --- /dev/null +++ b/dom/svg/SVGTransformListSMILType.h @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef SVGTRANSFORMLISTSMILTYPE_H_ +#define SVGTRANSFORMLISTSMILTYPE_H_ + +#include "mozilla/Attributes.h" +#include "nsISMILType.h" +#include "nsTArray.h" + +class nsSMILValue; + +namespace mozilla { + +class nsSVGTransform; +class SVGTransformList; +class SVGTransformSMILData; + +//////////////////////////////////////////////////////////////////////// +// SVGTransformListSMILType +// +// Operations for animating an nsSVGTransformList. +// +// This class is confused somewhat by the fact that: +// (i) An element animates an SVGTransformList +// (ii) BUT only allows the user to specify animation values +// for an nsSVGTransform +// +// This may be rectified in a future edition of SVG but for now it means that +// the underlying value of an animation may be something of the form: +// +// rotate(90) scale(2) skewX(50) +// +// BUT the animation values can only ever be SINGLE transform operations such as +// +// rotate(90) +// +// (actually the syntax here is: +// element and so these values can only ever contain 0 or +// 1 TRANSFORM elements as the syntax doesn't allow more. (A "value" here is +// a single element in the values array such as "0 50 20" above.) +// +// Likewise ComputeDistance() only ever operates within the values specified on +// an element so similar conditions hold. +// +// However, SandwichAdd() combines with a base value which may contain 0..n +// transforms either because the base value of the attribute specifies a series +// of transforms, e.g. +// +// +// +// +// +// or because several animations target the same attribute and are additive and +// so are simply appended on to the transformation array, e.g. +// +// +// +// +// +// +// +// Similar conditions hold for Interpolate() which in cases such as to-animation +// may have use a start-value the base value of the target attribute (which as +// we have seen above can contain 0..n elements) whilst the end-value comes from +// the and so can only hold 1 transform. +// +class SVGTransformListSMILType : public nsISMILType +{ +public: + // Singleton for nsSMILValue objects to hold onto. + static SVGTransformListSMILType* + Singleton() + { + static SVGTransformListSMILType sSingleton; + return &sSingleton; + } + +protected: + // nsISMILType Methods + // ------------------- + virtual void Init(nsSMILValue& aValue) const override; + virtual void Destroy(nsSMILValue& aValue) const override; + virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const override; + virtual bool IsEqual(const nsSMILValue& aLeft, + const nsSMILValue& aRight) const override; + virtual nsresult Add(nsSMILValue& aDest, + const nsSMILValue& aValueToAdd, + uint32_t aCount) const override; + virtual nsresult SandwichAdd(nsSMILValue& aDest, + const nsSMILValue& aValueToAdd) const override; + virtual nsresult ComputeDistance(const nsSMILValue& aFrom, + const nsSMILValue& aTo, + double& aDistance) const override; + virtual nsresult Interpolate(const nsSMILValue& aStartVal, + const nsSMILValue& aEndVal, + double aUnitDistance, + nsSMILValue& aResult) const override; + +public: + // Transform array accessors + // ------------------------- + static nsresult AppendTransform(const SVGTransformSMILData& aTransform, + nsSMILValue& aValue); + static bool AppendTransforms(const SVGTransformList& aList, + nsSMILValue& aValue); + static bool GetTransforms(const nsSMILValue& aValue, + FallibleTArray& aTransforms); + + +private: + // Private constructor: prevent instances beyond my singleton. + constexpr SVGTransformListSMILType() {} +}; + +} // end namespace mozilla + +#endif // SVGLISTTRANSFORMSMILTYPE_H_ -- cgit v1.2.3