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#include "config.h"
32#include "core/svg/SVGTransformTearOff.h"
33
34#include "bindings/core/v8/ExceptionState.h"
35#include "core/dom/ExceptionCode.h"
36
37namespace blink {
38
39SVGTransformTearOff::SVGTransformTearOff(PassRefPtr<SVGTransform> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName)
40    : SVGPropertyTearOff<SVGTransform>(target, contextElement, propertyIsAnimVal, attributeName)
41{
42}
43
44SVGTransformTearOff::~SVGTransformTearOff()
45{
46}
47
48SVGMatrixTearOff* SVGTransformTearOff::matrix()
49{
50    if (!m_matrixTearoff) {
51        m_matrixTearoff = SVGMatrixTearOff::create(this);
52    }
53
54    return m_matrixTearoff.get();
55}
56
57void SVGTransformTearOff::setMatrix(PassRefPtr<SVGMatrixTearOff> matrix, ExceptionState& exceptionState)
58{
59    if (isImmutable()) {
60        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
61        return;
62    }
63
64    target()->setMatrix(matrix->value());
65    commitChange();
66}
67
68void SVGTransformTearOff::setTranslate(float tx, float ty, ExceptionState& exceptionState)
69{
70    if (isImmutable()) {
71        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
72        return;
73    }
74
75    target()->setTranslate(tx, ty);
76    commitChange();
77}
78
79void SVGTransformTearOff::setScale(float sx, float sy, ExceptionState& exceptionState)
80{
81    if (isImmutable()) {
82        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
83        return;
84    }
85
86    target()->setScale(sx, sy);
87    commitChange();
88}
89
90void SVGTransformTearOff::setRotate(float angle, float cx, float cy, ExceptionState& exceptionState)
91{
92    if (isImmutable()) {
93        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
94        return;
95    }
96
97    target()->setRotate(angle, cx, cy);
98    commitChange();
99}
100
101void SVGTransformTearOff::setSkewX(float x, ExceptionState& exceptionState)
102{
103    if (isImmutable()) {
104        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
105        return;
106    }
107
108    target()->setSkewX(x);
109    commitChange();
110}
111
112void SVGTransformTearOff::setSkewY(float y, ExceptionState& exceptionState)
113{
114    if (isImmutable()) {
115        exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
116        return;
117    }
118
119    target()->setSkewY(y);
120    commitChange();
121}
122
123}
124