OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 11 matching lines...) Expand all Loading... |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/svg/SVGAngleTearOff.h" | 32 #include "core/svg/SVGTransformTearOff.h" |
33 | 33 |
34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 SVGAngleTearOff::SVGAngleTearOff(PassRefPtr<SVGAngle> targetProperty, SVGElement
* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName&
attributeName) | 39 SVGTransformTearOff::SVGTransformTearOff(PassRefPtr<SVGTransform> target, SVGEle
ment* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedNa
me& attributeName) |
40 : NewSVGPropertyTearOff<SVGAngle>(targetProperty, contextElement, propertyIs
AnimVal, attributeName) | 40 : NewSVGPropertyTearOff<SVGTransform>(target, contextElement, propertyIsAnim
Val, attributeName) |
41 { | 41 { |
42 ScriptWrappable::init(this); | 42 ScriptWrappable::init(this); |
43 } | 43 } |
44 | 44 |
45 SVGAngleTearOff::~SVGAngleTearOff() | 45 SVGTransformTearOff::~SVGTransformTearOff() |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 void SVGAngleTearOff::setValue(float value, ExceptionState& exceptionState) | 49 SVGMatrixTearOff* SVGTransformTearOff::matrix() |
| 50 { |
| 51 if (!m_matrixTearoff) { |
| 52 m_matrixTearoff = SVGMatrixTearOff::create(this); |
| 53 } |
| 54 |
| 55 return m_matrixTearoff.get(); |
| 56 } |
| 57 |
| 58 void SVGTransformTearOff::setMatrix(PassRefPtr<SVGMatrixTearOff> matrix, Excepti
onState& exceptionState) |
50 { | 59 { |
51 if (isImmutable()) { | 60 if (isImmutable()) { |
52 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 61 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
53 return; | 62 return; |
54 } | 63 } |
55 | 64 |
56 target()->setValue(value); | 65 target()->setMatrix(matrix->value()); |
57 commitChange(); | 66 commitChange(); |
58 } | 67 } |
59 | 68 |
60 void SVGAngleTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exce
ptionState) | 69 void SVGTransformTearOff::setTranslate(float tx, float ty, ExceptionState& excep
tionState) |
61 { | 70 { |
62 if (isImmutable()) { | 71 if (isImmutable()) { |
63 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 72 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
64 return; | 73 return; |
65 } | 74 } |
66 | 75 |
67 target()->setValueInSpecifiedUnits(value); | 76 target()->setTranslate(tx, ty); |
68 commitChange(); | 77 commitChange(); |
69 } | 78 } |
70 | 79 |
71 void SVGAngleTearOff::newValueSpecifiedUnits(unsigned short unitType, float valu
eInSpecifiedUnits, ExceptionState& exceptionState) | 80 void SVGTransformTearOff::setScale(float sx, float sy, ExceptionState& exception
State) |
72 { | 81 { |
73 if (isImmutable()) { | 82 if (isImmutable()) { |
74 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 83 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
75 return; | 84 return; |
76 } | 85 } |
77 | 86 |
78 if (unitType == SVGAngle::SVG_ANGLETYPE_UNKNOWN || unitType > SVGAngle::SVG_
ANGLETYPE_GRAD) { | 87 target()->setScale(sx, sy); |
79 exceptionState.throwDOMException(NotSupportedError, "Cannot set value wi
th unknown or invalid units (" + String::number(unitType) + ")."); | |
80 return; | |
81 } | |
82 | |
83 target()->newValueSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTyp
e), valueInSpecifiedUnits); | |
84 commitChange(); | 88 commitChange(); |
85 } | 89 } |
86 | 90 |
87 void SVGAngleTearOff::convertToSpecifiedUnits(unsigned short unitType, Exception
State& exceptionState) | 91 void SVGTransformTearOff::setRotate(float angle, float cx, float cy, ExceptionSt
ate& exceptionState) |
88 { | 92 { |
89 if (isImmutable()) { | 93 if (isImmutable()) { |
90 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 94 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
91 return; | 95 return; |
92 } | 96 } |
93 | 97 |
94 if (unitType == SVGAngle::SVG_ANGLETYPE_UNKNOWN || unitType > SVGAngle::SVG_
ANGLETYPE_GRAD) { | 98 target()->setRotate(angle, cx, cy); |
95 exceptionState.throwDOMException(NotSupportedError, "Cannot convert to u
nknown or invalid units (" + String::number(unitType) + ")."); | 99 commitChange(); |
96 return; | |
97 } | |
98 | |
99 target()->convertToSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTy
pe), exceptionState); | |
100 if (!exceptionState.hadException()) | |
101 commitChange(); | |
102 } | 100 } |
103 | 101 |
104 void SVGAngleTearOff::setValueAsString(const String& value, ExceptionState& exce
ptionState) | 102 void SVGTransformTearOff::setSkewX(float x, ExceptionState& exceptionState) |
105 { | 103 { |
106 if (isImmutable()) { | 104 if (isImmutable()) { |
107 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 105 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
108 return; | 106 return; |
109 } | 107 } |
110 | 108 |
111 target()->setValueAsString(value, exceptionState); | 109 target()->setSkewX(x); |
112 commitChange(); | 110 commitChange(); |
113 } | 111 } |
114 | 112 |
| 113 void SVGTransformTearOff::setSkewY(float y, ExceptionState& exceptionState) |
| 114 { |
| 115 if (isImmutable()) { |
| 116 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
| 117 return; |
| 118 } |
| 119 |
| 120 target()->setSkewY(y); |
| 121 commitChange(); |
| 122 } |
| 123 |
115 } | 124 } |
OLD | NEW |