diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/svg/SVGTransform.h')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/svg/SVGTransform.h | 76 |
1 files changed, 53 insertions, 23 deletions
diff --git a/chromium/third_party/WebKit/Source/core/svg/SVGTransform.h b/chromium/third_party/WebKit/Source/core/svg/SVGTransform.h index 71f7668b38d..51753bb1186 100644 --- a/chromium/third_party/WebKit/Source/core/svg/SVGTransform.h +++ b/chromium/third_party/WebKit/Source/core/svg/SVGTransform.h @@ -21,40 +21,62 @@ #ifndef SVGTransform_h #define SVGTransform_h -#include "core/svg/SVGMatrix.h" +#include "core/svg/properties/SVGProperty.h" #include "platform/geometry/FloatPoint.h" +#include "platform/transforms/AffineTransform.h" #include "wtf/text/WTFString.h" namespace WebCore { class FloatSize; +class SVGTransformTearOff; + +enum SVGTransformType { + SVG_TRANSFORM_UNKNOWN = 0, + SVG_TRANSFORM_MATRIX = 1, + SVG_TRANSFORM_TRANSLATE = 2, + SVG_TRANSFORM_SCALE = 3, + SVG_TRANSFORM_ROTATE = 4, + SVG_TRANSFORM_SKEWX = 5, + SVG_TRANSFORM_SKEWY = 6 +}; -class SVGTransform { +class SVGTransform : public SVGPropertyBase { public: - enum SVGTransformType { - SVG_TRANSFORM_UNKNOWN = 0, - SVG_TRANSFORM_MATRIX = 1, - SVG_TRANSFORM_TRANSLATE = 2, - SVG_TRANSFORM_SCALE = 3, - SVG_TRANSFORM_ROTATE = 4, - SVG_TRANSFORM_SKEWX = 5, - SVG_TRANSFORM_SKEWY = 6 - }; + typedef SVGTransformTearOff TearOffType; enum ConstructionMode { ConstructIdentityTransform, ConstructZeroTransform }; - SVGTransform(); - SVGTransform(SVGTransformType, ConstructionMode = ConstructIdentityTransform); - explicit SVGTransform(const AffineTransform&); + static PassRefPtr<SVGTransform> create() + { + return adoptRef(new SVGTransform()); + } + + static PassRefPtr<SVGTransform> create(SVGTransformType type, ConstructionMode mode = ConstructIdentityTransform) + { + return adoptRef(new SVGTransform(type, mode)); + } + + static PassRefPtr<SVGTransform> create(const AffineTransform& affineTransform) + { + return adoptRef(new SVGTransform(affineTransform)); + } + + virtual ~SVGTransform(); - SVGTransformType type() const { return m_type; } + PassRefPtr<SVGTransform> clone() const; + virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE; - SVGMatrix& svgMatrix() { return static_cast<SVGMatrix&>(m_matrix); } - AffineTransform matrix() const { return m_matrix; } - void updateSVGMatrix(); + SVGTransformType transformType() const { return m_transformType; } + + const AffineTransform& matrix() const { return m_matrix; } + + // |onMatrixChange| must be called after modifications via |mutableMatrix|. + AffineTransform* mutableMatrix() { return &m_matrix; } + void onMatrixChange(); float angle() const { return m_angle; } FloatPoint rotationCenter() const { return m_center; } @@ -70,15 +92,23 @@ public: FloatPoint translate() const; FloatSize scale() const; - bool isValid() const { return m_type != SVG_TRANSFORM_UNKNOWN; } - String valueAsString() const; + virtual String valueAsString() const OVERRIDE; + + virtual void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) OVERRIDE; + virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) OVERRIDE; + virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement* contextElement) OVERRIDE; - static const String& transformTypePrefixForParsing(SVGTransformType); + static AnimatedPropertyType classType() { return AnimatedTransform; } private: + SVGTransform(); + SVGTransform(SVGTransformType, ConstructionMode); + explicit SVGTransform(const AffineTransform&); + SVGTransform(SVGTransformType, float, const FloatPoint&, const AffineTransform&); + friend bool operator==(const SVGTransform& a, const SVGTransform& b); - SVGTransformType m_type; + SVGTransformType m_transformType; float m_angle; FloatPoint m_center; AffineTransform m_matrix; @@ -86,7 +116,7 @@ private: inline bool operator==(const SVGTransform& a, const SVGTransform& b) { - return a.m_type == b.m_type && a.m_angle == b.m_angle && a.m_matrix == b.m_matrix; + return a.m_transformType == b.m_transformType && a.m_angle == b.m_angle && a.m_matrix == b.m_matrix; } inline bool operator!=(const SVGTransform& a, const SVGTransform& b) |