Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGMatrixTearOff.h
1 /*
2  * Copyright (C) 2014 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef SVGMatrixTearOff_h
32 #define SVGMatrixTearOff_h
33
34 #include "bindings/core/v8/ExceptionState.h"
35 #include "bindings/core/v8/ScriptWrappable.h"
36 #include "platform/transforms/AffineTransform.h"
37 #include "wtf/RefCounted.h"
38
39 namespace blink {
40
41 class SVGTransformTearOff;
42
43 // SVGMatrixTearOff wraps a AffineTransform for Javascript.
44 // Its instance can either hold a static value, or this can be teared off from |SVGTransform.matrix|.
45 // This does not derive from SVGPropertyTearOff, as its instances are never tied to an animated property nor an XML attribute.
46 class SVGMatrixTearOff FINAL : public RefCounted<SVGMatrixTearOff>, public ScriptWrappable {
47 public:
48     static PassRefPtr<SVGMatrixTearOff> create(const AffineTransform& value)
49     {
50         return adoptRef(new SVGMatrixTearOff(value));
51     }
52
53     static PassRefPtr<SVGMatrixTearOff> create(SVGTransformTearOff* target)
54     {
55         return adoptRef(new SVGMatrixTearOff(target));
56     }
57
58     ~SVGMatrixTearOff();
59
60     double a() { return value().a(); }
61     double b() { return value().b(); }
62     double c() { return value().c(); }
63     double d() { return value().d(); }
64     double e() { return value().e(); }
65     double f() { return value().f(); }
66
67     void setA(double, ExceptionState&);
68     void setB(double, ExceptionState&);
69     void setC(double, ExceptionState&);
70     void setD(double, ExceptionState&);
71     void setE(double, ExceptionState&);
72     void setF(double, ExceptionState&);
73
74     PassRefPtr<SVGMatrixTearOff> translate(double tx, double ty);
75     PassRefPtr<SVGMatrixTearOff> scale(double);
76     PassRefPtr<SVGMatrixTearOff> scaleNonUniform(double sx, double sy);
77     PassRefPtr<SVGMatrixTearOff> rotate(double);
78     PassRefPtr<SVGMatrixTearOff> flipX();
79     PassRefPtr<SVGMatrixTearOff> flipY();
80     PassRefPtr<SVGMatrixTearOff> skewX(double);
81     PassRefPtr<SVGMatrixTearOff> skewY(double);
82     PassRefPtr<SVGMatrixTearOff> multiply(PassRefPtr<SVGMatrixTearOff>);
83     PassRefPtr<SVGMatrixTearOff> inverse(ExceptionState&);
84     PassRefPtr<SVGMatrixTearOff> rotateFromVector(double x, double y, ExceptionState&);
85
86     SVGTransformTearOff* contextTransform() { return m_contextTransform; }
87
88     const AffineTransform& value() const;
89
90 private:
91     SVGMatrixTearOff(const AffineTransform&);
92     SVGMatrixTearOff(SVGTransformTearOff*);
93
94     AffineTransform* mutableValue();
95     void commitChange();
96
97     AffineTransform m_staticValue;
98
99     // FIXME: oilpan: This is raw-ptr to avoid reference cycles. Should be Member in oilpan.
100     SVGTransformTearOff* m_contextTransform;
101 };
102
103 } // namespace blink
104
105 #endif // SVGMatrixTearOff_h_