| 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 15 matching lines...) Expand all Loading... |
| 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/SVGMatrixTearOff.h" | 32 #include "core/svg/SVGMatrixTearOff.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/svg/SVGElement.h" |
| 36 #include "core/svg/SVGTransformTearOff.h" | 37 #include "core/svg/SVGTransformTearOff.h" |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 SVGMatrixTearOff::SVGMatrixTearOff(const AffineTransform& staticValue) | 41 SVGMatrixTearOff::SVGMatrixTearOff(const AffineTransform& staticValue) |
| 41 : m_staticValue(staticValue) | 42 : m_staticValue(staticValue) |
| 42 , m_contextTransform(0) | 43 , m_contextTransform(nullptr) |
| 43 { | 44 { |
| 44 } | 45 } |
| 45 | 46 |
| 46 SVGMatrixTearOff::SVGMatrixTearOff(SVGTransformTearOff* transform) | 47 SVGMatrixTearOff::SVGMatrixTearOff(SVGTransformTearOff* transform) |
| 47 : m_contextTransform(transform) | 48 : m_contextTransform(transform) |
| 48 { | 49 { |
| 49 ASSERT(transform); | 50 ASSERT(transform); |
| 50 } | 51 } |
| 51 | 52 |
| 52 SVGMatrixTearOff::~SVGMatrixTearOff() | 53 SVGMatrixTearOff::~SVGMatrixTearOff() |
| 53 { | 54 { |
| 54 } | 55 } |
| 55 | 56 |
| 57 void SVGMatrixTearOff::trace(Visitor* visitor) |
| 58 { |
| 59 visitor->trace(m_contextTransform); |
| 60 } |
| 61 |
| 56 const AffineTransform& SVGMatrixTearOff::value() const | 62 const AffineTransform& SVGMatrixTearOff::value() const |
| 57 { | 63 { |
| 58 return m_contextTransform ? m_contextTransform->target()->matrix() : m_stati
cValue; | 64 return m_contextTransform ? m_contextTransform->target()->matrix() : m_stati
cValue; |
| 59 } | 65 } |
| 60 | 66 |
| 61 AffineTransform* SVGMatrixTearOff::mutableValue() | 67 AffineTransform* SVGMatrixTearOff::mutableValue() |
| 62 { | 68 { |
| 63 return m_contextTransform ? m_contextTransform->target()->mutableMatrix() :
&m_staticValue; | 69 return m_contextTransform ? m_contextTransform->target()->mutableMatrix() :
&m_staticValue; |
| 64 } | 70 } |
| 65 | 71 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 | 91 |
| 86 DEFINE_SETTER(A); | 92 DEFINE_SETTER(A); |
| 87 DEFINE_SETTER(B); | 93 DEFINE_SETTER(B); |
| 88 DEFINE_SETTER(C); | 94 DEFINE_SETTER(C); |
| 89 DEFINE_SETTER(D); | 95 DEFINE_SETTER(D); |
| 90 DEFINE_SETTER(E); | 96 DEFINE_SETTER(E); |
| 91 DEFINE_SETTER(F); | 97 DEFINE_SETTER(F); |
| 92 | 98 |
| 93 #undef DEFINE_SETTER | 99 #undef DEFINE_SETTER |
| 94 | 100 |
| 95 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::translate(double tx, double ty) | 101 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::translate(double tx,
double ty) |
| 96 { | 102 { |
| 97 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 103 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 98 matrix->mutableValue()->translate(tx, ty); | 104 matrix->mutableValue()->translate(tx, ty); |
| 99 return matrix.release(); | 105 return matrix.release(); |
| 100 } | 106 } |
| 101 | 107 |
| 102 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::scale(double s) | 108 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::scale(double s) |
| 103 { | 109 { |
| 104 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 110 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 105 matrix->mutableValue()->scale(s, s); | 111 matrix->mutableValue()->scale(s, s); |
| 106 return matrix.release(); | 112 return matrix.release(); |
| 107 } | 113 } |
| 108 | 114 |
| 109 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::scaleNonUniform(double sx, double
sy) | 115 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::scaleNonUniform(doubl
e sx, double sy) |
| 110 { | 116 { |
| 111 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 117 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 112 matrix->mutableValue()->scale(sx, sy); | 118 matrix->mutableValue()->scale(sx, sy); |
| 113 return matrix.release(); | 119 return matrix.release(); |
| 114 } | 120 } |
| 115 | 121 |
| 116 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::rotate(double d) | 122 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::rotate(double d) |
| 117 { | 123 { |
| 118 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 124 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 119 matrix->mutableValue()->rotate(d); | 125 matrix->mutableValue()->rotate(d); |
| 120 return matrix.release(); | 126 return matrix.release(); |
| 121 } | 127 } |
| 122 | 128 |
| 123 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::flipX() | 129 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::flipX() |
| 124 { | 130 { |
| 125 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 131 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 126 matrix->mutableValue()->flipX(); | 132 matrix->mutableValue()->flipX(); |
| 127 return matrix.release(); | 133 return matrix.release(); |
| 128 } | 134 } |
| 129 | 135 |
| 130 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::flipY() | 136 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::flipY() |
| 131 { | 137 { |
| 132 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 138 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 133 matrix->mutableValue()->flipY(); | 139 matrix->mutableValue()->flipY(); |
| 134 return matrix.release(); | 140 return matrix.release(); |
| 135 } | 141 } |
| 136 | 142 |
| 137 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::skewX(double angle) | 143 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::skewX(double angle) |
| 138 { | 144 { |
| 139 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 145 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 140 matrix->mutableValue()->skewX(angle); | 146 matrix->mutableValue()->skewX(angle); |
| 141 return matrix.release(); | 147 return matrix.release(); |
| 142 } | 148 } |
| 143 | 149 |
| 144 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::skewY(double angle) | 150 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::skewY(double angle) |
| 145 { | 151 { |
| 146 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 152 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 147 matrix->mutableValue()->skewY(angle); | 153 matrix->mutableValue()->skewY(angle); |
| 148 return matrix.release(); | 154 return matrix.release(); |
| 149 } | 155 } |
| 150 | 156 |
| 151 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::multiply(PassRefPtr<SVGMatrixTear
Off> other) | 157 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::multiply(PassRefPtrWi
llBeRawPtr<SVGMatrixTearOff> other) |
| 152 { | 158 { |
| 153 RefPtr<SVGMatrixTearOff> matrix = create(value()); | 159 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrix = create(value()); |
| 154 *matrix->mutableValue() *= other->value(); | 160 *matrix->mutableValue() *= other->value(); |
| 155 return matrix.release(); | 161 return matrix.release(); |
| 156 } | 162 } |
| 157 | 163 |
| 158 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::inverse(ExceptionState& exception
State) | 164 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::inverse(ExceptionStat
e& exceptionState) |
| 159 { | 165 { |
| 160 AffineTransform transform = value().inverse(); | 166 AffineTransform transform = value().inverse(); |
| 161 if (!value().isInvertible()) | 167 if (!value().isInvertible()) |
| 162 exceptionState.throwDOMException(InvalidStateError, "The matrix is not i
nvertible."); | 168 exceptionState.throwDOMException(InvalidStateError, "The matrix is not i
nvertible."); |
| 163 | 169 |
| 164 return create(transform); | 170 return create(transform); |
| 165 } | 171 } |
| 166 | 172 |
| 167 PassRefPtr<SVGMatrixTearOff> SVGMatrixTearOff::rotateFromVector(double x, double
y, ExceptionState& exceptionState) | 173 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGMatrixTearOff::rotateFromVector(doub
le x, double y, ExceptionState& exceptionState) |
| 168 { | 174 { |
| 169 if (!x || !y) | 175 if (!x || !y) |
| 170 exceptionState.throwDOMException(InvalidAccessError, "Arguments cannot b
e zero."); | 176 exceptionState.throwDOMException(InvalidAccessError, "Arguments cannot b
e zero."); |
| 171 | 177 |
| 172 AffineTransform copy = value(); | 178 AffineTransform copy = value(); |
| 173 copy.rotateFromVector(x, y); | 179 copy.rotateFromVector(x, y); |
| 174 return create(copy); | 180 return create(copy); |
| 175 } | 181 } |
| 176 | 182 |
| 177 } | 183 } |
| OLD | NEW |